Skip to content

Commit 0cb882a

Browse files
author
Uwe Kleine-König
committed
Merge branch 'negotiate-binary-transmission' of https://github.com/ukleinek/microcom
2 parents c41d017 + 2fdc58e commit 0cb882a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

telnet.c

+13
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,13 @@ static int do_com_port_option(struct ios_ops *ios, unsigned char *buf, int len)
235235
return -EINVAL;
236236
}
237237

238+
/* This is called with buf[-2:0] being IAC SB COM_PORT_OPTION */
239+
static int do_binary_transmission_option(struct ios_ops *ios, unsigned char *buf, int len)
240+
{
241+
/* There are no subcommands for the BINARY_TRANSMISSION option (rfc856) */
242+
return -EINVAL;
243+
}
244+
238245
struct telnet_option {
239246
unsigned char id;
240247
const char *name;
@@ -251,6 +258,8 @@ static const struct telnet_option telnet_options[] = {
251258
.sent_will = true,
252259
}, {
253260
TELNET_OPTION(BINARY_TRANSMISSION),
261+
.subneg_handler = do_binary_transmission_option,
262+
.sent_will = true,
254263
}, {
255264
TELNET_OPTION(ECHO),
256265
}, {
@@ -599,6 +608,10 @@ struct ios_ops *telnet_init(char *hostport)
599608
/* send intent we WILL do COM_PORT stuff */
600609
dbg_printf("-> WILL COM_PORT_CONTROL\n");
601610
dprintf(sock, "%c%c%c", IAC, WILL, TELNET_OPTION_COM_PORT_CONTROL);
611+
dbg_printf("-> DO BINARY_TRANSMISSION\n");
612+
dprintf(sock, "%c%c%c", IAC, DO, TELNET_OPTION_BINARY_TRANSMISSION);
613+
dbg_printf("-> WILL BINARY_TRANSMISSION\n");
614+
dprintf(sock, "%c%c%c", IAC, WILL, TELNET_OPTION_BINARY_TRANSMISSION);
602615
goto out;
603616
}
604617

0 commit comments

Comments
 (0)