// $Id$
//
-// Copyright (C) 2008
+// Copyright (C) 2008
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Stefan Bund <g0dil@berlios.de>
// Custom includes
#include <vector>
#include <map>
-#include <senf/Socket.hh>
#include <senf/Scheduler/Scheduler.hh>
#include <senf/Scheduler/ClockService.hh>
//#include "Telnet.mpp"
-///////////////////////////////hh.p////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
namespace senf {
namespace term {
\c v_handleOptionParameters() member is called.
\code
- class MyTelnetHandler
+ class MyTelnetHandler
: public senf::term::BaseTelnetProtocol::TelnetHandler
{
public:
protected:
MyTelnetHandler() { registerHandler(this); }
-
+
private:
virtual void v_init()
{
sendOptionParameters(OPTION_CODE, "my special subnegotiation");
incrementRequestCounter();
}
-
+
virtual void v_handleOptionParameters(std::string const & data)
{
if (data == "another special subnegotiation")
static unsigned const DEFAULT_REQUEST_TIMEOUT_MS = 500u;
typedef ClientSocketHandle<senf::MakeSocketPolicy<
- ConnectedCommunicationPolicy,
- StreamFramingPolicy,
+ ConnectedCommunicationPolicy,
+ StreamFramingPolicy,
ReadablePolicy,
WriteablePolicy>::policy> Handle; ///< Type of socket handle required
void sendEC(); ///< Send EraseCharacter to peer
void sendEL(); ///< Send EraseLine to peer
void sendGA(); ///< Send GoAhead to peer
-
+
void sendOptionParameters(option_type option, std::string const & data);
///< Send extended option parameter to peer
/**< This will send \a data as extended option parameter of
bool localOption(option_type option); ///< \c true, if \a option locally enabled
bool peerOption(option_type option); ///< \c true, if \a option enabled in peer
-
+
protected:
explicit BaseTelnetProtocol(Handle handle); ///< Construct telnet protocol handler
BaseTelnetProtocol(); ///< Provided for TelnetHandler mixins only
virtual void v_handleEC(); ///< Called, when the peer sends an EraseCharacter
virtual void v_handleEL(); ///< Called, when the peer sends an EraseLine
virtual void v_handleGA(); ///< Called, when the peer sends a GoAhead
-
+
private:
void handleChar(char c);
void handleNormalChar(char c);
void writeHandler(int state);
void timeout();
- enum Command {
- CMD_NONE = static_cast<char>(0),
- CMD_SE = static_cast<char>(240),
- CMD_NOP = static_cast<char>(241),
- CMD_DM = static_cast<char>(242),
- CMD_BRK = static_cast<char>(243),
- CMD_IP = static_cast<char>(244),
- CMD_AO = static_cast<char>(245),
- CMD_AYT = static_cast<char>(246),
- CMD_EC = static_cast<char>(247),
- CMD_EL = static_cast<char>(248),
- CMD_GA = static_cast<char>(249),
- CMD_SB = static_cast<char>(250),
- CMD_WILL = static_cast<char>(251),
- CMD_WONT = static_cast<char>(252),
- CMD_DO = static_cast<char>(253),
- CMD_DONT = static_cast<char>(254),
- CMD_IAC = static_cast<char>(255),
+ enum Command {
+ CMD_NONE = 0,
+ CMD_SE = 240,
+ CMD_NOP = 241,
+ CMD_DM = 242,
+ CMD_BRK = 243,
+ CMD_IP = 244,
+ CMD_AO = 245,
+ CMD_AYT = 246,
+ CMD_EC = 247,
+ CMD_EL = 248,
+ CMD_GA = 249,
+ CMD_SB = 250,
+ CMD_WILL = 251,
+ CMD_WONT = 252,
+ CMD_DO = 253,
+ CMD_DONT = 254,
+ CMD_IAC = 255,
};
struct OptInfo
OptInfo();
OptInfo(bool local, option_type option);
- ///////////////////////////////////////////////////////////////
+ //-////////////////////////////////////////////////////////////
bool const local;
option_type const option;
WantState wantState;
OptionState optionState;
bool enabled;
-
+
};
OptInfo & getOption(bool local, option_type option);
typedef std::vector<char> SendQueue;
SendQueue sendQueue_;
- enum CharState { NORMAL, IAC_SEEN, EXPECT_OPTION, CR_SEEN,
+ enum CharState { NORMAL, IAC_SEEN, EXPECT_OPTION, CR_SEEN,
SB_OPTION, SB_DATA, SB_IAC_SEEN };
CharState charState_;
option_type option_;
std::string data_;
- senf::scheduler::FdEvent inputEvent_;
- senf::scheduler::FdEvent outputEvent_;
+ scheduler::FdEvent inputEvent_;
+ scheduler::FdEvent outputEvent_;
unsigned pendingRequests_;
};
/** \brief Telnet handler base class
-
+
\see BaseTelnetProtocol
*/
struct BaseTelnetProtocol::TelnetHandler
See http://www.iana.org/assignments/telnet-options for a list of options
- \ingroup telnet_group
+ \ingroup telnet_group
*/
namespace telnetopt { BaseTelnetProtocol::option_type const ECHO = 1u; }
namespace telnetopt { BaseTelnetProtocol::option_type const TRANSMIT_BINARY = 0u; }
/** \brief Implement TERMINAL_TYPE option
This telnet handler implements the TERMINAL_TYPE option. The handler automatically requests
- the first terminal type during initialization. Further terminal types may then be reqeusted
+ the first terminal type during initialization. Further terminal types may then be requested
by calling nextTerminalType().
The last received terminal type will be returned by the terminalType() member.
void nextTerminalType(); ///< Request another terminal type
std::string const & terminalType() const; ///< Return current terminal type
-
+
protected:
TerminalType();
};
/** \brief Implement NAWS (Negotiation About Window Size) option
-
+
This telnet handler implements the NAWS option. The client terminals window size will be
requested during initialization. The current window size may always be accessed using the
- width() and height() members.
-
+ width() and height() members.
+
Whenever the window size is changed, the v_windowSizeChanged() function is called. This
function must be implemented in a derived class.
\see BaseTelnetProtocol for how to integrate this handler \n
<a href="http://tools.ietf.org/html/rfc1073">RFC 1073</a> Telnet Window Size Option
*/
- class NAWS
+ class NAWS
: public BaseTelnetProtocol::TelnetHandler
{
public:
protected:
NAWS();
-
+
# ifndef DOXYGEN
private:
# endif
unsigned width_;
unsigned height_;
};
-
+
}
}}
-///////////////////////////////hh.e////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
#include "Telnet.cci"
//#include "Telnet.ct"