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

Unified Diff: net/base/ip_endpoint.cc

Issue 6685013: Use IPEndPoint for P2P IPC messages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 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/ip_endpoint.h ('k') | net/base/ip_endpoint_unittest.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 626d12e9895a14207b23a1aac9f57411ce69e66b..df90f1a0eb8b23ed35a977d8fa2229ea33f17559 100644
--- a/net/base/ip_endpoint.cc
+++ b/net/base/ip_endpoint.cc
@@ -5,6 +5,7 @@
#include "net/base/ip_endpoint.h"
#include "base/logging.h"
+#include "base/string_number_conversions.h"
#if defined(OS_WIN)
#include <winsock2.h>
#elif defined(OS_POSIX)
@@ -108,6 +109,16 @@ bool IPEndPoint::FromSockAddr(const struct sockaddr* address,
return true;
}
+std::string IPEndPoint::ToString() const {
+ struct sockaddr_storage addr_storage;
+ size_t addr_len = sizeof(addr_storage);
+ struct sockaddr* addr = reinterpret_cast<struct sockaddr*>(&addr_storage);
+ if (!ToSockAddr(addr, &addr_len)) {
+ return "";
+ }
+ return NetAddressToString(addr, addr_len) + ":" + base::IntToString(port_);
pmarks 2011/03/28 01:53:45 This looks like it will mangle IPv6 addresses. Us
+}
+
bool IPEndPoint::operator<(const IPEndPoint& that) const {
return address_ < that.address_ || port_ < that.port_;
}
« no previous file with comments | « net/base/ip_endpoint.h ('k') | net/base/ip_endpoint_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698