| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 namespace rtc { | 25 namespace rtc { |
| 26 | 26 |
| 27 // Records an IP address and port. | 27 // Records an IP address and port. |
| 28 class SocketAddress { | 28 class SocketAddress { |
| 29 public: | 29 public: |
| 30 // Creates a nil address. | 30 // Creates a nil address. |
| 31 SocketAddress(); | 31 SocketAddress(); |
| 32 | 32 |
| 33 // Creates the address with the given host and port. Host may be a | 33 // Creates the address with the given host and port. Host may be a |
| 34 // literal IP string or a hostname to be resolved later. | 34 // literal IP string or a hostname to be resolved later. |
| 35 // DCHECKs that port is in valid range (0 to 2^16-1). |
| 35 SocketAddress(const std::string& hostname, int port); | 36 SocketAddress(const std::string& hostname, int port); |
| 36 | 37 |
| 37 // Creates the address with the given IP and port. | 38 // Creates the address with the given IP and port. |
| 38 // IP is given as an integer in host byte order. V4 only, to be deprecated. | 39 // IP is given as an integer in host byte order. V4 only, to be deprecated. |
| 40 // DCHECKs that port is in valid range (0 to 2^16-1). |
| 39 SocketAddress(uint32_t ip_as_host_order_integer, int port); | 41 SocketAddress(uint32_t ip_as_host_order_integer, int port); |
| 40 | 42 |
| 41 // Creates the address with the given IP and port. | 43 // Creates the address with the given IP and port. |
| 44 // DCHECKs that port is in valid range (0 to 2^16-1). |
| 42 SocketAddress(const IPAddress& ip, int port); | 45 SocketAddress(const IPAddress& ip, int port); |
| 43 | 46 |
| 44 // Creates a copy of the given address. | 47 // Creates a copy of the given address. |
| 45 SocketAddress(const SocketAddress& addr); | 48 SocketAddress(const SocketAddress& addr); |
| 46 | 49 |
| 47 // Resets to the nil address. | 50 // Resets to the nil address. |
| 48 void Clear(); | 51 void Clear(); |
| 49 | 52 |
| 50 // Determines if this is a nil address (empty hostname, any IP, null port) | 53 // Determines if this is a nil address (empty hostname, any IP, null port) |
| 51 bool IsNil() const; | 54 bool IsNil() const; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 70 // Sets the IP address while retaining the hostname. Useful for bypassing | 73 // Sets the IP address while retaining the hostname. Useful for bypassing |
| 71 // DNS for a pre-resolved IP. | 74 // DNS for a pre-resolved IP. |
| 72 // IP is given as an integer in host byte order. V4 only, to be deprecated. | 75 // IP is given as an integer in host byte order. V4 only, to be deprecated. |
| 73 void SetResolvedIP(uint32_t ip_as_host_order_integer); | 76 void SetResolvedIP(uint32_t ip_as_host_order_integer); |
| 74 | 77 |
| 75 // Sets the IP address while retaining the hostname. Useful for bypassing | 78 // Sets the IP address while retaining the hostname. Useful for bypassing |
| 76 // DNS for a pre-resolved IP. | 79 // DNS for a pre-resolved IP. |
| 77 void SetResolvedIP(const IPAddress& ip); | 80 void SetResolvedIP(const IPAddress& ip); |
| 78 | 81 |
| 79 // Changes the port of this address to the given one. | 82 // Changes the port of this address to the given one. |
| 83 // DCHECKs that port is in valid range (0 to 2^16-1). |
| 80 void SetPort(int port); | 84 void SetPort(int port); |
| 81 | 85 |
| 82 // Returns the hostname. | 86 // Returns the hostname. |
| 83 const std::string& hostname() const { return hostname_; } | 87 const std::string& hostname() const { return hostname_; } |
| 84 | 88 |
| 85 // Returns the IP address as a host byte order integer. | 89 // Returns the IP address as a host byte order integer. |
| 86 // Returns 0 for non-v4 addresses. | 90 // Returns 0 for non-v4 addresses. |
| 87 uint32_t ip() const; | 91 uint32_t ip() const; |
| 88 | 92 |
| 89 const IPAddress& ipaddr() const; | 93 const IPAddress& ipaddr() const; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 bool literal_; // Indicates that 'hostname_' contains a literal IP string. | 188 bool literal_; // Indicates that 'hostname_' contains a literal IP string. |
| 185 }; | 189 }; |
| 186 | 190 |
| 187 bool SocketAddressFromSockAddrStorage(const sockaddr_storage& saddr, | 191 bool SocketAddressFromSockAddrStorage(const sockaddr_storage& saddr, |
| 188 SocketAddress* out); | 192 SocketAddress* out); |
| 189 SocketAddress EmptySocketAddressWithFamily(int family); | 193 SocketAddress EmptySocketAddressWithFamily(int family); |
| 190 | 194 |
| 191 } // namespace rtc | 195 } // namespace rtc |
| 192 | 196 |
| 193 #endif // WEBRTC_BASE_SOCKETADDRESS_H_ | 197 #endif // WEBRTC_BASE_SOCKETADDRESS_H_ |
| OLD | NEW |