| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/sys_byteorder.h" | 9 #include "base/sys_byteorder.h" |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 IPEndPoint::IPEndPoint(const IPAddressNumber& address, int port) | 28 IPEndPoint::IPEndPoint(const IPAddressNumber& address, int port) |
| 29 : address_(address), | 29 : address_(address), |
| 30 port_(port) {} | 30 port_(port) {} |
| 31 | 31 |
| 32 IPEndPoint::IPEndPoint(const IPEndPoint& endpoint) { | 32 IPEndPoint::IPEndPoint(const IPEndPoint& endpoint) { |
| 33 address_ = endpoint.address_; | 33 address_ = endpoint.address_; |
| 34 port_ = endpoint.port_; | 34 port_ = endpoint.port_; |
| 35 } | 35 } |
| 36 | 36 |
| 37 int IPEndPoint::GetFamily() const { | 37 AddressFamily IPEndPoint::GetFamily() const { |
| 38 switch (address_.size()) { |
| 39 case kIPv4AddressSize: |
| 40 return ADDRESS_FAMILY_IPV4; |
| 41 case kIPv6AddressSize: |
| 42 return ADDRESS_FAMILY_IPV6; |
| 43 default: |
| 44 NOTREACHED() << "Bad IP address"; |
| 45 return ADDRESS_FAMILY_UNSPECIFIED; |
| 46 } |
| 47 } |
| 48 |
| 49 int IPEndPoint::GetSockAddrFamily() const { |
| 38 switch (address_.size()) { | 50 switch (address_.size()) { |
| 39 case kIPv4AddressSize: | 51 case kIPv4AddressSize: |
| 40 return AF_INET; | 52 return AF_INET; |
| 41 case kIPv6AddressSize: | 53 case kIPv6AddressSize: |
| 42 return AF_INET6; | 54 return AF_INET6; |
| 43 default: | 55 default: |
| 44 NOTREACHED() << "Bad IP address"; | 56 NOTREACHED() << "Bad IP address"; |
| 45 return AF_UNSPEC; | 57 return AF_UNSPEC; |
| 46 } | 58 } |
| 47 } | 59 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 return address_ < that.address_; | 126 return address_ < that.address_; |
| 115 } | 127 } |
| 116 return port_ < that.port_; | 128 return port_ < that.port_; |
| 117 } | 129 } |
| 118 | 130 |
| 119 bool IPEndPoint::operator==(const IPEndPoint& that) const { | 131 bool IPEndPoint::operator==(const IPEndPoint& that) const { |
| 120 return address_ == that.address_ && port_ == that.port_; | 132 return address_ == that.address_ && port_ == that.port_; |
| 121 } | 133 } |
| 122 | 134 |
| 123 } // namespace net | 135 } // namespace net |
| OLD | NEW |