static void tcp_chr_telnet_init(Chardev *chr) { SocketChardev *s = SOCKET_CHARDEV(chr); TCPChardevTelnetInit *init = g_new0(TCPChardevTelnetInit, 1); size_t n = 0; init->chr = chr; init->buflen = 12; #define IACSET(x, a, b, c) \ do { \ x[n++] = a; \ x[n++] = b; \ x[n++] = c; \ } while (0) /* Prep the telnet negotion to put telnet in binary, * no echo, single char mode */ IACSET(init->buf, 0xff, 0xfb, 0x01); /* IAC WILL ECHO */ IACSET(init->buf, 0xff, 0xfb, 0x03); /* IAC WILL Suppress go ahead */ IACSET(init->buf, 0xff, 0xfb, 0x00); /* IAC WILL Binary */ IACSET(init->buf, 0xff, 0xfd, 0x00); /* IAC DO Binary */ #undef IACSET qio_channel_add_watch( s->ioc, G_IO_OUT, tcp_chr_telnet_init_io, init, NULL); }
static void tcp_chr_telnet_init(Chardev *chr) { SocketChardev *s = SOCKET_CHARDEV(chr); TCPChardevTelnetInit *init = g_new0(TCPChardevTelnetInit, 1); size_t n = 0; #define IACSET(x, a, b, c) \ do { \ x[n++] = a; \ x[n++] = b; \ x[n++] = c; \ } while (0) init->chr = chr; if (!s->is_tn3270) { init->buflen = 12; /* Prep the telnet negotion to put telnet in binary, * no echo, single char mode */ IACSET(init->buf, 0xff, 0xfb, 0x01); /* IAC WILL ECHO */ IACSET(init->buf, 0xff, 0xfb, 0x03); /* IAC WILL Suppress go ahead */ IACSET(init->buf, 0xff, 0xfb, 0x00); /* IAC WILL Binary */ IACSET(init->buf, 0xff, 0xfd, 0x00); /* IAC DO Binary */ } else { init->buflen = 21; /* Prep the TN3270 negotion based on RFC1576 */ IACSET(init->buf, 0xff, 0xfd, 0x19); /* IAC DO EOR */ IACSET(init->buf, 0xff, 0xfb, 0x19); /* IAC WILL EOR */ IACSET(init->buf, 0xff, 0xfd, 0x00); /* IAC DO BINARY */ IACSET(init->buf, 0xff, 0xfb, 0x00); /* IAC WILL BINARY */ IACSET(init->buf, 0xff, 0xfd, 0x18); /* IAC DO TERMINAL TYPE */ IACSET(init->buf, 0xff, 0xfa, 0x18); /* IAC SB TERMINAL TYPE */ IACSET(init->buf, 0x01, 0xff, 0xf0); /* SEND IAC SE */ } #undef IACSET qio_channel_add_watch( s->ioc, G_IO_OUT, tcp_chr_telnet_init_io, init, NULL); }