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 #ifndef NET_BASE_NET_UTIL_H_ | 5 #ifndef NET_BASE_NET_UTIL_H_ |
6 #define NET_BASE_NET_UTIL_H_ | 6 #define NET_BASE_NET_UTIL_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 // | 509 // |
510 // Note that this function does not check for IP addresses other than | 510 // Note that this function does not check for IP addresses other than |
511 // the above, although other IP addresses may point to the local | 511 // the above, although other IP addresses may point to the local |
512 // machine. | 512 // machine. |
513 NET_EXPORT_PRIVATE bool IsLocalhost(const std::string& host); | 513 NET_EXPORT_PRIVATE bool IsLocalhost(const std::string& host); |
514 | 514 |
515 // struct that is used by GetNetworkList() to represent a network | 515 // struct that is used by GetNetworkList() to represent a network |
516 // interface. | 516 // interface. |
517 struct NET_EXPORT NetworkInterface { | 517 struct NET_EXPORT NetworkInterface { |
518 NetworkInterface(); | 518 NetworkInterface(); |
519 NetworkInterface(const std::string& name, const IPAddressNumber& address); | 519 NetworkInterface(const std::string& name, |
| 520 const IPAddressNumber& address, |
| 521 uint8 network_prefix); |
520 ~NetworkInterface(); | 522 ~NetworkInterface(); |
521 | 523 |
522 std::string name; | 524 std::string name; |
523 IPAddressNumber address; | 525 IPAddressNumber address; |
| 526 uint8 network_prefix; |
524 }; | 527 }; |
525 | 528 |
526 typedef std::vector<NetworkInterface> NetworkInterfaceList; | 529 typedef std::vector<NetworkInterface> NetworkInterfaceList; |
527 | 530 |
528 // Returns list of network interfaces except loopback interface. If an | 531 // Returns list of network interfaces except loopback interface. If an |
529 // interface has more than one address, a separate entry is added to | 532 // interface has more than one address, a separate entry is added to |
530 // the list for each address. | 533 // the list for each address. |
531 // Can be called only on a thread that allows IO. | 534 // Can be called only on a thread that allows IO. |
532 NET_EXPORT bool GetNetworkList(NetworkInterfaceList* networks); | 535 NET_EXPORT bool GetNetworkList(NetworkInterfaceList* networks); |
533 | 536 |
(...skipping 12 matching lines...) Expand all Loading... |
546 // 802.11n, HT rates. | 549 // 802.11n, HT rates. |
547 WIFI_PHY_LAYER_PROTOCOL_N, | 550 WIFI_PHY_LAYER_PROTOCOL_N, |
548 // Unclassified mode or failure to identify. | 551 // Unclassified mode or failure to identify. |
549 WIFI_PHY_LAYER_PROTOCOL_UNKNOWN | 552 WIFI_PHY_LAYER_PROTOCOL_UNKNOWN |
550 }; | 553 }; |
551 | 554 |
552 // Characterize the PHY mode of the currently associated access point. | 555 // Characterize the PHY mode of the currently associated access point. |
553 // Currently only available on OS_WIN. | 556 // Currently only available on OS_WIN. |
554 NET_EXPORT WifiPHYLayerProtocol GetWifiPHYLayerProtocol(); | 557 NET_EXPORT WifiPHYLayerProtocol GetWifiPHYLayerProtocol(); |
555 | 558 |
| 559 // Returns number of matching initial bits between the addresses |a1| and |a2|. |
| 560 unsigned CommonPrefixLength(const IPAddressNumber& a1, |
| 561 const IPAddressNumber& a2); |
| 562 |
| 563 // Computes the number of leading 1-bits in |mask|. |
| 564 unsigned MaskPrefixLength(const IPAddressNumber& mask); |
| 565 |
556 } // namespace net | 566 } // namespace net |
557 | 567 |
558 #endif // NET_BASE_NET_UTIL_H_ | 568 #endif // NET_BASE_NET_UTIL_H_ |
OLD | NEW |