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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "net/base/address_family.h" |
12 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
13 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
14 | 15 |
15 struct sockaddr; | 16 struct sockaddr; |
16 | 17 |
17 namespace net { | 18 namespace net { |
18 | 19 |
19 // An IPEndPoint represents the address of a transport endpoint: | 20 // An IPEndPoint represents the address of a transport endpoint: |
20 // * IP address (either v4 or v6) | 21 // * IP address (either v4 or v6) |
21 // * Port | 22 // * Port |
22 class NET_EXPORT IPEndPoint { | 23 class NET_EXPORT IPEndPoint { |
23 public: | 24 public: |
24 IPEndPoint(); | 25 IPEndPoint(); |
25 virtual ~IPEndPoint(); | 26 virtual ~IPEndPoint(); |
26 IPEndPoint(const IPAddressNumber& address, int port); | 27 IPEndPoint(const IPAddressNumber& address, int port); |
27 IPEndPoint(const IPEndPoint& endpoint); | 28 IPEndPoint(const IPEndPoint& endpoint); |
28 | 29 |
29 const IPAddressNumber& address() const { return address_; } | 30 const IPAddressNumber& address() const { return address_; } |
30 int port() const { return port_; } | 31 int port() const { return port_; } |
31 | 32 |
32 // Returns AF_INET or AF_INET6 depending on the type of the address. | 33 // Returns AddressFamily of the address. |
33 int GetFamily() const; | 34 AddressFamily GetFamily() const; |
| 35 |
| 36 // Returns the sockaddr family of the address, AF_INET or AF_INET6. |
| 37 int GetSockAddrFamily() const; |
34 | 38 |
35 // Convert to a provided sockaddr struct. | 39 // Convert to a provided sockaddr struct. |
36 // |address| is the sockaddr to copy into. Should be at least | 40 // |address| is the sockaddr to copy into. Should be at least |
37 // sizeof(struct sockaddr_storage) bytes. | 41 // sizeof(struct sockaddr_storage) bytes. |
38 // |address_length| is an input/output parameter. On input, it is the | 42 // |address_length| is an input/output parameter. On input, it is the |
39 // size of data in |address| available. On output, it is the size of | 43 // size of data in |address| available. On output, it is the size of |
40 // the address that was copied into |address|. | 44 // the address that was copied into |address|. |
41 // Returns true on success, false on failure. | 45 // Returns true on success, false on failure. |
42 bool ToSockAddr(struct sockaddr* address, socklen_t* address_length) const | 46 bool ToSockAddr(struct sockaddr* address, socklen_t* address_length) const |
43 WARN_UNUSED_RESULT; | 47 WARN_UNUSED_RESULT; |
(...skipping 17 matching lines...) Expand all Loading... |
61 bool operator==(const IPEndPoint& that) const; | 65 bool operator==(const IPEndPoint& that) const; |
62 | 66 |
63 private: | 67 private: |
64 IPAddressNumber address_; | 68 IPAddressNumber address_; |
65 int port_; | 69 int port_; |
66 }; | 70 }; |
67 | 71 |
68 } // namespace net | 72 } // namespace net |
69 | 73 |
70 #endif // NET_BASE_IP_ENDPOINT_H_ | 74 #endif // NET_BASE_IP_ENDPOINT_H_ |
OLD | NEW |