From: Steven Edwards Date: Fri, 6 Feb 2009 05:34:39 +0000 (+0000) Subject: - Make telnetd only slightly more RFC-compatible X-Git-Tag: backups/danny-web@40415~24^2~634 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=d0c78a0f46342f864c8505e616fb6f3800fb45c0;ds=sidebyside - Make telnetd only slightly more RFC-compatible Thanks to Fedora Anaconda telnet code as an example. This allows us to actually get an echo back on the screen when we type commands. svn path=/trunk/; revision=39428 --- diff --git a/rosapps/applications/sysutils/telnetd/telnetd.c b/rosapps/applications/sysutils/telnetd/telnetd.c index b5635b9714b..a5c365b3ad4 100644 --- a/rosapps/applications/sysutils/telnetd/telnetd.c +++ b/rosapps/applications/sysutils/telnetd/telnetd.c @@ -35,12 +35,21 @@ #define LF (10) #define DEL (127) -#define IAC (255) -#define DONT (254) -#define WONT (253) -#define DO (252) -#define WILL (251) -#define ECHO (1) +#define IAC "\xff" +#define DONT "\xfe" +#define WONT "\xfc" +#define WILL "\xfb" +#define DO "\xfd" +#define SB "\xfa" +#define SE "\xf0" +#define ECHO "\x01" +#define SUPPRESS_GO_AHEAD "\x03" +#define TERMINAL_TYPE "\x18" +#define NAWS "\x1f" +#define LINEMODE "\x22" +#define NEWENVIRON "\x27" +#define MODE "\x01" + #define HANDSHAKE_TIMEOUT (3) @@ -300,10 +309,23 @@ static int DoTelnetHandshake(int sock) int received; fd_set set; struct timeval timeout = { HANDSHAKE_TIMEOUT, 0 }; - unsigned char will_echo[3] = { IAC, WILL, ECHO }; + + char will_echo[]= + IAC DONT ECHO + IAC WILL ECHO + IAC WILL NAWS + IAC WILL SUPPRESS_GO_AHEAD + IAC DO SUPPRESS_GO_AHEAD + IAC DONT NEWENVIRON + IAC WONT NEWENVIRON + IAC WONT LINEMODE + IAC DO NAWS + IAC SB TERMINAL_TYPE "\x01" IAC SE + ; + unsigned char client_reply[256]; - if (send(sock, (const char *) will_echo, sizeof(will_echo), 0) < 0) { + if (send(sock, will_echo, sizeof(will_echo), 0) < 0) { return -1; } @@ -682,3 +704,4 @@ static VOID ErrorExit (LPTSTR lpszMessage) } ExitProcess(0); } +