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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/ip_endpoint.h ('k') | net/base/ip_endpoint_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "net/base/ip_endpoint.h" 5 #include "net/base/ip_endpoint.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_number_conversions.h"
8 #if defined(OS_WIN) 9 #if defined(OS_WIN)
9 #include <winsock2.h> 10 #include <winsock2.h>
10 #elif defined(OS_POSIX) 11 #elif defined(OS_POSIX)
11 #include <netinet/in.h> 12 #include <netinet/in.h>
12 #endif 13 #endif
13 14
14 namespace net { 15 namespace net {
15 16
16 const size_t kIPv4AddressSize = 4; 17 const size_t kIPv4AddressSize = 4;
17 const size_t kIPv6AddressSize = 16; 18 const size_t kIPv6AddressSize = 16;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 break; 102 break;
102 } 103 }
103 default: { 104 default: {
104 NOTREACHED() << "Bad IP address"; 105 NOTREACHED() << "Bad IP address";
105 break; 106 break;
106 } 107 }
107 } 108 }
108 return true; 109 return true;
109 } 110 }
110 111
112 std::string IPEndPoint::ToString() const {
113 struct sockaddr_storage addr_storage;
114 size_t addr_len = sizeof(addr_storage);
115 struct sockaddr* addr = reinterpret_cast<struct sockaddr*>(&addr_storage);
116 if (!ToSockAddr(addr, &addr_len)) {
117 return "";
118 }
119 return NetAddressToString(addr, addr_len) + ":" + base::IntToString(port_);
pmarks 2011/03/28 01:53:45 This looks like it will mangle IPv6 addresses. Us
120 }
121
111 bool IPEndPoint::operator<(const IPEndPoint& that) const { 122 bool IPEndPoint::operator<(const IPEndPoint& that) const {
112 return address_ < that.address_ || port_ < that.port_; 123 return address_ < that.address_ || port_ < that.port_;
113 } 124 }
114 125
115 bool IPEndPoint::operator==(const IPEndPoint& that) const { 126 bool IPEndPoint::operator==(const IPEndPoint& that) const {
116 return address_ == that.address_ && port_ == that.port_; 127 return address_ == that.address_ && port_ == that.port_;
117 } 128 }
118 129
119 } // namespace net 130 } // namespace net
OLDNEW
« 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