00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "TelnetProtocol.h"
00021
00022 namespace mdw
00023 {
00024
00025 namespace
00026 {
00027
00028 const unsigned char SE = 240;
00029 const unsigned char NOP = 241;
00030 const unsigned char DataMark = 242;
00031 const unsigned char Break = 243;
00032 const unsigned char InterruptProcess = 244;
00033 const unsigned char AbortOutput = 245;
00034 const unsigned char AreYouThere = 246;
00035 const unsigned char EraseCharacter = 247;
00036 const unsigned char EraseLine = 248;
00037 const unsigned char GoAhead = 249;
00038 const unsigned char SB = 250;
00039 const unsigned char WILL = 251;
00040 const unsigned char WONT = 252;
00041 const unsigned char DO = 253;
00042 const unsigned char DONT = 254;
00043 const unsigned char IAC = 255;
00044
00045 const unsigned char TransmitBinary = 0;
00046
00047 const unsigned char Echo = 1;
00048
00049 const unsigned char SuppressGoAhead = 3;
00050
00051 const unsigned char Status = 5;
00052
00053 const unsigned char TimingMark = 6;
00054
00055 const unsigned char ExtendedOptionList = 255;
00056
00057 const unsigned char RCTE = 7;
00058
00059 }
00060
00061 TelnetProtocol::TelnetProtocol (StreamServer &server) : _server (server)
00062 {
00063 }
00064
00065 TelnetProtocol::~TelnetProtocol()
00066 {
00067 }
00068
00069 void TelnetProtocol::visitRead (char * buffer, int size, StreamInfo &info)
00070 {
00071 _currentVisitor->visitRead(buffer, size, info);
00072 }
00073 void TelnetProtocol::visitConnect (StreamInfo &info)
00074 {
00075 _currentVisitor->visitConnect(info);
00076 }
00077 void TelnetProtocol::visitDisconnect (StreamInfo &info)
00078 {
00079 _currentVisitor->visitDisconnect(info);
00080 }
00081
00082 void TelnetProtocol::accept (StreamServerVisitor &visitor, int timeOutSec, int timeOutMicro)
00083 {
00084 _currentVisitor = &visitor;
00085 _server.accept (*this, timeOutSec, timeOutMicro);
00086 }
00087 void TelnetProtocol::write (const char * buffer, int size, int streamId)
00088 {
00089 _server.write (buffer, size, streamId);
00090 }
00091 void TelnetProtocol::close (int streamId)
00092 {
00093 _server.close (streamId);
00094 }
00095
00096 Stream &TelnetProtocol::outStream (int streamId)
00097 {
00098 return _server.outStream (streamId);
00099 }
00100
00101 }