--- telnetlib-orig.py 2003-04-17 16:19:44.000000000 -0400 +++ telnetlib.py 2003-04-17 17:07:21.000000000 -0400 @@ -55,6 +55,8 @@ DO = chr(253) WONT = chr(252) WILL = chr(251) +SB = chr(250) # interpret as subnegotiation +SE = chr(240) # end sub negotiation theNULL = chr(0) # Telnet protocol options code (don't change) @@ -118,6 +120,10 @@ PRAGMA_HEARTBEAT = chr(140) # TELOPT PRAGMA HEARTBEAT EXOPL = chr(255) # Extended-Options-List +# sub-option qualifiers +QUAL_IS = chr( 0 ) # option is... +QUAL_SEND = chr( 1 ) # send option + class Telnet: """Telnet interface class. @@ -420,6 +426,13 @@ self.option_callback(self.sock, c, opt) else: self.sock.sendall(IAC + DONT + opt) + elif c == SB: + opt, tmp = '', '' + while tmp != SE: + tmp = self.rawq_getchar() + opt += tmp + if self.option_callback: + self.option_callback( self.sock, c, opt ) else: self.msg('IAC %d not recognized' % ord(c)) except EOFError: # raised by self.rawq_getchar()