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

Unified Diff: net/base/ip_endpoint.cc

Issue 9716020: Add base::HostToNetXX() & NetToHostXX(), and use them to replace htonX() & ntohX() in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 9 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/host_resolver_proc.cc ('k') | net/base/listen_socket.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/ip_endpoint.cc
diff --git a/net/base/ip_endpoint.cc b/net/base/ip_endpoint.cc
index 2578ded92e0350ccc1202d5b1677d815bdf92377..14b4f3de7ad5babdc6653275bf9cd52b70562530 100644
--- a/net/base/ip_endpoint.cc
+++ b/net/base/ip_endpoint.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "base/string_number_conversions.h"
+#include "base/sys_byteorder.h"
#if defined(OS_WIN)
#include <winsock2.h>
#elif defined(OS_POSIX)
@@ -54,7 +55,7 @@ bool IPEndPoint::ToSockAddr(struct sockaddr* address,
struct sockaddr_in* addr = reinterpret_cast<struct sockaddr_in*>(address);
memset(addr, 0, sizeof(struct sockaddr_in));
addr->sin_family = AF_INET;
- addr->sin_port = htons(port_);
+ addr->sin_port = base::HostToNet16(port_);
memcpy(&addr->sin_addr, &address_[0], kIPv4AddressSize);
break;
}
@@ -66,7 +67,7 @@ bool IPEndPoint::ToSockAddr(struct sockaddr* address,
reinterpret_cast<struct sockaddr_in6*>(address);
memset(addr6, 0, sizeof(struct sockaddr_in6));
addr6->sin6_family = AF_INET6;
- addr6->sin6_port = htons(port_);
+ addr6->sin6_port = base::HostToNet16(port_);
memcpy(&addr6->sin6_addr, &address_[0], kIPv6AddressSize);
break;
}
@@ -87,7 +88,7 @@ bool IPEndPoint::FromSockAddr(const struct sockaddr* address,
return false;
const struct sockaddr_in* addr =
reinterpret_cast<const struct sockaddr_in*>(address);
- port_ = ntohs(addr->sin_port);
+ port_ = base::NetToHost16(addr->sin_port);
const char* bytes = reinterpret_cast<const char*>(&addr->sin_addr);
address_.assign(&bytes[0], &bytes[kIPv4AddressSize]);
break;
@@ -97,7 +98,7 @@ bool IPEndPoint::FromSockAddr(const struct sockaddr* address,
return false;
const struct sockaddr_in6* addr =
reinterpret_cast<const struct sockaddr_in6*>(address);
- port_ = ntohs(addr->sin6_port);
+ port_ = base::NetToHost16(addr->sin6_port);
const char* bytes = reinterpret_cast<const char*>(&addr->sin6_addr);
address_.assign(&bytes[0], &bytes[kIPv6AddressSize]);
break;
« no previous file with comments | « net/base/host_resolver_proc.cc ('k') | net/base/listen_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698