OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 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 |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 // Error values are negative. | 23 // Error values are negative. |
24 enum NetworkBindingResults { | 24 enum NetworkBindingResults { |
25 NETWORK_BIND_SUCCESS = 0, // No error | 25 NETWORK_BIND_SUCCESS = 0, // No error |
26 NETWORK_BIND_FAILURE = -1, // Generic error | 26 NETWORK_BIND_FAILURE = -1, // Generic error |
27 NETWORK_BIND_NOT_IMPLEMENTED = -2, | 27 NETWORK_BIND_NOT_IMPLEMENTED = -2, |
28 NETWORK_BIND_ADDRESS_NOT_FOUND = -3, | 28 NETWORK_BIND_ADDRESS_NOT_FOUND = -3, |
29 NETWORK_BIND_NETWORK_CHANGED = -4 | 29 NETWORK_BIND_NETWORK_CHANGED = -4 |
30 }; | 30 }; |
31 | 31 |
| 32 enum AdapterType { |
| 33 // This enum resembles the one in Chromium net::ConnectionType. |
| 34 ADAPTER_TYPE_UNKNOWN = 0, |
| 35 ADAPTER_TYPE_ETHERNET = 1 << 0, |
| 36 ADAPTER_TYPE_WIFI = 1 << 1, |
| 37 ADAPTER_TYPE_CELLULAR = 1 << 2, |
| 38 ADAPTER_TYPE_VPN = 1 << 3, |
| 39 ADAPTER_TYPE_LOOPBACK = 1 << 4 |
| 40 }; |
| 41 |
32 class NetworkBinderInterface { | 42 class NetworkBinderInterface { |
33 public: | 43 public: |
34 // Binds a socket to the network that is attached to |address| so that all | 44 // Binds a socket to the network that is attached to |address| so that all |
35 // packets on the socket |socket_fd| will be sent via that network. | 45 // packets on the socket |socket_fd| will be sent via that network. |
36 // This is needed because some operating systems (like Android) require a | 46 // This is needed because some operating systems (like Android) require a |
37 // special bind call to put packets on a non-default network interface. | 47 // special bind call to put packets on a non-default network interface. |
38 virtual int BindSocketToNetwork(int socket_fd, const IPAddress& address) = 0; | 48 virtual int BindSocketToNetwork(int socket_fd, const IPAddress& address) = 0; |
39 }; | 49 }; |
40 | 50 |
41 /* | 51 /* |
(...skipping 21 matching lines...) Expand all Loading... |
63 virtual ~NetworkMonitorInterface(); | 73 virtual ~NetworkMonitorInterface(); |
64 | 74 |
65 sigslot::signal0<> SignalNetworksChanged; | 75 sigslot::signal0<> SignalNetworksChanged; |
66 | 76 |
67 virtual void Start() = 0; | 77 virtual void Start() = 0; |
68 virtual void Stop() = 0; | 78 virtual void Stop() = 0; |
69 | 79 |
70 // Implementations should call this method on the base when networks change, | 80 // Implementations should call this method on the base when networks change, |
71 // and the base will fire SignalNetworksChanged on the right thread. | 81 // and the base will fire SignalNetworksChanged on the right thread. |
72 virtual void OnNetworksChanged() = 0; | 82 virtual void OnNetworksChanged() = 0; |
| 83 |
| 84 virtual AdapterType GetAdapterType(const std::string& interface_name) = 0; |
73 }; | 85 }; |
74 | 86 |
75 class NetworkMonitorBase : public NetworkMonitorInterface, | 87 class NetworkMonitorBase : public NetworkMonitorInterface, |
76 public MessageHandler, | 88 public MessageHandler, |
77 public sigslot::has_slots<> { | 89 public sigslot::has_slots<> { |
78 public: | 90 public: |
79 NetworkMonitorBase(); | 91 NetworkMonitorBase(); |
80 ~NetworkMonitorBase() override; | 92 ~NetworkMonitorBase() override; |
81 | 93 |
82 void OnNetworksChanged() override; | 94 void OnNetworksChanged() override; |
(...skipping 23 matching lines...) Expand all Loading... |
106 | 118 |
107 virtual ~NetworkMonitorFactory(); | 119 virtual ~NetworkMonitorFactory(); |
108 | 120 |
109 protected: | 121 protected: |
110 NetworkMonitorFactory(); | 122 NetworkMonitorFactory(); |
111 }; | 123 }; |
112 | 124 |
113 } // namespace rtc | 125 } // namespace rtc |
114 | 126 |
115 #endif // WEBRTC_BASE_NETWORKMONITOR_H_ | 127 #endif // WEBRTC_BASE_NETWORKMONITOR_H_ |
OLD | NEW |