OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_BASE_TELNET_SERVER_H_ | 5 #ifndef NET_BASE_TELNET_SERVER_H_ |
6 #define NET_BASE_TELNET_SERVER_H_ | 6 #define NET_BASE_TELNET_SERVER_H_ |
7 | 7 |
8 #include "net/base/listen_socket.h" | 8 #include "net/base/listen_socket.h" |
9 | 9 |
10 // Implements the telnet protocol on top of the raw socket interface. | 10 // Implements the telnet protocol on top of the raw socket interface. |
11 // DidRead calls to the delegate are buffered on a line by line basis. | 11 // DidRead calls to the delegate are buffered on a line by line basis. |
12 // (for now this means that basic line editing is handled in this object) | 12 // (for now this means that basic line editing is handled in this object) |
13 class TelnetServer : public ListenSocket { | 13 class TelnetServer : public ListenSocket { |
14 public: | 14 public: |
15 static TelnetServer* Listen(std::string ip, int port, | 15 static TelnetServer* Listen(std::string ip, int port, |
16 ListenSocketDelegate *del); | 16 ListenSocketDelegate *del); |
17 virtual ~TelnetServer(); | |
18 | 17 |
19 protected: | 18 protected: |
20 void Listen() { ListenSocket::Listen(); } | 19 void Listen() { ListenSocket::Listen(); } |
21 virtual void Read(); | 20 virtual void Read(); |
22 virtual void Accept(); | 21 virtual void Accept(); |
23 virtual void SendInternal(const char* bytes, int len); | 22 virtual void SendInternal(const char* bytes, int len); |
24 | 23 |
25 private: | 24 private: |
26 enum TelnetInputState { | 25 enum TelnetInputState { |
27 // Currently not processing any IAC or ESC sequence. | 26 // Currently not processing any IAC or ESC sequence. |
(...skipping 10 matching lines...) Expand all Loading... |
38 SUBNEGOTIATION_EXPECTING_SE, | 37 SUBNEGOTIATION_EXPECTING_SE, |
39 // Processing ESC sequence. | 38 // Processing ESC sequence. |
40 EXPECTING_FIRST_ESC_CHARACTER, | 39 EXPECTING_FIRST_ESC_CHARACTER, |
41 // Processing ESC sequence with two characters. | 40 // Processing ESC sequence with two characters. |
42 EXPECTING_SECOND_ESC_CHARACTER, | 41 EXPECTING_SECOND_ESC_CHARACTER, |
43 // Processing "ESC [" sequence. | 42 // Processing "ESC [" sequence. |
44 EXPECTING_NUMBER_SEMICOLON_OR_END | 43 EXPECTING_NUMBER_SEMICOLON_OR_END |
45 }; | 44 }; |
46 | 45 |
47 TelnetServer(SOCKET s, ListenSocketDelegate* del); | 46 TelnetServer(SOCKET s, ListenSocketDelegate* del); |
| 47 virtual ~TelnetServer(); |
48 | 48 |
49 // telnet commands | 49 // telnet commands |
50 void SendIAC(int command, int option); | 50 void SendIAC(int command, int option); |
51 void StateMachineStep(unsigned char c); | 51 void StateMachineStep(unsigned char c); |
52 | 52 |
53 TelnetInputState input_state_; | 53 TelnetInputState input_state_; |
54 int iac_command_; // Last command read. | 54 int iac_command_; // Last command read. |
55 int iac_option_; // Last option read. | 55 int iac_option_; // Last option read. |
56 std::string command_line_; | 56 std::string command_line_; |
57 | 57 |
58 DISALLOW_EVIL_CONSTRUCTORS(TelnetServer); | 58 DISALLOW_EVIL_CONSTRUCTORS(TelnetServer); |
59 }; | 59 }; |
60 | 60 |
61 #endif // NET_BASE_TELNET_SERVER_H_ | 61 #endif // NET_BASE_TELNET_SERVER_H_ |
OLD | NEW |