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 #ifndef NET_BASE_IP_ENDPOINT_H_ | 5 #ifndef NET_BASE_IP_ENDPOINT_H_ |
6 #define NET_BASE_IP_ENDPOINT_H_ | 6 #define NET_BASE_IP_ENDPOINT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "net/base/address_family.h" | 13 #include "net/base/address_family.h" |
14 #include "net/base/ip_address_number.h" | 14 #include "net/base/ip_address.h" |
15 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
16 #include "net/base/sys_addrinfo.h" | 16 #include "net/base/sys_addrinfo.h" |
17 | 17 |
18 struct sockaddr; | 18 struct sockaddr; |
19 | 19 |
20 namespace net { | 20 namespace net { |
21 | 21 |
22 class IPAddress; | |
23 | |
24 // An IPEndPoint represents the address of a transport endpoint: | 22 // An IPEndPoint represents the address of a transport endpoint: |
25 // * IP address (either v4 or v6) | 23 // * IP address (either v4 or v6) |
26 // * Port | 24 // * Port |
27 class NET_EXPORT IPEndPoint { | 25 class NET_EXPORT IPEndPoint { |
28 public: | 26 public: |
29 IPEndPoint(); | 27 IPEndPoint(); |
30 ~IPEndPoint(); | 28 ~IPEndPoint(); |
31 // DEPRECATED(crbug.com/496258): Use the ctor that takes IPAddress instead. | 29 // DEPRECATED(crbug.com/496258): Use the ctor that takes IPAddress instead. |
32 IPEndPoint(const IPAddressNumber& address, uint16_t port); | 30 IPEndPoint(const IPAddressNumber& address, uint16_t port); |
33 IPEndPoint(const IPAddress& address, uint16_t port); | 31 IPEndPoint(const IPAddress& address, uint16_t port); |
34 IPEndPoint(const IPEndPoint& endpoint); | 32 IPEndPoint(const IPEndPoint& endpoint); |
35 | 33 |
36 const IPAddressNumber& address() const { return address_; } | 34 const IPAddress& address() const { return address_; } |
37 uint16_t port() const { return port_; } | 35 uint16_t port() const { return port_; } |
38 | 36 |
39 // Returns AddressFamily of the address. | 37 // Returns AddressFamily of the address. |
40 AddressFamily GetFamily() const; | 38 AddressFamily GetFamily() const; |
41 | 39 |
42 // Returns the sockaddr family of the address, AF_INET or AF_INET6. | 40 // Returns the sockaddr family of the address, AF_INET or AF_INET6. |
43 int GetSockAddrFamily() const; | 41 int GetSockAddrFamily() const; |
44 | 42 |
45 // Convert to a provided sockaddr struct. | 43 // Convert to a provided sockaddr struct. |
46 // |address| is the sockaddr to copy into. Should be at least | 44 // |address| is the sockaddr to copy into. Should be at least |
(...skipping 16 matching lines...) Expand all Loading... |
63 // valid. | 61 // valid. |
64 std::string ToString() const; | 62 std::string ToString() const; |
65 | 63 |
66 // As above, but without port. | 64 // As above, but without port. |
67 std::string ToStringWithoutPort() const; | 65 std::string ToStringWithoutPort() const; |
68 | 66 |
69 bool operator<(const IPEndPoint& that) const; | 67 bool operator<(const IPEndPoint& that) const; |
70 bool operator==(const IPEndPoint& that) const; | 68 bool operator==(const IPEndPoint& that) const; |
71 | 69 |
72 private: | 70 private: |
73 IPAddressNumber address_; | 71 IPAddress address_; |
74 uint16_t port_; | 72 uint16_t port_; |
75 }; | 73 }; |
76 | 74 |
77 } // namespace net | 75 } // namespace net |
78 | 76 |
79 #endif // NET_BASE_IP_ENDPOINT_H_ | 77 #endif // NET_BASE_IP_ENDPOINT_H_ |
OLD | NEW |