Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(544)

Side by Side Diff: content/renderer/p2p/ipc_network_manager.cc

Issue 30193002: Push IPv6 addresses to libjingle PortAllocator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <iostream>
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/sys_byteorder.h" 8 #include "base/sys_byteorder.h"
9 #include "net/base/net_util.h" 9 #include "net/base/net_util.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 IpcNetworkManager::IpcNetworkManager(P2PSocketDispatcher* socket_dispatcher) 13 IpcNetworkManager::IpcNetworkManager(P2PSocketDispatcher* socket_dispatcher)
14 : socket_dispatcher_(socket_dispatcher), 14 : socket_dispatcher_(socket_dispatcher),
15 start_count_(0), 15 start_count_(0),
16 network_list_received_(false), 16 network_list_received_(false),
(...skipping 25 matching lines...) Expand all
42 void IpcNetworkManager::OnNetworkListChanged( 42 void IpcNetworkManager::OnNetworkListChanged(
43 const net::NetworkInterfaceList& list) { 43 const net::NetworkInterfaceList& list) {
44 44
45 // Update flag if network list received for the first time. 45 // Update flag if network list received for the first time.
46 if (!network_list_received_) 46 if (!network_list_received_)
47 network_list_received_ = true; 47 network_list_received_ = true;
48 48
49 std::vector<talk_base::Network*> networks; 49 std::vector<talk_base::Network*> networks;
50 for (net::NetworkInterfaceList::const_iterator it = list.begin(); 50 for (net::NetworkInterfaceList::const_iterator it = list.begin();
51 it != list.end(); it++) { 51 it != list.end(); it++) {
52 uint32 address; 52 if (it->address.size() == net::kIPv4AddressSize) {
53 if (it->address.size() != net::kIPv4AddressSize) 53 uint32 address;
54 continue; 54 memcpy(&address, &it->address[0], sizeof(uint32));
55 memcpy(&address, &it->address[0], sizeof(uint32)); 55 address = talk_base::NetworkToHost32(address);
56 address = talk_base::NetworkToHost32(address); 56 talk_base::IPAddress ip4_addr(address);
57 talk_base::Network* network = new talk_base::Network( 57 int prefix_length = talk_base::CountIPMaskBits(ip4_addr);
Ronghua Wu (Left Chromium) 2013/10/21 16:49:58 Is the CountIPMaskBits (returns the number of cont
Mallinath (Gone from Chromium) 2013/10/21 16:55:46 Agree. Prefix length should be used for only ident
58 it->name, it->name, talk_base::IPAddress(address), 32); 58 talk_base::Network* network = new talk_base::Network(
59 network->AddIP(talk_base::IPAddress(address)); 59 it->name, it->name, talk_base::TruncateIP(ip4_addr, prefix_length),
60 networks.push_back(network); 60 prefix_length);
61 network->AddIP(ip4_addr);
62 networks.push_back(network);
63 } else if (it->address.size() == net::kIPv6AddressSize) {
64 in6_addr address;
65 memcpy(&address, &it->address[0], sizeof(in6_addr));
66 talk_base::IPAddress ip6_addr(address);
67 int prefix_length = talk_base::CountIPMaskBits(ip6_addr);
68 talk_base::Network* network = new talk_base::Network(
69 it->name, it->name, talk_base::TruncateIP(ip6_addr, prefix_length),
70 prefix_length);
71 network->AddIP(ip6_addr);
72 networks.push_back(network);
73 }
61 } 74 }
62 75
63 bool changed = false; 76 bool changed = false;
64 MergeNetworkList(networks, &changed); 77 MergeNetworkList(networks, &changed);
65 if (changed) 78 if (changed)
66 SignalNetworksChanged(); 79 SignalNetworksChanged();
67 } 80 }
68 81
69 void IpcNetworkManager::SendNetworksChangedSignal() { 82 void IpcNetworkManager::SendNetworksChangedSignal() {
70 SignalNetworksChanged(); 83 SignalNetworksChanged();
71 } 84 }
72 85
73 } // namespace content 86 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698