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 #include "webrtc/base/network.h" | 11 #include "webrtc/base/network.h" |
12 | 12 |
13 #include "webrtc/base/nethelpers.h" | 13 #include "webrtc/base/nethelpers.h" |
14 #include "webrtc/base/networkmonitor.h" | 14 #include "webrtc/base/networkmonitor.h" |
| 15 #include <memory> |
15 #include <vector> | 16 #include <vector> |
16 #if defined(WEBRTC_POSIX) | 17 #if defined(WEBRTC_POSIX) |
17 #include <sys/types.h> | 18 #include <sys/types.h> |
18 #include <net/if.h> | 19 #include <net/if.h> |
19 #include "webrtc/base/ifaddrs_converter.h" | 20 #include "webrtc/base/ifaddrs_converter.h" |
20 #endif // defined(WEBRTC_POSIX) | 21 #endif // defined(WEBRTC_POSIX) |
21 #include "webrtc/base/gunit.h" | 22 #include "webrtc/base/gunit.h" |
22 #if defined(WEBRTC_WIN) | 23 #if defined(WEBRTC_WIN) |
23 #include "webrtc/base/logging.h" // For LOG_GLE | 24 #include "webrtc/base/logging.h" // For LOG_GLE |
24 #endif | 25 #endif |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 network_manager.networks_map_.clear(); | 102 network_manager.networks_map_.clear(); |
102 } | 103 } |
103 | 104 |
104 #if defined(WEBRTC_POSIX) | 105 #if defined(WEBRTC_POSIX) |
105 // Separated from CreateNetworks for tests. | 106 // Separated from CreateNetworks for tests. |
106 static void CallConvertIfAddrs(const BasicNetworkManager& network_manager, | 107 static void CallConvertIfAddrs(const BasicNetworkManager& network_manager, |
107 struct ifaddrs* interfaces, | 108 struct ifaddrs* interfaces, |
108 bool include_ignored, | 109 bool include_ignored, |
109 NetworkManager::NetworkList* networks) { | 110 NetworkManager::NetworkList* networks) { |
110 // Use the base IfAddrsConverter for test cases. | 111 // Use the base IfAddrsConverter for test cases. |
111 rtc::scoped_ptr<IfAddrsConverter> ifaddrs_converter(new IfAddrsConverter()); | 112 std::unique_ptr<IfAddrsConverter> ifaddrs_converter(new IfAddrsConverter()); |
112 network_manager.ConvertIfAddrs(interfaces, ifaddrs_converter.get(), | 113 network_manager.ConvertIfAddrs(interfaces, ifaddrs_converter.get(), |
113 include_ignored, networks); | 114 include_ignored, networks); |
114 } | 115 } |
115 | 116 |
116 struct sockaddr_in6* CreateIpv6Addr(const std::string& ip_string, | 117 struct sockaddr_in6* CreateIpv6Addr(const std::string& ip_string, |
117 uint32_t scope_id) { | 118 uint32_t scope_id) { |
118 struct sockaddr_in6* ipv6_addr = new struct sockaddr_in6; | 119 struct sockaddr_in6* ipv6_addr = new struct sockaddr_in6; |
119 memset(ipv6_addr, 0, sizeof(struct sockaddr_in6)); | 120 memset(ipv6_addr, 0, sizeof(struct sockaddr_in6)); |
120 ipv6_addr->sin6_family = AF_INET6; | 121 ipv6_addr->sin6_family = AF_INET6; |
121 ipv6_addr->sin6_scope_id = scope_id; | 122 ipv6_addr->sin6_scope_id = scope_id; |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 // If the set default address is in a network, GetDefaultLocalAddress will | 1033 // If the set default address is in a network, GetDefaultLocalAddress will |
1033 // return the best IP in that network. | 1034 // return the best IP in that network. |
1034 manager.set_default_local_addresses(GetLoopbackIP(AF_INET), ip2); | 1035 manager.set_default_local_addresses(GetLoopbackIP(AF_INET), ip2); |
1035 EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET6, &ip)); | 1036 EXPECT_TRUE(manager.GetDefaultLocalAddress(AF_INET6, &ip)); |
1036 EXPECT_EQ(static_cast<IPAddress>(ip1), ip); | 1037 EXPECT_EQ(static_cast<IPAddress>(ip1), ip); |
1037 | 1038 |
1038 manager.StopUpdating(); | 1039 manager.StopUpdating(); |
1039 } | 1040 } |
1040 | 1041 |
1041 } // namespace rtc | 1042 } // namespace rtc |
OLD | NEW |