| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <tuple> | 7 #include <tuple> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/sys_byteorder.h" | 11 #include "base/sys_byteorder.h" |
| 12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
| 13 #include <winsock2.h> | 13 #include <winsock2.h> |
| 14 #elif defined(OS_POSIX) | 14 #elif defined(OS_POSIX) |
| 15 #include <netinet/in.h> | 15 #include <netinet/in.h> |
| 16 #endif | 16 #endif |
| 17 #include "net/base/ip_address.h" |
| 17 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 18 | 19 |
| 19 namespace net { | 20 namespace net { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 // By definition, socklen_t is large enough to hold both sizes. | 23 // By definition, socklen_t is large enough to hold both sizes. |
| 23 const socklen_t kSockaddrInSize = sizeof(struct sockaddr_in); | 24 const socklen_t kSockaddrInSize = sizeof(struct sockaddr_in); |
| 24 const socklen_t kSockaddrIn6Size = sizeof(struct sockaddr_in6); | 25 const socklen_t kSockaddrIn6Size = sizeof(struct sockaddr_in6); |
| 25 } | 26 } |
| 26 | 27 |
| 27 IPEndPoint::IPEndPoint() : port_(0) {} | 28 IPEndPoint::IPEndPoint() : port_(0) {} |
| 28 | 29 |
| 29 IPEndPoint::~IPEndPoint() {} | 30 IPEndPoint::~IPEndPoint() {} |
| 30 | 31 |
| 31 IPEndPoint::IPEndPoint(const IPAddressNumber& address, uint16_t port) | 32 IPEndPoint::IPEndPoint(const IPAddressNumber& address, uint16_t port) |
| 32 : address_(address), port_(port) { | 33 : address_(address), port_(port) { |
| 33 } | 34 } |
| 34 | 35 |
| 36 IPEndPoint::IPEndPoint(const IPAddress& address, uint16_t port) |
| 37 : address_(address.bytes()), port_(port) {} |
| 38 |
| 35 IPEndPoint::IPEndPoint(const IPEndPoint& endpoint) { | 39 IPEndPoint::IPEndPoint(const IPEndPoint& endpoint) { |
| 36 address_ = endpoint.address_; | 40 address_ = endpoint.address_; |
| 37 port_ = endpoint.port_; | 41 port_ = endpoint.port_; |
| 38 } | 42 } |
| 39 | 43 |
| 40 AddressFamily IPEndPoint::GetFamily() const { | 44 AddressFamily IPEndPoint::GetFamily() const { |
| 41 return GetAddressFamily(address_); | 45 return GetAddressFamily(address_); |
| 42 } | 46 } |
| 43 | 47 |
| 44 int IPEndPoint::GetSockAddrFamily() const { | 48 int IPEndPoint::GetSockAddrFamily() const { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 return address_.size() < other.address_.size(); | 122 return address_.size() < other.address_.size(); |
| 119 } | 123 } |
| 120 return std::tie(address_, port_) < std::tie(other.address_, other.port_); | 124 return std::tie(address_, port_) < std::tie(other.address_, other.port_); |
| 121 } | 125 } |
| 122 | 126 |
| 123 bool IPEndPoint::operator==(const IPEndPoint& other) const { | 127 bool IPEndPoint::operator==(const IPEndPoint& other) const { |
| 124 return address_ == other.address_ && port_ == other.port_; | 128 return address_ == other.address_ && port_ == other.port_; |
| 125 } | 129 } |
| 126 | 130 |
| 127 } // namespace net | 131 } // namespace net |
| OLD | NEW |