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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 170 |
171 // Read and write the address to/from a sockaddr_storage. | 171 // Read and write the address to/from a sockaddr_storage. |
172 // Dual stack version always sets family to AF_INET6, and maps v4 addresses. | 172 // Dual stack version always sets family to AF_INET6, and maps v4 addresses. |
173 // The other version doesn't map, and outputs an AF_INET address for | 173 // The other version doesn't map, and outputs an AF_INET address for |
174 // v4 or mapped addresses, and AF_INET6 addresses for others. | 174 // v4 or mapped addresses, and AF_INET6 addresses for others. |
175 // Returns the size of the sockaddr_in or sockaddr_in6 structure that is | 175 // Returns the size of the sockaddr_in or sockaddr_in6 structure that is |
176 // written to the sockaddr_storage, or zero on failure. | 176 // written to the sockaddr_storage, or zero on failure. |
177 size_t ToDualStackSockAddrStorage(sockaddr_storage* saddr) const; | 177 size_t ToDualStackSockAddrStorage(sockaddr_storage* saddr) const; |
178 size_t ToSockAddrStorage(sockaddr_storage* saddr) const; | 178 size_t ToSockAddrStorage(sockaddr_storage* saddr) const; |
179 | 179 |
180 // Converts the IP address given in 'compact form' into dotted form. | |
181 // IP is given as an integer in host byte order. V4 only, to be deprecated. | |
182 // TODO: Deprecate this. | |
183 static std::string IPToString(uint32_t ip_as_host_order_integer); | |
184 | |
185 // Same as IPToString but anonymizes it by hiding the last part. | |
186 // TODO: Deprecate this. | |
187 static std::string IPToSensitiveString(uint32_t ip_as_host_order_integer); | |
188 | |
189 // Converts the IP address given in dotted form into compact form. | 180 // Converts the IP address given in dotted form into compact form. |
190 // Only dotted names (A.B.C.D) are converted. | 181 // Only dotted names (A.B.C.D) are converted. |
191 // Output integer is returned in host byte order. | 182 // Output integer is returned in host byte order. |
192 // TODO: Deprecate, replace wth agnostic versions. | 183 // TODO: Deprecate, replace wth agnostic versions. |
193 static bool StringToIP(const std::string& str, uint32_t* ip); | 184 static bool StringToIP(const std::string& str, uint32_t* ip); |
194 static uint32_t StringToIP(const std::string& str); | 185 static uint32_t StringToIP(const std::string& str); |
195 | 186 |
196 // Converts the IP address given in printable form into an IPAddress. | 187 // Converts the IP address given in printable form into an IPAddress. |
197 static bool StringToIP(const std::string& str, IPAddress* ip); | 188 static bool StringToIP(const std::string& str, IPAddress* ip); |
198 | 189 |
199 private: | 190 private: |
200 std::string hostname_; | 191 std::string hostname_; |
201 IPAddress ip_; | 192 IPAddress ip_; |
202 uint16_t port_; | 193 uint16_t port_; |
203 int scope_id_; | 194 int scope_id_; |
204 bool literal_; // Indicates that 'hostname_' contains a literal IP string. | 195 bool literal_; // Indicates that 'hostname_' contains a literal IP string. |
205 }; | 196 }; |
206 | 197 |
207 bool SocketAddressFromSockAddrStorage(const sockaddr_storage& saddr, | 198 bool SocketAddressFromSockAddrStorage(const sockaddr_storage& saddr, |
208 SocketAddress* out); | 199 SocketAddress* out); |
209 SocketAddress EmptySocketAddressWithFamily(int family); | 200 SocketAddress EmptySocketAddressWithFamily(int family); |
210 | 201 |
211 } // namespace rtc | 202 } // namespace rtc |
212 | 203 |
213 #endif // WEBRTC_BASE_SOCKETADDRESS_H_ | 204 #endif // WEBRTC_BASE_SOCKETADDRESS_H_ |
OLD | NEW |