diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-05-07 17:57:45 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-05-07 17:57:45 +0000 |
commit | 7e1273edf7a75f2797ea5c0d95d33ff1056f21d8 (patch) | |
tree | 027b6be3c7e471def7c0658631eb6d1cb82db50e | |
parent | 238bc4090d518d1ee17c454337831b81f5fc83d3 (diff) | |
download | busybox-w32-7e1273edf7a75f2797ea5c0d95d33ff1056f21d8.tar.gz busybox-w32-7e1273edf7a75f2797ea5c0d95d33ff1056f21d8.tar.bz2 busybox-w32-7e1273edf7a75f2797ea5c0d95d33ff1056f21d8.zip |
Patch from Jim McQuillan to pass the terminal type to the remote host.
-rw-r--r-- | Config.h | 3 | ||||
-rw-r--r-- | networking/telnet.c | 54 | ||||
-rw-r--r-- | telnet.c | 54 |
3 files changed, 109 insertions, 2 deletions
@@ -362,6 +362,9 @@ | |||
362 | // Enable a if you system have setuped locale | 362 | // Enable a if you system have setuped locale |
363 | //#define BB_LOCALE_SUPPORT | 363 | //#define BB_LOCALE_SUPPORT |
364 | // | 364 | // |
365 | // Support for TELNET to pass TERM type to remote host. Adds 384 bytes. | ||
366 | #define BB_FEATURE_TELNET_TTYPE | ||
367 | // | ||
365 | // End of Features List | 368 | // End of Features List |
366 | // | 369 | // |
367 | // | 370 | // |
diff --git a/networking/telnet.c b/networking/telnet.c index edcc5081f..207732b72 100644 --- a/networking/telnet.c +++ b/networking/telnet.c | |||
@@ -27,6 +27,8 @@ | |||
27 | * initial revision | 27 | * initial revision |
28 | * Modified 2000/06/13 for inclusion into BusyBox by Erik Andersen | 28 | * Modified 2000/06/13 for inclusion into BusyBox by Erik Andersen |
29 | * <andersen@lineo.com> | 29 | * <andersen@lineo.com> |
30 | * Modified 2001/05/07 to add ability to pass TTYPE to remote host by Jim McQuillan | ||
31 | * <jam@ltsp.org> | ||
30 | * | 32 | * |
31 | */ | 33 | */ |
32 | 34 | ||
@@ -136,6 +138,10 @@ static int local_bind(int port); | |||
136 | /* Some globals */ | 138 | /* Some globals */ |
137 | static int one = 1; | 139 | static int one = 1; |
138 | 140 | ||
141 | #ifdef BB_FEATURE_TELNET_TTYPE | ||
142 | static char *ttype; | ||
143 | #endif | ||
144 | |||
139 | static void doexit(int ev) | 145 | static void doexit(int ev) |
140 | { | 146 | { |
141 | cookmode(); | 147 | cookmode(); |
@@ -321,6 +327,27 @@ static void putiac1(byte c) | |||
321 | } | 327 | } |
322 | #endif | 328 | #endif |
323 | 329 | ||
330 | #ifdef BB_FEATURE_TELNET_TTYPE | ||
331 | static void putiac_subopt(byte c, char *str) | ||
332 | { | ||
333 | int len = strlen(str) + 6; // ( 2 + 1 + 1 + strlen + 2 ) | ||
334 | |||
335 | if (G.iaclen + len > IACBUFSIZE) | ||
336 | iacflush(); | ||
337 | |||
338 | putiac(IAC); | ||
339 | putiac(SB); | ||
340 | putiac(c); | ||
341 | putiac(0); | ||
342 | |||
343 | while(*str) | ||
344 | putiac(*str++); | ||
345 | |||
346 | putiac(IAC); | ||
347 | putiac(SE); | ||
348 | } | ||
349 | #endif | ||
350 | |||
324 | /* void putiacstring (subneg strings) */ | 351 | /* void putiacstring (subneg strings) */ |
325 | 352 | ||
326 | /* ******************************* */ | 353 | /* ******************************* */ |
@@ -427,12 +454,29 @@ static inline void to_sga() | |||
427 | return; | 454 | return; |
428 | } | 455 | } |
429 | 456 | ||
457 | #ifdef BB_FEATURE_TELNET_TTYPE | ||
458 | static inline void to_ttype() | ||
459 | { | ||
460 | /* Tell server we will (or won't) do TTYPE */ | ||
461 | |||
462 | if(ttype) | ||
463 | putiac2(WILL, TELOPT_TTYPE); | ||
464 | else | ||
465 | putiac2(WONT, TELOPT_TTYPE); | ||
466 | |||
467 | return; | ||
468 | } | ||
469 | #endif | ||
470 | |||
430 | static void telopt(byte c) | 471 | static void telopt(byte c) |
431 | { | 472 | { |
432 | switch (c) | 473 | switch (c) |
433 | { | 474 | { |
434 | case TELOPT_ECHO: to_echo(c); break; | 475 | case TELOPT_ECHO: to_echo(c); break; |
435 | case TELOPT_SGA: to_sga(c); break; | 476 | case TELOPT_SGA: to_sga(c); break; |
477 | #ifdef BB_FEATURE_TELNET_TTYPE | ||
478 | case TELOPT_TTYPE: to_ttype(c); break; | ||
479 | #endif | ||
436 | default: to_notsup(c); break; | 480 | default: to_notsup(c); break; |
437 | } | 481 | } |
438 | } | 482 | } |
@@ -440,7 +484,7 @@ static void telopt(byte c) | |||
440 | 484 | ||
441 | /* ******************************* */ | 485 | /* ******************************* */ |
442 | 486 | ||
443 | /* subnegotiation -- ignore all */ | 487 | /* subnegotiation -- ignore all (except TTYPE) */ |
444 | 488 | ||
445 | static int subneg(byte c) | 489 | static int subneg(byte c) |
446 | { | 490 | { |
@@ -449,6 +493,11 @@ static int subneg(byte c) | |||
449 | case TS_SUB1: | 493 | case TS_SUB1: |
450 | if (c == IAC) | 494 | if (c == IAC) |
451 | G.telstate = TS_SUB2; | 495 | G.telstate = TS_SUB2; |
496 | #ifdef BB_FEATURE_TELNET_TTYPE | ||
497 | else | ||
498 | if (c == TELOPT_TTYPE) | ||
499 | putiac_subopt(TELOPT_TTYPE,ttype); | ||
500 | #endif | ||
452 | break; | 501 | break; |
453 | case TS_SUB2: | 502 | case TS_SUB2: |
454 | if (c == SE) | 503 | if (c == SE) |
@@ -488,6 +537,9 @@ extern int telnet_main(int argc, char** argv) | |||
488 | int maxfd; | 537 | int maxfd; |
489 | #endif | 538 | #endif |
490 | 539 | ||
540 | #ifdef BB_FEATURE_TELNET_TTYPE | ||
541 | ttype = getenv("TERM"); | ||
542 | #endif | ||
491 | 543 | ||
492 | memset(&G, 0, sizeof G); | 544 | memset(&G, 0, sizeof G); |
493 | 545 | ||
@@ -27,6 +27,8 @@ | |||
27 | * initial revision | 27 | * initial revision |
28 | * Modified 2000/06/13 for inclusion into BusyBox by Erik Andersen | 28 | * Modified 2000/06/13 for inclusion into BusyBox by Erik Andersen |
29 | * <andersen@lineo.com> | 29 | * <andersen@lineo.com> |
30 | * Modified 2001/05/07 to add ability to pass TTYPE to remote host by Jim McQuillan | ||
31 | * <jam@ltsp.org> | ||
30 | * | 32 | * |
31 | */ | 33 | */ |
32 | 34 | ||
@@ -136,6 +138,10 @@ static int local_bind(int port); | |||
136 | /* Some globals */ | 138 | /* Some globals */ |
137 | static int one = 1; | 139 | static int one = 1; |
138 | 140 | ||
141 | #ifdef BB_FEATURE_TELNET_TTYPE | ||
142 | static char *ttype; | ||
143 | #endif | ||
144 | |||
139 | static void doexit(int ev) | 145 | static void doexit(int ev) |
140 | { | 146 | { |
141 | cookmode(); | 147 | cookmode(); |
@@ -321,6 +327,27 @@ static void putiac1(byte c) | |||
321 | } | 327 | } |
322 | #endif | 328 | #endif |
323 | 329 | ||
330 | #ifdef BB_FEATURE_TELNET_TTYPE | ||
331 | static void putiac_subopt(byte c, char *str) | ||
332 | { | ||
333 | int len = strlen(str) + 6; // ( 2 + 1 + 1 + strlen + 2 ) | ||
334 | |||
335 | if (G.iaclen + len > IACBUFSIZE) | ||
336 | iacflush(); | ||
337 | |||
338 | putiac(IAC); | ||
339 | putiac(SB); | ||
340 | putiac(c); | ||
341 | putiac(0); | ||
342 | |||
343 | while(*str) | ||
344 | putiac(*str++); | ||
345 | |||
346 | putiac(IAC); | ||
347 | putiac(SE); | ||
348 | } | ||
349 | #endif | ||
350 | |||
324 | /* void putiacstring (subneg strings) */ | 351 | /* void putiacstring (subneg strings) */ |
325 | 352 | ||
326 | /* ******************************* */ | 353 | /* ******************************* */ |
@@ -427,12 +454,29 @@ static inline void to_sga() | |||
427 | return; | 454 | return; |
428 | } | 455 | } |
429 | 456 | ||
457 | #ifdef BB_FEATURE_TELNET_TTYPE | ||
458 | static inline void to_ttype() | ||
459 | { | ||
460 | /* Tell server we will (or won't) do TTYPE */ | ||
461 | |||
462 | if(ttype) | ||
463 | putiac2(WILL, TELOPT_TTYPE); | ||
464 | else | ||
465 | putiac2(WONT, TELOPT_TTYPE); | ||
466 | |||
467 | return; | ||
468 | } | ||
469 | #endif | ||
470 | |||
430 | static void telopt(byte c) | 471 | static void telopt(byte c) |
431 | { | 472 | { |
432 | switch (c) | 473 | switch (c) |
433 | { | 474 | { |
434 | case TELOPT_ECHO: to_echo(c); break; | 475 | case TELOPT_ECHO: to_echo(c); break; |
435 | case TELOPT_SGA: to_sga(c); break; | 476 | case TELOPT_SGA: to_sga(c); break; |
477 | #ifdef BB_FEATURE_TELNET_TTYPE | ||
478 | case TELOPT_TTYPE: to_ttype(c); break; | ||
479 | #endif | ||
436 | default: to_notsup(c); break; | 480 | default: to_notsup(c); break; |
437 | } | 481 | } |
438 | } | 482 | } |
@@ -440,7 +484,7 @@ static void telopt(byte c) | |||
440 | 484 | ||
441 | /* ******************************* */ | 485 | /* ******************************* */ |
442 | 486 | ||
443 | /* subnegotiation -- ignore all */ | 487 | /* subnegotiation -- ignore all (except TTYPE) */ |
444 | 488 | ||
445 | static int subneg(byte c) | 489 | static int subneg(byte c) |
446 | { | 490 | { |
@@ -449,6 +493,11 @@ static int subneg(byte c) | |||
449 | case TS_SUB1: | 493 | case TS_SUB1: |
450 | if (c == IAC) | 494 | if (c == IAC) |
451 | G.telstate = TS_SUB2; | 495 | G.telstate = TS_SUB2; |
496 | #ifdef BB_FEATURE_TELNET_TTYPE | ||
497 | else | ||
498 | if (c == TELOPT_TTYPE) | ||
499 | putiac_subopt(TELOPT_TTYPE,ttype); | ||
500 | #endif | ||
452 | break; | 501 | break; |
453 | case TS_SUB2: | 502 | case TS_SUB2: |
454 | if (c == SE) | 503 | if (c == SE) |
@@ -488,6 +537,9 @@ extern int telnet_main(int argc, char** argv) | |||
488 | int maxfd; | 537 | int maxfd; |
489 | #endif | 538 | #endif |
490 | 539 | ||
540 | #ifdef BB_FEATURE_TELNET_TTYPE | ||
541 | ttype = getenv("TERM"); | ||
542 | #endif | ||
491 | 543 | ||
492 | memset(&G, 0, sizeof G); | 544 | memset(&G, 0, sizeof G); |
493 | 545 | ||