summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ttymodes.c25
-rw-r--r--ttymodes.h21
2 files changed, 14 insertions, 32 deletions
diff --git a/ttymodes.c b/ttymodes.c
index 2fc783b2f..845139635 100644
--- a/ttymodes.c
+++ b/ttymodes.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ttymodes.c,v 1.31 2017/04/30 23:13:25 djm Exp $ */ 1/* $OpenBSD: ttymodes.c,v 1.32 2017/04/30 23:26:54 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -59,12 +59,10 @@
59 59
60#define TTY_OP_END 0 60#define TTY_OP_END 0
61/* 61/*
62 * uint32 (u_int) follows speed in SSH1 and SSH2 62 * uint32 (u_int) follows speed.
63 */ 63 */
64#define TTY_OP_ISPEED_PROTO1 192 64#define TTY_OP_ISPEED 128
65#define TTY_OP_OSPEED_PROTO1 193 65#define TTY_OP_OSPEED 129
66#define TTY_OP_ISPEED_PROTO2 128
67#define TTY_OP_OSPEED_PROTO2 129
68 66
69/* 67/*
70 * Converts POSIX speed_t to a baud rate. The values of the 68 * Converts POSIX speed_t to a baud rate. The values of the
@@ -282,11 +280,8 @@ tty_make_modes(int fd, struct termios *tiop)
282 struct termios tio; 280 struct termios tio;
283 int baud; 281 int baud;
284 Buffer buf; 282 Buffer buf;
285 int tty_op_ospeed, tty_op_ispeed;
286 283
287 buffer_init(&buf); 284 buffer_init(&buf);
288 tty_op_ospeed = TTY_OP_OSPEED_PROTO2;
289 tty_op_ispeed = TTY_OP_ISPEED_PROTO2;
290 285
291 if (tiop == NULL) { 286 if (tiop == NULL) {
292 if (fd == -1) { 287 if (fd == -1) {
@@ -302,10 +297,10 @@ tty_make_modes(int fd, struct termios *tiop)
302 297
303 /* Store input and output baud rates. */ 298 /* Store input and output baud rates. */
304 baud = speed_to_baud(cfgetospeed(&tio)); 299 baud = speed_to_baud(cfgetospeed(&tio));
305 buffer_put_char(&buf, tty_op_ospeed); 300 buffer_put_char(&buf, TTY_OP_OSPEED);
306 buffer_put_int(&buf, baud); 301 buffer_put_int(&buf, baud);
307 baud = speed_to_baud(cfgetispeed(&tio)); 302 baud = speed_to_baud(cfgetispeed(&tio));
308 buffer_put_char(&buf, tty_op_ispeed); 303 buffer_put_char(&buf, TTY_OP_ISPEED);
309 buffer_put_int(&buf, baud); 304 buffer_put_int(&buf, baud);
310 305
311 /* Store values of mode flags. */ 306 /* Store values of mode flags. */
@@ -362,9 +357,7 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
362 case TTY_OP_END: 357 case TTY_OP_END:
363 goto set; 358 goto set;
364 359
365 /* XXX: future conflict possible */ 360 case TTY_OP_ISPEED:
366 case TTY_OP_ISPEED_PROTO1:
367 case TTY_OP_ISPEED_PROTO2:
368 n_bytes += 4; 361 n_bytes += 4;
369 baud = packet_get_int(); 362 baud = packet_get_int();
370 if (failure != -1 && 363 if (failure != -1 &&
@@ -372,9 +365,7 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
372 error("cfsetispeed failed for %d", baud); 365 error("cfsetispeed failed for %d", baud);
373 break; 366 break;
374 367
375 /* XXX: future conflict possible */ 368 case TTY_OP_OSPEED:
376 case TTY_OP_OSPEED_PROTO1:
377 case TTY_OP_OSPEED_PROTO2:
378 n_bytes += 4; 369 n_bytes += 4;
379 baud = packet_get_int(); 370 baud = packet_get_int();
380 if (failure != -1 && 371 if (failure != -1 &&
diff --git a/ttymodes.h b/ttymodes.h
index 14e177cef..24f07560c 100644
--- a/ttymodes.h
+++ b/ttymodes.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ttymodes.h,v 1.15 2016/05/03 09:03:49 dtucker Exp $ */ 1/* $OpenBSD: ttymodes.h,v 1.16 2017/04/30 23:26:54 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -38,22 +38,13 @@
38 */ 38 */
39 39
40/* 40/*
41 * SSH1: 41 * The tty mode description is a string, consisting of
42 * The tty mode description is a stream of bytes. The stream consists of
43 * opcode-arguments pairs. It is terminated by opcode TTY_OP_END (0). 42 * opcode-arguments pairs. It is terminated by opcode TTY_OP_END (0).
44 * Opcodes 1-127 have one-byte arguments. Opcodes 128-159 have integer 43 * Opcodes 1-159 have uint32 arguments.
45 * arguments. Opcodes 160-255 are not yet defined, and cause parsing to 44 * Opcodes 160-255 are not yet defined and cause parsing to stop (they
46 * stop (they should only be used after any other data). 45 * should only be used after any other data).
47 * 46 *
48 * SSH2: 47 * The client puts in the string any modes it knows about, and the
49 * Differences between SSH1 and SSH2 terminal mode encoding include:
50 * 1. Encoded terminal modes are represented as a string, and a stream
51 * of bytes within that string.
52 * 2. Opcode arguments are uint32 (1-159); 160-255 remain undefined.
53 * 3. The values for TTY_OP_ISPEED and TTY_OP_OSPEED are different;
54 * 128 and 129 vs. 192 and 193 respectively.
55 *
56 * The client puts in the stream any modes it knows about, and the
57 * server ignores any modes it does not know about. This allows some degree 48 * server ignores any modes it does not know about. This allows some degree
58 * of machine-independence, at least between systems that use a posix-like 49 * of machine-independence, at least between systems that use a posix-like
59 * tty interface. The protocol can support other systems as well, but might 50 * tty interface. The protocol can support other systems as well, but might