OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_BASE_FIREWALLSOCKETSERVER_H_ | 11 #ifndef WEBRTC_BASE_FIREWALLSOCKETSERVER_H_ |
12 #define WEBRTC_BASE_FIREWALLSOCKETSERVER_H_ | 12 #define WEBRTC_BASE_FIREWALLSOCKETSERVER_H_ |
13 | 13 |
14 #include <vector> | 14 #include <vector> |
15 #include "webrtc/base/socketserver.h" | 15 #include "webrtc/base/socketserver.h" |
16 #include "webrtc/base/criticalsection.h" | 16 #include "webrtc/base/criticalsection.h" |
17 | 17 |
18 namespace rtc { | 18 namespace rtc { |
19 | 19 |
20 class FirewallManager; | 20 class FirewallManager; |
21 | 21 |
22 // This SocketServer shim simulates a rule-based firewall server. | 22 // This SocketServer shim simulates a rule-based firewall server. |
23 | 23 |
24 enum FirewallProtocol { FP_UDP, FP_TCP, FP_ANY }; | 24 enum FirewallProtocol { FP_UDP, FP_TCP, FP_ANY }; |
25 enum FirewallDirection { FD_IN, FD_OUT, FD_ANY }; | 25 enum FirewallDirection { FD_IN, FD_OUT, FD_ANY }; |
26 | 26 |
27 class FirewallSocketServer : public SocketServer { | 27 class FirewallSocketServer : public SocketServer { |
28 public: | 28 public: |
29 FirewallSocketServer(SocketServer * server, | 29 FirewallSocketServer(SocketServer* server, |
30 FirewallManager * manager = NULL, | 30 FirewallManager* manager = nullptr, |
31 bool should_delete_server = false); | 31 bool should_delete_server = false); |
32 ~FirewallSocketServer() override; | 32 ~FirewallSocketServer() override; |
33 | 33 |
34 SocketServer* socketserver() const { return server_; } | 34 SocketServer* socketserver() const { return server_; } |
35 void set_socketserver(SocketServer* server) { | 35 void set_socketserver(SocketServer* server) { |
36 if (server_ && should_delete_server_) { | 36 if (server_ && should_delete_server_) { |
37 delete server_; | 37 delete server_; |
38 server_ = NULL; | 38 server_ = nullptr; |
39 should_delete_server_ = false; | 39 should_delete_server_ = false; |
40 } | 40 } |
41 server_ = server; | 41 server_ = server; |
42 } | 42 } |
43 | 43 |
44 // Settings to control whether CreateSocket or Socket::Listen succeed. | 44 // Settings to control whether CreateSocket or Socket::Listen succeed. |
45 void set_udp_sockets_enabled(bool enabled) { udp_sockets_enabled_ = enabled; } | 45 void set_udp_sockets_enabled(bool enabled) { udp_sockets_enabled_ = enabled; } |
46 void set_tcp_sockets_enabled(bool enabled) { tcp_sockets_enabled_ = enabled; } | 46 void set_tcp_sockets_enabled(bool enabled) { tcp_sockets_enabled_ = enabled; } |
47 bool tcp_listen_enabled() const { return tcp_listen_enabled_; } | 47 bool tcp_listen_enabled() const { return tcp_listen_enabled_; } |
48 void set_tcp_listen_enabled(bool enabled) { tcp_listen_enabled_ = enabled; } | 48 void set_tcp_listen_enabled(bool enabled) { tcp_listen_enabled_ = enabled; } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 void ClearRules(); | 105 void ClearRules(); |
106 | 106 |
107 private: | 107 private: |
108 CriticalSection crit_; | 108 CriticalSection crit_; |
109 std::vector<FirewallSocketServer *> servers_; | 109 std::vector<FirewallSocketServer *> servers_; |
110 }; | 110 }; |
111 | 111 |
112 } // namespace rtc | 112 } // namespace rtc |
113 | 113 |
114 #endif // WEBRTC_BASE_FIREWALLSOCKETSERVER_H_ | 114 #endif // WEBRTC_BASE_FIREWALLSOCKETSERVER_H_ |
OLD | NEW |