Reply to IAC WILL/WONT ECHO

Posted by Falanyx on Mon 21 Jul 2014 12:42 AM — 2 posts, 13,269 views.

#0
MUSHclient does not respond to IAC WILL ECHO or IAC WONT ECHO in a manner as defined by the following RFCs:
RFC 854 - Telnet Specification [1]
RFC 857 - Telnet ECHO Option [2]

Expected behaviour:

On receive IAC WILL ECHO
  If ignoring 'No Echo' messages
    Reply IAC DONT ECHO
  Else
    Reply IAC DO ECHO
On receive IAC WONT ECHO
  Reply IAC DONT ECHO


Current behaviour:
Client does not reply for ECHO Telopt.

Scope:
While most MUD servers implement ECHO loosely and don't expect a reply back, those that implement RFC 1143 [3] strictly will have to force a state change for any changes after the first IAC WILL ECHO. An example of an implementation affected by this is libtelnet [4].

Confirmed with:
v4.85
Current Git (v4.93)

Patch:

diff --git a/telnet_phases.cpp b/telnet_phases.cpp
index 765c01b..358e5ab 100644
--- a/telnet_phases.cpp
+++ b/telnet_phases.cpp
@@ -291,7 +291,10 @@ void CMUSHclientDoc::Phase_WILL (const unsigned char c)
               {
               m_bNoEcho = true;
               TRACE ("Echo turned off\n");
+              Send_IAC_DO (c);
               }
+          else
+              Send_IAC_DONT (c);
           break; // end of TELOPT_ECHO

     case TELOPT_MXP:
@@ -352,6 +355,7 @@ void CMUSHclientDoc::Phase_WONT (const unsigned char c)
           m_bNoEcho = false;
           TRACE ("Echo turned on\n");
           }
+          Send_IAC_DONT (c);
           break; // end of TELOPT_ECHO

     default:


References:
[1] http://www.ietf.org/rfc/rfc854.txt
[2] http://www.ietf.org/rfc/rfc857.txt
[3] http://www.ietf.org/rfc/rfc1143.txt
[4] https://github.com/seanmiddleditch/libtelnet

Edits:
1 - Forums ate some indentation. Wrapped in code tags.
Amended on Mon 21 Jul 2014 12:43 AM by Falanyx
Australia Forum Administrator #1
Fixed. See:

https://github.com/nickgammon/mushclient/commit/c284ba5

Thanks.