version 1.30, 2016/05/04 14:22:33 |
version 1.31, 2017/04/30 23:13:25 |
|
|
int baud; |
int baud; |
Buffer buf; |
Buffer buf; |
int tty_op_ospeed, tty_op_ispeed; |
int tty_op_ospeed, tty_op_ispeed; |
void (*put_arg)(Buffer *, u_int); |
|
|
|
buffer_init(&buf); |
buffer_init(&buf); |
if (compat20) { |
tty_op_ospeed = TTY_OP_OSPEED_PROTO2; |
tty_op_ospeed = TTY_OP_OSPEED_PROTO2; |
tty_op_ispeed = TTY_OP_ISPEED_PROTO2; |
tty_op_ispeed = TTY_OP_ISPEED_PROTO2; |
|
put_arg = buffer_put_int; |
|
} else { |
|
tty_op_ospeed = TTY_OP_OSPEED_PROTO1; |
|
tty_op_ispeed = TTY_OP_ISPEED_PROTO1; |
|
put_arg = (void (*)(Buffer *, u_int)) buffer_put_char; |
|
} |
|
|
|
if (tiop == NULL) { |
if (tiop == NULL) { |
if (fd == -1) { |
if (fd == -1) { |
|
|
/* Store values of mode flags. */ |
/* Store values of mode flags. */ |
#define TTYCHAR(NAME, OP) \ |
#define TTYCHAR(NAME, OP) \ |
buffer_put_char(&buf, OP); \ |
buffer_put_char(&buf, OP); \ |
put_arg(&buf, tio.c_cc[NAME]); |
buffer_put_int(&buf, tio.c_cc[NAME]); |
|
|
#define TTYMODE(NAME, FIELD, OP) \ |
#define TTYMODE(NAME, FIELD, OP) \ |
buffer_put_char(&buf, OP); \ |
buffer_put_char(&buf, OP); \ |
put_arg(&buf, ((tio.FIELD & NAME) != 0)); |
buffer_put_int(&buf, ((tio.FIELD & NAME) != 0)); |
|
|
#include "ttymodes.h" |
#include "ttymodes.h" |
|
|
|
|
end: |
end: |
/* Mark end of mode data. */ |
/* Mark end of mode data. */ |
buffer_put_char(&buf, TTY_OP_END); |
buffer_put_char(&buf, TTY_OP_END); |
if (compat20) |
packet_put_string(buffer_ptr(&buf), buffer_len(&buf)); |
packet_put_string(buffer_ptr(&buf), buffer_len(&buf)); |
|
else |
|
packet_put_raw(buffer_ptr(&buf), buffer_len(&buf)); |
|
buffer_free(&buf); |
buffer_free(&buf); |
} |
} |
|
|
|
|
int opcode, baud; |
int opcode, baud; |
int n_bytes = 0; |
int n_bytes = 0; |
int failure = 0; |
int failure = 0; |
u_int (*get_arg)(void); |
|
int arg_size; |
|
|
|
if (compat20) { |
*n_bytes_ptr = packet_get_int(); |
*n_bytes_ptr = packet_get_int(); |
if (*n_bytes_ptr == 0) |
if (*n_bytes_ptr == 0) |
return; |
return; |
|
get_arg = packet_get_int; |
|
arg_size = 4; |
|
} else { |
|
get_arg = packet_get_char; |
|
arg_size = 1; |
|
} |
|
|
|
/* |
/* |
* Get old attributes for the terminal. We will modify these |
* Get old attributes for the terminal. We will modify these |
|
|
|
|
#define TTYCHAR(NAME, OP) \ |
#define TTYCHAR(NAME, OP) \ |
case OP: \ |
case OP: \ |
n_bytes += arg_size; \ |
n_bytes += 4; \ |
tio.c_cc[NAME] = get_arg(); \ |
tio.c_cc[NAME] = packet_get_int(); \ |
break; |
break; |
#define TTYMODE(NAME, FIELD, OP) \ |
#define TTYMODE(NAME, FIELD, OP) \ |
case OP: \ |
case OP: \ |
n_bytes += arg_size; \ |
n_bytes += 4; \ |
if (get_arg()) \ |
if (packet_get_int()) \ |
tio.FIELD |= NAME; \ |
tio.FIELD |= NAME; \ |
else \ |
else \ |
tio.FIELD &= ~NAME; \ |
tio.FIELD &= ~NAME; \ |
|
|
default: |
default: |
debug("Ignoring unsupported tty mode opcode %d (0x%x)", |
debug("Ignoring unsupported tty mode opcode %d (0x%x)", |
opcode, opcode); |
opcode, opcode); |
if (!compat20) { |
/* |
/* |
* SSH2: |
* SSH1: |
* Opcodes 1 to 159 are defined to have a uint32 |
* Opcodes 1 to 127 are defined to have |
* argument. |
* a one-byte argument. |
* Opcodes 160 to 255 are undefined and cause parsing |
* Opcodes 128 to 159 are defined to have |
* to stop. |
* an integer argument. |
*/ |
*/ |
if (opcode > 0 && opcode < 160) { |
if (opcode > 0 && opcode < 128) { |
n_bytes += 4; |
n_bytes += 1; |
(void) packet_get_int(); |
(void) packet_get_char(); |
break; |
break; |
|
} else if (opcode >= 128 && opcode < 160) { |
|
n_bytes += 4; |
|
(void) packet_get_int(); |
|
break; |
|
} else { |
|
/* |
|
* It is a truly undefined opcode (160 to 255). |
|
* We have no idea about its arguments. So we |
|
* must stop parsing. Note that some data |
|
* may be left in the packet; hopefully there |
|
* is nothing more coming after the mode data. |
|
*/ |
|
logit("parse_tty_modes: unknown opcode %d", |
|
opcode); |
|
goto set; |
|
} |
|
} else { |
} else { |
/* |
logit("parse_tty_modes: unknown opcode %d", |
* SSH2: |
opcode); |
* Opcodes 1 to 159 are defined to have |
goto set; |
* a uint32 argument. |
|
* Opcodes 160 to 255 are undefined and |
|
* cause parsing to stop. |
|
*/ |
|
if (opcode > 0 && opcode < 160) { |
|
n_bytes += 4; |
|
(void) packet_get_int(); |
|
break; |
|
} else { |
|
logit("parse_tty_modes: unknown opcode %d", |
|
opcode); |
|
goto set; |
|
} |
|
} |
} |
} |
} |
} |
} |