17 #ifndef HH_SENF_Utils_Termlib_Telnet_ 18 #define HH_SENF_Utils_Termlib_Telnet_ 1 146 void write(std::string
const & s);
194 template <
class Handler>
223 virtual void v_eof() = 0;
235 void handleChar(
char c);
236 void handleNormalChar(
char c);
237 void handleCommand(
char c);
238 void handleOption(
char c);
239 void handleCR(
char c);
240 void handleSBOption(
char c);
241 void handleSBData(
char c);
242 void handleSBIAC(
char c);
244 void processCommand();
245 void transmit(
char c);
247 void sendWILL(
char option);
248 void sendWONT(
char option);
249 void sendDO(
char option);
250 void sendDONT(
char option);
252 void readHandler(
int state);
253 void writeHandler(
int state);
278 enum WantState { WANTED, ACCEPTED, DISABLED };
279 enum OptionState { NONE, REQUEST_SENT, ACKNOWLEDGED };
282 OptInfo(
bool local, option_type option);
287 option_type
const option;
290 OptionState optionState;
295 OptInfo & getOption(
bool local, option_type option);
296 void request(OptInfo & info,
bool enabled);
297 void response(OptInfo & info,
bool enabled);
299 typedef std::map<std::pair<bool, option_type>, OptInfo> OptionsMap;
302 typedef std::map<option_type, TelnetHandler*> OptionHandlerMap;
303 OptionHandlerMap handlers_;
307 typedef std::vector<char> SendQueue;
308 SendQueue sendQueue_;
310 enum CharState { NORMAL, IAC_SEEN, EXPECT_OPTION, CR_SEEN,
311 SB_OPTION, SB_DATA, SB_IAC_SEEN };
312 CharState charState_;
321 unsigned pendingRequests_;
337 virtual void v_init() = 0;
338 virtual void v_handleOptionParameters(std::string
const &
data) = 0;
358 namespace telnethandler {
379 void nextTerminalType();
380 std::string
const & terminalType()
const;
386 virtual void v_init();
387 virtual void v_handleOptionParameters(std::string
const & data);
410 unsigned width()
const;
411 unsigned height()
const;
419 virtual void v_windowSizeChanged() = 0;
424 virtual void v_init();
425 virtual void v_handleOptionParameters(std::string
const & data);
BaseTelnetProtocol::option_type const SUPPRESS_GO_AHEAD
virtual void v_handleGA()
Called, when the peer sends a GoAhead.
config::time_type clock_type
static unsigned const DEFAULT_REQUEST_TIMEOUT_MS
BaseTelnetProtocol()
Provided for TelnetHandler mixins only.
virtual void v_handleEC()
Called, when the peer sends an EraseCharacter.
void sendEC()
Send EraseCharacter to peer.
virtual void v_handleBRK()
Called, when the peer sends a BReaK.
void sendBRK()
Send BReaK to peer.
virtual void v_charReceived(char c)=0
Called whenever a data character is received.
bool localOption(option_type option)
true, if option locally enabled
void write(std::string const &s)
Send string to peer.
void requestLocalOption(option_type option, bool enabled=true)
Request option to be enabled here.
u8 data[SPECTRAL_HT20_NUM_BINS]
void incrementRequestCounter()
Increment request counter.
virtual void v_handleEL()
Called, when the peer sends an EraseLine.
void sendOptionParameters(option_type option, std::string const &data)
Send extended option parameter to peer.
void sendEL()
Send EraseLine to peer.
void acceptLocalOption(option_type option, bool enabled=true)
Accept a request for an option to be enabled here.
void registerHandler(Handler *h, bool request=true)
Register a TelnetHandler.
Telnet handler base class.
void sendIP()
Send InterruptProcess to peer.
virtual void v_handleIP()
Called, when the peer sends an InterruptProcess.
void sendNOP()
Send NOP to peer.
bool requestsPending()
true, if there are pending requests
Implement NAWS (Negotiation About Window Size) option.
Handle handle()
Get socket handle.
Telnet protocol implementation.
BaseTelnetProtocol::option_type const TRANSMIT_BINARY
BaseTelnetProtocol::option_type const LINEMODE
virtual void v_eof()=0
Called on input EOF.
void decrementRequestCounter()
Decrement request counter.
BaseTelnetProtocol::option_type const NAWS
void sendAYT()
Send AreYouThere to peer.
BaseTelnetProtocol::option_type const ECHO
unsigned char option_type
Type of telnet option numbers.
virtual void v_setupComplete()=0
Called, when no further requests are pending.
void acceptPeerOption(option_type option, bool enabled=true)
Accept a request by the peer to enable an option.
virtual void v_handleAYT()
Called, when the peer sends an AreYouThere.
virtual void v_handleNOP()
Called, when the peer sends a NOP.
BaseTelnetProtocol::option_type const TERMINAL_TYPE
void sendAO()
Send AbortOutput to peer.
Implement TERMINAL_TYPE option.
bool peerOption(option_type option)
true, if option enabled in peer
virtual ~BaseTelnetProtocol()
virtual void v_handleAO()
Called, when the peer sends an AbortOutput.
void sendGA()
Send GoAhead to peer.
void requestPeerOption(option_type option, bool enabled=true)
Request peer to enable an option.
ClientSocketHandle< senf::MakeSocketPolicy< ConnectedCommunicationPolicy, StreamFramingPolicy, ReadablePolicy, WriteablePolicy >::policy > Handle
Type of socket handle required.