1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#ifndef BU_PROTOCOL_TELNET_H
#define BU_PROTOCOL_TELNET_H
#include "bu/protocol.h"
#include "bu/hash.h"
namespace Bu
{
class ProtocolTelnet : public Protocol
{
public:
ProtocolTelnet();
virtual ~ProtocolTelnet();
virtual void onNewConnection( class Bu::Client *pClient );
virtual void onNewData( class Bu::Client *pClient );
enum OptMode
{
optOff,
optOn,
optDesire,
optRefuse
};
OptMode getLocalOptBinary();
void setLocalOptBinary( OptMode eMode );
OptMode getRemoteOptBinary();
void setRemoteOptBinary( OptMode eMode );
OptMode getLocalOptEcho();
void setLocalOptEcho( OptMode eMode );
OptMode getRemoteOptEcho();
void setRemoteOptEcho( OptMode eMode );
private:
/**
* Represents a basic telnet option, either on or off, no parameters.
* Each Option can negotiate effectively on it's own, and has two
* parameters in each of two classes. Both local and remote can be
* enabled/disabled and set/unset. Enabled represents the ability to
* set the option, disabling an option should also unset it. Set or
* unset represent wether the option is being used, if it is allowed.
*/
class Option
{
friend class Bu::ProtocolTelnet;
private:
Option( ProtocolTelnet &rPT, char cCode );
virtual ~Option();
public:
void localEnable( bool bSet=true );
void localSet( bool bSet=true );
bool isLocalEnabled();
bool isLocalSet();
void remoteEnable( bool bSet=true );
void remoteSet( bool bSet=true );
bool isRemoteEnabled();
bool isRemoteSet();
private:
enum
{
fLocalCant = 0x01, /**< Local can't/won't allow option. */
fLocalIs = 0x02, /**< Local is using option. */
fRemoteCant = 0x04, /**< Remote can't/won't allow option. */
fRemoteIs = 0x08 /**< Remote is using option. */
};
ProtocolTelnet &rPT;
char fOpts;
char cCode;
};
Hash<char, Option *> hOpts;
Option oBinary;
Option oEcho;
Client *pClient;
friend class Bu::ProtocolTelnet::Option;
};
}
#endif
|