]>
git.saurik.com Git - apple/network_cmds.git/blob - telnet.tproj/telnet.c
2 * Copyright (c) 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include <sys/cdefs.h>
37 __FBSDID("$FreeBSD: src/crypto/telnet/telnet/telnet.c,v 1.4.2.5 2002/04/13 10:59:08 markm Exp $");
41 #define __unused __attribute__((__unused__))
45 static const char sccsid
[] = "@(#)telnet.c 8.4 (Berkeley) 5/30/95";
48 #include <sys/types.h>
50 /* By the way, we need to include curses.h before telnet.h since,
51 * among other things, telnet.h #defines 'DO', which is a variable
52 * declared in curses.h.
60 #include <arpa/telnet.h>
70 #include <libtelnet/auth.h>
73 #include <libtelnet/encrypt.h>
75 #include <libtelnet/misc.h>
77 #define strip(x) ((my_want_state_is_wont(TELOPT_BINARY)) ? ((x)&0x7f) : (x))
79 static unsigned char subbuffer
[SUBBUFSIZE
],
80 *subpointer
, *subend
; /* buffer for sub-options */
81 #define SB_CLEAR() subpointer = subbuffer;
82 #define SB_TERM() { subend = subpointer; SB_CLEAR(); }
83 #define SB_ACCUM(c) if (subpointer < (subbuffer+sizeof subbuffer)) { \
84 *subpointer++ = (c); \
87 #define SB_GET() ((*subpointer++)&0xff)
88 #define SB_PEEK() ((*subpointer)&0xff)
89 #define SB_EOF() (subpointer >= subend)
90 #define SB_LEN() (subend - subpointer)
92 char options
[256]; /* The combined options */
93 char do_dont_resp
[256];
94 char will_wont_resp
[256];
98 autologin
= 0, /* Autologin anyone? */
102 ISend
, /* trying to send network data in */
105 netdata
, /* Print out network data flow */
106 crlf
, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
108 SYNCHing
, /* we are in TELNET SYNCH mode */
109 flushout
, /* flush output */
110 autoflush
= 0, /* flush output when interrupting? */
111 autosynch
, /* send interrupt characters with SYNCH? */
112 localflow
, /* we handle flow control locally */
113 restartany
, /* if flow control enabled, restart on any character */
114 localchars
, /* we recognize interrupt/quit */
115 donelclchars
, /* the user has set "localchars" */
116 donebinarytoggle
, /* the user has put us in binary */
117 dontlecho
, /* do we suppress local echoing right now? */
119 doaddrlookup
= 1, /* do a reverse address lookup? */
124 char *line
; /* hack around breakage in sra.c :-( !! */
129 #ifdef KLUDGELINEMODE
134 * Telnet receiver states for fsm
143 #define TS_SB 7 /* sub-option collection */
144 #define TS_SE 8 /* looking for sub-option end */
146 static int telrcv_state
;
148 unsigned char telopt_environ
= TELOPT_NEW_ENVIRON
;
150 # define telopt_environ TELOPT_NEW_ENVIRON
159 #ifdef KLUDGELINEMODE
160 int kludgelinemode
= 1;
163 static int is_unique(char *, char **, char **);
166 * The following are some clocks used to decide how to interpret
167 * the relationship between various variables.
173 * Initialize telnet environment.
184 connected
= ISend
= localflow
= donebinarytoggle
= 0;
185 #ifdef AUTHENTICATION
187 auth_encrypt_connect(connected
);
194 /* Don't change NetTrace */
196 escape
= CONTROL(']');
197 rlogin
= _POSIX_VDISABLE
;
198 #ifdef KLUDGELINEMODE
199 echoc
= CONTROL('E');
203 telrcv_state
= TS_DATA
;
208 * These routines are in charge of sending option negotiations
211 * The basic idea is that we send the negotiation if either side
212 * is in disagreement as to what the current state should be.
216 send_do(int c
, int init
)
219 if (((do_dont_resp
[c
] == 0) && my_state_is_do(c
)) ||
220 my_want_state_is_do(c
))
222 set_my_want_state_do(c
);
227 printoption("SENT", DO
, c
);
231 send_dont(int c
, int init
)
234 if (((do_dont_resp
[c
] == 0) && my_state_is_dont(c
)) ||
235 my_want_state_is_dont(c
))
237 set_my_want_state_dont(c
);
242 printoption("SENT", DONT
, c
);
246 send_will(int c
, int init
)
249 if (((will_wont_resp
[c
] == 0) && my_state_is_will(c
)) ||
250 my_want_state_is_will(c
))
252 set_my_want_state_will(c
);
257 printoption("SENT", WILL
, c
);
261 send_wont(int c
, int init
)
264 if (((will_wont_resp
[c
] == 0) && my_state_is_wont(c
)) ||
265 my_want_state_is_wont(c
))
267 set_my_want_state_wont(c
);
272 printoption("SENT", WONT
, c
);
276 willoption(int option
)
278 int new_state_ok
= 0;
280 if (do_dont_resp
[option
]) {
281 --do_dont_resp
[option
];
282 if (do_dont_resp
[option
] && my_state_is_do(option
))
283 --do_dont_resp
[option
];
286 if ((do_dont_resp
[option
] == 0) && my_want_state_is_dont(option
)) {
293 settimer(modenegotiated
);
296 #ifdef AUTHENTICATION
297 case TELOPT_AUTHENTICATION
:
301 #endif /* ENCRYPTION */
309 * Special case for TM. If we get back a WILL,
310 * pretend we got back a WONT.
312 set_my_want_state_dont(option
);
313 set_my_state_dont(option
);
314 return; /* Never reply to TM will's/wont's */
316 case TELOPT_LINEMODE
:
322 set_my_want_state_do(option
);
324 setconnmode(0); /* possibly set new tty mode */
326 do_dont_resp
[option
]++;
327 send_dont(option
, 0);
330 set_my_state_do(option
);
332 if (option
== TELOPT_ENCRYPT
)
333 encrypt_send_support();
334 #endif /* ENCRYPTION */
338 wontoption(int option
)
340 if (do_dont_resp
[option
]) {
341 --do_dont_resp
[option
];
342 if (do_dont_resp
[option
] && my_state_is_dont(option
))
343 --do_dont_resp
[option
];
346 if ((do_dont_resp
[option
] == 0) && my_want_state_is_do(option
)) {
350 #ifdef KLUDGELINEMODE
357 settimer(modenegotiated
);
363 set_my_want_state_dont(option
);
364 set_my_state_dont(option
);
365 return; /* Never reply to TM will's/wont's */
370 set_my_want_state_dont(option
);
371 if (my_state_is_do(option
))
372 send_dont(option
, 0);
373 setconnmode(0); /* Set new tty mode */
374 } else if (option
== TELOPT_TM
) {
376 * Special case for TM.
380 set_my_want_state_dont(option
);
382 set_my_state_dont(option
);
388 int new_state_ok
= 0;
390 if (will_wont_resp
[option
]) {
391 --will_wont_resp
[option
];
392 if (will_wont_resp
[option
] && my_state_is_will(option
))
393 --will_wont_resp
[option
];
396 if (will_wont_resp
[option
] == 0) {
397 if (my_want_state_is_wont(option
)) {
403 * Special case for TM. We send a WILL, but pretend
406 send_will(option
, 0);
407 set_my_want_state_wont(TELOPT_TM
);
408 set_my_state_wont(TELOPT_TM
);
411 case TELOPT_BINARY
: /* binary mode */
412 case TELOPT_NAWS
: /* window size */
413 case TELOPT_TSPEED
: /* terminal speed */
414 case TELOPT_LFLOW
: /* local flow control */
415 case TELOPT_TTYPE
: /* terminal type option */
416 case TELOPT_SGA
: /* no big deal */
418 case TELOPT_ENCRYPT
: /* encryption variable option */
419 #endif /* ENCRYPTION */
423 case TELOPT_NEW_ENVIRON
: /* New environment variable option */
425 if (my_state_is_will(TELOPT_OLD_ENVIRON
))
426 send_wont(TELOPT_OLD_ENVIRON
, 1); /* turn off the old */
428 case TELOPT_OLD_ENVIRON
: /* Old environment variable option */
429 if (my_state_is_will(TELOPT_NEW_ENVIRON
))
430 break; /* Don't enable if new one is in use! */
432 telopt_environ
= option
;
437 #ifdef AUTHENTICATION
438 case TELOPT_AUTHENTICATION
:
444 case TELOPT_XDISPLOC
: /* X Display location */
445 if (env_getvalue("DISPLAY"))
449 case TELOPT_LINEMODE
:
450 #ifdef KLUDGELINEMODE
452 send_do(TELOPT_SGA
, 1);
454 set_my_want_state_will(TELOPT_LINEMODE
);
455 send_will(option
, 0);
456 set_my_state_will(TELOPT_LINEMODE
);
460 case TELOPT_ECHO
: /* We're never going to echo... */
466 set_my_want_state_will(option
);
467 send_will(option
, 0);
468 setconnmode(0); /* Set new tty mode */
470 will_wont_resp
[option
]++;
471 send_wont(option
, 0);
475 * Handle options that need more things done after the
476 * other side has acknowledged the option.
479 case TELOPT_LINEMODE
:
480 #ifdef KLUDGELINEMODE
482 send_do(TELOPT_SGA
, 1);
484 set_my_state_will(option
);
486 send_do(TELOPT_SGA
, 0);
491 set_my_state_will(option
);
495 dontoption(int option
)
498 if (will_wont_resp
[option
]) {
499 --will_wont_resp
[option
];
500 if (will_wont_resp
[option
] && my_state_is_wont(option
))
501 --will_wont_resp
[option
];
504 if ((will_wont_resp
[option
] == 0) && my_want_state_is_will(option
)) {
506 case TELOPT_LINEMODE
:
507 linemode
= 0; /* put us back to the default state */
510 case TELOPT_NEW_ENVIRON
:
512 * The new environ option wasn't recognized, try
515 send_will(TELOPT_OLD_ENVIRON
, 1);
516 telopt_environ
= TELOPT_OLD_ENVIRON
;
520 /* we always accept a DONT */
521 set_my_want_state_wont(option
);
522 if (my_state_is_will(option
))
523 send_wont(option
, 0);
524 setconnmode(0); /* Set new tty mode */
526 set_my_state_wont(option
);
530 * Given a buffer returned by tgetent(), this routine will turn
531 * the pipe separated list of names in the buffer into an array
532 * of pointers to null terminated names. We toss out any bad,
533 * duplicate, or verbose names (names with spaces).
536 static const char *name_unknown
= "UNKNOWN";
537 static const char *unknown
[] = { NULL
, NULL
};
540 mklist(char *buf
, char *name
)
543 char c
, *cp
, **argvp
, *cp2
, **argv
, **avt
;
546 if (strlen(name
) > 40) {
548 unknown
[0] = name_unknown
;
554 unknown
[0] = name_unknown
;
556 * Count up the number of names.
558 for (n
= 1, cp
= buf
; *cp
&& *cp
!= ':'; cp
++) {
563 * Allocate an array to put the name pointers into
565 argv
= (char **)malloc((n
+3)*sizeof(char *));
570 * Fill up the array of pointers to names.
575 for (cp
= cp2
= buf
; (c
= *cp
); cp
++) {
576 if (c
== '|' || c
== ':') {
579 * Skip entries that have spaces or are over 40
580 * characters long. If this is our environment
581 * name, then put it up front. Otherwise, as
582 * long as this is not a duplicate name (case
583 * insensitive) add it to the list.
585 if (n
|| (cp
- cp2
> 41))
587 else if (name
&& (strncasecmp(name
, cp2
, cp
-cp2
) == 0))
589 else if (is_unique(cp2
, argv
+1, argvp
))
594 * Skip multiple delimiters. Reset cp2 to
595 * the beginning of the next name. Reset n,
596 * the flag for names with spaces.
598 while ((c
= *cp
) == '|')
604 * Skip entries with spaces or non-ascii values.
605 * Convert lower case letters to upper case.
607 if ((c
== ' ') || !isascii(c
))
614 * Check for an old V6 2 character name. If the second
615 * name points to the beginning of the buffer, and is
616 * only 2 characters long, move it to the end of the array.
618 if ((argv
[1] == buf
) && (strlen(argv
[1]) == 2)) {
620 for (avt
= &argv
[1]; avt
< argvp
; avt
++)
626 * Duplicate last name, for TTYPE option, and null
627 * terminate the array. If we didn't find a match on
628 * our terminal name, put that name at the beginning.
639 for (avt
= argv
; avt
< argvp
; avt
++)
644 return((const char **)argv
);
650 is_unique(char *name
, char **as
, char **ae
)
655 n
= strlen(name
) + 1;
656 for (ap
= as
; ap
< ae
; ap
++)
657 if (strncasecmp(*ap
, name
, n
) == 0)
667 setupterm(char *tname
, int fd
, int *errp
)
669 if (tgetent(termbuf
, tname
) == 1) {
670 termbuf
[1023] = '\0';
680 #define termbuf ttytype
681 extern char ttytype
[];
684 int resettermname
= 1;
690 static const char **tnamep
= 0;
691 static const char **next
;
696 if (tnamep
&& tnamep
!= unknown
)
698 if ((tname
= env_getvalue("TERM")) &&
699 (setupterm(tname
, 1, &err
) == 0)) {
700 tnamep
= mklist(termbuf
, tname
);
702 if (tname
&& (strlen(tname
) <= 40)) {
706 unknown
[0] = name_unknown
;
718 * Look at the sub-option buffer, and try to be helpful to the other
721 * Currently we recognize:
723 * Terminal type, send request.
724 * Terminal speed (send request).
725 * Local flow control (is request).
732 unsigned char subchar
;
734 printsub('<', subbuffer
, SB_LEN()+2);
735 switch (subchar
= SB_GET()) {
737 if (my_want_state_is_wont(TELOPT_TTYPE
))
739 if (SB_EOF() || SB_GET() != TELQUAL_SEND
) {
743 unsigned char temp
[50];
746 name
= gettermname();
747 len
= strlen(name
) + 4 + 2;
748 if (len
< NETROOM()) {
749 sprintf(temp
, "%c%c%c%c%s%c%c", IAC
, SB
, TELOPT_TTYPE
,
750 TELQUAL_IS
, name
, IAC
, SE
);
751 ring_supply_data(&netoring
, temp
, len
);
752 printsub('>', &temp
[2], len
-2);
754 ExitString("No room in buffer for terminal type.\n", 1);
760 if (my_want_state_is_wont(TELOPT_TSPEED
))
764 if (SB_GET() == TELQUAL_SEND
) {
766 unsigned char temp
[50];
769 TerminalSpeeds(&ispeed
, &ospeed
);
771 sprintf((char *)temp
, "%c%c%c%c%ld,%ld%c%c", IAC
, SB
, TELOPT_TSPEED
,
772 TELQUAL_IS
, ospeed
, ispeed
, IAC
, SE
);
773 len
= strlen((char *)temp
+4) + 4; /* temp[3] is 0 ... */
775 if (len
< NETROOM()) {
776 ring_supply_data(&netoring
, temp
, len
);
777 printsub('>', temp
+2, len
- 2);
779 /*@*/ else printf("lm_will: not enough room in buffer\n");
783 if (my_want_state_is_wont(TELOPT_LFLOW
))
788 case LFLOW_RESTART_ANY
:
791 case LFLOW_RESTART_XON
:
807 case TELOPT_LINEMODE
:
808 if (my_want_state_is_wont(TELOPT_LINEMODE
))
814 lm_will(subpointer
, SB_LEN());
817 lm_wont(subpointer
, SB_LEN());
820 lm_do(subpointer
, SB_LEN());
823 lm_dont(subpointer
, SB_LEN());
826 slc(subpointer
, SB_LEN());
829 lm_mode(subpointer
, SB_LEN(), 0);
837 case TELOPT_OLD_ENVIRON
:
839 case TELOPT_NEW_ENVIRON
:
845 if (my_want_state_is_dont(subchar
))
849 if (my_want_state_is_wont(subchar
)) {
856 env_opt(subpointer
, SB_LEN());
859 case TELOPT_XDISPLOC
:
860 if (my_want_state_is_wont(TELOPT_XDISPLOC
))
864 if (SB_GET() == TELQUAL_SEND
) {
865 unsigned char temp
[50], *dp
;
868 if ((dp
= env_getvalue("DISPLAY")) == NULL
||
869 strlen(dp
) > sizeof(temp
) - 7) {
871 * Something happened, we no longer have a DISPLAY
872 * variable. Or it is too long. So, turn off the option.
874 send_wont(TELOPT_XDISPLOC
, 1);
877 snprintf(temp
, sizeof(temp
), "%c%c%c%c%s%c%c", IAC
, SB
,
878 TELOPT_XDISPLOC
, TELQUAL_IS
, dp
, IAC
, SE
);
879 len
= strlen((char *)temp
+4) + 4; /* temp[3] is 0 ... */
881 if (len
< NETROOM()) {
882 ring_supply_data(&netoring
, temp
, len
);
883 printsub('>', temp
+2, len
- 2);
885 /*@*/ else printf("lm_will: not enough room in buffer\n");
889 #ifdef AUTHENTICATION
890 case TELOPT_AUTHENTICATION
: {
897 if (my_want_state_is_dont(TELOPT_AUTHENTICATION
))
899 auth_is(subpointer
, SB_LEN());
902 if (my_want_state_is_wont(TELOPT_AUTHENTICATION
))
904 auth_send(subpointer
, SB_LEN());
907 if (my_want_state_is_wont(TELOPT_AUTHENTICATION
))
909 auth_reply(subpointer
, SB_LEN());
912 if (my_want_state_is_dont(TELOPT_AUTHENTICATION
))
914 auth_name(subpointer
, SB_LEN());
926 if (my_want_state_is_dont(TELOPT_ENCRYPT
))
928 encrypt_start(subpointer
, SB_LEN());
931 if (my_want_state_is_dont(TELOPT_ENCRYPT
))
935 case ENCRYPT_SUPPORT
:
936 if (my_want_state_is_wont(TELOPT_ENCRYPT
))
938 encrypt_support(subpointer
, SB_LEN());
940 case ENCRYPT_REQSTART
:
941 if (my_want_state_is_wont(TELOPT_ENCRYPT
))
943 encrypt_request_start(subpointer
, SB_LEN());
946 if (my_want_state_is_wont(TELOPT_ENCRYPT
))
949 * We can always send an REQEND so that we cannot
950 * get stuck encrypting. We should only get this
951 * if we have been able to get in the correct mode
954 encrypt_request_end();
957 if (my_want_state_is_dont(TELOPT_ENCRYPT
))
959 encrypt_is(subpointer
, SB_LEN());
962 if (my_want_state_is_wont(TELOPT_ENCRYPT
))
964 encrypt_reply(subpointer
, SB_LEN());
966 case ENCRYPT_ENC_KEYID
:
967 if (my_want_state_is_dont(TELOPT_ENCRYPT
))
969 encrypt_enc_keyid(subpointer
, SB_LEN());
971 case ENCRYPT_DEC_KEYID
:
972 if (my_want_state_is_wont(TELOPT_ENCRYPT
))
974 encrypt_dec_keyid(subpointer
, SB_LEN());
980 #endif /* ENCRYPTION */
986 static unsigned char str_lm
[] = { IAC
, SB
, TELOPT_LINEMODE
, 0, 0, IAC
, SE
};
989 lm_will(unsigned char *cmd
, int len
)
992 /*@*/ printf("lm_will: no command!!!\n"); /* Should not happen... */
996 case LM_FORWARDMASK
: /* We shouldn't ever get this... */
1000 if (NETROOM() > (int)sizeof(str_lm
)) {
1001 ring_supply_data(&netoring
, str_lm
, sizeof(str_lm
));
1002 printsub('>', &str_lm
[2], sizeof(str_lm
)-2);
1004 /*@*/ else printf("lm_will: not enough room in buffer\n");
1010 lm_wont(unsigned char *cmd
, int len
)
1013 /*@*/ printf("lm_wont: no command!!!\n"); /* Should not happen... */
1017 case LM_FORWARDMASK
: /* We shouldn't ever get this... */
1019 /* We are always DONT, so don't respond */
1025 lm_do(unsigned char *cmd
, int len
)
1028 /*@*/ printf("lm_do: no command!!!\n"); /* Should not happen... */
1032 case LM_FORWARDMASK
:
1036 if (NETROOM() > (int)sizeof(str_lm
)) {
1037 ring_supply_data(&netoring
, str_lm
, sizeof(str_lm
));
1038 printsub('>', &str_lm
[2], sizeof(str_lm
)-2);
1040 /*@*/ else printf("lm_do: not enough room in buffer\n");
1046 lm_dont(unsigned char *cmd
, int len
)
1049 /*@*/ printf("lm_dont: no command!!!\n"); /* Should not happen... */
1053 case LM_FORWARDMASK
:
1055 /* we are always WONT, so don't respond */
1060 static unsigned char str_lm_mode
[] = {
1061 IAC
, SB
, TELOPT_LINEMODE
, LM_MODE
, 0, IAC
, SE
1065 lm_mode(unsigned char *cmd
, int len
, int init
)
1069 if ((linemode
&MODE_MASK
&~MODE_ACK
) == *cmd
)
1073 linemode
= *cmd
&(MODE_MASK
&~MODE_ACK
);
1074 str_lm_mode
[4] = linemode
;
1076 str_lm_mode
[4] |= MODE_ACK
;
1077 if (NETROOM() > (int)sizeof(str_lm_mode
)) {
1078 ring_supply_data(&netoring
, str_lm_mode
, sizeof(str_lm_mode
));
1079 printsub('>', &str_lm_mode
[2], sizeof(str_lm_mode
)-2);
1081 /*@*/ else printf("lm_mode: not enough room in buffer\n");
1082 setconnmode(0); /* set changed mode */
1089 * Handle special character suboption of LINEMODE.
1095 char flags
; /* Current flags & level */
1096 char mylevel
; /* Maximum level & flags */
1099 #define SLC_IMPORT 0
1100 #define SLC_EXPORT 1
1101 #define SLC_RVALUE 2
1102 static int slc_mode
= SLC_EXPORT
;
1110 for (spcp
= spc_data
; spcp
< &spc_data
[NSLC
+1]; spcp
++) {
1113 spcp
->flags
= spcp
->mylevel
= SLC_NOSUPPORT
;
1116 #define initfunc(func, flags) { \
1117 spcp = &spc_data[func]; \
1118 if ((spcp->valp = tcval(func))) { \
1119 spcp->val = *spcp->valp; \
1120 spcp->mylevel = SLC_VARIABLE|flags; \
1123 spcp->mylevel = SLC_DEFAULT; \
1127 initfunc(SLC_SYNCH
, 0);
1129 initfunc(SLC_AO
, 0);
1130 initfunc(SLC_AYT
, 0);
1132 initfunc(SLC_ABORT
, SLC_FLUSHIN
|SLC_FLUSHOUT
);
1133 initfunc(SLC_EOF
, 0);
1135 initfunc(SLC_SUSP
, SLC_FLUSHIN
);
1137 initfunc(SLC_EC
, 0);
1138 initfunc(SLC_EL
, 0);
1140 initfunc(SLC_EW
, 0);
1141 initfunc(SLC_RP
, 0);
1142 initfunc(SLC_LNEXT
, 0);
1144 initfunc(SLC_XON
, 0);
1145 initfunc(SLC_XOFF
, 0);
1147 spc_data
[SLC_XON
].mylevel
= SLC_CANTCHANGE
;
1148 spc_data
[SLC_XOFF
].mylevel
= SLC_CANTCHANGE
;
1150 initfunc(SLC_FORW1
, 0);
1152 initfunc(SLC_FORW2
, 0);
1156 initfunc(SLC_IP
, SLC_FLUSHIN
|SLC_FLUSHOUT
);
1159 if (slc_mode
== SLC_EXPORT
)
1169 printf("Special characters are %s values\n",
1170 slc_mode
== SLC_IMPORT
? "remote default" :
1171 slc_mode
== SLC_EXPORT
? "local" :
1176 slc_mode_export(void)
1178 slc_mode
= SLC_EXPORT
;
1179 if (my_state_is_will(TELOPT_LINEMODE
))
1184 slc_mode_import(int def
)
1186 slc_mode
= def
? SLC_IMPORT
: SLC_RVALUE
;
1187 if (my_state_is_will(TELOPT_LINEMODE
))
1191 unsigned char slc_import_val
[] = {
1192 IAC
, SB
, TELOPT_LINEMODE
, LM_SLC
, 0, SLC_VARIABLE
, 0, IAC
, SE
1194 unsigned char slc_import_def
[] = {
1195 IAC
, SB
, TELOPT_LINEMODE
, LM_SLC
, 0, SLC_DEFAULT
, 0, IAC
, SE
1201 if (NETROOM() > (int)sizeof(slc_import_val
)) {
1203 ring_supply_data(&netoring
, slc_import_def
, sizeof(slc_import_def
));
1204 printsub('>', &slc_import_def
[2], sizeof(slc_import_def
)-2);
1206 ring_supply_data(&netoring
, slc_import_val
, sizeof(slc_import_val
));
1207 printsub('>', &slc_import_val
[2], sizeof(slc_import_val
)-2);
1210 /*@*/ else printf("slc_import: not enough room\n");
1218 TerminalDefaultChars();
1221 for (spcp
= &spc_data
[1]; spcp
< &spc_data
[NSLC
+1]; spcp
++) {
1222 if (spcp
->mylevel
!= SLC_NOSUPPORT
) {
1223 if (spcp
->val
== (cc_t
)(_POSIX_VDISABLE
))
1224 spcp
->flags
= SLC_NOSUPPORT
;
1226 spcp
->flags
= spcp
->mylevel
;
1228 spcp
->val
= *spcp
->valp
;
1229 slc_add_reply(spcp
- spc_data
, spcp
->flags
, spcp
->val
);
1234 setconnmode(1); /* Make sure the character values are set */
1238 slc(unsigned char *cp
, int len
)
1245 for (; len
>= 3; len
-=3, cp
+=3) {
1247 func
= cp
[SLC_FUNC
];
1251 * Client side: always ignore 0 function.
1256 if ((cp
[SLC_FLAGS
] & SLC_LEVELBITS
) != SLC_NOSUPPORT
)
1257 slc_add_reply(func
, SLC_NOSUPPORT
, 0);
1261 spcp
= &spc_data
[func
];
1263 level
= cp
[SLC_FLAGS
]&(SLC_LEVELBITS
|SLC_ACK
);
1265 if ((cp
[SLC_VALUE
] == (unsigned char)spcp
->val
) &&
1266 ((level
&SLC_LEVELBITS
) == (spcp
->flags
&SLC_LEVELBITS
))) {
1270 if (level
== (SLC_DEFAULT
|SLC_ACK
)) {
1272 * This is an error condition, the SLC_ACK
1273 * bit should never be set for the SLC_DEFAULT
1274 * level. Our best guess to recover is to
1275 * ignore the SLC_ACK bit.
1277 cp
[SLC_FLAGS
] &= ~SLC_ACK
;
1280 if (level
== ((spcp
->flags
&SLC_LEVELBITS
)|SLC_ACK
)) {
1281 spcp
->val
= (cc_t
)cp
[SLC_VALUE
];
1282 spcp
->flags
= cp
[SLC_FLAGS
]; /* include SLC_ACK */
1288 if (level
<= (spcp
->mylevel
&SLC_LEVELBITS
)) {
1289 spcp
->flags
= cp
[SLC_FLAGS
]|SLC_ACK
;
1290 spcp
->val
= (cc_t
)cp
[SLC_VALUE
];
1292 if (level
== SLC_DEFAULT
) {
1293 if ((spcp
->mylevel
&SLC_LEVELBITS
) != SLC_DEFAULT
)
1294 spcp
->flags
= spcp
->mylevel
;
1296 spcp
->flags
= SLC_NOSUPPORT
;
1298 slc_add_reply(func
, spcp
->flags
, spcp
->val
);
1302 setconnmode(1); /* set the new character values */
1311 for (spcp
= &spc_data
[1]; spcp
< &spc_data
[NSLC
+1]; spcp
++) {
1312 if (spcp
->valp
&& spcp
->val
!= *spcp
->valp
) {
1313 spcp
->val
= *spcp
->valp
;
1314 if (spcp
->val
== (cc_t
)(_POSIX_VDISABLE
))
1315 spcp
->flags
= SLC_NOSUPPORT
;
1317 spcp
->flags
= spcp
->mylevel
;
1318 slc_add_reply(spcp
- spc_data
, spcp
->flags
, spcp
->val
);
1325 unsigned char slc_reply
[128];
1326 unsigned char const * const slc_reply_eom
= &slc_reply
[sizeof(slc_reply
)];
1327 unsigned char *slc_replyp
;
1330 slc_start_reply(void)
1332 slc_replyp
= slc_reply
;
1333 *slc_replyp
++ = IAC
;
1335 *slc_replyp
++ = TELOPT_LINEMODE
;
1336 *slc_replyp
++ = LM_SLC
;
1340 slc_add_reply(unsigned char func
, unsigned char flags
, cc_t value
)
1342 /* A sequence of up to 6 bytes my be written for this member of the SLC
1343 * suboption list by this function. The end of negotiation command,
1344 * which is written by slc_end_reply(), will require 2 additional
1345 * bytes. Do not proceed unless there is sufficient space for these
1348 if (&slc_replyp
[6+2] > slc_reply_eom
)
1350 if ((*slc_replyp
++ = func
) == IAC
)
1351 *slc_replyp
++ = IAC
;
1352 if ((*slc_replyp
++ = flags
) == IAC
)
1353 *slc_replyp
++ = IAC
;
1354 if ((*slc_replyp
++ = (unsigned char)value
) == IAC
)
1355 *slc_replyp
++ = IAC
;
1363 *slc_replyp
++ = IAC
;
1365 len
= slc_replyp
- slc_reply
;
1368 if (NETROOM() > len
) {
1369 ring_supply_data(&netoring
, slc_reply
, slc_replyp
- slc_reply
);
1370 printsub('>', &slc_reply
[2], slc_replyp
- slc_reply
- 2);
1372 /*@*/else printf("slc_end_reply: not enough room\n");
1379 int need_update
= 0;
1381 for (spcp
= &spc_data
[1]; spcp
< &spc_data
[NSLC
+1]; spcp
++) {
1382 if (!(spcp
->flags
&SLC_ACK
))
1384 spcp
->flags
&= ~SLC_ACK
;
1385 if (spcp
->valp
&& (*spcp
->valp
!= spcp
->val
)) {
1386 *spcp
->valp
= spcp
->val
;
1390 return(need_update
);
1396 * Earlier version of telnet/telnetd from the BSD code had
1397 * the definitions of VALUE and VAR reversed. To ensure
1398 * maximum interoperability, we assume that the server is
1399 * an older BSD server, until proven otherwise. The newer
1400 * BSD servers should be able to handle either definition,
1401 * so it is better to use the wrong values if we don't
1402 * know what type of server it is.
1405 int old_env_var
= OLD_ENV_VAR
;
1406 int old_env_value
= OLD_ENV_VALUE
;
1408 # define old_env_var OLD_ENV_VAR
1409 # define old_env_value OLD_ENV_VALUE
1414 env_opt(unsigned char *buf
, int len
)
1416 unsigned char *ep
= 0, *epc
= 0;
1419 switch(buf
[0]&0xff) {
1424 } else for (i
= 1; i
< len
; i
++) {
1425 switch (buf
[i
]&0xff) {
1429 if (telopt_environ
== TELOPT_OLD_ENVIRON
1431 /* Server has the same definitions */
1432 old_env_var
= OLD_ENV_VAR
;
1433 old_env_value
= OLD_ENV_VALUE
;
1439 * Although OLD_ENV_VALUE is not legal, we will
1440 * still recognize it, just in case it is an
1441 * old server that has VAR & VALUE mixed up...
1452 ep
= epc
= &buf
[i
+1];
1472 /* Ignore for now. We shouldn't get it anyway. */
1480 #define OPT_REPLY_SIZE 256
1481 unsigned char *opt_reply
;
1482 unsigned char *opt_replyp
;
1483 unsigned char *opt_replyend
;
1489 opt_reply
= (unsigned char *)realloc(opt_reply
, OPT_REPLY_SIZE
);
1491 opt_reply
= (unsigned char *)malloc(OPT_REPLY_SIZE
);
1492 if (opt_reply
== NULL
) {
1493 /*@*/ printf("env_opt_start: malloc()/realloc() failed!!!\n");
1494 opt_reply
= opt_replyp
= opt_replyend
= NULL
;
1497 opt_replyp
= opt_reply
;
1498 opt_replyend
= opt_reply
+ OPT_REPLY_SIZE
;
1499 *opt_replyp
++ = IAC
;
1501 *opt_replyp
++ = telopt_environ
;
1502 *opt_replyp
++ = TELQUAL_IS
;
1506 env_opt_start_info(void)
1510 opt_replyp
[-1] = TELQUAL_INFO
;
1514 env_opt_add(unsigned char *ep
)
1516 unsigned char *vp
, c
;
1518 if (opt_reply
== NULL
) /*XXX*/
1521 if (ep
== NULL
|| *ep
== '\0') {
1522 /* Send user defined variables first. */
1524 while ((ep
= env_default(0, 0)))
1527 /* Now add the list of well know variables. */
1529 while ((ep
= env_default(0, 1)))
1533 vp
= env_getvalue(ep
);
1534 if (opt_replyp
+ 2*(vp
? strlen((char *)vp
) : 0) +
1535 2*strlen((char *)ep
) + 6 > opt_replyend
)
1538 opt_replyend
+= OPT_REPLY_SIZE
+ 2*strlen((char *)ep
) + 2*(vp
? strlen((char *)vp
) : 0);
1539 len
= opt_replyend
- opt_reply
;
1540 opt_reply
= (unsigned char *)realloc(opt_reply
, len
);
1541 if (opt_reply
== NULL
) {
1542 /*@*/ printf("env_opt_add: realloc() failed!!!\n");
1543 opt_reply
= opt_replyp
= opt_replyend
= NULL
;
1546 opt_replyp
= opt_reply
+ len
- (opt_replyend
- opt_replyp
);
1547 opt_replyend
= opt_reply
+ len
;
1549 if (opt_welldefined(ep
))
1551 if (telopt_environ
== TELOPT_OLD_ENVIRON
)
1552 *opt_replyp
++ = old_env_var
;
1555 *opt_replyp
++ = NEW_ENV_VAR
;
1557 *opt_replyp
++ = ENV_USERVAR
;
1559 while ((c
= *ep
++)) {
1562 *opt_replyp
++ = IAC
;
1568 *opt_replyp
++ = ENV_ESC
;
1575 if (telopt_environ
== TELOPT_OLD_ENVIRON
)
1576 *opt_replyp
++ = old_env_value
;
1579 *opt_replyp
++ = NEW_ENV_VALUE
;
1587 opt_welldefined(const char *ep
)
1589 if ((strcmp(ep
, "USER") == 0) ||
1590 (strcmp(ep
, "DISPLAY") == 0) ||
1591 (strcmp(ep
, "PRINTER") == 0) ||
1592 (strcmp(ep
, "SYSTEMTYPE") == 0) ||
1593 (strcmp(ep
, "JOB") == 0) ||
1594 (strcmp(ep
, "ACCT") == 0))
1600 env_opt_end(int emptyok
)
1604 len
= opt_replyp
- opt_reply
+ 2;
1605 if (emptyok
|| len
> 6) {
1606 *opt_replyp
++ = IAC
;
1608 if (NETROOM() > len
) {
1609 ring_supply_data(&netoring
, opt_reply
, len
);
1610 printsub('>', &opt_reply
[2], len
- 2);
1612 /*@*/ else printf("slc_end_reply: not enough room\n");
1616 opt_reply
= opt_replyp
= opt_replyend
= NULL
;
1629 int returnValue
= 0;
1633 while (TTYROOM() > 2) {
1636 ring_consumed(&netiring
, count
);
1640 sbp
= netiring
.consume
;
1641 scc
= ring_full_consecutive(&netiring
);
1643 /* No more data coming in */
1648 c
= *sbp
++ & 0xff, scc
--; count
++;
1651 c
= (*decrypt_input
)(c
);
1652 #endif /* ENCRYPTION */
1654 switch (telrcv_state
) {
1657 telrcv_state
= TS_DATA
;
1659 break; /* Ignore \0 after CR */
1661 else if ((c
== '\n') && my_want_state_is_dont(TELOPT_ECHO
) && !crmod
) {
1665 /* Else, fall through */
1669 telrcv_state
= TS_IAC
;
1673 * The 'crmod' hack (see following) is needed
1674 * since we can't * set CRMOD on output only.
1675 * Machines like MULTICS like to send \r without
1676 * \n; since we must turn off CRMOD to get proper
1677 * input, the mapping is done here (sigh).
1679 if ((c
== '\r') && my_want_state_is_dont(TELOPT_BINARY
)) {
1684 c
= (*decrypt_input
)(c
);
1685 #endif /* ENCRYPTION */
1687 sbp
++, scc
--; count
++;
1690 } else if (my_want_state_is_dont(TELOPT_ECHO
) &&
1692 sbp
++, scc
--; count
++;
1697 (*decrypt_input
)(-1);
1698 #endif /* ENCRYPTION */
1706 telrcv_state
= TS_CR
;
1722 telrcv_state
= TS_WILL
;
1726 telrcv_state
= TS_WONT
;
1730 telrcv_state
= TS_DO
;
1734 telrcv_state
= TS_DONT
;
1739 * We may have missed an urgent notification,
1740 * so make sure we flush whatever is in the
1743 printoption("RCVD", IAC
, DM
);
1746 SYNCHing
= stilloob();
1752 telrcv_state
= TS_SB
;
1762 printoption("RCVD", IAC
, c
);
1765 telrcv_state
= TS_DATA
;
1769 printoption("RCVD", WILL
, c
);
1771 telrcv_state
= TS_DATA
;
1775 printoption("RCVD", WONT
, c
);
1777 telrcv_state
= TS_DATA
;
1781 printoption("RCVD", DO
, c
);
1783 if (c
== TELOPT_NAWS
) {
1785 } else if (c
== TELOPT_LFLOW
) {
1790 telrcv_state
= TS_DATA
;
1794 printoption("RCVD", DONT
, c
);
1797 setconnmode(0); /* set new tty mode (maybe) */
1798 telrcv_state
= TS_DATA
;
1803 telrcv_state
= TS_SE
;
1813 * This is an error. We only expect to get
1814 * "IAC IAC" or "IAC SE". Several things may
1815 * have happend. An IAC was not doubled, the
1816 * IAC SE was left off, or another option got
1817 * inserted into the suboption are all possibilities.
1818 * If we assume that the IAC was not doubled,
1819 * and really the IAC SE was left off, we could
1820 * get into an infinate loop here. So, instead,
1821 * we terminate the suboption, and process the
1822 * partial suboption if we can.
1829 printoption("In SUBOPTION processing, RCVD", IAC
, c
);
1830 suboption(); /* handle sub-option */
1831 telrcv_state
= TS_IAC
;
1835 telrcv_state
= TS_SB
;
1841 suboption(); /* handle sub-option */
1842 telrcv_state
= TS_DATA
;
1847 ring_consumed(&netiring
, count
);
1848 return returnValue
||count
;
1851 static int bol
= 1, local
= 0;
1859 command(0, "z\n", 2);
1870 int returnValue
= 0;
1875 while (NETROOM() > 2) {
1881 ring_consumed(&ttyiring
, count
);
1885 tbp
= ttyiring
.consume
;
1886 tcc
= ring_full_consecutive(&ttyiring
);
1891 c
= *tbp
++ & 0xff, sc
= strip(c
), tcc
--; count
++;
1892 if (rlogin
!= _POSIX_VDISABLE
) {
1901 if (sc
== '.' || c
== termEofChar
) {
1903 command(0, "close\n", 6);
1906 if (sc
== termSuspChar
) {
1908 command(0, "z\n", 2);
1912 command(0, tbp
, tcc
);
1926 if ((sc
== '\n') || (sc
== '\r'))
1928 } else if (escape
!= _POSIX_VDISABLE
&& sc
== escape
) {
1930 * Double escape is a pass through of a single escape character.
1932 if (tcc
&& strip(*tbp
) == escape
) {
1938 command(0, (char *)tbp
, tcc
);
1947 #ifdef KLUDGELINEMODE
1948 if (kludgelinemode
&& (globalmode
&MODE_EDIT
) && (sc
== echoc
)) {
1949 if (tcc
> 0 && strip(*tbp
) == echoc
) {
1950 tcc
--; tbp
++; count
++;
1952 dontlecho
= !dontlecho
;
1953 settimer(echotoggle
);
1960 if (MODE_LOCAL_CHARS(globalmode
)) {
1961 if (TerminalSpecialChars(sc
) == 0) {
1966 if (my_want_state_is_wont(TELOPT_BINARY
)) {
1970 * If we are in CRMOD mode (\r ==> \n)
1971 * on our local machine, then probably
1972 * a newline (unix) is CRLF (TELNET).
1974 if (MODE_LOCAL_CHARS(globalmode
)) {
1978 bol
= flushline
= 1;
1982 NET2ADD('\r', '\0');
1984 NET2ADD('\r', '\n');
1986 bol
= flushline
= 1;
1995 } else if (c
== IAC
) {
2002 ring_consumed(&ttyiring
, count
);
2003 return returnValue
||count
; /* Non-zero if we did anything */
2009 * Try to do something.
2011 * If we do something useful, return 1; else return 0.
2016 Scheduler(int block
)
2018 /* One wants to be a bit careful about setting returnValue
2019 * to one, since a one implies we did some useful work,
2020 * and therefore probably won't be called to block next
2023 int netin
, netout
, netex
, ttyin
, ttyout
;
2025 /* Decide which rings should be processed */
2027 netout
= ring_full_count(&netoring
) &&
2029 (my_want_state_is_wont(TELOPT_LINEMODE
)
2030 #ifdef KLUDGELINEMODE
2031 && (!kludgelinemode
|| my_want_state_is_do(TELOPT_SGA
))
2034 my_want_state_is_will(TELOPT_BINARY
));
2035 ttyout
= ring_full_count(&ttyoring
);
2037 ttyin
= ring_empty_count(&ttyiring
) && (clienteof
== 0);
2039 netin
= !ISend
&& ring_empty_count(&netiring
);
2043 /* Call to system code to process rings */
2045 returnValue
= process_rings(netin
, netout
, netex
, ttyin
, ttyout
, !block
);
2047 /* Now, look at the input rings, looking for work to do. */
2049 if (ring_full_count(&ttyiring
)) {
2050 returnValue
|= telsnd();
2053 if (ring_full_count(&netiring
)) {
2054 returnValue
|= telrcv();
2059 #ifdef AUTHENTICATION
2060 #define __unusedhere
2062 #define __unusedhere __unused
2065 * Select from tty and network...
2068 telnet(char *user __unusedhere
)
2072 #ifdef AUTHENTICATION
2075 static char local_host
[256] = { 0 };
2077 if (!local_host
[0]) {
2078 gethostname(local_host
, sizeof(local_host
));
2079 local_host
[sizeof(local_host
)-1] = 0;
2081 auth_encrypt_init(local_host
, hostname
, "TELNET", 0);
2082 auth_encrypt_user(user
);
2087 #ifdef AUTHENTICATION
2089 send_will(TELOPT_AUTHENTICATION
, 1);
2092 send_do(TELOPT_ENCRYPT
, 1);
2093 send_will(TELOPT_ENCRYPT
, 1);
2094 #endif /* ENCRYPTION */
2095 send_do(TELOPT_SGA
, 1);
2096 send_will(TELOPT_TTYPE
, 1);
2097 send_will(TELOPT_NAWS
, 1);
2098 send_will(TELOPT_TSPEED
, 1);
2099 send_will(TELOPT_LFLOW
, 1);
2100 send_will(TELOPT_LINEMODE
, 1);
2101 send_will(TELOPT_NEW_ENVIRON
, 1);
2102 send_do(TELOPT_STATUS
, 1);
2103 if (env_getvalue("DISPLAY"))
2104 send_will(TELOPT_XDISPLOC
, 1);
2106 tel_enter_binary(eight
);
2112 while ((schedValue
= Scheduler(0)) != 0) {
2113 if (schedValue
== -1) {
2119 if (Scheduler(1) == -1) {
2126 #if 0 /* XXX - this not being in is a bug */
2130 * Return the address of the next "item" in the TELNET data
2131 * stream. This will be the address of the next character if
2132 * the current address is a user data character, or it will
2133 * be the address of the character following the TELNET command
2134 * if the current address is a TELNET IAC ("I Am a Command")
2139 nextitem(char *current
)
2141 if ((*current
&0xff) != IAC
) {
2144 switch (*(current
+1)&0xff) {
2150 case SB
: /* loop forever looking for the SE */
2152 char *look
= current
+2;
2155 if ((*look
++&0xff) == IAC
) {
2156 if ((*look
++&0xff) == SE
) {
2171 * We are about to do a TELNET SYNCH operation. Clear
2172 * the path to the network.
2174 * Things are a bit tricky since we may have sent the first
2175 * byte or so of a previous TELNET command into the network.
2176 * So, we have to scan the network buffer from the beginning
2177 * until we are up to where we want to be.
2179 * A side effect of what we do, just to keep things
2180 * simple, is to clear the urgent data pointer. The principal
2181 * caller should be setting the urgent data pointer AFTER calling
2192 * These routines add various telnet commands to the data stream.
2202 (void) ttyflush(1); /* Flush/drop output */
2203 /* do printoption AFTER flush, otherwise the output gets tossed... */
2204 printoption("SENT", DO
, TELOPT_TM
);
2211 printoption("SENT", IAC
, AO
);
2221 printoption("SENT", IAC
, EL
);
2228 printoption("SENT", IAC
, EC
);
2232 dosynch(char *ch __unused
)
2234 netclear(); /* clear the path to the network */
2238 printoption("SENT", IAC
, DM
);
2242 int want_status_response
= 0;
2245 get_status(char *ch __unused
)
2247 unsigned char tmp
[16];
2250 if (my_want_state_is_dont(TELOPT_STATUS
)) {
2251 printf("Remote side does not support STATUS option\n");
2258 *cp
++ = TELOPT_STATUS
;
2259 *cp
++ = TELQUAL_SEND
;
2262 if (NETROOM() >= cp
- tmp
) {
2263 ring_supply_data(&netoring
, tmp
, cp
-tmp
);
2264 printsub('>', tmp
+2, cp
- tmp
- 2);
2266 ++want_status_response
;
2274 printoption("SENT", IAC
, IP
);
2287 NET2ADD(IAC
, BREAK
);
2288 printoption("SENT", IAC
, BREAK
);
2301 NET2ADD(IAC
, ABORT
);
2302 printoption("SENT", IAC
, ABORT
);
2316 printoption("SENT", IAC
, SUSP
);
2330 printoption("SENT", IAC
, xEOF
);
2337 printoption("SENT", IAC
, AYT
);
2341 * Send a window size update to the remote system.
2348 unsigned char tmp
[16];
2351 if (my_state_is_wont(TELOPT_NAWS
))
2354 #define PUTSHORT(cp, x) { if ((*cp++ = ((x)>>8)&0xff) == IAC) *cp++ = IAC; \
2355 if ((*cp++ = ((x))&0xff) == IAC) *cp++ = IAC; }
2357 if (TerminalWindowSize(&rows
, &cols
) == 0) { /* Failed */
2365 *cp
++ = TELOPT_NAWS
;
2370 if (NETROOM() >= cp
- tmp
) {
2371 ring_supply_data(&netoring
, tmp
, cp
-tmp
);
2372 printsub('>', tmp
+2, cp
- tmp
- 2);
2377 tel_enter_binary(int rw
)
2380 send_do(TELOPT_BINARY
, 1);
2382 send_will(TELOPT_BINARY
, 1);
2386 tel_leave_binary(int rw
)
2389 send_dont(TELOPT_BINARY
, 1);
2391 send_wont(TELOPT_BINARY
, 1);