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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } else { | 136 } else { |
137 // Skip non-IP addresses. | 137 // Skip non-IP addresses. |
138 continue; | 138 continue; |
139 } | 139 } |
140 | 140 |
141 IPEndPoint address; | 141 IPEndPoint address; |
142 std::string name = interface->ifa_name; | 142 std::string name = interface->ifa_name; |
143 if (address.FromSockAddr(addr, addr_size)) { | 143 if (address.FromSockAddr(addr, addr_size)) { |
144 uint8 net_mask = 0; | 144 uint8 net_mask = 0; |
145 if (interface->ifa_netmask) { | 145 if (interface->ifa_netmask) { |
| 146 // If not otherwise set, assume the same sa_family as ifa_addr. |
| 147 if (interface->ifa_netmask->sa_family == 0) { |
| 148 interface->ifa_netmask->sa_family = addr->sa_family; |
| 149 } |
146 IPEndPoint netmask; | 150 IPEndPoint netmask; |
147 if (netmask.FromSockAddr(interface->ifa_netmask, addr_size)) { | 151 if (netmask.FromSockAddr(interface->ifa_netmask, addr_size)) { |
148 net_mask = MaskPrefixLength(netmask.address()); | 152 net_mask = MaskPrefixLength(netmask.address()); |
149 } | 153 } |
150 } | 154 } |
151 | 155 |
152 networks->push_back( | 156 networks->push_back( |
153 NetworkInterface(name, if_nametoindex(name.c_str()), | 157 NetworkInterface(name, if_nametoindex(name.c_str()), |
154 address.address(), net_mask)); | 158 address.address(), net_mask)); |
155 } | 159 } |
156 } | 160 } |
157 | 161 |
158 freeifaddrs(interfaces); | 162 freeifaddrs(interfaces); |
159 | 163 |
160 return true; | 164 return true; |
161 #endif | 165 #endif |
162 } | 166 } |
163 | 167 |
164 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() { | 168 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() { |
165 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; | 169 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; |
166 } | 170 } |
167 | 171 |
168 } // namespace net | 172 } // namespace net |
OLD | NEW |