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 #include "content/renderer/p2p/ipc_network_manager.h" | 5 #include "content/renderer/p2p/ipc_network_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/sys_byteorder.h" | 10 #include "base/sys_byteorder.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 // interfaces discovered. | 77 // interfaces discovered. |
78 std::vector<rtc::Network*> networks; | 78 std::vector<rtc::Network*> networks; |
79 int ipv4_interfaces = 0; | 79 int ipv4_interfaces = 0; |
80 int ipv6_interfaces = 0; | 80 int ipv6_interfaces = 0; |
81 for (net::NetworkInterfaceList::const_iterator it = list.begin(); | 81 for (net::NetworkInterfaceList::const_iterator it = list.begin(); |
82 it != list.end(); it++) { | 82 it != list.end(); it++) { |
83 if (it->address.size() == net::kIPv4AddressSize) { | 83 if (it->address.size() == net::kIPv4AddressSize) { |
84 uint32 address; | 84 uint32 address; |
85 memcpy(&address, &it->address[0], sizeof(uint32)); | 85 memcpy(&address, &it->address[0], sizeof(uint32)); |
86 address = rtc::NetworkToHost32(address); | 86 address = rtc::NetworkToHost32(address); |
87 rtc::IPAddress prefix = rtc::TruncateIP(rtc::IPAddress(address), | |
Sergey Ulanov
2014/09/03 22:55:22
Do you really need to truncate the prefix? Shouldn
guoweis_webrtc
2014/09/03 22:58:14
Yes, I do want to truncate the address. Network is
juberti2
2014/09/03 23:11:02
It does seem unnecessary to pass both |prefix| and
| |
88 it->network_prefix); | |
87 rtc::Network* network = new rtc::Network( | 89 rtc::Network* network = new rtc::Network( |
88 it->name, it->name, rtc::IPAddress(address), 32, | 90 it->name, it->name, prefix, it->network_prefix, |
89 ConvertConnectionTypeToAdapterType(it->type)); | 91 ConvertConnectionTypeToAdapterType(it->type)); |
90 network->AddIP(rtc::IPAddress(address)); | 92 network->AddIP(rtc::IPAddress(address)); |
91 networks.push_back(network); | 93 networks.push_back(network); |
92 ++ipv4_interfaces; | 94 ++ipv4_interfaces; |
93 } else if (it->address.size() == net::kIPv6AddressSize) { | 95 } else if (it->address.size() == net::kIPv6AddressSize) { |
94 in6_addr address; | 96 in6_addr address; |
95 memcpy(&address, &it->address[0], sizeof(in6_addr)); | 97 memcpy(&address, &it->address[0], sizeof(in6_addr)); |
96 rtc::IPAddress ip6_addr(address); | 98 rtc::IPAddress ip6_addr(address); |
97 if (!rtc::IPIsPrivate(ip6_addr)) { | 99 if (!rtc::IPIsPrivate(ip6_addr)) { |
100 rtc::IPAddress prefix = rtc::TruncateIP(rtc::IPAddress(ip6_addr), | |
101 it->network_prefix); | |
98 rtc::Network* network = new rtc::Network( | 102 rtc::Network* network = new rtc::Network( |
99 it->name, it->name, ip6_addr, 64, | 103 it->name, it->name, prefix, it->network_prefix, |
100 ConvertConnectionTypeToAdapterType(it->type)); | 104 ConvertConnectionTypeToAdapterType(it->type)); |
101 network->AddIP(ip6_addr); | 105 network->AddIP(ip6_addr); |
102 networks.push_back(network); | 106 networks.push_back(network); |
103 ++ipv6_interfaces; | 107 ++ipv6_interfaces; |
104 } | 108 } |
105 } | 109 } |
106 } | 110 } |
107 | 111 |
108 | 112 |
109 // Send interface counts to UMA. | 113 // Send interface counts to UMA. |
(...skipping 23 matching lines...) Expand all Loading... | |
133 MergeNetworkList(networks, &changed); | 137 MergeNetworkList(networks, &changed); |
134 if (changed) | 138 if (changed) |
135 SignalNetworksChanged(); | 139 SignalNetworksChanged(); |
136 } | 140 } |
137 | 141 |
138 void IpcNetworkManager::SendNetworksChangedSignal() { | 142 void IpcNetworkManager::SendNetworksChangedSignal() { |
139 SignalNetworksChanged(); | 143 SignalNetworksChanged(); |
140 } | 144 } |
141 | 145 |
142 } // namespace content | 146 } // namespace content |
OLD | NEW |