summaryrefslogtreecommitdiffstats
path: root/telnet.c
diff options
context:
space:
mode:
Diffstat (limited to 'telnet.c')
-rw-r--r--telnet.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/telnet.c b/telnet.c
index 89b6057..fe30da7 100644
--- a/telnet.c
+++ b/telnet.c
@@ -29,11 +29,11 @@
static int telnet_set_speed(struct ios_ops *ios, unsigned long speed)
{
-// unsigned char buf1[] = {IAC, WILL , COM_PORT_OPTION};
- unsigned char buf2[] = {IAC, SB, COM_PORT_OPTION, SET_BAUDRATE_CS, 0, 0, 0, 0, IAC, SE};
+ unsigned char buf2[] = {IAC, SB, TELNET_OPTION_COM_PORT_CONTROL, SET_BAUDRATE_CS, 0, 0, 0, 0, IAC, SE};
int *speedp = (int *)&buf2[4];
*speedp = htonl(speed);
+ dbg_printf("-> IAC SB COM_PORT_CONTROL SET_BAUDRATE_CS 0x%lx IAC SE\n", speed);
write(ios->fd, buf2, 10);
return 0;
@@ -41,7 +41,7 @@ static int telnet_set_speed(struct ios_ops *ios, unsigned long speed)
static int telnet_set_flow(struct ios_ops *ios, int flow)
{
- unsigned char buf2[] = {IAC, SB, COM_PORT_OPTION, SET_CONTROL_CS, 0, IAC, SE};
+ unsigned char buf2[] = {IAC, SB, TELNET_OPTION_COM_PORT_CONTROL, SET_CONTROL_CS, 0, IAC, SE};
switch (flow) {
case FLOW_NONE:
@@ -58,6 +58,7 @@ static int telnet_set_flow(struct ios_ops *ios, int flow)
break;
}
+ dbg_printf("-> IAC SB COM_PORT_CONTROL SET_CONTROL_CS %d IAC SE\n", buf2[4]);
write(ios->fd, buf2, sizeof(buf2));
return 0;
@@ -149,10 +150,17 @@ struct ios_ops *telnet_init(char *hostport)
connected_host, sizeof(connected_host),
connected_port, sizeof(connected_port),
NI_NUMERICHOST | NI_NUMERICSERV);
- if (ret)
+ if (ret) {
fprintf(stderr, "getnameinfo: %s\n", gai_strerror(ret));
- else
- printf("connected to %s (port %s)\n", connected_host, connected_port);
+ goto out;
+ }
+ printf("connected to %s (port %s)\n", connected_host, connected_port);
+
+ /* send intent to do and accept COM_PORT stuff */
+ dbg_printf("-> WILL COM_PORT_CONTROL\n");
+ dprintf(sock, "%c%c%c", IAC, WILL, TELNET_OPTION_COM_PORT_CONTROL);
+ dbg_printf("-> DO COM_PORT_CONTROL\n");
+ dprintf(sock, "%c%c%c", IAC, DO, TELNET_OPTION_COM_PORT_CONTROL);
goto out;
}