2 * Copyright (c) 1989, 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
36 __RCSID("$Heimdal: state.c 18110 2006-09-19 08:25:20Z lha $"
39 unsigned char doopt
[] = { IAC
, DO
, '%', 'c', 0 };
40 unsigned char dont
[] = { IAC
, DONT
, '%', 'c', 0 };
41 unsigned char will
[] = { IAC
, WILL
, '%', 'c', 0 };
42 unsigned char wont
[] = { IAC
, WONT
, '%', 'c', 0 };
46 * Buffer for sub-options, and macros
47 * for suboptions buffer manipulations
49 unsigned char subbuffer
[1024*64], *subpointer
= subbuffer
, *subend
= subbuffer
;
51 #define SB_CLEAR() subpointer = subbuffer
52 #define SB_TERM() { subend = subpointer; SB_CLEAR(); }
53 #define SB_ACCUM(c) if (subpointer < (subbuffer+sizeof subbuffer)) { \
54 *subpointer++ = (c); \
56 #define SB_GET() ((*subpointer++)&0xff)
57 #define SB_EOF() (subpointer >= subend)
58 #define SB_LEN() (subend - subpointer)
61 unsigned char *subsave
;
62 #define SB_SAVE() subsave = subpointer;
63 #define SB_RESTORE() subpointer = subsave;
70 #define TS_DATA 0 /* base state */
71 #define TS_IAC 1 /* look for double IAC's */
72 #define TS_CR 2 /* CR-LF ->'s CR */
73 #define TS_SB 3 /* throw away begin's... */
74 #define TS_SE 4 /* ...end's (suboption negotiation) */
75 #define TS_WILL 5 /* will option negotiation */
76 #define TS_WONT 6 /* wont -''- */
77 #define TS_DO 7 /* do -''- */
78 #define TS_DONT 8 /* dont -''- */
84 static int state
= TS_DATA
;
87 if ((&ptyobuf
[BUFSIZ
] - pfrontp
) < 2)
89 c
= *netip
++ & 0377, ncc
--;
92 c
= (*decrypt_input
)(c
);
98 /* Strip off \n or \0 after a \r */
99 if ((c
== 0) || (c
== '\n')) {
110 * We now map \r\n ==> \r for pragmatic reasons.
111 * Many client implementations send \r\n when
112 * the user hits the CarriageReturn key.
114 * We USED to map \r\n ==> \n, since \r\n says
115 * that we want to be in column 1 of the next
116 * printable line, and \n is the standard
117 * unix way of saying that (\r is only good
118 * if CRMOD is set, which it normally is).
120 if ((c
== '\r') && his_state_is_wont(TELOPT_BINARY
)) {
124 nc
= (*decrypt_input
)(nc
& 0xff);
129 (void)(*decrypt_input
)(-1);
141 * Send the process on the pty side an
142 * interrupt. Do this with a NULL or
143 * interrupt char; depending on the tty mode.
147 printoption("td: recv IAC", c
));
153 printoption("td: recv IAC", c
));
162 printoption("td: recv IAC", c
));
172 printoption("td: recv IAC", c
));
173 ptyflush(); /* half-hearted */
176 if (slctab
[SLC_AO
].sptr
&&
177 *slctab
[SLC_AO
].sptr
!= (cc_t
)(_POSIX_VDISABLE
)) {
179 (unsigned char)*slctab
[SLC_AO
].sptr
;
182 netclear(); /* clear buffer back */
183 output_data ("%c%c", IAC
, DM
);
184 neturg
= nfrontp
-1; /* off by one XXX */
186 printoption("td: send IAC", DM
));
191 * Erase Character and
200 printoption("td: recv IAC", c
));
201 ptyflush(); /* half-hearted */
204 ch
= *slctab
[SLC_EC
].sptr
;
206 ch
= *slctab
[SLC_EL
].sptr
;
207 if (ch
!= (cc_t
)(_POSIX_VDISABLE
))
208 *pfrontp
++ = (unsigned char)ch
;
213 * Check for urgent data...
217 printoption("td: recv IAC", c
));
218 SYNCHing
= stilloob(net
);
224 * Begin option subnegotiation...
247 if (his_state_is_will(TELOPT_EOR
))
252 * Handle RFC 10xx Telnet linemode option additions
253 * to command stream (EOF, SUSP, ABORT).
286 * bad form of suboption negotiation.
287 * handle it in such a way as to avoid
288 * damage to local state. Parse
289 * suboption buffer found so far,
290 * then treat remaining stream as
291 * another command sequence.
294 /* for DIAGNOSTICS */
307 /* for DIAGNOSTICS */
313 suboption(); /* handle sub-option */
325 if (c
==TELOPT_ENCRYPT
&& his_do_dont_is_changing(TELOPT_ENCRYPT
) )
341 syslog(LOG_ERR
, "telnetd: panic state=%d\n", state
);
342 printf("telnetd: panic state=%d\n", state
);
346 } /* end of telrcv */
349 * The will/wont/do/dont state machines are based on Dave Borman's
350 * Telnet option processing state machine.
352 * These correspond to the following states:
353 * my_state = the last negotiated state
354 * want_state = what I want the state to go to
355 * want_resp = how many requests I have sent
356 * All state defaults are negative, and resp defaults to 0.
358 * When initiating a request to change state to new_state:
360 * if ((want_resp == 0 && new_state == my_state) || want_state == new_state) {
363 * want_state = new_state;
368 * When receiving new_state:
372 * if (want_resp && (new_state == my_state))
375 * if ((want_resp == 0) && (new_state != want_state)) {
376 * if (ok_to_switch_to new_state)
377 * want_state = new_state;
382 * my_state = new_state;
384 * Note that new_state is implied in these functions by the function itself.
385 * will and do imply positive new_state, wont and dont imply negative.
387 * Finally, there is one catch. If we send a negative response to a
388 * positive request, my_state will be the positive while want_state will
389 * remain negative. my_state will revert to negative when the negative
390 * acknowlegment arrives from the peer. Thus, my_state generally tells
391 * us not only the last negotiated state, but also tells us what the peer
392 * wants to be doing as well. It is important to understand this difference
393 * as we may wish to be processing data streams based on our desired state
394 * (want_state) or based on what the peer thinks the state is (my_state).
396 * This all works fine because if the peer sends a positive request, the data
397 * that we receive prior to negative acknowlegment will probably be affected
398 * by the positive state, and we can process it as such (if we can; if we
399 * can't then it really doesn't matter). If it is that important, then the
400 * peer probably should be buffering until this option state negotiation
405 send_do(int option
, int init
)
408 if ((do_dont_resp
[option
] == 0 && his_state_is_will(option
)) ||
409 his_want_state_is_will(option
))
412 * Special case for TELOPT_TM: We send a DO, but pretend
413 * that we sent a DONT, so that we can send more DOs if
416 if (option
== TELOPT_TM
)
417 set_his_want_state_wont(option
);
419 set_his_want_state_will(option
);
420 do_dont_resp
[option
]++;
422 output_data((const char *)doopt
, option
);
424 DIAG(TD_OPTIONS
, printoption("td: send do", option
));
427 #ifdef AUTHENTICATION
428 extern void auth_request(void);
431 extern void encrypt_send_support(void);
435 willoption(int option
)
438 void (*func
)(void) = NULL
;
441 * process input from peer.
444 DIAG(TD_OPTIONS
, printoption("td: recv will", option
));
446 if (do_dont_resp
[option
]) {
447 do_dont_resp
[option
]--;
448 if (do_dont_resp
[option
] && his_state_is_will(option
))
449 do_dont_resp
[option
]--;
451 if (do_dont_resp
[option
] == 0) {
452 if (his_want_state_is_wont(option
)) {
464 * See comments below for more info.
466 not42
= 0; /* looks like a 4.2 system */
471 * We never respond to a WILL TM, and
472 * we leave the state WONT.
478 * If we are going to support flow control
479 * option, then don't worry peer that we can't
480 * change the flow control characters.
482 slctab
[SLC_XON
].defset
.flag
&= ~SLC_LEVELBITS
;
483 slctab
[SLC_XON
].defset
.flag
|= SLC_DEFAULT
;
484 slctab
[SLC_XOFF
].defset
.flag
&= ~SLC_LEVELBITS
;
485 slctab
[SLC_XOFF
].defset
.flag
|= SLC_DEFAULT
;
490 case TELOPT_XDISPLOC
:
491 case TELOPT_NEW_ENVIRON
:
492 case TELOPT_OLD_ENVIRON
:
497 #ifdef AUTHENTICATION
498 case TELOPT_AUTHENTICATION
:
506 func
= encrypt_send_support
;
515 set_his_want_state_will(option
);
518 do_dont_resp
[option
]++;
519 send_dont(option
, 0);
523 * Option processing that should happen when
524 * we receive conformation of a change in
525 * state that we had requested.
529 not42
= 0; /* looks like a 4.2 system */
531 * Egads, he responded "WILL ECHO". Turn
534 send_dont(option
, 1);
536 * "WILL ECHO". Kludge upon kludge!
537 * A 4.2 client is now echoing user input at
538 * the tty. This is probably undesireable and
539 * it should be stopped. The client will
540 * respond WONT TM to the DO TM that we send to
541 * check for kludge linemode. When the WONT TM
542 * arrives, linemode will be turned off and a
543 * change propogated to the pty. This change
544 * will cause us to process the new pty state
545 * in localstat(), which will notice that
546 * linemode is off and send a WILL ECHO
547 * so that we are properly in character mode and
552 #ifdef AUTHENTICATION
553 case TELOPT_AUTHENTICATION
:
560 func
= encrypt_send_support
;
570 set_his_state_will(option
);
573 } /* end of willoption */
576 send_dont(int option
, int init
)
579 if ((do_dont_resp
[option
] == 0 && his_state_is_wont(option
)) ||
580 his_want_state_is_wont(option
))
582 set_his_want_state_wont(option
);
583 do_dont_resp
[option
]++;
585 output_data((const char *)dont
, option
);
587 DIAG(TD_OPTIONS
, printoption("td: send dont", option
));
591 wontoption(int option
)
594 * Process client input.
597 DIAG(TD_OPTIONS
, printoption("td: recv wont", option
));
599 if (do_dont_resp
[option
]) {
600 do_dont_resp
[option
]--;
601 if (do_dont_resp
[option
] && his_state_is_wont(option
))
602 do_dont_resp
[option
]--;
604 if (do_dont_resp
[option
] == 0) {
605 if (his_want_state_is_will(option
)) {
606 /* it is always ok to change to negative state */
609 not42
= 1; /* doesn't seem to be a 4.2 system */
620 * If we get a WONT TM, and had sent a DO TM,
621 * don't respond with a DONT TM, just leave it
622 * as is. Short circut the state machine to
625 set_his_want_state_wont(TELOPT_TM
);
630 * If we are not going to support flow control
631 * option, then let peer know that we can't
632 * change the flow control characters.
634 slctab
[SLC_XON
].defset
.flag
&= ~SLC_LEVELBITS
;
635 slctab
[SLC_XON
].defset
.flag
|= SLC_CANTCHANGE
;
636 slctab
[SLC_XOFF
].defset
.flag
&= ~SLC_LEVELBITS
;
637 slctab
[SLC_XOFF
].defset
.flag
|= SLC_CANTCHANGE
;
640 #ifdef AUTHENTICATION
641 case TELOPT_AUTHENTICATION
:
642 auth_finished(0, AUTH_REJECT
);
647 * For options that we might spin waiting for
648 * sub-negotiation, if the client turns off the
649 * option rather than responding to the request,
650 * we have to treat it here as if we got a response
651 * to the sub-negotiation, (by updating the timers)
652 * so that we'll break out of the loop.
655 settimer(ttypesubopt
);
659 settimer(tspeedsubopt
);
662 case TELOPT_XDISPLOC
:
663 settimer(xdisplocsubopt
);
666 case TELOPT_OLD_ENVIRON
:
667 settimer(oenvironsubopt
);
670 case TELOPT_NEW_ENVIRON
:
671 settimer(environsubopt
);
677 set_his_want_state_wont(option
);
678 if (his_state_is_will(option
))
679 send_dont(option
, 0);
685 #ifdef AUTHENTICATION
686 case TELOPT_AUTHENTICATION
:
687 auth_finished(0, AUTH_REJECT
);
695 set_his_state_wont(option
);
697 } /* end of wontoption */
700 send_will(int option
, int init
)
703 if ((will_wont_resp
[option
] == 0 && my_state_is_will(option
))||
704 my_want_state_is_will(option
))
706 set_my_want_state_will(option
);
707 will_wont_resp
[option
]++;
709 output_data ((const char *)will
, option
);
711 DIAG(TD_OPTIONS
, printoption("td: send will", option
));
715 * When we get a DONT SGA, we will try once to turn it
716 * back on. If the other side responds DONT SGA, we
717 * leave it at that. This is so that when we talk to
718 * clients that understand KLUDGELINEMODE but not LINEMODE,
719 * we'll keep them in char-at-a-time mode.
729 * Process client input.
732 DIAG(TD_OPTIONS
, printoption("td: recv do", option
));
734 if (will_wont_resp
[option
]) {
735 will_wont_resp
[option
]--;
736 if (will_wont_resp
[option
] && my_state_is_will(option
))
737 will_wont_resp
[option
]--;
739 if ((will_wont_resp
[option
] == 0) && (my_want_state_is_wont(option
))) {
768 * Special case for TM. We send a WILL, but
769 * pretend we sent a WONT.
771 send_will(option
, 0);
772 set_my_want_state_wont(option
);
773 set_my_state_wont(option
);
778 * When we get a LOGOUT option, respond
779 * with a WILL LOGOUT, make sure that
780 * it gets written out to the network,
781 * and then just go away...
783 set_my_want_state_will(TELOPT_LOGOUT
);
784 send_will(TELOPT_LOGOUT
, 0);
785 set_my_state_will(TELOPT_LOGOUT
);
796 case TELOPT_LINEMODE
:
801 case TELOPT_XDISPLOC
:
802 #ifdef TELOPT_ENVIRON
803 case TELOPT_NEW_ENVIRON
:
805 case TELOPT_OLD_ENVIRON
:
810 set_my_want_state_will(option
);
811 send_will(option
, 0);
813 will_wont_resp
[option
]++;
814 send_wont(option
, 0);
817 set_my_state_will(option
);
819 } /* end of dooption */
822 send_wont(int option
, int init
)
825 if ((will_wont_resp
[option
] == 0 && my_state_is_wont(option
)) ||
826 my_want_state_is_wont(option
))
828 set_my_want_state_wont(option
);
829 will_wont_resp
[option
]++;
831 output_data ((const char *)wont
, option
);
833 DIAG(TD_OPTIONS
, printoption("td: send wont", option
));
837 dontoption(int option
)
840 * Process client input.
844 DIAG(TD_OPTIONS
, printoption("td: recv dont", option
));
846 if (will_wont_resp
[option
]) {
847 will_wont_resp
[option
]--;
848 if (will_wont_resp
[option
] && my_state_is_wont(option
))
849 will_wont_resp
[option
]--;
851 if ((will_wont_resp
[option
] == 0) && (my_want_state_is_will(option
))) {
859 case TELOPT_ECHO
: /* we should stop echoing */
868 set_my_want_state_wont(option
);
869 if (my_state_is_will(option
))
870 send_wont(option
, 0);
871 set_my_state_wont(option
);
872 if (turn_on_sga
^= 1)
873 send_will(option
, 1);
880 set_my_want_state_wont(option
);
881 if (my_state_is_will(option
))
882 send_wont(option
, 0);
884 set_my_state_wont(option
);
886 } /* end of dontoption */
892 # define env_ovar OLD_ENV_VAR
893 # define env_ovalue OLD_ENV_VALUE
894 #endif /* ENV_HACK */
899 * Look at the sub-option buffer, and try to be helpful to the other
902 * Currently we recognize:
914 DIAG(TD_OPTIONS
, {netflush(); printsub('<', subpointer
, SB_LEN()+2);});
918 case TELOPT_TSPEED
: {
921 if (his_state_is_wont(TELOPT_TSPEED
)) /* Ignore if option disabled */
924 settimer(tspeedsubopt
);
926 if (SB_EOF() || SB_GET() != TELQUAL_IS
)
929 xspeed
= atoi((char *)subpointer
);
931 while (SB_GET() != ',' && !SB_EOF());
935 rspeed
= atoi((char *)subpointer
);
936 clientstat(TELOPT_TSPEED
, xspeed
, rspeed
);
940 } /* end of case TELOPT_TSPEED */
942 case TELOPT_TTYPE
: { /* Yaaaay! */
945 if (his_state_is_wont(TELOPT_TTYPE
)) /* Ignore if option disabled */
947 settimer(ttypesubopt
);
949 if (SB_EOF() || SB_GET() != TELQUAL_IS
) {
950 return; /* ??? XXX but, this is the most robust */
955 while ((p
< (terminaltype
+ sizeof terminaltype
-1)) &&
963 *p
++ = c
; /* accumulate name */
967 } /* end of case TELOPT_TTYPE */
970 int xwinsize
, ywinsize
;
972 if (his_state_is_wont(TELOPT_NAWS
)) /* Ignore if option disabled */
977 xwinsize
= SB_GET() << 8;
980 xwinsize
|= SB_GET();
983 ywinsize
= SB_GET() << 8;
986 ywinsize
|= SB_GET();
987 clientstat(TELOPT_NAWS
, xwinsize
, ywinsize
);
991 } /* end of case TELOPT_NAWS */
993 case TELOPT_STATUS
: {
1001 if (my_state_is_will(TELOPT_STATUS
))
1012 } /* end of case TELOPT_STATUS */
1014 case TELOPT_XDISPLOC
: {
1015 if (SB_EOF() || SB_GET() != TELQUAL_IS
)
1017 settimer(xdisplocsubopt
);
1018 subpointer
[SB_LEN()] = '\0';
1019 esetenv("DISPLAY", (char *)subpointer
, 1);
1021 } /* end of case TELOPT_XDISPLOC */
1023 #ifdef TELOPT_NEW_ENVIRON
1024 case TELOPT_NEW_ENVIRON
:
1026 case TELOPT_OLD_ENVIRON
: {
1028 char *cp
, *varp
, *valp
;
1033 if (c
== TELQUAL_IS
) {
1034 if (subchar
== TELOPT_OLD_ENVIRON
)
1035 settimer(oenvironsubopt
);
1037 settimer(environsubopt
);
1038 } else if (c
!= TELQUAL_INFO
) {
1042 #ifdef TELOPT_NEW_ENVIRON
1043 if (subchar
== TELOPT_NEW_ENVIRON
) {
1046 if ((c
== NEW_ENV_VAR
) || (c
== ENV_USERVAR
))
1054 * We only want to do this if we haven't already decided
1055 * whether or not the other side has its VALUE and VAR
1059 int last
= -1; /* invalid value */
1061 int got_var
= 0, got_value
= 0, got_uservar
= 0;
1064 * The other side might have its VALUE and VAR values
1065 * reversed. To be interoperable, we need to determine
1066 * which way it is. If the first recognized character
1067 * is a VAR or VALUE, then that will tell us what
1068 * type of client it is. If the fist recognized
1069 * character is a USERVAR, then we continue scanning
1070 * the suboption looking for two consecutive
1071 * VAR or VALUE fields. We should not get two
1072 * consecutive VALUE fields, so finding two
1073 * consecutive VALUE or VAR fields will tell us
1074 * what the client is.
1081 if (last
< 0 || last
== OLD_ENV_VAR
1082 || (empty
&& (last
== OLD_ENV_VALUE
)))
1088 if (last
< 0 || last
== OLD_ENV_VALUE
1089 || (empty
&& (last
== OLD_ENV_VAR
)))
1090 goto env_ovar_wrong
;
1092 last
= OLD_ENV_VALUE
;
1095 /* count strings of USERVAR as one */
1096 if (last
!= ENV_USERVAR
)
1099 if (last
== OLD_ENV_VALUE
)
1101 if (last
== OLD_ENV_VAR
)
1102 goto env_ovar_wrong
;
1117 if (last
== OLD_ENV_VALUE
)
1119 if (last
== OLD_ENV_VAR
)
1120 goto env_ovar_wrong
;
1123 * Ok, the first thing was a USERVAR, and there
1124 * are not two consecutive VAR or VALUE commands,
1125 * and none of the VAR or VALUE commands are empty.
1126 * If the client has sent us a well-formed option,
1127 * then the number of VALUEs received should always
1128 * be less than or equal to the number of VARs and
1129 * USERVARs received.
1131 * If we got exactly as many VALUEs as VARs and
1132 * USERVARs, the client has the same definitions.
1134 * If we got exactly as many VARs as VALUEs and
1135 * USERVARS, the client has reversed definitions.
1137 if (got_uservar
+ got_var
== got_value
) {
1139 env_ovar
= OLD_ENV_VAR
;
1140 env_ovalue
= OLD_ENV_VALUE
;
1141 } else if (got_uservar
+ got_value
== got_var
) {
1143 env_ovar
= OLD_ENV_VALUE
;
1144 env_ovalue
= OLD_ENV_VAR
;
1146 output_data("ENVIRON VALUE and VAR are reversed!\r\n");
1156 if ((c
== env_ovar
) || (c
== ENV_USERVAR
))
1164 cp
= varp
= (char *)subpointer
;
1169 if (subchar
== TELOPT_OLD_ENVIRON
) {
1172 else if (c
== env_ovalue
)
1179 cp
= valp
= (char *)subpointer
;
1186 esetenv(varp
, valp
, 1);
1189 cp
= varp
= (char *)subpointer
;
1205 esetenv(varp
, valp
, 1);
1209 } /* end of case TELOPT_NEW_ENVIRON */
1210 #ifdef AUTHENTICATION
1211 case TELOPT_AUTHENTICATION
:
1218 * These are sent by us and cannot be sent by
1223 auth_is(subpointer
, SB_LEN());
1226 auth_name(subpointer
, SB_LEN());
1232 case TELOPT_ENCRYPT
:
1236 case ENCRYPT_SUPPORT
:
1237 encrypt_support(subpointer
, SB_LEN());
1240 encrypt_is(subpointer
, SB_LEN());
1243 encrypt_reply(subpointer
, SB_LEN());
1246 encrypt_start(subpointer
, SB_LEN());
1249 if (require_encryption
)
1250 fatal(net
, "Output encryption is not possible to turn off");
1253 case ENCRYPT_REQSTART
:
1254 encrypt_request_start(subpointer
, SB_LEN());
1256 case ENCRYPT_REQEND
:
1258 * We can always send an REQEND so that we cannot
1259 * get stuck encrypting. We should only get this
1260 * if we have been able to get in the correct mode
1263 if (require_encryption
)
1264 fatal(net
, "Input encryption is not possible to turn off");
1265 encrypt_request_end();
1267 case ENCRYPT_ENC_KEYID
:
1268 encrypt_enc_keyid(subpointer
, SB_LEN());
1270 case ENCRYPT_DEC_KEYID
:
1271 encrypt_dec_keyid(subpointer
, SB_LEN());
1281 } /* end of switch */
1283 } /* end of suboption */
1288 clientstat(TELOPT_LINEMODE
, WILL
, 0);
1292 #define ADD(c) *ncp++ = c
1293 #define ADD_DATA(c) { *ncp++ = c; if (c == SE || c == IAC) *ncp++ = c; }
1298 unsigned char statusbuf
[256];
1304 netflush(); /* get rid of anything waiting to go out */
1312 * We check the want_state rather than the current state,
1313 * because if we received a DO/WILL for an option that we
1314 * don't support, and the other side didn't send a DONT/WONT
1315 * in response to our WONT/DONT, then the "state" will be
1316 * WILL/DO, and the "want_state" will be WONT/DONT. We
1317 * need to go by the latter.
1319 for (i
= 0; i
< (unsigned char)NTELOPTS
; i
++) {
1320 if (my_want_state_is_will(i
)) {
1324 if (his_want_state_is_will(i
)) {
1330 if (his_want_state_is_will(TELOPT_LFLOW
)) {
1340 if (restartany
>= 0) {
1344 ADD(LFLOW_RESTART_ANY
);
1346 ADD(LFLOW_RESTART_XON
);
1356 writenet(statusbuf
, ncp
- statusbuf
);
1357 netflush(); /* Send it on its way */
1360 {printsub('>', statusbuf
, ncp
- statusbuf
); netflush();});