OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 TOOLS_ANDROID_FORWARDER2_COMMAND_H_ | 5 #ifndef TOOLS_ANDROID_FORWARDER2_COMMAND_H_ |
6 #define TOOLS_ANDROID_FORWARDER2_COMMAND_H_ | 6 #define TOOLS_ANDROID_FORWARDER2_COMMAND_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 | 9 |
10 namespace forwarder2 { | 10 namespace forwarder2 { |
11 | 11 |
12 class Socket; | 12 class Socket; |
13 | 13 |
14 namespace command { | 14 namespace command { |
15 | 15 |
16 enum Type { | 16 enum Type { |
17 ACCEPT_ERROR = 0, | 17 ACCEPT_ERROR = 0, |
18 ACCEPT_SUCCESS, | 18 ACCEPT_SUCCESS, |
19 ACK, | 19 ACK, |
20 ADB_DATA_SOCKET_ERROR, | 20 ADB_DATA_SOCKET_ERROR, |
21 ADB_DATA_SOCKET_SUCCESS, | 21 ADB_DATA_SOCKET_SUCCESS, |
22 BIND_ERROR, | 22 BIND_ERROR, |
23 BIND_SUCCESS, | 23 BIND_SUCCESS, |
24 DATA_CONNECTION, | 24 DATA_CONNECTION, |
25 HOST_SERVER_ERROR, | 25 HOST_SERVER_ERROR, |
26 HOST_SERVER_SUCCESS, | 26 HOST_SERVER_SUCCESS, |
27 KILL_ALL_LISTENERS, | 27 KILL_ALL_LISTENERS, |
28 LISTEN, | 28 LISTEN, |
29 UNMAP_PORT, | 29 UNLISTEN, |
30 UNMAP_PORT_ERROR, | 30 UNLISTEN_ERROR, |
31 UNMAP_PORT_SUCCESS, | 31 UNLISTEN_SUCCESS, |
32 }; | 32 }; |
33 | 33 |
34 } // namespace command | 34 } // namespace command |
35 | 35 |
36 bool ReadCommand(Socket* socket, | 36 bool ReadCommand(Socket* socket, |
37 int* port_out, | 37 int* port_out, |
38 command::Type* command_type_out); | 38 command::Type* command_type_out); |
39 | 39 |
40 // Helper function to read the command from the |socket| and return true if the | 40 // Helper function to read the command from the |socket| and return true if the |
41 // |command| is equal to the given command parameter. | 41 // |command| is equal to the given command parameter. |
42 bool ReceivedCommand(command::Type command, Socket* socket); | 42 bool ReceivedCommand(command::Type command, Socket* socket); |
43 | 43 |
44 bool SendCommand(command::Type command, int port, Socket* socket); | 44 bool SendCommand(command::Type command, int port, Socket* socket); |
45 | 45 |
46 } // namespace forwarder | 46 } // namespace forwarder |
47 | 47 |
48 #endif // TOOLS_ANDROID_FORWARDER2_COMMAND_H_ | 48 #endif // TOOLS_ANDROID_FORWARDER2_COMMAND_H_ |
OLD | NEW |