| 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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 // IP address whose |prefix_length_in_bits| most significant bits match | 434 // IP address whose |prefix_length_in_bits| most significant bits match |
| 435 // |ip_prefix| will be matched. | 435 // |ip_prefix| will be matched. |
| 436 // | 436 // |
| 437 // In cases when an IPv4 address is being compared to an IPv6 address prefix | 437 // In cases when an IPv4 address is being compared to an IPv6 address prefix |
| 438 // and vice versa, the IPv4 addresses will be converted to IPv4-mapped | 438 // and vice versa, the IPv4 addresses will be converted to IPv4-mapped |
| 439 // (IPv6) addresses. | 439 // (IPv6) addresses. |
| 440 bool IPNumberMatchesPrefix(const IPAddressNumber& ip_number, | 440 bool IPNumberMatchesPrefix(const IPAddressNumber& ip_number, |
| 441 const IPAddressNumber& ip_prefix, | 441 const IPAddressNumber& ip_prefix, |
| 442 size_t prefix_length_in_bits); | 442 size_t prefix_length_in_bits); |
| 443 | 443 |
| 444 // Makes a copy of |info|. The dynamically-allocated parts are copied as well. |
| 445 // If |recursive| is true, chained entries via ai_next are copied too. |
| 446 // The copy returned by this function should be freed using |
| 447 // FreeCopyOfAddrinfo(), and NOT freeaddrinfo(). |
| 448 struct addrinfo* CreateCopyOfAddrinfo(const struct addrinfo* info, |
| 449 bool recursive); |
| 450 |
| 451 // Frees an addrinfo that was created by CreateCopyOfAddrinfo(). |
| 452 void FreeCopyOfAddrinfo(struct addrinfo* info); |
| 453 |
| 444 // Returns the port field of the sockaddr in |info|. | 454 // Returns the port field of the sockaddr in |info|. |
| 445 const uint16* GetPortFieldFromAddrinfo(const struct addrinfo* info); | 455 const uint16* GetPortFieldFromAddrinfo(const struct addrinfo* info); |
| 446 uint16* GetPortFieldFromAddrinfo(struct addrinfo* info); | 456 uint16* GetPortFieldFromAddrinfo(struct addrinfo* info); |
| 447 | 457 |
| 448 // Returns the value of |info's| port (in host byte ordering). | 458 // Returns the value of |info's| port (in host byte ordering). |
| 449 int GetPortFromAddrinfo(const struct addrinfo* info); | 459 int GetPortFromAddrinfo(const struct addrinfo* info); |
| 450 | 460 |
| 451 // Same except for struct sockaddr. | 461 // Same except for struct sockaddr. |
| 452 const uint16* GetPortFieldFromSockaddr(const struct sockaddr* address, | 462 const uint16* GetPortFieldFromSockaddr(const struct sockaddr* address, |
| 453 socklen_t address_len); | 463 socklen_t address_len); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 struct ClampComponentOffset { | 497 struct ClampComponentOffset { |
| 488 explicit ClampComponentOffset(size_t component_start); | 498 explicit ClampComponentOffset(size_t component_start); |
| 489 size_t operator()(size_t offset); | 499 size_t operator()(size_t offset); |
| 490 | 500 |
| 491 const size_t component_start; | 501 const size_t component_start; |
| 492 }; | 502 }; |
| 493 | 503 |
| 494 } // namespace net | 504 } // namespace net |
| 495 | 505 |
| 496 #endif // NET_BASE_NET_UTIL_H_ | 506 #endif // NET_BASE_NET_UTIL_H_ |
| OLD | NEW |