Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Unified Diff: net/base/net_util.cc

Issue 10309002: Reimplements net::AddressList without struct addrinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: get_canonical_name -> canonical_name. iterator to indexing Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/net_util.h ('k') | net/base/net_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/net_util.cc
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index 6060fd8551b52194342511f4db7f53a46ac492e1..b9e7ad1517ef64b414cac587fc88f7ac0544a288 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -2265,73 +2265,6 @@ bool IPNumberMatchesPrefix(const IPAddressNumber& ip_number,
return true;
}
-struct addrinfo* CreateCopyOfAddrinfo(const struct addrinfo* info,
- bool recursive) {
- DCHECK(info);
- struct addrinfo* copy = new addrinfo;
-
- // Copy all the fields (some of these are pointers, we will fix that next).
- memcpy(copy, info, sizeof(addrinfo));
-
- // ai_canonname is a NULL-terminated string.
- if (info->ai_canonname) {
- copy->ai_canonname = base::strdup(info->ai_canonname);
- }
-
- // ai_addr is a buffer of length ai_addrlen.
- if (info->ai_addr) {
- copy->ai_addr = reinterpret_cast<sockaddr *>(new char[info->ai_addrlen]);
- memcpy(copy->ai_addr, info->ai_addr, info->ai_addrlen);
- }
-
- // Recursive copy.
- if (recursive && info->ai_next)
- copy->ai_next = CreateCopyOfAddrinfo(info->ai_next, recursive);
- else
- copy->ai_next = NULL;
-
- return copy;
-}
-
-void FreeCopyOfAddrinfo(struct addrinfo* info) {
- DCHECK(info);
- if (info->ai_canonname)
- free(info->ai_canonname); // Allocated by strdup.
-
- if (info->ai_addr)
- delete [] reinterpret_cast<char*>(info->ai_addr);
-
- struct addrinfo* next = info->ai_next;
-
- delete info;
-
- // Recursive free.
- if (next)
- FreeCopyOfAddrinfo(next);
-}
-
-// Returns the port field of the sockaddr in |info|.
-uint16* GetPortFieldFromAddrinfo(struct addrinfo* info) {
- const struct addrinfo* const_info = info;
- const uint16* port_field = GetPortFieldFromAddrinfo(const_info);
- return const_cast<uint16*>(port_field);
-}
-
-const uint16* GetPortFieldFromAddrinfo(const struct addrinfo* info) {
- DCHECK(info);
- const struct sockaddr* address = info->ai_addr;
- DCHECK(address);
- DCHECK_EQ(info->ai_family, address->sa_family);
- return GetPortFieldFromSockaddr(address, info->ai_addrlen);
-}
-
-uint16 GetPortFromAddrinfo(const struct addrinfo* info) {
- const uint16* port_field = GetPortFieldFromAddrinfo(info);
- if (!port_field)
- return -1;
- return base::NetToHost16(*port_field);
-}
-
const uint16* GetPortFieldFromSockaddr(const struct sockaddr* address,
socklen_t address_len) {
if (address->sa_family == AF_INET) {
@@ -2357,16 +2290,6 @@ int GetPortFromSockaddr(const struct sockaddr* address, socklen_t address_len) {
return base::NetToHost16(*port_field);
}
-// Assign |port| to each address in the linked list starting from |head|.
-void SetPortForAllAddrinfos(struct addrinfo* head, uint16 port) {
- DCHECK(head);
- for (struct addrinfo* ai = head; ai; ai = ai->ai_next) {
- uint16* port_field = GetPortFieldFromAddrinfo(ai);
- if (port_field)
- *port_field = base::HostToNet16(port);
- }
-}
-
bool IsLocalhost(const std::string& host) {
if (host == "localhost" ||
host == "localhost.localdomain" ||
« no previous file with comments | « net/base/net_util.h ('k') | net/base/net_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698