| OLD | NEW |
| 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> |
| 10 |
| 9 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
| 10 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
| 11 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
| 12 | 15 |
| 13 struct sockaddr; | 16 struct sockaddr; |
| 14 | 17 |
| 15 namespace net { | 18 namespace net { |
| 16 | 19 |
| 17 // An IPEndPoint represents the address of a transport endpoint: | 20 // An IPEndPoint represents the address of a transport endpoint: |
| 18 // * IP address (either v4 or v6) | 21 // * IP address (either v4 or v6) |
| 19 // * Port | 22 // * Port |
| (...skipping 10 matching lines...) Expand all Loading... |
| 30 // Returns AF_INET or AF_INET6 depending on the type of the address. | 33 // Returns AF_INET or AF_INET6 depending on the type of the address. |
| 31 int GetFamily() const; | 34 int GetFamily() const; |
| 32 | 35 |
| 33 // Convert to a provided sockaddr struct. | 36 // Convert to a provided sockaddr struct. |
| 34 // |address| is the sockaddr to copy into. Should be at least | 37 // |address| is the sockaddr to copy into. Should be at least |
| 35 // sizeof(struct sockaddr_storage) bytes. | 38 // sizeof(struct sockaddr_storage) bytes. |
| 36 // |address_length| is an input/output parameter. On input, it is the | 39 // |address_length| is an input/output parameter. On input, it is the |
| 37 // size of data in |address| available. On output, it is the size of | 40 // size of data in |address| available. On output, it is the size of |
| 38 // the address that was copied into |address|. | 41 // the address that was copied into |address|. |
| 39 // Returns true on success, false on failure. | 42 // Returns true on success, false on failure. |
| 40 bool ToSockAddr(struct sockaddr* address, size_t* address_length) const; | 43 bool ToSockAddr(struct sockaddr* address, socklen_t* address_length) const |
| 44 WARN_UNUSED_RESULT; |
| 41 | 45 |
| 42 // Convert from a sockaddr struct. | 46 // Convert from a sockaddr struct. |
| 43 // |address| is the address. | 47 // |address| is the address. |
| 44 // |address_length| is the length of |address|. | 48 // |address_length| is the length of |address|. |
| 45 // Returns true on success, false on failure. | 49 // Returns true on success, false on failure. |
| 46 bool FromSockAddr(const struct sockaddr* address, size_t address_length); | 50 bool FromSockAddr(const struct sockaddr* address, socklen_t address_length) |
| 51 WARN_UNUSED_RESULT; |
| 47 | 52 |
| 48 // Returns value as a string (e.g. "127.0.0.1:80"). Returns empty | 53 // Returns value as a string (e.g. "127.0.0.1:80"). Returns empty |
| 49 // string if the address is invalid, and cannot not be converted to a | 54 // string if the address is invalid, and cannot not be converted to a |
| 50 // string. | 55 // string. |
| 51 std::string ToString() const; | 56 std::string ToString() const; |
| 52 | 57 |
| 58 // As above, but without port. |
| 59 std::string ToStringWithoutPort() const; |
| 60 |
| 53 bool operator<(const IPEndPoint& that) const; | 61 bool operator<(const IPEndPoint& that) const; |
| 54 bool operator==(const IPEndPoint& that) const; | 62 bool operator==(const IPEndPoint& that) const; |
| 55 | 63 |
| 56 private: | 64 private: |
| 57 IPAddressNumber address_; | 65 IPAddressNumber address_; |
| 58 int port_; | 66 int port_; |
| 59 }; | 67 }; |
| 60 | 68 |
| 61 } // namespace net | 69 } // namespace net |
| 62 | 70 |
| 63 #endif // NET_BASE_IP_ENDPOINT_H_ | 71 #endif // NET_BASE_IP_ENDPOINT_H_ |
| OLD | NEW |