OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 // IP address whose |prefix_length_in_bits| most significant bits match | 403 // IP address whose |prefix_length_in_bits| most significant bits match |
404 // |ip_prefix| will be matched. | 404 // |ip_prefix| will be matched. |
405 // | 405 // |
406 // In cases when an IPv4 address is being compared to an IPv6 address prefix | 406 // In cases when an IPv4 address is being compared to an IPv6 address prefix |
407 // and vice versa, the IPv4 addresses will be converted to IPv4-mapped | 407 // and vice versa, the IPv4 addresses will be converted to IPv4-mapped |
408 // (IPv6) addresses. | 408 // (IPv6) addresses. |
409 bool IPNumberMatchesPrefix(const IPAddressNumber& ip_number, | 409 bool IPNumberMatchesPrefix(const IPAddressNumber& ip_number, |
410 const IPAddressNumber& ip_prefix, | 410 const IPAddressNumber& ip_prefix, |
411 size_t prefix_length_in_bits); | 411 size_t prefix_length_in_bits); |
412 | 412 |
| 413 // Makes a copy of |info|. The dynamically-allocated parts are copied as well. |
| 414 // If |recursive| is true, chained entries via ai_next are copied too. |
| 415 // The copy returned by this function should be freed using |
| 416 // FreeCopyOfAddrinfo(), and NOT freeaddrinfo(). |
| 417 struct addrinfo* CreateCopyOfAddrinfo(const struct addrinfo* info, |
| 418 bool recursive); |
| 419 |
| 420 // Frees an addrinfo that was created by CreateCopyOfAddrinfo(). |
| 421 void FreeCopyOfAddrinfo(struct addrinfo* info); |
| 422 |
413 // Returns the port field of the sockaddr in |info|. | 423 // Returns the port field of the sockaddr in |info|. |
414 const uint16* GetPortFieldFromAddrinfo(const struct addrinfo* info); | 424 const uint16* GetPortFieldFromAddrinfo(const struct addrinfo* info); |
415 uint16* GetPortFieldFromAddrinfo(struct addrinfo* info); | 425 uint16* GetPortFieldFromAddrinfo(struct addrinfo* info); |
416 | 426 |
417 // Returns the value of |info's| port (in host byte ordering). | 427 // Returns the value of |info's| port (in host byte ordering). |
418 int GetPortFromAddrinfo(const struct addrinfo* info); | 428 int GetPortFromAddrinfo(const struct addrinfo* info); |
419 | 429 |
420 // Same except for struct sockaddr. | 430 // Same except for struct sockaddr. |
421 const uint16* GetPortFieldFromSockaddr(const struct sockaddr* address, | 431 const uint16* GetPortFieldFromSockaddr(const struct sockaddr* address, |
422 socklen_t address_len); | 432 socklen_t address_len); |
423 int GetPortFromSockaddr(const struct sockaddr* address, | 433 int GetPortFromSockaddr(const struct sockaddr* address, |
424 socklen_t address_len); | 434 socklen_t address_len); |
425 | 435 |
426 } // namespace net | 436 } // namespace net |
427 | 437 |
428 #endif // NET_BASE_NET_UTIL_H_ | 438 #endif // NET_BASE_NET_UTIL_H_ |
OLD | NEW |