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