| 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 #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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 420 |
| 421 // Returns the value of |info's| port (in host byte ordering). | 421 // Returns the value of |info's| port (in host byte ordering). |
| 422 int GetPortFromAddrinfo(const struct addrinfo* info); | 422 int GetPortFromAddrinfo(const struct addrinfo* info); |
| 423 | 423 |
| 424 // Same except for struct sockaddr. | 424 // Same except for struct sockaddr. |
| 425 const uint16* GetPortFieldFromSockaddr(const struct sockaddr* address, | 425 const uint16* GetPortFieldFromSockaddr(const struct sockaddr* address, |
| 426 socklen_t address_len); | 426 socklen_t address_len); |
| 427 int GetPortFromSockaddr(const struct sockaddr* address, | 427 int GetPortFromSockaddr(const struct sockaddr* address, |
| 428 socklen_t address_len); | 428 socklen_t address_len); |
| 429 | 429 |
| 430 // Returns true if |host| is "localhost" or one of the IP-address |
| 431 // representations of the loopback address (IPv4 127.0.0.0/8 or IPv6 ::1). |
| 432 // |
| 433 // Note that this function does not check for IP addresses other than |
| 434 // the above being mapped back to the local machine, it only checks |
| 435 // for those exact IP addresses. |
| 436 bool IsLocalhost(const std::string& host); |
| 437 |
| 430 // struct that is used by GetNetworkList() to represent a network | 438 // struct that is used by GetNetworkList() to represent a network |
| 431 // interface. | 439 // interface. |
| 432 struct NetworkInterface { | 440 struct NetworkInterface { |
| 433 NetworkInterface(); | 441 NetworkInterface(); |
| 434 NetworkInterface(const std::string& name, const IPAddressNumber& address); | 442 NetworkInterface(const std::string& name, const IPAddressNumber& address); |
| 435 ~NetworkInterface(); | 443 ~NetworkInterface(); |
| 436 | 444 |
| 437 std::string name; | 445 std::string name; |
| 438 IPAddressNumber address; | 446 IPAddressNumber address; |
| 439 }; | 447 }; |
| 440 | 448 |
| 441 typedef std::list<NetworkInterface> NetworkInterfaceList; | 449 typedef std::list<NetworkInterface> NetworkInterfaceList; |
| 442 | 450 |
| 443 // Returns list of network interfaces except loopback interface. If an | 451 // Returns list of network interfaces except loopback interface. If an |
| 444 // interface has more than one address, a separate entry is added to | 452 // interface has more than one address, a separate entry is added to |
| 445 // the list for each address. | 453 // the list for each address. |
| 446 // Can be called only on a thread that allows IO. | 454 // Can be called only on a thread that allows IO. |
| 447 bool GetNetworkList(NetworkInterfaceList* networks); | 455 bool GetNetworkList(NetworkInterfaceList* networks); |
| 448 | 456 |
| 449 } // namespace net | 457 } // namespace net |
| 450 | 458 |
| 451 #endif // NET_BASE_NET_UTIL_H_ | 459 #endif // NET_BASE_NET_UTIL_H_ |
| OLD | NEW |