Migrate some of the uses of QuicIpAddress(QuicIpAddressImpl) constructor to quic::ToQuicIpAddress This is done in preparation of making QuicIpAddress a non-platform class. gfe-relnote: n/a (no functional change) PiperOrigin-RevId: 242743726 Change-Id: I46848cbb5239dca5b650c6e4cde10a9e8d6f3912
diff --git a/quic/platform/api/quic_ip_address.cc b/quic/platform/api/quic_ip_address.cc index e7a0fd9..2b86cad 100644 --- a/quic/platform/api/quic_ip_address.cc +++ b/quic/platform/api/quic_ip_address.cc
@@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <string> - #include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" +#include <string> + namespace quic { QuicIpAddress QuicIpAddress::Loopback4() { @@ -26,6 +26,11 @@ QuicIpAddress::QuicIpAddress(const QuicIpAddressImpl& impl) : impl_(impl) {} +QuicIpAddress::QuicIpAddress(const in_addr& ipv4_address) + : impl_(ipv4_address) {} +QuicIpAddress::QuicIpAddress(const in6_addr& ipv6_address) + : impl_(ipv6_address) {} + bool operator==(QuicIpAddress lhs, QuicIpAddress rhs) { return lhs.impl_ == rhs.impl_; }
diff --git a/quic/platform/api/quic_ip_address.h b/quic/platform/api/quic_ip_address.h index 72dabed..8f8db3a 100644 --- a/quic/platform/api/quic_ip_address.h +++ b/quic/platform/api/quic_ip_address.h
@@ -5,6 +5,14 @@ #ifndef QUICHE_QUIC_PLATFORM_API_QUIC_IP_ADDRESS_H_ #define QUICHE_QUIC_PLATFORM_API_QUIC_IP_ADDRESS_H_ +#if defined(_WIN32) +#include <winsock2.h> +#include <ws2tcpip.h> +#else +#include <sys/socket.h> +#include <sys/types.h> +#endif + #include <string> #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" @@ -31,6 +39,8 @@ QuicIpAddress() = default; QuicIpAddress(const QuicIpAddress& other) = default; explicit QuicIpAddress(const QuicIpAddressImpl& impl); + explicit QuicIpAddress(const in_addr& ipv4_address); + explicit QuicIpAddress(const in6_addr& ipv6_address); QuicIpAddress& operator=(const QuicIpAddress& other) = default; QuicIpAddress& operator=(QuicIpAddress&& other) = default; QUIC_EXPORT_PRIVATE friend bool operator==(QuicIpAddress lhs,