OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_QUIC_PLATFORM_API_QUIC_SOCKET_ADDRESS_H_ | 5 #ifndef NET_QUIC_PLATFORM_API_QUIC_SOCKET_ADDRESS_H_ |
6 #define NET_QUIC_PLATFORM_API_QUIC_SOCKET_ADDRESS_H_ | 6 #define NET_QUIC_PLATFORM_API_QUIC_SOCKET_ADDRESS_H_ |
7 | 7 |
8 #include "net/quic/platform/api/quic_export.h" | 8 #include "net/quic/platform/api/quic_export.h" |
9 #include "net/quic/platform/api/quic_ip_address.h" | 9 #include "net/quic/platform/api/quic_ip_address.h" |
10 #include "net/quic/platform/impl/quic_socket_address_impl.h" | 10 #include "net/quic/platform/impl/quic_socket_address_impl.h" |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 | 13 |
14 class QUIC_EXPORT_PRIVATE QuicSocketAddress { | 14 class QUIC_EXPORT_PRIVATE QuicSocketAddress { |
15 // A class representing a socket endpoint address (i.e., IP address plus a | 15 // A class representing a socket endpoint address (i.e., IP address plus a |
16 // port) in QUIC. The actual implementation (platform dependent) of a socket | 16 // port) in QUIC. The actual implementation (platform dependent) of a socket |
17 // address is in QuicSocketAddressImpl. | 17 // address is in QuicSocketAddressImpl. |
18 public: | 18 public: |
19 QuicSocketAddress() = default; | 19 QuicSocketAddress() = default; |
20 QuicSocketAddress(QuicIpAddress address, uint16_t port); | 20 QuicSocketAddress(QuicIpAddress address, uint16_t port); |
21 explicit QuicSocketAddress(const struct sockaddr_storage& saddr); | 21 explicit QuicSocketAddress(const struct sockaddr_storage& saddr); |
22 explicit QuicSocketAddress(const struct sockaddr& saddr); | 22 explicit QuicSocketAddress(const struct sockaddr& saddr); |
23 explicit QuicSocketAddress(const QuicSocketAddressImpl& impl); | 23 explicit QuicSocketAddress(const QuicSocketAddressImpl& impl); |
24 QuicSocketAddress(const QuicSocketAddress& other) = default; | 24 QuicSocketAddress(const QuicSocketAddress& other) = default; |
25 QuicSocketAddress& operator=(const QuicSocketAddress& other) = default; | 25 QuicSocketAddress& operator=(const QuicSocketAddress& other) = default; |
26 QuicSocketAddress& operator=(QuicSocketAddress&& other) = default; | 26 QuicSocketAddress& operator=(QuicSocketAddress&& other) = default; |
27 QUIC_EXPORT_PRIVATE friend bool operator==(QuicSocketAddress lhs, | 27 QUIC_EXPORT_PRIVATE friend bool operator==(const QuicSocketAddress& lhs, |
28 QuicSocketAddress rhs); | 28 const QuicSocketAddress& rhs); |
29 QUIC_EXPORT_PRIVATE friend bool operator!=(QuicSocketAddress lhs, | 29 QUIC_EXPORT_PRIVATE friend bool operator!=(const QuicSocketAddress& lhs, |
30 QuicSocketAddress rhs); | 30 const QuicSocketAddress& rhs); |
31 | 31 |
32 bool IsInitialized() const; | 32 bool IsInitialized() const; |
33 std::string ToString() const; | 33 std::string ToString() const; |
34 int FromSocket(int fd); | 34 int FromSocket(int fd); |
35 QuicSocketAddress Normalized() const; | 35 QuicSocketAddress Normalized() const; |
36 | 36 |
37 QuicIpAddress host() const; | 37 QuicIpAddress host() const; |
38 uint16_t port() const; | 38 uint16_t port() const; |
39 sockaddr_storage generic_address() const; | 39 sockaddr_storage generic_address() const; |
40 const QuicSocketAddressImpl& impl() const { return impl_; } | 40 const QuicSocketAddressImpl& impl() const { return impl_; } |
41 | 41 |
42 private: | 42 private: |
43 QuicSocketAddressImpl impl_; | 43 QuicSocketAddressImpl impl_; |
44 }; | 44 }; |
45 | 45 |
46 } // namespace net | 46 } // namespace net |
47 | 47 |
48 #endif // NET_QUIC_PLATFORM_API_QUIC_SOCKET_ADDRESS_H_ | 48 #endif // NET_QUIC_PLATFORM_API_QUIC_SOCKET_ADDRESS_H_ |
OLD | NEW |