Skip to content

Commit 2fdc58e

Browse files
author
Uwe Kleine-König
committed
telnet: DO and WILL BINARY_TRANSMISSION
microcom doesn't treat 8bit data special, so let it announce being able to send and receive binary data. In practise the absense of this negotiated option didn't make a relevant difference, the communication with both ser2net and moxa devices still included 8bit data. So there is no urgent need to properly handle the comport side refusing the BINARY_TRANSMISSION option. Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 679049a commit 2fdc58e

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
}, {
@@ -601,6 +610,10 @@ struct ios_ops *telnet_init(char *hostport)
601610
dprintf(sock, "%c%c%c", IAC, WILL, TELNET_OPTION_COM_PORT_CONTROL);
602611
dbg_printf("-> DO COM_PORT_CONTROL\n");
603612
dprintf(sock, "%c%c%c", IAC, DO, TELNET_OPTION_COM_PORT_CONTROL);
613+
dbg_printf("-> DO BINARY_TRANSMISSION\n");
614+
dprintf(sock, "%c%c%c", IAC, DO, TELNET_OPTION_BINARY_TRANSMISSION);
615+
dbg_printf("-> WILL BINARY_TRANSMISSION\n");
616+
dprintf(sock, "%c%c%c", IAC, WILL, TELNET_OPTION_BINARY_TRANSMISSION);
604617
goto out;
605618
}
606619

0 commit comments

Comments
 (0)