OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/base/net_util.h" | 5 #include "net/base/net_util.h" |
6 | 6 |
7 #include <sys/types.h> | 7 #include <sys/types.h> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 reinterpret_cast<struct sockaddr_in*>(addr); | 126 reinterpret_cast<struct sockaddr_in*>(addr); |
127 addr_size = sizeof(*addr_in); | 127 addr_size = sizeof(*addr_in); |
128 if (addr_in->sin_addr.s_addr == INADDR_LOOPBACK || | 128 if (addr_in->sin_addr.s_addr == INADDR_LOOPBACK || |
129 addr_in->sin_addr.s_addr == 0) { | 129 addr_in->sin_addr.s_addr == 0) { |
130 continue; | 130 continue; |
131 } | 131 } |
132 } else { | 132 } else { |
133 // Skip non-IP addresses. | 133 // Skip non-IP addresses. |
134 continue; | 134 continue; |
135 } | 135 } |
| 136 |
136 IPEndPoint address; | 137 IPEndPoint address; |
137 std::string name = interface->ifa_name; | 138 std::string name = interface->ifa_name; |
138 if (address.FromSockAddr(addr, addr_size)) { | 139 if (address.FromSockAddr(addr, addr_size)) { |
139 networks->push_back(NetworkInterface(name, address.address())); | 140 uint8 net_mask = 0; |
| 141 if (interface->ifa_netmask) { |
| 142 IPEndPoint netmask; |
| 143 if (netmask.FromSockAddr(interface->ifa_netmask, addr_size)) { |
| 144 net_mask = MaskPrefixLength(netmask.address()); |
| 145 } |
| 146 } |
| 147 |
| 148 networks->push_back(NetworkInterface(name, address.address(), net_mask)); |
140 } | 149 } |
141 } | 150 } |
142 | 151 |
143 freeifaddrs(interfaces); | 152 freeifaddrs(interfaces); |
144 | 153 |
145 return true; | 154 return true; |
146 #endif | 155 #endif |
147 } | 156 } |
148 | 157 |
149 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() { | 158 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() { |
150 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; | 159 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; |
151 } | 160 } |
152 | 161 |
153 } // namespace net | 162 } // namespace net |
OLD | NEW |