13 #define IAC 255 /* interpret as command: */
14 #define DONT 254 /* you are not to use option */
15 #define DO 253 /* please, you use option */
16 #define WONT 252 /* I won't use option */
17 #define WILL 251 /* I will use option */
18 #define SB 250 /* interpret as subnegotiation */
19 #define SE 240 /* end sub negotiation */
21 #define GA 249 /* you may reverse the line */
22 #define EL 248 /* erase the current line */
23 #define EC 247 /* erase the current character */
24 #define AYT 246 /* are you there */
25 #define AO 245 /* abort output--but let prog finish */
26 #define IP 244 /* interrupt process--permanently */
27 #define BREAK 243 /* break */
28 #define DM 242 /* data mark--for connect. cleaning */
29 #define NOP 241 /* nop */
30 #define EOR 239 /* end of record (transparent mode) */
31 #define ABORT 238 /* Abort process */
32 #define SUSP 237 /* Suspend process */
33 #define xEOF 236 /* End of file: EOF is already used... */
35 #define TELOPT_BINARY 0 /* 8-bit data path */
36 #define TELOPT_ECHO 1 /* echo */
37 #define TELOPT_RCP 2 /* prepare to reconnect */
38 #define TELOPT_SGA 3 /* suppress go ahead */
39 #define TELOPT_NAMS 4 /* approximate message size */
40 #define TELOPT_STATUS 5 /* give status */
41 #define TELOPT_TM 6 /* timing mark */
42 #define TELOPT_RCTE 7 /* remote controlled transmission and echo */
43 #define TELOPT_NAOL 8 /* negotiate about output line width */
44 #define TELOPT_NAOP 9 /* negotiate about output page size */
45 #define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
46 #define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
47 #define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
48 #define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
49 #define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
50 #define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
51 #define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
52 #define TELOPT_XASCII 17 /* extended ascic character set */
53 #define TELOPT_LOGOUT 18 /* force logout */
54 #define TELOPT_BM 19 /* byte macro */
55 #define TELOPT_DET 20 /* data entry terminal */
56 #define TELOPT_SUPDUP 21 /* supdup protocol */
57 #define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
58 #define TELOPT_SNDLOC 23 /* send location */
59 #define TELOPT_TTYPE 24 /* terminal type */
60 #define TELOPT_EOR 25 /* end or record */
61 #define TELOPT_TUID 26 /* TACACS user identification */
62 #define TELOPT_OUTMRK 27 /* output marking */
63 #define TELOPT_TTYLOC 28 /* terminal location number */
64 #define TELOPT_3270REGIME 29 /* 3270 regime */
65 #define TELOPT_X3PAD 30 /* X.3 PAD */
66 #define TELOPT_NAWS 31 /* window size */
67 #define TELOPT_TSPEED 32 /* terminal speed */
68 #define TELOPT_LFLOW 33 /* remote flow control */
69 #define TELOPT_LINEMODE 34 /* Linemode option */
70 #define TELOPT_XDISPLOC 35 /* X Display Location */
71 #define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */
72 #define TELOPT_AUTHENTICATION 37 /* Authenticate */
73 #define TELOPT_ENCRYPT 38 /* Encryption option */
74 #define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */
75 #define TELOPT_EXOPL 255 /* extended-options-list */
77 #define TELQUAL_IS 0 /* option is... */
78 #define TELQUAL_SEND 1 /* send option */
79 #define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
89 #define iswritable(x) ( (x) != IAC && (x) != CR )
91 static char *telopt(int opt
)
93 #define i(x) if (opt == TELOPT_ ## x) return #x;
138 static void telnet_size(void *handle
, int width
, int height
);
141 int send
; /* what we initially send */
142 int nsend
; /* -ve send if requested to stop it */
143 int ack
, nak
; /* +ve and -ve acknowledgements */
144 int option
; /* the option code */
145 int index
; /* index into telnet->opt_states[] */
147 REQUESTED
, ACTIVE
, INACTIVE
, REALLY_INACTIVE
163 static const struct Opt o_naws
=
164 { WILL
, WONT
, DO
, DONT
, TELOPT_NAWS
, OPTINDEX_NAWS
, REQUESTED
};
165 static const struct Opt o_tspeed
=
166 { WILL
, WONT
, DO
, DONT
, TELOPT_TSPEED
, OPTINDEX_TSPEED
, REQUESTED
};
167 static const struct Opt o_ttype
=
168 { WILL
, WONT
, DO
, DONT
, TELOPT_TTYPE
, OPTINDEX_TTYPE
, REQUESTED
};
169 static const struct Opt o_oenv
= { WILL
, WONT
, DO
, DONT
, TELOPT_OLD_ENVIRON
,
170 OPTINDEX_OENV
, INACTIVE
172 static const struct Opt o_nenv
= { WILL
, WONT
, DO
, DONT
, TELOPT_NEW_ENVIRON
,
173 OPTINDEX_NENV
, REQUESTED
175 static const struct Opt o_echo
=
176 { DO
, DONT
, WILL
, WONT
, TELOPT_ECHO
, OPTINDEX_ECHO
, REQUESTED
};
177 static const struct Opt o_we_sga
=
178 { WILL
, WONT
, DO
, DONT
, TELOPT_SGA
, OPTINDEX_WE_SGA
, REQUESTED
};
179 static const struct Opt o_they_sga
=
180 { DO
, DONT
, WILL
, WONT
, TELOPT_SGA
, OPTINDEX_THEY_SGA
, REQUESTED
};
182 static const struct Opt
*const opts
[] = {
183 &o_naws
, &o_tspeed
, &o_ttype
, &o_oenv
, &o_nenv
, &o_echo
,
184 &o_we_sga
, &o_they_sga
, NULL
187 typedef struct telnet_tag
{
188 const struct plug_function_table
*fn
;
189 /* the above field _must_ be first in the structure */
195 int term_width
, term_height
;
197 int opt_states
[NUM_OPTS
];
199 int echoing
, editing
;
208 TOP_LEVEL
, SEENIAC
, SEENWILL
, SEENWONT
, SEENDO
, SEENDONT
,
209 SEENSB
, SUBNEGOT
, SUBNEG_IAC
, SEENCR
214 #define TELNET_MAX_BACKLOG 4096
216 #define SB_DELTA 1024
218 static void c_write1(Telnet telnet
, int c
)
222 backlog
= from_backend(telnet
->frontend
, 0, &cc
, 1);
223 sk_set_frozen(telnet
->s
, backlog
> TELNET_MAX_BACKLOG
);
226 static void log_option(Telnet telnet
, char *sender
, int cmd
, int option
)
230 * The strange-looking "<?""?>" below is there to avoid a
231 * trigraph - a double question mark followed by > maps to a
232 * closing brace character!
234 buf
= dupprintf("%s:\t%s %s", sender
,
235 (cmd
== WILL ?
"WILL" : cmd
== WONT ?
"WONT" :
236 cmd
== DO ?
"DO" : cmd
== DONT ?
"DONT" : "<?""?>"),
238 logevent(telnet
->frontend
, buf
);
242 static void send_opt(Telnet telnet
, int cmd
, int option
)
249 telnet
->bufsize
= sk_write(telnet
->s
, b
, 3);
250 log_option(telnet
, "client", cmd
, option
);
253 static void deactivate_option(Telnet telnet
, const struct Opt
*o
)
255 if (telnet
->opt_states
[o
->index
] == REQUESTED
||
256 telnet
->opt_states
[o
->index
] == ACTIVE
)
257 send_opt(telnet
, o
->nsend
, o
->option
);
258 telnet
->opt_states
[o
->index
] = REALLY_INACTIVE
;
262 * Generate side effects of enabling or disabling an option.
264 static void option_side_effects(Telnet telnet
, const struct Opt
*o
, int enabled
)
266 if (o
->option
== TELOPT_ECHO
&& o
->send
== DO
)
267 telnet
->echoing
= !enabled
;
268 else if (o
->option
== TELOPT_SGA
&& o
->send
== DO
)
269 telnet
->editing
= !enabled
;
270 if (telnet
->ldisc
) /* cause ldisc to notice the change */
271 ldisc_send(telnet
->ldisc
, NULL
, 0, 0);
273 /* Ensure we get the minimum options */
274 if (!telnet
->activated
) {
275 if (telnet
->opt_states
[o_echo
.index
] == INACTIVE
) {
276 telnet
->opt_states
[o_echo
.index
] = REQUESTED
;
277 send_opt(telnet
, o_echo
.send
, o_echo
.option
);
279 if (telnet
->opt_states
[o_we_sga
.index
] == INACTIVE
) {
280 telnet
->opt_states
[o_we_sga
.index
] = REQUESTED
;
281 send_opt(telnet
, o_we_sga
.send
, o_we_sga
.option
);
283 if (telnet
->opt_states
[o_they_sga
.index
] == INACTIVE
) {
284 telnet
->opt_states
[o_they_sga
.index
] = REQUESTED
;
285 send_opt(telnet
, o_they_sga
.send
, o_they_sga
.option
);
287 telnet
->activated
= TRUE
;
291 static void activate_option(Telnet telnet
, const struct Opt
*o
)
293 if (o
->send
== WILL
&& o
->option
== TELOPT_NAWS
)
294 telnet_size(telnet
, telnet
->term_width
, telnet
->term_height
);
295 if (o
->send
== WILL
&&
296 (o
->option
== TELOPT_NEW_ENVIRON
||
297 o
->option
== TELOPT_OLD_ENVIRON
)) {
299 * We may only have one kind of ENVIRON going at a time.
300 * This is a hack, but who cares.
302 deactivate_option(telnet
, o
->option
==
303 TELOPT_NEW_ENVIRON ?
&o_oenv
: &o_nenv
);
305 option_side_effects(telnet
, o
, 1);
308 static void refused_option(Telnet telnet
, const struct Opt
*o
)
310 if (o
->send
== WILL
&& o
->option
== TELOPT_NEW_ENVIRON
&&
311 telnet
->opt_states
[o_oenv
.index
] == INACTIVE
) {
312 send_opt(telnet
, WILL
, TELOPT_OLD_ENVIRON
);
313 telnet
->opt_states
[o_oenv
.index
] = REQUESTED
;
315 option_side_effects(telnet
, o
, 0);
318 static void proc_rec_opt(Telnet telnet
, int cmd
, int option
)
320 const struct Opt
*const *o
;
322 log_option(telnet
, "server", cmd
, option
);
323 for (o
= opts
; *o
; o
++) {
324 if ((*o
)->option
== option
&& (*o
)->ack
== cmd
) {
325 switch (telnet
->opt_states
[(*o
)->index
]) {
327 telnet
->opt_states
[(*o
)->index
] = ACTIVE
;
328 activate_option(telnet
, *o
);
333 telnet
->opt_states
[(*o
)->index
] = ACTIVE
;
334 send_opt(telnet
, (*o
)->send
, option
);
335 activate_option(telnet
, *o
);
337 case REALLY_INACTIVE
:
338 send_opt(telnet
, (*o
)->nsend
, option
);
342 } else if ((*o
)->option
== option
&& (*o
)->nak
== cmd
) {
343 switch (telnet
->opt_states
[(*o
)->index
]) {
345 telnet
->opt_states
[(*o
)->index
] = INACTIVE
;
346 refused_option(telnet
, *o
);
349 telnet
->opt_states
[(*o
)->index
] = INACTIVE
;
350 send_opt(telnet
, (*o
)->nsend
, option
);
351 option_side_effects(telnet
, *o
, 0);
354 case REALLY_INACTIVE
:
361 * If we reach here, the option was one we weren't prepared to
362 * cope with. So send a negative ack.
364 send_opt(telnet
, (cmd
== WILL ? DONT
: WONT
), option
);
367 static void process_subneg(Telnet telnet
)
369 unsigned char b
[2048], *p
, *q
;
373 switch (telnet
->sb_opt
) {
375 if (telnet
->sb_len
== 1 && telnet
->sb_buf
[0] == TELQUAL_SEND
) {
379 b
[2] = TELOPT_TSPEED
;
381 strcpy(b
+ 4, cfg
.termspeed
);
382 n
= 4 + strlen(cfg
.termspeed
);
385 telnet
->bufsize
= sk_write(telnet
->s
, b
, n
+ 2);
386 logevent(telnet
->frontend
, "server:\tSB TSPEED SEND");
387 logbuf
= dupprintf("client:\tSB TSPEED IS %s", cfg
.termspeed
);
388 logevent(telnet
->frontend
, logbuf
);
391 logevent(telnet
->frontend
, "server:\tSB TSPEED <something weird>");
394 if (telnet
->sb_len
== 1 && telnet
->sb_buf
[0] == TELQUAL_SEND
) {
400 for (n
= 0; cfg
.termtype
[n
]; n
++)
401 b
[n
+ 4] = (cfg
.termtype
[n
] >= 'a'
402 && cfg
.termtype
[n
] <=
403 'z' ? cfg
.termtype
[n
] + 'A' -
404 'a' : cfg
.termtype
[n
]);
407 telnet
->bufsize
= sk_write(telnet
->s
, b
, n
+ 6);
409 logevent(telnet
->frontend
, "server:\tSB TTYPE SEND");
410 logbuf
= dupprintf("client:\tSB TTYPE IS %s", b
+ 4);
411 logevent(telnet
->frontend
, logbuf
);
414 logevent(telnet
->frontend
, "server:\tSB TTYPE <something weird>\r\n");
416 case TELOPT_OLD_ENVIRON
:
417 case TELOPT_NEW_ENVIRON
:
419 q
= p
+ telnet
->sb_len
;
420 if (p
< q
&& *p
== TELQUAL_SEND
) {
423 logbuf
= dupprintf("server:\tSB %s SEND", telopt(telnet
->sb_opt
));
424 logevent(telnet
->frontend
, logbuf
);
426 if (telnet
->sb_opt
== TELOPT_OLD_ENVIRON
) {
427 if (cfg
.rfc_environ
) {
435 * Try to guess the sense of VAR and VALUE.
441 } else if (*p
== BSD_VAR
) {
449 * With NEW_ENVIRON, the sense of VAR and VALUE
457 b
[2] = telnet
->sb_opt
;
463 while (*e
&& *e
!= '\t')
485 telnet
->bufsize
= sk_write(telnet
->s
, b
, n
);
486 logbuf
= dupprintf("client:\tSB %s IS %s", telopt(telnet
->sb_opt
),
487 n
== 6 ?
"<nothing>" : "<stuff>");
488 logevent(telnet
->frontend
, logbuf
);
495 static void do_telnet_read(Telnet telnet
, char *buf
, int len
)
499 int c
= (unsigned char) *buf
++;
501 switch (telnet
->state
) {
504 if (c
== NUL
&& telnet
->state
== SEENCR
)
505 telnet
->state
= TOP_LEVEL
;
507 telnet
->state
= SEENIAC
;
509 if (!telnet
->in_synch
)
513 /* I can't get the F***ing winsock to insert the urgent IAC
514 * into the right position! Even with SO_OOBINLINE it gives
515 * it to recv too soon. And of course the DM byte (that
516 * arrives in the same packet!) appears several K later!!
518 * Oh well, we do get the DM in the right place so I'll
519 * just stop hiding on the next 0xf2 and hope for the best.
522 telnet
->in_synch
= 0;
525 telnet
->state
= SEENCR
;
527 telnet
->state
= TOP_LEVEL
;
532 telnet
->state
= SEENDO
;
534 telnet
->state
= SEENDONT
;
536 telnet
->state
= SEENWILL
;
538 telnet
->state
= SEENWONT
;
540 telnet
->state
= SEENSB
;
542 telnet
->in_synch
= 0;
543 telnet
->state
= TOP_LEVEL
;
545 /* ignore everything else; print it if it's IAC */
549 telnet
->state
= TOP_LEVEL
;
553 proc_rec_opt(telnet
, WILL
, c
);
554 telnet
->state
= TOP_LEVEL
;
557 proc_rec_opt(telnet
, WONT
, c
);
558 telnet
->state
= TOP_LEVEL
;
561 proc_rec_opt(telnet
, DO
, c
);
562 telnet
->state
= TOP_LEVEL
;
565 proc_rec_opt(telnet
, DONT
, c
);
566 telnet
->state
= TOP_LEVEL
;
571 telnet
->state
= SUBNEGOT
;
575 telnet
->state
= SUBNEG_IAC
;
578 if (telnet
->sb_len
>= telnet
->sb_size
) {
580 telnet
->sb_size
+= SB_DELTA
;
581 newbuf
= (telnet
->sb_buf ?
582 srealloc(telnet
->sb_buf
, telnet
->sb_size
) :
583 smalloc(telnet
->sb_size
));
585 telnet
->sb_buf
= newbuf
;
587 telnet
->sb_size
-= SB_DELTA
;
589 if (telnet
->sb_len
< telnet
->sb_size
)
590 telnet
->sb_buf
[telnet
->sb_len
++] = c
;
591 telnet
->state
= SUBNEGOT
; /* in case we came here by goto */
596 goto subneg_addchar
; /* yes, it's a hack, I know, but... */
598 process_subneg(telnet
);
599 telnet
->state
= TOP_LEVEL
;
606 static int telnet_closing(Plug plug
, char *error_msg
, int error_code
,
609 Telnet telnet
= (Telnet
) plug
;
616 /* A socket error has occurred. */
617 logevent(telnet
->frontend
, error_msg
);
618 connection_fatal("%s", error_msg
);
619 } /* Otherwise, the remote side closed the connection normally. */
623 static int telnet_receive(Plug plug
, int urgent
, char *data
, int len
)
625 Telnet telnet
= (Telnet
) plug
;
627 telnet
->in_synch
= TRUE
;
628 do_telnet_read(telnet
, data
, len
);
632 static void telnet_sent(Plug plug
, int bufsize
)
634 Telnet telnet
= (Telnet
) plug
;
635 telnet
->bufsize
= bufsize
;
639 * Called to set up the Telnet connection.
641 * Returns an error message, or NULL on success.
643 * Also places the canonical host name into `realhost'. It must be
644 * freed by the caller.
646 static char *telnet_init(void *frontend_handle
, void **backend_handle
,
647 char *host
, int port
, char **realhost
, int nodelay
)
649 static const struct plug_function_table fn_table
= {
658 telnet
= smalloc(sizeof(*telnet
));
659 telnet
->fn
= &fn_table
;
661 telnet
->echoing
= TRUE
;
662 telnet
->editing
= TRUE
;
663 telnet
->activated
= FALSE
;
664 telnet
->sb_buf
= NULL
;
666 telnet
->frontend
= frontend_handle
;
667 telnet
->term_width
= cfg
.width
;
668 telnet
->term_height
= cfg
.height
;
669 telnet
->state
= TOP_LEVEL
;
670 *backend_handle
= telnet
;
677 buf
= dupprintf("Looking up host \"%s\"", host
);
678 logevent(telnet
->frontend
, buf
);
681 addr
= sk_namelookup(host
, realhost
);
682 if ((err
= sk_addr_error(addr
)))
686 port
= 23; /* default telnet port */
692 char *buf
, addrbuf
[100];
693 sk_getaddr(addr
, addrbuf
, 100);
694 buf
= dupprintf("Connecting to %s port %d", addrbuf
, port
);
695 logevent(telnet
->frontend
, buf
);
698 telnet
->s
= new_connection(addr
, *realhost
, port
, 0, 1,
699 nodelay
, (Plug
) telnet
);
700 if ((err
= sk_socket_error(telnet
->s
)))
706 * Initialise option states.
708 if (cfg
.passive_telnet
) {
709 const struct Opt
*const *o
;
711 for (o
= opts
; *o
; o
++)
712 telnet
->opt_states
[(*o
)->index
] = INACTIVE
;
714 const struct Opt
*const *o
;
716 for (o
= opts
; *o
; o
++) {
717 telnet
->opt_states
[(*o
)->index
] = (*o
)->initial_state
;
718 if (telnet
->opt_states
[(*o
)->index
] == REQUESTED
)
719 send_opt(telnet
, (*o
)->send
, (*o
)->option
);
721 telnet
->activated
= TRUE
;
725 * Set up SYNCH state.
727 telnet
->in_synch
= FALSE
;
733 * Called to send data down the Telnet connection.
735 static int telnet_send(void *handle
, char *buf
, int len
)
737 Telnet telnet
= (Telnet
) handle
;
739 static unsigned char iac
[2] = { IAC
, IAC
};
740 static unsigned char cr
[2] = { CR
, NUL
};
742 static unsigned char nl
[2] = { CR
, LF
};
745 if (telnet
->s
== NULL
)
749 while (p
< buf
+ len
) {
752 while (p
< buf
+ len
&& iswritable((unsigned char) *p
))
754 telnet
->bufsize
= sk_write(telnet
->s
, q
, p
- q
);
756 while (p
< buf
+ len
&& !iswritable((unsigned char) *p
)) {
758 sk_write(telnet
->s
, (unsigned char) *p
== IAC ? iac
: cr
, 2);
763 return telnet
->bufsize
;
767 * Called to query the current socket sendability status.
769 static int telnet_sendbuffer(void *handle
)
771 Telnet telnet
= (Telnet
) handle
;
772 return telnet
->bufsize
;
776 * Called to set the size of the window from Telnet's POV.
778 static void telnet_size(void *handle
, int width
, int height
)
780 Telnet telnet
= (Telnet
) handle
;
784 telnet
->term_width
= width
;
785 telnet
->term_height
= height
;
787 if (telnet
->s
== NULL
|| telnet
->opt_states
[o_naws
.index
] != ACTIVE
)
792 b
[3] = telnet
->term_width
>> 8;
793 b
[4] = telnet
->term_width
& 0xFF;
794 b
[5] = telnet
->term_height
>> 8;
795 b
[6] = telnet
->term_height
& 0xFF;
798 telnet
->bufsize
= sk_write(telnet
->s
, b
, 9);
799 logbuf
= dupprintf("client:\tSB NAWS %d,%d",
800 ((unsigned char) b
[3] << 8) + (unsigned char) b
[4],
801 ((unsigned char) b
[5] << 8) + (unsigned char) b
[6]);
802 logevent(telnet
->frontend
, logbuf
);
807 * Send Telnet special codes.
809 static void telnet_special(void *handle
, Telnet_Special code
)
811 Telnet telnet
= (Telnet
) handle
;
814 if (telnet
->s
== NULL
)
821 telnet
->bufsize
= sk_write(telnet
->s
, b
, 2);
825 telnet
->bufsize
= sk_write(telnet
->s
, b
, 2);
829 telnet
->bufsize
= sk_write(telnet
->s
, b
, 2);
833 telnet
->bufsize
= sk_write(telnet
->s
, b
, 2);
837 telnet
->bufsize
= sk_write(telnet
->s
, b
, 2);
841 telnet
->bufsize
= sk_write(telnet
->s
, b
, 2);
845 telnet
->bufsize
= sk_write(telnet
->s
, b
, 2);
849 telnet
->bufsize
= sk_write(telnet
->s
, b
, 2);
853 telnet
->bufsize
= sk_write(telnet
->s
, b
, 2);
857 telnet
->bufsize
= sk_write(telnet
->s
, b
, 2);
861 telnet
->bufsize
= sk_write(telnet
->s
, b
, 2);
865 telnet
->bufsize
= sk_write(telnet
->s
, b
, 2);
868 telnet
->bufsize
= sk_write(telnet
->s
, "\r\n", 2);
872 telnet
->bufsize
= sk_write(telnet
->s
, b
, 1);
873 telnet
->bufsize
= sk_write_oob(telnet
->s
, b
+ 1, 1);
876 if (telnet
->opt_states
[o_echo
.index
] == INACTIVE
||
877 telnet
->opt_states
[o_echo
.index
] == REALLY_INACTIVE
) {
878 telnet
->opt_states
[o_echo
.index
] = REQUESTED
;
879 send_opt(telnet
, o_echo
.send
, o_echo
.option
);
883 if (telnet
->opt_states
[o_echo
.index
] == ACTIVE
) {
884 telnet
->opt_states
[o_echo
.index
] = REQUESTED
;
885 send_opt(telnet
, o_echo
.nsend
, o_echo
.option
);
889 if (telnet
->opt_states
[o_they_sga
.index
] == ACTIVE
) {
891 telnet
->bufsize
= sk_write(telnet
->s
, b
, 2);
897 static Socket
telnet_socket(void *handle
)
899 Telnet telnet
= (Telnet
) handle
;
903 static int telnet_sendok(void *handle
)
905 /* Telnet telnet = (Telnet) handle; */
909 static void telnet_unthrottle(void *handle
, int backlog
)
911 Telnet telnet
= (Telnet
) handle
;
912 sk_set_frozen(telnet
->s
, backlog
> TELNET_MAX_BACKLOG
);
915 static int telnet_ldisc(void *handle
, int option
)
917 Telnet telnet
= (Telnet
) handle
;
918 if (option
== LD_ECHO
)
919 return telnet
->echoing
;
920 if (option
== LD_EDIT
)
921 return telnet
->editing
;
925 static void telnet_provide_ldisc(void *handle
, void *ldisc
)
927 Telnet telnet
= (Telnet
) handle
;
928 telnet
->ldisc
= ldisc
;
931 static void telnet_provide_logctx(void *handle
, void *logctx
)
933 /* This is a stub. */
936 static int telnet_exitcode(void *handle
)
938 /* Telnet telnet = (Telnet) handle; */
939 /* Telnet doesn't transmit exit codes back to the client */
943 Backend telnet_backend
= {
953 telnet_provide_ldisc
,
954 telnet_provide_logctx
,