[ECOS] RedBoot doesn't handle telnet WILL properly.

Grant Edwards grante@visi.com
Sat Apr 1 17:56:00 GMT 2006

Why does RedBoot handle DO but not WILL?  It's normal for a
telnet client to send a bunch of WILL commands after connecting
to a server.

The current code in net_io_getc_nonblock() handles the telnet
DO by replying with a WONT (which is a correct). But, when it
receives a WILL sequence from the client, it just returns the
option code as a received character and doesn't reply to the

This causes the first command read by the main loop to contain
a bunch of "garbage" characters consisting of all of the option
codes which the client said it "WILL" do during option

I've added code to net_io_getc_nonblock() in my version of
RedBoot to fix this problem.

Is there interest in merging this fix into CVS?

--- net_io.c-old	2006-04-01 11:52:30.000000000 -0600
+++ net_io.c	2006-04-01 11:52:52.000000000 -0600
@@ -161,18 +161,20 @@
 // Functions in this module
 static void net_io_flush(void);
 static void net_io_revert_console(void);
 static void net_io_putc(void*, cyg_uint8);
 // Special characters used by Telnet - must be interpretted here
 #define TELNET_IAC    0xFF // Interpret as command (escape)
 #define TELNET_IP     0xF4 // Interrupt process
-#define TELNET_WONT   0xFC // I Won't do it
+#define TELNET_WILL   0xFB // I Will do XXX
+#define TELNET_WONT   0xFC // I Won't do XXX
 #define TELNET_DO     0xFD // Will you XXX
+#define TELNET_DONT   0xFE // Don't you XXX
 #define TELNET_TM     0x06 // Time marker (special DO/WONT after IP)
 static cyg_bool
 _net_io_getc_nonblock(void* __ch_data, cyg_uint8* ch)
     if (in_buflen == 0) {
         if (tcp_sock.state == _CLOSE_WAIT) {
@@ -239,16 +241,24 @@
     case TELNET_DO:
         // Telnet DO option
         while (!_net_io_getc_nonblock(__ch_data, &esc)) ;                
         // Respond with WONT option
         net_io_putc(__ch_data, TELNET_IAC);
         net_io_putc(__ch_data, TELNET_WONT);
         net_io_putc(__ch_data, esc);
         return false;  // Ignore this whole thing!
+    case TELNET_WILL:
+        // Telnet WILL option
+        while (!_net_io_getc_nonblock(__ch_data, &esc)) ;                
+        // Respond with DONT option
+        net_io_putc(__ch_data, TELNET_IAC);
+        net_io_putc(__ch_data, TELNET_DONT);
+        net_io_putc(__ch_data, esc);
+        return false;  // Ignore this whole thing!
         return false;
 static cyg_uint8
 net_io_getc(void* __ch_data)

Grant Edwards                   grante             Yow!  Yow! It's a hole
                                  at               all the way to downtown
                               visi.com            Burbank!

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list