Fixed bug with sending suboptions so telnet works.

This commit is contained in:
Chris Osborn 2016-05-24 15:29:41 -07:00
parent 223310bfa8
commit 2304321c79
4 changed files with 15 additions and 16 deletions

View File

@ -13,7 +13,7 @@ void print_help(char *name)
fprintf(stderr, " 's' = modem input\n");
fprintf(stderr, " 'S' = modem output\n");
fprintf(stderr, " 'i' = IP input\n");
fprintf(stderr, " 'I' = IP input\n");
fprintf(stderr, " 'I' = IP output\n");
fprintf(stderr, " -l 0 (NONE), 1 (FATAL) - 7 (DEBUG_X) (defaults to 0)\n");
fprintf(stderr, " -L log file (defaults to stderr)\n");
fprintf(stderr, "\n");

View File

@ -15,7 +15,6 @@ int line_init_config(modem_config *cfg)
return 0;
}
int line_write(modem_config *cfg, char *data, int len)
{
int retval;
@ -24,6 +23,7 @@ int line_write(modem_config *cfg, char *data, int len)
char text[1024];
int text_len = 0;
if (cfg->line_data.is_telnet && cfg->line_data.nvt_data.binary_xmit) {
retval = 0;
while (i < len) {
@ -55,7 +55,6 @@ int line_write(modem_config *cfg, char *data, int len)
return ip_write(cfg->line_data.fd, data, len);
}
int line_listen(modem_config *cfg)
{
return 0;
@ -66,11 +65,11 @@ int line_off_hook(modem_config *cfg)
return 0;
}
int line_connect(modem_config *cfg)
{
char *addy = cfg->dialno;
LOG(LOG_INFO, "Connecting");
addy = pb_search(addy);
cfg->line_data.fd = ip_connect(addy);
@ -86,7 +85,6 @@ int line_connect(modem_config *cfg)
}
}
int line_disconnect(modem_config *cfg)
{
LOG(LOG_INFO, "Disconnecting");

View File

@ -386,8 +386,8 @@ int mdm_parse_cmd(modem_config *cfg)
strncpy(cfg->dialno, cfg->last_dialno, strlen(cfg->last_dialno));
cfg->dial_type = cfg->dial_type;
cfg->memory_dial = TRUE;
mdm_write(cfg, cfg->crlf, 2);
mdm_write(cfg, cfg->dialno, strlen(cfg->dialno));
mdm_write_parity(cfg, cfg->crlf, 2);
mdm_write_parity(cfg, cfg->dialno, strlen(cfg->dialno));
}
else {
cfg->dialno[0] = 0;
@ -474,7 +474,7 @@ int mdm_parse_cmd(modem_config *cfg)
break;
case AT_CMD_FLAG_QUERY | 'S':
sprintf(tmp, "%s%3.3d", cfg->crlf, cfg->s[num]);
mdm_write(cfg, tmp, strlen(tmp));
mdm_write_parity(cfg, tmp, strlen(tmp));
break;
case 'T': // defaut to tone dialing
//cfg->default_dial_type=MDM_DT_TONE;
@ -573,7 +573,7 @@ int mdm_handle_char(modem_config *cfg, char ch)
if (cfg->cmd_started == TRUE) {
if (ch == (char) (cfg->s[5])) {
if (cfg->cur_line_idx == 0 && cfg->echo == TRUE) {
mdm_write_char(cfg, 'T');
mdm_write_parity(cfg, "T", 1);
}
else {
cfg->cur_line_idx--;

View File

@ -71,13 +71,13 @@ int parse_nvt_subcommand(int fd, nvt_vars *vars, char *data, int len)
}
}
if (rc > 5 && (NVT_SB_SEND == data[4])) {
if (rc > 5 && (NVT_SB_SEND == data[3])) {
switch (opt) {
case NVT_OPT_TERMINAL_TYPE:
case NVT_OPT_TERMINAL_SPEED:
case NVT_OPT_X_DISPLAY_LOCATION: // should not have to have these
case NVT_OPT_ENVIRON: // but telnet seems to expect.
case NVT_OPT_NEW_ENVIRON: // them.
case NVT_OPT_TERMINAL_SPEED:
response[response_len++] = NVT_SB_IS;
switch (opt) {
case NVT_OPT_TERMINAL_TYPE:
@ -148,14 +148,15 @@ int parse_nvt_command(int fd, nvt_vars *vars, char action, int opt)
case NVT_OPT_NAWS:
case NVT_OPT_TERMINAL_TYPE:
case NVT_OPT_TERMINAL_SPEED:
case NVT_OPT_SUPPRESS_GO_AHEAD:
case NVT_OPT_ECHO:
case NVT_OPT_X_DISPLAY_LOCATION: // should not have to have these
case NVT_OPT_ENVIRON: // but telnet seems to expect.
case NVT_OPT_NEW_ENVIRON: // them.
case NVT_OPT_TERMINAL_SPEED:
resp[1] = get_nvt_cmd_response(action, TRUE);
break;
default:
resp[1] = get_nvt_cmd_response(action, FALSE);
break;