summaryrefslogtreecommitdiff
path: root/chromium/net/quic/platform
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/net/quic/platform')
-rw-r--r--chromium/net/quic/platform/impl/quic_chromium_clock.h1
-rw-r--r--chromium/net/quic/platform/impl/quic_chromium_clock_test.cc1
-rw-r--r--chromium/net/quic/platform/impl/quic_containers_impl.h43
-rw-r--r--chromium/net/quic/platform/impl/quic_estimate_memory_usage_impl.h21
-rw-r--r--chromium/net/quic/platform/impl/quic_export_impl.h17
-rw-r--r--chromium/net/quic/platform/impl/quic_flag_utils_impl.h8
-rw-r--r--chromium/net/quic/platform/impl/quic_flags_impl.h4
-rw-r--r--chromium/net/quic/platform/impl/quic_flags_test.cc2
-rw-r--r--chromium/net/quic/platform/impl/quic_iovec_impl.h4
-rw-r--r--chromium/net/quic/platform/impl/quic_linux_socket_utils.cc139
-rw-r--r--chromium/net/quic/platform/impl/quic_linux_socket_utils.h245
-rw-r--r--chromium/net/quic/platform/impl/quic_linux_socket_utils_test.cc259
-rw-r--r--chromium/net/quic/platform/impl/quic_map_util_impl.h2
-rw-r--r--chromium/net/quic/platform/impl/quic_port_utils_impl.cc17
-rw-r--r--chromium/net/quic/platform/impl/quic_port_utils_impl.h15
-rw-r--r--chromium/net/quic/platform/impl/quic_socket_address_impl.cc98
-rw-r--r--chromium/net/quic/platform/impl/quic_socket_address_impl.h47
-rw-r--r--chromium/net/quic/platform/impl/quic_socket_utils.cc419
-rw-r--r--chromium/net/quic/platform/impl/quic_socket_utils.h202
-rw-r--r--chromium/net/quic/platform/impl/quic_socket_utils_test.cc175
-rw-r--r--chromium/net/quic/platform/impl/quic_stream_buffer_allocator_impl.h3
-rw-r--r--chromium/net/quic/platform/impl/quic_test_impl.h9
-rw-r--r--chromium/net/quic/platform/impl/quic_testvalue_impl.h17
23 files changed, 12 insertions, 1736 deletions
diff --git a/chromium/net/quic/platform/impl/quic_chromium_clock.h b/chromium/net/quic/platform/impl/quic_chromium_clock.h
index 78ef0b5e170..30c83e45e08 100644
--- a/chromium/net/quic/platform/impl/quic_chromium_clock.h
+++ b/chromium/net/quic/platform/impl/quic_chromium_clock.h
@@ -6,7 +6,6 @@
#define NET_QUIC_PLATFORM_IMPL_QUIC_CHROMIUM_CLOCK_H_
#include "base/macros.h"
-#include "base/time/time.h"
#include "net/third_party/quiche/src/quic/core/quic_clock.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
diff --git a/chromium/net/quic/platform/impl/quic_chromium_clock_test.cc b/chromium/net/quic/platform/impl/quic_chromium_clock_test.cc
index adf446b7117..4ade317f9b5 100644
--- a/chromium/net/quic/platform/impl/quic_chromium_clock_test.cc
+++ b/chromium/net/quic/platform/impl/quic_chromium_clock_test.cc
@@ -4,6 +4,7 @@
#include "net/quic/platform/impl/quic_chromium_clock.h"
+#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace quic {
diff --git a/chromium/net/quic/platform/impl/quic_containers_impl.h b/chromium/net/quic/platform/impl/quic_containers_impl.h
index 3985388d647..e4e950c7051 100644
--- a/chromium/net/quic/platform/impl/quic_containers_impl.h
+++ b/chromium/net/quic/platform/impl/quic_containers_impl.h
@@ -5,20 +5,11 @@
#ifndef NET_QUIC_PLATFORM_IMPL_QUIC_CONTAINERS_IMPL_H_
#define NET_QUIC_PLATFORM_IMPL_QUIC_CONTAINERS_IMPL_H_
-#include <functional>
-#include <unordered_map>
-#include <unordered_set>
+#include <memory>
+#include <vector>
-#include "base/containers/queue.h"
-#include "base/containers/small_map.h"
-#include "net/third_party/quiche/src/common/simple_linked_hash_map.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
+#include "net/third_party/quiche/src/common/quiche_linked_hash_map.h"
#include "third_party/abseil-cpp/absl/container/btree_set.h"
-#include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
-#include "third_party/abseil-cpp/absl/container/flat_hash_set.h"
-#include "third_party/abseil-cpp/absl/container/inlined_vector.h"
-#include "third_party/abseil-cpp/absl/container/node_hash_map.h"
-#include "third_party/abseil-cpp/absl/container/node_hash_set.h"
namespace quic {
@@ -27,33 +18,7 @@ template <typename Key>
using QuicDefaultHasherImpl = absl::Hash<Key>;
template <typename Key, typename Value, typename Hash>
-using QuicUnorderedMapImpl = absl::node_hash_map<Key, Value, Hash>;
-
-template <typename Key, typename Value, typename Hash>
-using QuicHashMapImpl = absl::flat_hash_map<Key, Value, Hash>;
-
-template <typename Key, typename Hash>
-using QuicUnorderedSetImpl = absl::node_hash_set<Key, Hash>;
-
-template <typename Key, typename Hash>
-using QuicHashSetImpl = absl::flat_hash_set<Key, Hash>;
-
-// A map which offers insertion-ordered iteration.
-template <typename Key, typename Value, typename Hash>
-using QuicLinkedHashMapImpl = quiche::SimpleLinkedHashMap<Key, Value, Hash>;
-
-// A map which is faster than (for example) hash_map for a certain number of
-// unique key-value-pair elements, and upgrades itself to unordered_map when
-// runs out of space.
-template <typename Key, typename Value, int Size>
-using QuicSmallMapImpl = base::small_map<std::unordered_map<Key, Value>, Size>;
-
-// Represents a simple queue which may be backed by a list or
-// a flat circular buffer.
-//
-// DOES NOT GUARANTEE POINTER STABILITY!
-template <typename T>
-using QuicQueueImpl = base::queue<T>;
+using QuicLinkedHashMapImpl = quiche::QuicheLinkedHashMap<Key, Value, Hash>;
// TODO(wub): Switch to absl::InlinedVector once it is allowed.
template <typename T, size_t N, typename A = std::allocator<T>>
diff --git a/chromium/net/quic/platform/impl/quic_estimate_memory_usage_impl.h b/chromium/net/quic/platform/impl/quic_estimate_memory_usage_impl.h
deleted file mode 100644
index 8e3349e170c..00000000000
--- a/chromium/net/quic/platform/impl/quic_estimate_memory_usage_impl.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef NET_QUIC_PLATFORM_IMPL_QUIC_ESTIMATE_MEMORY_USAGE_IMPL_H_
-#define NET_QUIC_PLATFORM_IMPL_QUIC_ESTIMATE_MEMORY_USAGE_IMPL_H_
-
-#include <cstddef>
-
-#include "base/trace_event/memory_usage_estimator.h"
-
-namespace quic {
-
-template <class T>
-size_t QuicEstimateMemoryUsageImpl(const T& object) {
- return base::trace_event::EstimateMemoryUsage(object);
-}
-
-} // namespace quic
-
-#endif // NET_QUIC_PLATFORM_IMPL_QUIC_ESTIMATE_MEMORY_USAGE_IMPL_H_
diff --git a/chromium/net/quic/platform/impl/quic_export_impl.h b/chromium/net/quic/platform/impl/quic_export_impl.h
deleted file mode 100644
index 338497431a0..00000000000
--- a/chromium/net/quic/platform/impl/quic_export_impl.h
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef NET_QUIC_PLATFORM_IMPL_QUIC_EXPORT_IMPL_H_
-#define NET_QUIC_PLATFORM_IMPL_QUIC_EXPORT_IMPL_H_
-
-#include "net/base/net_export.h"
-
-// These macros are documented in:
-// net/third_party/quiche/src/quic/platform/api/quic_export.h
-
-#define QUIC_EXPORT NET_EXPORT
-#define QUIC_EXPORT_PRIVATE NET_EXPORT_PRIVATE
-#define QUIC_NO_EXPORT
-
-#endif // NET_QUIC_PLATFORM_IMPL_QUIC_EXPORT_IMPL_H_
diff --git a/chromium/net/quic/platform/impl/quic_flag_utils_impl.h b/chromium/net/quic/platform/impl/quic_flag_utils_impl.h
deleted file mode 100644
index 717cc0e0824..00000000000
--- a/chromium/net/quic/platform/impl/quic_flag_utils_impl.h
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright (c) 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef NET_QUIC_PLATFORM_IMPL_QUIC_FLAG_UTILS_IMPL_H_
-#define NET_QUIC_PLATFORM_IMPL_QUIC_FLAG_UTILS_IMPL_H_
-
-#endif // NET_QUIC_PLATFORM_IMPL_QUIC_FLAG_UTILS_IMPL_H_
diff --git a/chromium/net/quic/platform/impl/quic_flags_impl.h b/chromium/net/quic/platform/impl/quic_flags_impl.h
index fa13f9015da..dab7dd05275 100644
--- a/chromium/net/quic/platform/impl/quic_flags_impl.h
+++ b/chromium/net/quic/platform/impl/quic_flags_impl.h
@@ -12,9 +12,9 @@
#include <vector>
#include "base/export_template.h"
-#include "base/optional.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_flags.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
#define QUIC_PROTOCOL_FLAG(type, flag, ...) \
QUIC_EXPORT_PRIVATE extern type FLAGS_##flag;
@@ -155,7 +155,7 @@ struct QUIC_EXPORT_PRIVATE QuicParseCommandLineFlagsResult {
~QuicParseCommandLineFlagsResult();
std::vector<std::string> non_flag_args;
- base::Optional<int> exit_status;
+ absl::optional<int> exit_status;
};
QUIC_EXPORT_PRIVATE QuicParseCommandLineFlagsResult
diff --git a/chromium/net/quic/platform/impl/quic_flags_test.cc b/chromium/net/quic/platform/impl/quic_flags_test.cc
index f850c9a2794..f8fa493ac1d 100644
--- a/chromium/net/quic/platform/impl/quic_flags_test.cc
+++ b/chromium/net/quic/platform/impl/quic_flags_test.cc
@@ -7,7 +7,6 @@
#include <string>
#include "base/command_line.h"
-#include "base/optional.h"
#include "base/stl_util.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
@@ -15,6 +14,7 @@
#include "net/quic/platform/impl/quic_flags_impl.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
DEFINE_QUIC_COMMAND_LINE_FLAG(bool, foo, false, "An old silent pond...");
DEFINE_QUIC_COMMAND_LINE_FLAG(int32_t, bar, 123, "A frog jumps into the pond,");
diff --git a/chromium/net/quic/platform/impl/quic_iovec_impl.h b/chromium/net/quic/platform/impl/quic_iovec_impl.h
index dea9b78e030..eb7f6ab2840 100644
--- a/chromium/net/quic/platform/impl/quic_iovec_impl.h
+++ b/chromium/net/quic/platform/impl/quic_iovec_impl.h
@@ -9,7 +9,7 @@
#include "build/build_config.h"
-#if defined(OS_WIN) || defined(OS_NACL)
+#if defined(OS_WIN)
/* Structure for scatter/gather I/O. */
struct iovec {
void* iov_base; /* Pointer to data. */
@@ -17,6 +17,6 @@ struct iovec {
};
#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
#include <sys/uio.h>
-#endif // defined(OS_WIN) || defined(OS_NACL)
+#endif // defined(OS_WIN)
#endif // NET_QUIC_PLATFORM_IMPL_QUIC_IOVEC_IMPL_H_
diff --git a/chromium/net/quic/platform/impl/quic_linux_socket_utils.cc b/chromium/net/quic/platform/impl/quic_linux_socket_utils.cc
deleted file mode 100644
index c326db59466..00000000000
--- a/chromium/net/quic/platform/impl/quic_linux_socket_utils.cc
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright (c) 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/quic/platform/impl/quic_linux_socket_utils.h"
-
-#include <netinet/in.h>
-#include <iostream>
-
-#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h"
-
-namespace quic {
-
-BufferedWrite::BufferedWrite(const char* buffer,
- size_t buf_len,
- const QuicIpAddress& self_address,
- const QuicSocketAddress& peer_address)
- : BufferedWrite(buffer,
- buf_len,
- self_address,
- peer_address,
- std::unique_ptr<PerPacketOptions>()) {}
-
-BufferedWrite::BufferedWrite(const char* buffer,
- size_t buf_len,
- const QuicIpAddress& self_address,
- const QuicSocketAddress& peer_address,
- std::unique_ptr<PerPacketOptions> options)
- : buffer(buffer),
- buf_len(buf_len),
- self_address(self_address),
- peer_address(peer_address),
- options(std::move(options)) {}
-
-BufferedWrite::BufferedWrite(BufferedWrite&&) = default;
-
-BufferedWrite::~BufferedWrite() = default;
-
-QuicMMsgHdr::~QuicMMsgHdr() = default;
-
-void QuicMMsgHdr::InitOneHeader(int i, const BufferedWrite& buffered_write) {
- mmsghdr* mhdr = GetMMsgHdr(i);
- msghdr* hdr = &mhdr->msg_hdr;
- iovec* iov = GetIov(i);
-
- iov->iov_base = const_cast<char*>(buffered_write.buffer);
- iov->iov_len = buffered_write.buf_len;
- hdr->msg_iov = iov;
- hdr->msg_iovlen = 1;
- hdr->msg_control = nullptr;
- hdr->msg_controllen = 0;
-
- // Only support unconnected sockets.
- DCHECK(buffered_write.peer_address.IsInitialized());
-
- sockaddr_storage* peer_address_storage = GetPeerAddressStorage(i);
- *peer_address_storage = buffered_write.peer_address.generic_address();
- hdr->msg_name = peer_address_storage;
- hdr->msg_namelen = peer_address_storage->ss_family == AF_INET
- ? sizeof(sockaddr_in)
- : sizeof(sockaddr_in6);
-}
-
-void QuicMMsgHdr::SetIpInNextCmsg(int i, const QuicIpAddress& self_address) {
- if (!self_address.IsInitialized()) {
- return;
- }
-
- if (self_address.IsIPv4()) {
- QuicSocketUtils::SetIpInfoInCmsgData(
- self_address, GetNextCmsgData<in_pktinfo>(i, IPPROTO_IP, IP_PKTINFO));
- } else {
- QuicSocketUtils::SetIpInfoInCmsgData(
- self_address,
- GetNextCmsgData<in6_pktinfo>(i, IPPROTO_IPV6, IPV6_PKTINFO));
- }
-}
-
-void* QuicMMsgHdr::GetNextCmsgDataInternal(int i,
- int cmsg_level,
- int cmsg_type,
- size_t data_size) {
- mmsghdr* mhdr = GetMMsgHdr(i);
- msghdr* hdr = &mhdr->msg_hdr;
- cmsghdr*& cmsg = *GetCmsgHdr(i);
-
- // msg_controllen needs to be increased first, otherwise CMSG_NXTHDR will
- // return nullptr.
- hdr->msg_controllen += CMSG_SPACE(data_size);
- DCHECK_LE(hdr->msg_controllen, cbuf_size_);
-
- if (cmsg == nullptr) {
- DCHECK_EQ(nullptr, hdr->msg_control);
- hdr->msg_control = GetCbuf(i);
- cmsg = CMSG_FIRSTHDR(hdr);
- } else {
- DCHECK_NE(nullptr, hdr->msg_control);
- cmsg = CMSG_NXTHDR(hdr, cmsg);
- }
-
- DCHECK_NE(nullptr, cmsg) << "Insufficient control buffer space";
-
- cmsg->cmsg_len = CMSG_LEN(data_size);
- cmsg->cmsg_level = cmsg_level;
- cmsg->cmsg_type = cmsg_type;
-
- return CMSG_DATA(cmsg);
-}
-
-int QuicMMsgHdr::num_bytes_sent(int num_packets_sent) {
- DCHECK_LE(0, num_packets_sent);
- DCHECK_LE(num_packets_sent, num_msgs_);
-
- int bytes_sent = 0;
- iovec* iov = GetIov(0);
- for (int i = 0; i < num_packets_sent; ++i) {
- bytes_sent += iov[i].iov_len;
- }
- return bytes_sent;
-}
-
-// static
-int QuicLinuxSocketUtils::GetUDPSegmentSize(int fd) {
- int optval;
- socklen_t optlen = sizeof(optval);
- int rc = getsockopt(fd, SOL_UDP, UDP_SEGMENT, &optval, &optlen);
- if (rc < 0) {
- QUIC_LOG_EVERY_N_SEC(INFO, 10)
- << "getsockopt(UDP_SEGMENT) failed: " << strerror(errno);
- return -1;
- }
- QUIC_LOG_EVERY_N_SEC(INFO, 10)
- << "getsockopt(UDP_SEGMENT) returned segment size: " << optval;
- return optval;
-}
-
-} // namespace quic
diff --git a/chromium/net/quic/platform/impl/quic_linux_socket_utils.h b/chromium/net/quic/platform/impl/quic_linux_socket_utils.h
deleted file mode 100644
index a5ac07ff186..00000000000
--- a/chromium/net/quic/platform/impl/quic_linux_socket_utils.h
+++ /dev/null
@@ -1,245 +0,0 @@
-// Copyright (c) 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef NET_QUIC_PLATFORM_IMPL_QUIC_LINUX_SOCKET_UTILS_H_
-#define NET_QUIC_PLATFORM_IMPL_QUIC_LINUX_SOCKET_UTILS_H_
-
-#include <errno.h>
-#include <stddef.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-#include <deque>
-#include <functional>
-#include <iterator>
-#include <memory>
-#include <type_traits>
-#include <utility>
-
-#include "net/quic/platform/impl/quic_socket_utils.h"
-#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h"
-#include "net/third_party/quiche/src/quic/core/quic_types.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h"
-
-#ifndef SOL_UDP
-#define SOL_UDP 17
-#endif
-
-#ifndef UDP_SEGMENT
-#define UDP_SEGMENT 103
-#endif
-
-#ifndef UDP_MAX_SEGMENTS
-#define UDP_MAX_SEGMENTS (1 << 6UL)
-#endif
-
-namespace quic {
-
-// BufferedWrite holds all information needed to send a packet.
-struct BufferedWrite {
- BufferedWrite(const char* buffer,
- size_t buf_len,
- const QuicIpAddress& self_address,
- const QuicSocketAddress& peer_address);
-
- BufferedWrite(const char* buffer,
- size_t buf_len,
- const QuicIpAddress& self_address,
- const QuicSocketAddress& peer_address,
- std::unique_ptr<PerPacketOptions> options);
-
- BufferedWrite(BufferedWrite&&);
- ~BufferedWrite();
-
- const char* buffer; // Not owned.
- size_t buf_len;
- QuicIpAddress self_address;
- QuicSocketAddress peer_address;
- std::unique_ptr<PerPacketOptions> options;
-};
-
-// QuicMMsgHdr is used to build mmsghdr objects that can be used to send
-// multiple packets at once via ::sendmmsg.
-//
-// Example:
-// QuicDeque<BufferedWrite> buffered_writes;
-// ... (Populate buffered_writes) ...
-//
-// QuicMMsgHdr mhdr(
-// buffered_writes.begin(), buffered_writes.end(), kCmsgSpaceForIp,
-// [](QuicMMsgHdr* mhdr, int i, const BufferedWrite& buffered_write) {
-// mhdr->SetIpInNextCmsg(i, buffered_write.self_address);
-// });
-//
-// int num_packets_sent;
-// QuicSocketUtils::WriteMultiplePackets(fd, &mhdr, &num_packets_sent);
-class QuicMMsgHdr {
- public:
- typedef std::function<
- void(QuicMMsgHdr* mhdr, int i, const BufferedWrite& buffered_write)>
- ControlBufferInitializer;
- template <typename IteratorT>
- QuicMMsgHdr(const IteratorT& first,
- const IteratorT& last,
- size_t cbuf_size,
- ControlBufferInitializer cbuf_initializer)
- : num_msgs_(std::distance(first, last)), cbuf_size_(cbuf_size) {
- static_assert(
- std::is_same<typename std::iterator_traits<IteratorT>::value_type,
- BufferedWrite>::value,
- "Must iterate over a collection of BufferedWrite.");
-
- DCHECK_LE(0, num_msgs_);
- if (num_msgs_ == 0) {
- return;
- }
-
- storage_ = std::make_unique<char[]>(StorageSize());
- memset(&storage_[0], 0, StorageSize());
-
- int i = -1;
- for (auto it = first; it != last; ++it) {
- ++i;
-
- InitOneHeader(i, *it);
- if (cbuf_initializer) {
- cbuf_initializer(this, i, *it);
- }
- }
- }
-
- ~QuicMMsgHdr();
-
- void SetIpInNextCmsg(int i, const QuicIpAddress& self_address);
-
- template <typename DataType>
- DataType* GetNextCmsgData(int i, int cmsg_level, int cmsg_type) {
- return reinterpret_cast<DataType*>(
- GetNextCmsgDataInternal(i, cmsg_level, cmsg_type, sizeof(DataType)));
- }
-
- mmsghdr* mhdr() { return GetMMsgHdr(0); }
-
- int num_msgs() const { return num_msgs_; }
-
- // Get the total number of bytes in the first |num_packets_sent| packets.
- int num_bytes_sent(int num_packets_sent);
-
- protected:
- void InitOneHeader(int i, const BufferedWrite& buffered_write);
-
- void* GetNextCmsgDataInternal(int i,
- int cmsg_level,
- int cmsg_type,
- size_t data_size);
-
- size_t StorageSize() const {
- return num_msgs_ *
- (sizeof(mmsghdr) + sizeof(iovec) + sizeof(sockaddr_storage) +
- sizeof(cmsghdr*) + cbuf_size_);
- }
-
- mmsghdr* GetMMsgHdr(int i) {
- auto* first = reinterpret_cast<mmsghdr*>(&storage_[0]);
- return &first[i];
- }
-
- iovec* GetIov(int i) {
- auto* first = reinterpret_cast<iovec*>(GetMMsgHdr(num_msgs_));
- return &first[i];
- }
-
- sockaddr_storage* GetPeerAddressStorage(int i) {
- auto* first = reinterpret_cast<sockaddr_storage*>(GetIov(num_msgs_));
- return &first[i];
- }
-
- cmsghdr** GetCmsgHdr(int i) {
- auto** first =
- reinterpret_cast<cmsghdr**>(GetPeerAddressStorage(num_msgs_));
- return &first[i];
- }
-
- char* GetCbuf(int i) {
- auto* first = reinterpret_cast<char*>(GetCmsgHdr(num_msgs_));
- return &first[i * cbuf_size_];
- }
-
- const int num_msgs_;
- // Size of cmsg buffer for each message.
- const size_t cbuf_size_;
- // storage_ holds the memory of
- // |num_msgs_| mmsghdr
- // |num_msgs_| iovec
- // |num_msgs_| sockaddr_storage, for peer addresses
- // |num_msgs_| cmsghdr*
- // |num_msgs_| cbuf, each of size cbuf_size
- std::unique_ptr<char[]> storage_;
-};
-
-// QuicSyscallWrapper wraps system calls for testing.
-class QuicSyscallWrapper {
- public:
- int Sendmmsg(int sockfd,
- mmsghdr* msgvec,
- unsigned int vlen,
- int flags) const {
- return ::sendmmsg(sockfd, msgvec, vlen, flags);
- }
-};
-
-class QuicLinuxSocketUtils : public QuicSocketUtils {
- public:
- // Return the UDP segment size of |fd|, 0 means segment size has not been set
- // on this socket. If GSO is not supported, return -1.
- static int GetUDPSegmentSize(int fd);
-
- // Writes the packets in |mhdr| to the socket, using ::sendmmsg.
- static WriteResult WriteMultiplePackets(int fd,
- QuicMMsgHdr* mhdr,
- int* num_packets_sent) {
- return WriteMultiplePackets(fd, mhdr, num_packets_sent,
- QuicSyscallWrapper());
- }
-
- template <typename SyscallWrapper>
- static WriteResult WriteMultiplePackets(int fd,
- QuicMMsgHdr* mhdr,
- int* num_packets_sent,
- const SyscallWrapper& syscall) {
- *num_packets_sent = 0;
-
- if (mhdr->num_msgs() <= 0) {
- return WriteResult(WRITE_STATUS_ERROR, EINVAL);
- }
-
- int rc;
- do {
- rc = syscall.Sendmmsg(fd, mhdr->mhdr(), mhdr->num_msgs(), 0);
- } while (rc < 0 && errno == EINTR);
-
- if (rc > 0) {
- *num_packets_sent = rc;
-
- return WriteResult(WRITE_STATUS_OK, mhdr->num_bytes_sent(rc));
- } else if (rc == 0) {
- LOG(DFATAL)
- << "sendmmsg returned 0, returning WRITE_STATUS_ERROR. errno: "
- << errno;
- errno = EIO;
- }
-
- return WriteResult((errno == EAGAIN || errno == EWOULDBLOCK)
- ? WRITE_STATUS_BLOCKED
- : WRITE_STATUS_ERROR,
- errno);
- }
-};
-
-} // namespace quic
-
-#endif // NET_QUIC_PLATFORM_IMPL_QUIC_LINUX_SOCKET_UTILS_H_
diff --git a/chromium/net/quic/platform/impl/quic_linux_socket_utils_test.cc b/chromium/net/quic/platform/impl/quic_linux_socket_utils_test.cc
deleted file mode 100644
index 06e97548d9f..00000000000
--- a/chromium/net/quic/platform/impl/quic_linux_socket_utils_test.cc
+++ /dev/null
@@ -1,259 +0,0 @@
-// Copyright (c) 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/quic/platform/impl/quic_linux_socket_utils.h"
-
-#include <netinet/in.h>
-#include <stdint.h>
-#include <sstream>
-#include <vector>
-
-#include "net/third_party/quiche/src/quic/core/quic_circular_deque.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
-
-using testing::_;
-using testing::InSequence;
-using testing::Invoke;
-
-namespace quic {
-namespace test {
-namespace {
-
-class MockQuicSyscallWrapper {
- public:
- MOCK_CONST_METHOD4(
- Sendmmsg,
- int(int sockfd, mmsghdr* msgvec, unsigned int vlen, int flags));
-};
-
-class QuicLinuxSocketUtilsTest : public QuicTest {
- protected:
- WriteResult TestWriteMultiplePackets(
- int fd,
- const QuicCircularDeque<BufferedWrite>::const_iterator& first,
- const QuicCircularDeque<BufferedWrite>::const_iterator& last,
- int* num_packets_sent) {
- QuicMMsgHdr mhdr(
- first, last, kCmsgSpaceForIp,
- [](QuicMMsgHdr* mhdr, int i, const BufferedWrite& buffered_write) {
- mhdr->SetIpInNextCmsg(i, buffered_write.self_address);
- });
-
- WriteResult res = QuicLinuxSocketUtils::WriteMultiplePackets(
- fd, &mhdr, num_packets_sent, mock_syscalls_);
- return res;
- }
-
- MockQuicSyscallWrapper mock_syscalls_;
-};
-
-void CheckMsghdrWithoutCbuf(const msghdr* hdr,
- const void* buffer,
- size_t buf_len,
- const QuicSocketAddress& peer_addr) {
- EXPECT_EQ(
- peer_addr.host().IsIPv4() ? sizeof(sockaddr_in) : sizeof(sockaddr_in6),
- hdr->msg_namelen);
- sockaddr_storage peer_generic_addr = peer_addr.generic_address();
- EXPECT_EQ(0, memcmp(hdr->msg_name, &peer_generic_addr, hdr->msg_namelen));
- EXPECT_EQ(1u, hdr->msg_iovlen);
- EXPECT_EQ(buffer, hdr->msg_iov->iov_base);
- EXPECT_EQ(buf_len, hdr->msg_iov->iov_len);
- EXPECT_EQ(0, hdr->msg_flags);
- EXPECT_EQ(nullptr, hdr->msg_control);
- EXPECT_EQ(0u, hdr->msg_controllen);
-}
-
-void CheckIpAndGsoSizeInCbuf(msghdr* hdr,
- const void* cbuf,
- const QuicIpAddress& self_addr,
- uint16_t gso_size) {
- const bool is_ipv4 = self_addr.IsIPv4();
- const size_t ip_cmsg_space = is_ipv4 ? kCmsgSpaceForIpv4 : kCmsgSpaceForIpv6;
-
- EXPECT_EQ(cbuf, hdr->msg_control);
- EXPECT_EQ(ip_cmsg_space + CMSG_SPACE(sizeof(uint16_t)), hdr->msg_controllen);
-
- cmsghdr* cmsg = CMSG_FIRSTHDR(hdr);
- EXPECT_EQ(cmsg->cmsg_len, is_ipv4 ? CMSG_LEN(sizeof(in_pktinfo))
- : CMSG_LEN(sizeof(in6_pktinfo)));
- EXPECT_EQ(cmsg->cmsg_level, is_ipv4 ? IPPROTO_IP : IPPROTO_IPV6);
- EXPECT_EQ(cmsg->cmsg_type, is_ipv4 ? IP_PKTINFO : IPV6_PKTINFO);
-
- const std::string& self_addr_str = self_addr.ToPackedString();
- if (is_ipv4) {
- in_pktinfo* pktinfo = reinterpret_cast<in_pktinfo*>(CMSG_DATA(cmsg));
- EXPECT_EQ(0, memcmp(&pktinfo->ipi_spec_dst, self_addr_str.c_str(),
- self_addr_str.length()));
- } else {
- in6_pktinfo* pktinfo = reinterpret_cast<in6_pktinfo*>(CMSG_DATA(cmsg));
- EXPECT_EQ(0, memcmp(&pktinfo->ipi6_addr, self_addr_str.c_str(),
- self_addr_str.length()));
- }
-
- cmsg = CMSG_NXTHDR(hdr, cmsg);
- EXPECT_EQ(cmsg->cmsg_len, CMSG_LEN(sizeof(uint16_t)));
- EXPECT_EQ(cmsg->cmsg_level, SOL_UDP);
- EXPECT_EQ(cmsg->cmsg_type, UDP_SEGMENT);
- EXPECT_EQ(gso_size, *reinterpret_cast<uint16_t*>(CMSG_DATA(cmsg)));
-
- EXPECT_EQ(nullptr, CMSG_NXTHDR(hdr, cmsg));
-}
-
-TEST_F(QuicLinuxSocketUtilsTest, QuicMMsgHdr) {
- QuicCircularDeque<BufferedWrite> buffered_writes;
- char packet_buf1[1024];
- char packet_buf2[512];
- buffered_writes.emplace_back(
- packet_buf1, sizeof(packet_buf1), QuicIpAddress::Loopback4(),
- QuicSocketAddress(QuicIpAddress::Loopback4(), 4));
- buffered_writes.emplace_back(
- packet_buf2, sizeof(packet_buf2), QuicIpAddress::Loopback6(),
- QuicSocketAddress(QuicIpAddress::Loopback6(), 6));
-
- QuicMMsgHdr quic_mhdr_without_cbuf(buffered_writes.begin(),
- buffered_writes.end(), 0, nullptr);
- for (size_t i = 0; i < buffered_writes.size(); ++i) {
- const BufferedWrite& bw = buffered_writes[i];
- CheckMsghdrWithoutCbuf(&quic_mhdr_without_cbuf.mhdr()[i].msg_hdr, bw.buffer,
- bw.buf_len, bw.peer_address);
- }
-
- QuicMMsgHdr quic_mhdr_with_cbuf(
- buffered_writes.begin(), buffered_writes.end(),
- kCmsgSpaceForIp + kCmsgSpaceForSegmentSize,
- [](QuicMMsgHdr* mhdr, int i, const BufferedWrite& buffered_write) {
- mhdr->SetIpInNextCmsg(i, buffered_write.self_address);
- *mhdr->GetNextCmsgData<uint16_t>(i, SOL_UDP, UDP_SEGMENT) = 1300;
- });
- for (size_t i = 0; i < buffered_writes.size(); ++i) {
- const BufferedWrite& bw = buffered_writes[i];
- msghdr* hdr = &quic_mhdr_with_cbuf.mhdr()[i].msg_hdr;
- CheckIpAndGsoSizeInCbuf(hdr, hdr->msg_control, bw.self_address, 1300);
- }
-}
-
-TEST_F(QuicLinuxSocketUtilsTest, WriteMultiplePackets_NoPacketsToSend) {
- int num_packets_sent;
- QuicCircularDeque<BufferedWrite> buffered_writes;
-
- EXPECT_CALL(mock_syscalls_, Sendmmsg(_, _, _, _)).Times(0);
-
- EXPECT_EQ(WriteResult(WRITE_STATUS_ERROR, EINVAL),
- TestWriteMultiplePackets(1, buffered_writes.begin(),
- buffered_writes.end(), &num_packets_sent));
-}
-
-TEST_F(QuicLinuxSocketUtilsTest, WriteMultiplePackets_WriteBlocked) {
- int num_packets_sent;
- QuicCircularDeque<BufferedWrite> buffered_writes;
- buffered_writes.emplace_back(nullptr, 0, QuicIpAddress(),
- QuicSocketAddress(QuicIpAddress::Any4(), 0));
-
- EXPECT_CALL(mock_syscalls_, Sendmmsg(_, _, _, _))
- .WillOnce(
- Invoke([](int fd, mmsghdr* msgvec, unsigned int vlen, int flags) {
- errno = EWOULDBLOCK;
- return -1;
- }));
-
- EXPECT_EQ(WriteResult(WRITE_STATUS_BLOCKED, EWOULDBLOCK),
- TestWriteMultiplePackets(1, buffered_writes.begin(),
- buffered_writes.end(), &num_packets_sent));
- EXPECT_EQ(0, num_packets_sent);
-}
-
-TEST_F(QuicLinuxSocketUtilsTest, WriteMultiplePackets_WriteError) {
- int num_packets_sent;
- QuicCircularDeque<BufferedWrite> buffered_writes;
- buffered_writes.emplace_back(nullptr, 0, QuicIpAddress(),
- QuicSocketAddress(QuicIpAddress::Any4(), 0));
-
- EXPECT_CALL(mock_syscalls_, Sendmmsg(_, _, _, _))
- .WillOnce(
- Invoke([](int fd, mmsghdr* msgvec, unsigned int vlen, int flags) {
- errno = EPERM;
- return -1;
- }));
-
- EXPECT_EQ(WriteResult(WRITE_STATUS_ERROR, EPERM),
- TestWriteMultiplePackets(1, buffered_writes.begin(),
- buffered_writes.end(), &num_packets_sent));
- EXPECT_EQ(0, num_packets_sent);
-}
-
-TEST_F(QuicLinuxSocketUtilsTest, WriteMultiplePackets_WriteSuccess) {
- int num_packets_sent;
- QuicCircularDeque<BufferedWrite> buffered_writes;
- const int kNumBufferedWrites = 10;
- static_assert(kNumBufferedWrites < 256, "Must be less than 256");
- std::vector<std::string> buffer_holder;
- for (int i = 0; i < kNumBufferedWrites; ++i) {
- size_t buf_len = (i + 1) * 2;
- std::ostringstream buffer_ostream;
- while (buffer_ostream.str().length() < buf_len) {
- buffer_ostream << i;
- }
- buffer_holder.push_back(buffer_ostream.str().substr(0, buf_len - 1) + '$');
-
- buffered_writes.emplace_back(buffer_holder.back().data(), buf_len,
- QuicIpAddress(),
- QuicSocketAddress(QuicIpAddress::Any4(), 0));
-
- // Leave the first self_address uninitialized.
- if (i != 0) {
- ASSERT_TRUE(buffered_writes.back().self_address.FromString("127.0.0.1"));
- }
-
- std::ostringstream peer_ip_ostream;
- QuicIpAddress peer_ip_address;
- peer_ip_ostream << "127.0.1." << i + 1;
- ASSERT_TRUE(peer_ip_address.FromString(peer_ip_ostream.str()));
- buffered_writes.back().peer_address =
- QuicSocketAddress(peer_ip_address, i + 1);
- }
-
- InSequence s;
-
- for (int expected_num_packets_sent : {1, 2, 3, 10}) {
- SCOPED_TRACE(testing::Message()
- << "expected_num_packets_sent=" << expected_num_packets_sent);
- EXPECT_CALL(mock_syscalls_, Sendmmsg(_, _, _, _))
- .WillOnce(Invoke([&](int fd, mmsghdr* msgvec, unsigned int vlen,
- int flags) {
- EXPECT_LE(static_cast<unsigned int>(expected_num_packets_sent), vlen);
- for (unsigned int i = 0; i < vlen; ++i) {
- const BufferedWrite& buffered_write = buffered_writes[i];
- const msghdr& hdr = msgvec[i].msg_hdr;
- EXPECT_EQ(1u, hdr.msg_iovlen);
- EXPECT_EQ(buffered_write.buffer, hdr.msg_iov->iov_base);
- EXPECT_EQ(buffered_write.buf_len, hdr.msg_iov->iov_len);
- sockaddr_storage expected_peer_address =
- buffered_write.peer_address.generic_address();
- EXPECT_EQ(0, memcmp(&expected_peer_address, hdr.msg_name,
- sizeof(sockaddr_storage)));
- EXPECT_EQ(buffered_write.self_address.IsInitialized(),
- hdr.msg_control != nullptr);
- }
- return expected_num_packets_sent;
- }))
- .RetiresOnSaturation();
-
- int expected_bytes_written = 0;
- for (auto it = buffered_writes.cbegin();
- it != buffered_writes.cbegin() + expected_num_packets_sent; ++it) {
- expected_bytes_written += it->buf_len;
- }
-
- EXPECT_EQ(
- WriteResult(WRITE_STATUS_OK, expected_bytes_written),
- TestWriteMultiplePackets(1, buffered_writes.cbegin(),
- buffered_writes.cend(), &num_packets_sent));
- EXPECT_EQ(expected_num_packets_sent, num_packets_sent);
- }
-}
-
-} // namespace
-} // namespace test
-} // namespace quic
diff --git a/chromium/net/quic/platform/impl/quic_map_util_impl.h b/chromium/net/quic/platform/impl/quic_map_util_impl.h
index c25e1c41128..006877a9cfa 100644
--- a/chromium/net/quic/platform/impl/quic_map_util_impl.h
+++ b/chromium/net/quic/platform/impl/quic_map_util_impl.h
@@ -5,7 +5,7 @@
#ifndef NET_QUIC_PLATFORM_IMPL_QUIC_MAP_UTIL_IMPL_H_
#define NET_QUIC_PLATFORM_IMPL_QUIC_MAP_UTIL_IMPL_H_
-#include "base/stl_util.h"
+#include "base/containers/contains.h"
namespace quic {
diff --git a/chromium/net/quic/platform/impl/quic_port_utils_impl.cc b/chromium/net/quic/platform/impl/quic_port_utils_impl.cc
deleted file mode 100644
index 4209b73e3f3..00000000000
--- a/chromium/net/quic/platform/impl/quic_port_utils_impl.cc
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/quic/platform/impl/quic_port_utils_impl.h"
-
-#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h"
-
-namespace quic {
-
-int QuicPickServerPortForTestsOrDieImpl() {
- return 0; // Let the OS find an unused port.
-}
-
-void QuicRecyclePortImpl(int port) {}
-
-} // namespace quic
diff --git a/chromium/net/quic/platform/impl/quic_port_utils_impl.h b/chromium/net/quic/platform/impl/quic_port_utils_impl.h
deleted file mode 100644
index a0c6affdf05..00000000000
--- a/chromium/net/quic/platform/impl/quic_port_utils_impl.h
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef NET_QUIC_PLATFORM_IMPL_QUIC_PORT_UTILS_IMPL_H_
-#define NET_QUIC_PLATFORM_IMPL_QUIC_PORT_UTILS_IMPL_H_
-
-namespace quic {
-
-int QuicPickServerPortForTestsOrDieImpl();
-void QuicRecyclePortImpl(int port);
-
-} // namespace quic
-
-#endif // NET_QUIC_PLATFORM_IMPL_QUIC_PORT_UTILS_IMPL_H_
diff --git a/chromium/net/quic/platform/impl/quic_socket_address_impl.cc b/chromium/net/quic/platform/impl/quic_socket_address_impl.cc
deleted file mode 100644
index 50668abe52e..00000000000
--- a/chromium/net/quic/platform/impl/quic_socket_address_impl.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright (c) 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/quic/platform/impl/quic_socket_address_impl.h"
-
-#include "net/base/sockaddr_storage.h"
-#include "net/quic/address_utils.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
-
-using std::string;
-
-namespace quic {
-
-QuicSocketAddressImpl::QuicSocketAddressImpl(const net::IPEndPoint& address)
- : socket_address_(address) {}
-
-QuicSocketAddressImpl::QuicSocketAddressImpl(QuicIpAddress address,
- uint16_t port)
- : socket_address_(net::ToIPAddress(address), port) {}
-
-QuicSocketAddressImpl::QuicSocketAddressImpl(
- const struct sockaddr_storage& saddr) {
- if (saddr.ss_family == AF_INET) {
- CHECK(socket_address_.FromSockAddr(
- reinterpret_cast<const sockaddr*>(&saddr), sizeof(struct sockaddr_in)));
- } else if (saddr.ss_family == AF_INET6) {
- CHECK(
- socket_address_.FromSockAddr(reinterpret_cast<const sockaddr*>(&saddr),
- sizeof(struct sockaddr_in6)));
- }
-}
-
-QuicSocketAddressImpl::QuicSocketAddressImpl(const sockaddr* saddr,
- socklen_t len) {
- if (saddr->sa_family == AF_INET) {
- CHECK(socket_address_.FromSockAddr(saddr, len));
- } else if (saddr->sa_family == AF_INET6) {
- CHECK(socket_address_.FromSockAddr(saddr, len));
- }
-}
-
-bool operator==(const QuicSocketAddressImpl& lhs,
- const QuicSocketAddressImpl& rhs) {
- return lhs.socket_address_ == rhs.socket_address_;
-}
-
-bool operator!=(const QuicSocketAddressImpl& lhs,
- const QuicSocketAddressImpl& rhs) {
- return lhs.socket_address_.address() != rhs.socket_address_.address() ||
- lhs.socket_address_.port() != rhs.socket_address_.port();
-}
-
-bool QuicSocketAddressImpl::IsInitialized() const {
- return net::GetAddressFamily(socket_address_.address()) !=
- net::ADDRESS_FAMILY_UNSPECIFIED;
- ;
-}
-
-string QuicSocketAddressImpl::ToString() const {
- if (!IsInitialized()) {
- return "Uninitialized address";
- }
- return socket_address_.ToString();
-}
-
-int QuicSocketAddressImpl::FromSocket(int fd) {
- net::SockaddrStorage storage;
- if (getsockname(fd, storage.addr, &storage.addr_len) != 0 ||
- !socket_address_.FromSockAddr(storage.addr, storage.addr_len)) {
- return 1;
- }
-
- return 0;
-}
-
-QuicSocketAddressImpl QuicSocketAddressImpl::Normalized() const {
- LOG(DFATAL) << "QuicSocketAddressImpl::Normalized() is not implemented.";
- return QuicSocketAddressImpl();
-}
-
-QuicIpAddress QuicSocketAddressImpl::host() const {
- return ToQuicIpAddress(socket_address_.address());
-}
-
-uint16_t QuicSocketAddressImpl::port() const {
- return socket_address_.port();
-}
-
-sockaddr_storage QuicSocketAddressImpl::generic_address() const {
- sockaddr_storage raw_address = {};
- socklen_t address_len = sizeof(raw_address);
- CHECK(socket_address_.ToSockAddr(
- reinterpret_cast<struct sockaddr*>(&raw_address), &address_len));
- return raw_address;
-}
-
-} // namespace quic
diff --git a/chromium/net/quic/platform/impl/quic_socket_address_impl.h b/chromium/net/quic/platform/impl/quic_socket_address_impl.h
deleted file mode 100644
index e6006baea8b..00000000000
--- a/chromium/net/quic/platform/impl/quic_socket_address_impl.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef NET_QUIC_PLATFORM_IMPL_QUIC_SOCKET_ADDRESS_IMPL_H_
-#define NET_QUIC_PLATFORM_IMPL_QUIC_SOCKET_ADDRESS_IMPL_H_
-
-#include "net/base/ip_endpoint.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h"
-
-namespace quic {
-
-class QUIC_EXPORT_PRIVATE QuicSocketAddressImpl {
- public:
- QuicSocketAddressImpl() = default;
- explicit QuicSocketAddressImpl(const net::IPEndPoint& addr);
- QuicSocketAddressImpl(QuicIpAddress address, uint16_t port);
- explicit QuicSocketAddressImpl(const struct sockaddr_storage& saddr);
- explicit QuicSocketAddressImpl(const sockaddr* saddr, socklen_t len);
- QuicSocketAddressImpl(const QuicSocketAddressImpl& other) = default;
- QuicSocketAddressImpl& operator=(const QuicSocketAddressImpl& other) =
- default;
- QuicSocketAddressImpl& operator=(QuicSocketAddressImpl&& other) = default;
- friend bool operator==(const QuicSocketAddressImpl& lhs,
- const QuicSocketAddressImpl& rhs);
- friend bool operator!=(const QuicSocketAddressImpl& lhs,
- const QuicSocketAddressImpl& rhs);
-
- bool IsInitialized() const;
- std::string ToString() const;
- int FromSocket(int fd);
- QuicSocketAddressImpl Normalized() const;
-
- QuicIpAddress host() const;
- uint16_t port() const;
-
- sockaddr_storage generic_address() const;
- const net::IPEndPoint& socket_address() const { return socket_address_; }
-
- private:
- net::IPEndPoint socket_address_;
-};
-
-} // namespace quic
-
-#endif // NET_QUIC_PLATFORM_IMPL_QUIC_SOCKET_ADDRESS_IMPL_H_
diff --git a/chromium/net/quic/platform/impl/quic_socket_utils.cc b/chromium/net/quic/platform/impl/quic_socket_utils.cc
deleted file mode 100644
index 2922dcdd290..00000000000
--- a/chromium/net/quic/platform/impl/quic_socket_utils.cc
+++ /dev/null
@@ -1,419 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/quic/platform/impl/quic_socket_utils.h"
-
-#include <errno.h>
-#include <fcntl.h>
-#include <linux/net_tstamp.h>
-#include <netinet/in.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-#include <unistd.h>
-#include <string>
-
-#include "base/notreached.h"
-#include "net/third_party/quiche/src/quic/core/quic_packets.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h"
-
-#ifndef SO_RXQ_OVFL
-#define SO_RXQ_OVFL 40
-#endif
-
-using std::string;
-
-namespace quic {
-
-QuicMsgHdr::QuicMsgHdr(const char* buffer,
- size_t buf_len,
- const QuicSocketAddress& peer_address,
- char* cbuf,
- size_t cbuf_size)
- : iov_{const_cast<char*>(buffer), buf_len},
- cbuf_(cbuf),
- cbuf_size_(cbuf_size),
- cmsg_(nullptr) {
- // Only support unconnected sockets.
- DCHECK(peer_address.IsInitialized());
-
- raw_peer_address_ = peer_address.generic_address();
- hdr_.msg_name = &raw_peer_address_;
- hdr_.msg_namelen = raw_peer_address_.ss_family == AF_INET
- ? sizeof(sockaddr_in)
- : sizeof(sockaddr_in6);
-
- hdr_.msg_iov = &iov_;
- hdr_.msg_iovlen = 1;
- hdr_.msg_flags = 0;
-
- hdr_.msg_control = nullptr;
- hdr_.msg_controllen = 0;
-}
-
-void QuicMsgHdr::SetIpInNextCmsg(const QuicIpAddress& self_address) {
- if (!self_address.IsInitialized()) {
- return;
- }
-
- if (self_address.IsIPv4()) {
- QuicSocketUtils::SetIpInfoInCmsgData(
- self_address, GetNextCmsgData<in_pktinfo>(IPPROTO_IP, IP_PKTINFO));
- } else {
- QuicSocketUtils::SetIpInfoInCmsgData(
- self_address, GetNextCmsgData<in6_pktinfo>(IPPROTO_IPV6, IPV6_PKTINFO));
- }
-}
-
-void* QuicMsgHdr::GetNextCmsgDataInternal(int cmsg_level,
- int cmsg_type,
- size_t data_size) {
- // msg_controllen needs to be increased first, otherwise CMSG_NXTHDR will
- // return nullptr.
- hdr_.msg_controllen += CMSG_SPACE(data_size);
- DCHECK_LE(hdr_.msg_controllen, cbuf_size_);
-
- if (cmsg_ == nullptr) {
- DCHECK_EQ(nullptr, hdr_.msg_control);
- memset(cbuf_, 0, cbuf_size_);
- hdr_.msg_control = cbuf_;
- cmsg_ = CMSG_FIRSTHDR(&hdr_);
- } else {
- DCHECK_NE(nullptr, hdr_.msg_control);
- cmsg_ = CMSG_NXTHDR(&hdr_, cmsg_);
- }
-
- DCHECK_NE(nullptr, cmsg_) << "Insufficient control buffer space";
-
- cmsg_->cmsg_len = CMSG_LEN(data_size);
- cmsg_->cmsg_level = cmsg_level;
- cmsg_->cmsg_type = cmsg_type;
-
- return CMSG_DATA(cmsg_);
-}
-
-// static
-void QuicSocketUtils::GetAddressAndTimestampFromMsghdr(
- struct msghdr* hdr,
- QuicIpAddress* address,
- QuicWallTime* walltimestamp) {
- if (hdr->msg_controllen > 0) {
- for (cmsghdr* cmsg = CMSG_FIRSTHDR(hdr); cmsg != nullptr;
- cmsg = CMSG_NXTHDR(hdr, cmsg)) {
- char* addr_data = nullptr;
- int len = 0;
- if (cmsg->cmsg_type == IPV6_PKTINFO) {
- in6_pktinfo* info = reinterpret_cast<in6_pktinfo*>(CMSG_DATA(cmsg));
- addr_data = reinterpret_cast<char*>(&info->ipi6_addr);
- len = sizeof(in6_addr);
- address->FromPackedString(addr_data, len);
- } else if (cmsg->cmsg_type == IP_PKTINFO) {
- in_pktinfo* info = reinterpret_cast<in_pktinfo*>(CMSG_DATA(cmsg));
- addr_data = reinterpret_cast<char*>(&info->ipi_addr);
- len = sizeof(in_addr);
- address->FromPackedString(addr_data, len);
- } else if (cmsg->cmsg_level == SOL_SOCKET &&
- cmsg->cmsg_type == SO_TIMESTAMPING) {
- LinuxTimestamping* lts =
- reinterpret_cast<LinuxTimestamping*>(CMSG_DATA(cmsg));
- timespec* ts = &lts->systime;
- int64_t usec = (static_cast<int64_t>(ts->tv_sec) * 1000 * 1000) +
- (static_cast<int64_t>(ts->tv_nsec) / 1000);
- *walltimestamp = QuicWallTime::FromUNIXMicroseconds(usec);
- }
- }
- }
-}
-
-// static
-bool QuicSocketUtils::GetOverflowFromMsghdr(struct msghdr* hdr,
- QuicPacketCount* dropped_packets) {
- if (hdr->msg_controllen > 0) {
- struct cmsghdr* cmsg;
- for (cmsg = CMSG_FIRSTHDR(hdr); cmsg != nullptr;
- cmsg = CMSG_NXTHDR(hdr, cmsg)) {
- if (cmsg->cmsg_type == SO_RXQ_OVFL) {
- *dropped_packets = *(reinterpret_cast<uint32_t*> CMSG_DATA(cmsg));
- return true;
- }
- }
- }
- return false;
-}
-
-// static
-bool QuicSocketUtils::GetTtlFromMsghdr(struct msghdr* hdr, int* ttl) {
- if (hdr->msg_controllen > 0) {
- struct cmsghdr* cmsg;
- for (cmsg = CMSG_FIRSTHDR(hdr); cmsg != nullptr;
- cmsg = CMSG_NXTHDR(hdr, cmsg)) {
- if ((cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_TTL) ||
- (cmsg->cmsg_level == IPPROTO_IPV6 &&
- cmsg->cmsg_type == IPV6_HOPLIMIT)) {
- *ttl = *(reinterpret_cast<int*>(CMSG_DATA(cmsg)));
- return true;
- }
- }
- }
- return false;
-}
-
-// static
-int QuicSocketUtils::SetGetAddressInfo(int fd, int address_family) {
- int get_local_ip = 1;
- int rc = setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &get_local_ip,
- sizeof(get_local_ip));
- if (rc == 0 && address_family == AF_INET6) {
- rc = setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &get_local_ip,
- sizeof(get_local_ip));
- }
- return rc;
-}
-
-// static
-int QuicSocketUtils::SetGetSoftwareReceiveTimestamp(int fd) {
- int timestamping = SOF_TIMESTAMPING_RX_SOFTWARE | SOF_TIMESTAMPING_SOFTWARE;
- return setsockopt(fd, SOL_SOCKET, SO_TIMESTAMPING, &timestamping,
- sizeof(timestamping));
-}
-
-// static
-bool QuicSocketUtils::SetSendBufferSize(int fd, size_t size) {
- if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)) != 0) {
- LOG(ERROR) << "Failed to set socket send size";
- return false;
- }
- return true;
-}
-
-// static
-bool QuicSocketUtils::SetReceiveBufferSize(int fd, size_t size) {
- if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)) != 0) {
- LOG(ERROR) << "Failed to set socket recv size";
- return false;
- }
- return true;
-}
-
-// static
-int QuicSocketUtils::ReadPacket(int fd,
- char* buffer,
- size_t buf_len,
- QuicPacketCount* dropped_packets,
- QuicIpAddress* self_address,
- QuicWallTime* walltimestamp,
- QuicSocketAddress* peer_address) {
- DCHECK(peer_address != nullptr);
- char cbuf[kCmsgSpaceForReadPacket];
-
- iovec iov = {buffer, buf_len};
- struct sockaddr_storage raw_address;
- msghdr hdr;
-
- hdr.msg_name = &raw_address;
- hdr.msg_namelen = sizeof(sockaddr_storage);
- hdr.msg_iov = &iov;
- hdr.msg_iovlen = 1;
- hdr.msg_flags = 0;
-
- struct cmsghdr* cmsg = reinterpret_cast<struct cmsghdr*>(cbuf);
- cmsg->cmsg_len = sizeof(cbuf);
- hdr.msg_control = cmsg;
- hdr.msg_controllen = sizeof(cbuf);
-
- int bytes_read = recvmsg(fd, &hdr, 0);
-
- // Return before setting dropped packets: if we get EAGAIN, it will
- // be 0.
- if (bytes_read < 0 && errno != 0) {
- if (errno != EAGAIN) {
- LOG(ERROR) << "Error reading " << strerror(errno);
- }
- return -1;
- }
-
- if (hdr.msg_flags & MSG_CTRUNC) {
- LOG(DFATAL) << "Incorrectly set control length: " << hdr.msg_controllen
- << ", expected " << sizeof(cbuf);
- return -1;
- }
-
- if (dropped_packets != nullptr) {
- GetOverflowFromMsghdr(&hdr, dropped_packets);
- }
-
- QuicIpAddress stack_address;
- if (self_address == nullptr) {
- self_address = &stack_address;
- }
-
- QuicWallTime stack_walltimestamp = QuicWallTime::FromUNIXMicroseconds(0);
- if (walltimestamp == nullptr) {
- walltimestamp = &stack_walltimestamp;
- }
-
- GetAddressAndTimestampFromMsghdr(&hdr, self_address, walltimestamp);
-
- *peer_address = QuicSocketAddress(raw_address);
- return bytes_read;
-}
-
-size_t QuicSocketUtils::SetIpInfoInCmsg(const QuicIpAddress& self_address,
- cmsghdr* cmsg) {
- string address_string;
- if (self_address.IsIPv4()) {
- cmsg->cmsg_len = CMSG_LEN(sizeof(in_pktinfo));
- cmsg->cmsg_level = IPPROTO_IP;
- cmsg->cmsg_type = IP_PKTINFO;
- in_pktinfo* pktinfo = reinterpret_cast<in_pktinfo*>(CMSG_DATA(cmsg));
- memset(pktinfo, 0, sizeof(in_pktinfo));
- pktinfo->ipi_ifindex = 0;
- address_string = self_address.ToPackedString();
- memcpy(&pktinfo->ipi_spec_dst, address_string.c_str(),
- address_string.length());
- return sizeof(in_pktinfo);
- } else if (self_address.IsIPv6()) {
- cmsg->cmsg_len = CMSG_LEN(sizeof(in6_pktinfo));
- cmsg->cmsg_level = IPPROTO_IPV6;
- cmsg->cmsg_type = IPV6_PKTINFO;
- in6_pktinfo* pktinfo = reinterpret_cast<in6_pktinfo*>(CMSG_DATA(cmsg));
- memset(pktinfo, 0, sizeof(in6_pktinfo));
- address_string = self_address.ToPackedString();
- memcpy(&pktinfo->ipi6_addr, address_string.c_str(),
- address_string.length());
- return sizeof(in6_pktinfo);
- } else {
- NOTREACHED() << "Unrecognized net::IPAddress";
- return 0;
- }
-}
-
-// static
-WriteResult QuicSocketUtils::WritePacket(
- int fd,
- const char* buffer,
- size_t buf_len,
- const QuicIpAddress& self_address,
- const QuicSocketAddress& peer_address) {
- sockaddr_storage raw_address = peer_address.generic_address();
- iovec iov = {const_cast<char*>(buffer), buf_len};
-
- msghdr hdr;
- hdr.msg_name = &raw_address;
- hdr.msg_namelen = raw_address.ss_family == AF_INET ? sizeof(sockaddr_in)
- : sizeof(sockaddr_in6);
- hdr.msg_iov = &iov;
- hdr.msg_iovlen = 1;
- hdr.msg_flags = 0;
-
- const int kSpaceForIpv4 = CMSG_SPACE(sizeof(in_pktinfo));
- const int kSpaceForIpv6 = CMSG_SPACE(sizeof(in6_pktinfo));
- // kSpaceForIp should be big enough to hold both IPv4 and IPv6 packet info.
- const int kSpaceForIp =
- (kSpaceForIpv4 < kSpaceForIpv6) ? kSpaceForIpv6 : kSpaceForIpv4;
- char cbuf[kSpaceForIp];
- if (!self_address.IsInitialized()) {
- hdr.msg_control = nullptr;
- hdr.msg_controllen = 0;
- } else {
- hdr.msg_control = cbuf;
- hdr.msg_controllen = kSpaceForIp;
- cmsghdr* cmsg = CMSG_FIRSTHDR(&hdr);
- SetIpInfoInCmsg(self_address, cmsg);
- hdr.msg_controllen = cmsg->cmsg_len;
- }
-
- int rc;
- do {
- rc = sendmsg(fd, &hdr, 0);
- } while (rc < 0 && errno == EINTR);
- if (rc >= 0) {
- return WriteResult(WRITE_STATUS_OK, rc);
- }
- return WriteResult((errno == EAGAIN || errno == EWOULDBLOCK)
- ? WRITE_STATUS_BLOCKED
- : WRITE_STATUS_ERROR,
- errno);
-}
-
-// static
-WriteResult QuicSocketUtils::WritePacket(int fd, const QuicMsgHdr& hdr) {
- int rc;
- do {
- rc = sendmsg(fd, hdr.hdr(), 0);
- } while (rc < 0 && errno == EINTR);
- if (rc >= 0) {
- return WriteResult(WRITE_STATUS_OK, rc);
- }
- return WriteResult((errno == EAGAIN || errno == EWOULDBLOCK)
- ? WRITE_STATUS_BLOCKED
- : WRITE_STATUS_ERROR,
- errno);
-}
-
-// static
-void QuicSocketUtils::SetIpInfoInCmsgData(const QuicIpAddress& self_address,
- void* cmsg_data) {
- DCHECK(self_address.IsInitialized());
- const std::string& address_str = self_address.ToPackedString();
- if (self_address.IsIPv4()) {
- in_pktinfo* pktinfo = static_cast<in_pktinfo*>(cmsg_data);
- pktinfo->ipi_ifindex = 0;
- memcpy(&pktinfo->ipi_spec_dst, address_str.c_str(), address_str.length());
- } else if (self_address.IsIPv6()) {
- in6_pktinfo* pktinfo = static_cast<in6_pktinfo*>(cmsg_data);
- memcpy(&pktinfo->ipi6_addr, address_str.c_str(), address_str.length());
- } else {
- LOG(DFATAL) << "Unrecognized IPAddress";
- }
-}
-
-// static
-int QuicSocketUtils::CreateUDPSocket(const QuicSocketAddress& address,
- int32_t receive_buffer_size,
- int32_t send_buffer_size,
- bool* overflow_supported) {
- int address_family = address.host().AddressFamilyToInt();
- int fd = socket(address_family, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP);
- if (fd < 0) {
- QUIC_LOG(ERROR) << "socket() failed: " << strerror(errno);
- return -1;
- }
-
- int get_overflow = 1;
- int rc = setsockopt(fd, SOL_SOCKET, SO_RXQ_OVFL, &get_overflow,
- sizeof(get_overflow));
- if (rc < 0) {
- QUIC_DLOG(WARNING) << "Socket overflow detection not supported";
- } else {
- *overflow_supported = true;
- }
-
- if (!SetReceiveBufferSize(fd, receive_buffer_size)) {
- return -1;
- }
-
- if (!SetSendBufferSize(fd, send_buffer_size)) {
- return -1;
- }
-
- rc = SetGetAddressInfo(fd, address_family);
- if (rc < 0) {
- LOG(ERROR) << "IP detection not supported" << strerror(errno);
- return -1;
- }
-
- rc = SetGetSoftwareReceiveTimestamp(fd);
- if (rc < 0) {
- QUIC_LOG(WARNING) << "SO_TIMESTAMPING not supported; using fallback: "
- << strerror(errno);
- }
-
- return fd;
-}
-
-} // namespace quic
diff --git a/chromium/net/quic/platform/impl/quic_socket_utils.h b/chromium/net/quic/platform/impl/quic_socket_utils.h
deleted file mode 100644
index f17845a08ae..00000000000
--- a/chromium/net/quic/platform/impl/quic_socket_utils.h
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// Some socket related helper methods for quic.
-
-#ifndef NET_QUIC_PLATFORM_IMPL_QUIC_SOCKET_UTILS_H_
-#define NET_QUIC_PLATFORM_IMPL_QUIC_SOCKET_UTILS_H_
-
-#include <netinet/in.h>
-#include <stddef.h>
-#include <sys/socket.h>
-
-#include <string>
-
-#include "base/macros.h"
-#include "net/base/ip_address.h"
-#include "net/base/ip_endpoint.h"
-#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h"
-#include "net/third_party/quiche/src/quic/core/quic_types.h"
-
-#define MMSG_MORE 0
-#define MMSG_MORE_NO_ANDROID 0
-
-namespace quic {
-class QuicIpAddress;
-class QuicSocketAddress;
-
-// This is the structure that SO_TIMESTAMPING fills into the cmsg header. It is
-// well-defined, but does not have a definition in a public header. See
-// https://www.kernel.org/doc/Documentation/networking/timestamping.txt for more
-// information.
-struct LinuxTimestamping {
- // The converted system time of the timestamp.
- struct timespec systime;
- // Deprecated; serves only as padding.
- struct timespec hwtimetrans;
- // The raw hardware timestamp.
- struct timespec hwtimeraw;
-};
-
-const int kCmsgSpaceForIpv4 = CMSG_SPACE(sizeof(in_pktinfo));
-const int kCmsgSpaceForIpv6 = CMSG_SPACE(sizeof(in6_pktinfo));
-// kCmsgSpaceForIp should be big enough to hold both IPv4 and IPv6 packet info.
-const int kCmsgSpaceForIp = (kCmsgSpaceForIpv4 < kCmsgSpaceForIpv6)
- ? kCmsgSpaceForIpv6
- : kCmsgSpaceForIpv4;
-
-const int kCmsgSpaceForSegmentSize = CMSG_SPACE(sizeof(uint16_t));
-
-const int kCmsgSpaceForRecvQueueOverflow = CMSG_SPACE(sizeof(int));
-const int kCmsgSpaceForLinuxTimestamping =
- CMSG_SPACE(sizeof(LinuxTimestamping));
-const int kCmsgSpaceForTTL = CMSG_SPACE(sizeof(int));
-
-// The minimum cmsg buffer size when receiving a packet. It is possible for a
-// received packet to contain both IPv4 and IPv6 addresses.
-const int kCmsgSpaceForReadPacket =
- kCmsgSpaceForRecvQueueOverflow + kCmsgSpaceForIpv4 + kCmsgSpaceForIpv6 +
- kCmsgSpaceForLinuxTimestamping + kCmsgSpaceForTTL;
-
-// QuicMsgHdr is used to build msghdr objects that can be used send packets via
-// ::sendmsg.
-//
-// Example:
-// // cbuf holds control messages(cmsgs). The size is determined from what
-// // cmsgs will be set for this msghdr.
-// char cbuf[kCmsgSpaceForIp + kCmsgSpaceForSegmentSize];
-// QuicMsgHdr hdr(packet_buf, packet_buf_len, peer_addr, cbuf, sizeof(cbuf));
-//
-// // Set IP in cmsgs.
-// hdr.SetIpInNextCmsg(self_addr);
-//
-// // Set GSO size in cmsgs.
-// *hdr.GetNextCmsgData<uint16_t>(SOL_UDP, UDP_SEGMENT) = 1200;
-//
-// QuicSocketUtils::WritePacket(fd, hdr);
-class QuicMsgHdr {
- public:
- QuicMsgHdr(const char* buffer,
- size_t buf_len,
- const QuicSocketAddress& peer_address,
- char* cbuf,
- size_t cbuf_size);
-
- // Set IP info in the next cmsg. Both IPv4 and IPv6 are supported.
- void SetIpInNextCmsg(const QuicIpAddress& self_address);
-
- template <typename DataType>
- DataType* GetNextCmsgData(int cmsg_level, int cmsg_type) {
- return reinterpret_cast<DataType*>(
- GetNextCmsgDataInternal(cmsg_level, cmsg_type, sizeof(DataType)));
- }
-
- const msghdr* hdr() const { return &hdr_; }
-
- protected:
- void* GetNextCmsgDataInternal(int cmsg_level,
- int cmsg_type,
- size_t data_size);
-
- msghdr hdr_;
- iovec iov_;
- sockaddr_storage raw_peer_address_;
- char* cbuf_;
- const size_t cbuf_size_;
- // The last cmsg populated so far. nullptr means nothing has been populated.
- cmsghdr* cmsg_;
-};
-
-class QuicSocketUtils {
- public:
- QuicSocketUtils() = delete;
-
- // Fills in |address| if |hdr| contains IP_PKTINFO or IPV6_PKTINFO. Fills in
- // |timestamp| if |hdr| contains |SO_TIMESTAMPING|. |address| and |timestamp|
- // must not be null.
- static void GetAddressAndTimestampFromMsghdr(struct msghdr* hdr,
- QuicIpAddress* address,
- QuicWallTime* walltimestamp);
-
- // If the msghdr contains an SO_RXQ_OVFL entry, this will set dropped_packets
- // to the correct value and return true. Otherwise it will return false.
- static bool GetOverflowFromMsghdr(struct msghdr* hdr,
- QuicPacketCount* dropped_packets);
-
- // If the msghdr contains an IP_TTL entry, this will set ttl to the correct
- // value and return true. Otherwise it will return false.
- static bool GetTtlFromMsghdr(struct msghdr* hdr, int* ttl);
-
- // Sets either IP_PKTINFO or IPV6_PKTINFO on the socket, based on
- // address_family. Returns the return code from setsockopt.
- static int SetGetAddressInfo(int fd, int address_family);
-
- // Sets SO_TIMESTAMPING on the socket for software receive timestamping.
- // Returns the return code from setsockopt.
- static int SetGetSoftwareReceiveTimestamp(int fd);
-
- // Sets the send buffer size to |size| and returns false if it fails.
- static bool SetSendBufferSize(int fd, size_t size);
-
- // Sets the receive buffer size to |size| and returns false if it fails.
- static bool SetReceiveBufferSize(int fd, size_t size);
-
- // Reads buf_len from the socket. If reading is successful, returns bytes
- // read and sets peer_address to the peer address. Otherwise returns -1.
- //
- // If dropped_packets is non-null, it will be set to the number of packets
- // dropped on the socket since the socket was created, assuming the kernel
- // supports this feature.
- //
- // If self_address is non-null, it will be set to the address the peer sent
- // packets to, assuming a packet was read.
- //
- // If timestamp is non-null, it will be filled with the timestamp of the
- // received packet, assuming a packet was read and the platform supports
- // packet receipt timestamping. If the platform does not support packet
- // receipt timestamping, timestamp will not be changed.
- static int ReadPacket(int fd,
- char* buffer,
- size_t buf_len,
- QuicPacketCount* dropped_packets,
- QuicIpAddress* self_address,
- QuicWallTime* walltimestamp,
- QuicSocketAddress* peer_address);
-
- // Writes buf_len to the socket. If writing is successful, sets the result's
- // status to WRITE_STATUS_OK and sets bytes_written. Otherwise sets the
- // result's status to WRITE_STATUS_BLOCKED or WRITE_STATUS_ERROR and sets
- // error_code to errno.
- static WriteResult WritePacket(int fd,
- const char* buffer,
- size_t buf_len,
- const QuicIpAddress& self_address,
- const QuicSocketAddress& peer_address);
-
- // Writes the packet in |hdr| to the socket, using ::sendmsg.
- static WriteResult WritePacket(int fd, const QuicMsgHdr& hdr);
-
- // Set IP(self_address) in |cmsg_data|. Does not touch other fields in the
- // containing cmsghdr.
- static void SetIpInfoInCmsgData(const QuicIpAddress& self_address,
- void* cmsg_data);
-
- // A helper for WritePacket which fills in the cmsg with the supplied self
- // address.
- // Returns the length of the packet info structure used.
- static size_t SetIpInfoInCmsg(const QuicIpAddress& self_address,
- cmsghdr* cmsg);
-
- // Creates a UDP socket and sets appropriate socket options for QUIC.
- // Returns the created FD if successful, -1 otherwise.
- // |overflow_supported| is set to true if the socket supports it.
- static int CreateUDPSocket(const QuicSocketAddress& address,
- int32_t receive_buffer_size,
- int32_t send_buffer_size,
- bool* overflow_supported);
-};
-
-} // namespace quic
-
-#endif // NET_QUIC_PLATFORM_IMPL_QUIC_SOCKET_UTILS_H_
diff --git a/chromium/net/quic/platform/impl/quic_socket_utils_test.cc b/chromium/net/quic/platform/impl/quic_socket_utils_test.cc
deleted file mode 100644
index 4ccc38656c5..00000000000
--- a/chromium/net/quic/platform/impl/quic_socket_utils_test.cc
+++ /dev/null
@@ -1,175 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/quic/platform/impl/quic_socket_utils.h"
-
-#include <fcntl.h>
-
-#include <array>
-
-#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h"
-#include "net/third_party/quiche/src/quic/platform/api/quic_test.h"
-
-namespace quic {
-namespace test {
-namespace {
-
-// A test fixture is used to ensure that all sockets are closed down gracefully
-// upon test completion. Also provides a convenient API to Bind not presently
-// available in QuicSocketUtils.
-class QuicSocketUtilsTest : public QuicTest {
- protected:
- ~QuicSocketUtilsTest() override {
- for (int fd : open_sockets_) {
- close(fd);
- }
- }
-
- int CreateUDPSocket(const QuicSocketAddress& address) {
- bool overflow_supported = false;
- int fd = QuicSocketUtils::CreateUDPSocket(
- address, /*receive_buffer_size =*/kDefaultSocketReceiveBuffer,
- /*send_buffer_size =*/kDefaultSocketReceiveBuffer, &overflow_supported);
- if (fd != -1) {
- open_sockets_.push_back(fd);
- }
- return fd;
- }
-
- int CreateBoundUDPSocket(QuicSocketAddress* address) {
- int fd = CreateUDPSocket(*address);
- *address = BindSocket(fd, *address);
- if (!address->IsInitialized()) {
- close(fd);
- fd = -1;
- }
- return fd;
- }
-
- QuicSocketAddress BindSocket(int fd, const QuicSocketAddress& address) {
- QuicSocketAddress bound_address;
-
- if (fd == -1) {
- return bound_address;
- }
-
- sockaddr_storage bind_addr_native = address.generic_address();
- socklen_t bind_addr_size = 0;
-
- switch (address.host().address_family()) {
- case IpAddressFamily::IP_V4:
- bind_addr_size = sizeof(struct sockaddr_in);
- break;
- case IpAddressFamily::IP_V6:
- bind_addr_size = sizeof(struct sockaddr_in6);
- break;
- case IpAddressFamily::IP_UNSPEC:
- QUIC_LOG(FATAL) << "Unspecified IP address family";
- }
-
- int rc = bind(fd, reinterpret_cast<sockaddr*>(&bind_addr_native),
- bind_addr_size);
- if (rc != 0) {
- QUIC_LOG(ERROR) << "Failed to bind socket to " << address.ToString()
- << ": " << strerror(errno);
- return bound_address;
- }
-
- rc = bound_address.FromSocket(fd);
- if (rc != 0) {
- QUIC_LOG(ERROR) << "Failed to get bound socket address from fd: "
- << strerror(errno);
- bound_address = QuicSocketAddress();
- }
- return bound_address;
- }
-
- private:
- std::vector<int> open_sockets_;
-};
-
-// This test verifies that QuicSocketUtils creates a non-blocking socket
-// successfully by seeing if a read blocks.
-TEST_F(QuicSocketUtilsTest, NonBlockingSocket) {
- std::array<char, 512> buffer;
-
- QuicIpAddress localhost = QuicIpAddress::Loopback4();
- QuicSocketAddress addr(localhost, 0);
-
- int fd = CreateUDPSocket(addr);
- ASSERT_NE(-1, fd);
-
- int fd_flags = fcntl(fd, F_GETFL, 0);
-
- // Assert so that the test errors out quickly rather than blocking below and
- // relying on timeouts.
- ASSERT_TRUE(fd_flags & O_NONBLOCK) << "Socket not reporting as non-blocking";
-
- QuicIpAddress target_server_addr;
- auto walltimestamp = QuicWallTime::Zero();
- QuicSocketAddress remote_addr;
- int bytes_read = QuicSocketUtils::ReadPacket(fd, buffer.data(), buffer.size(),
- nullptr, &target_server_addr,
- &walltimestamp, &remote_addr);
- EXPECT_EQ(-1, bytes_read);
-}
-
-// This test verifies that we can successfully WritePacket/ReadPacket between
-// two localhost sockets.
-TEST_F(QuicSocketUtilsTest, PacketRoundTrip) {
- QuicIpAddress localhost = QuicIpAddress::Loopback4();
- QuicSocketAddress client_addr(localhost, 0);
- QuicSocketAddress server_addr(localhost, 0);
-
- int server_fd = CreateBoundUDPSocket(&server_addr);
- int client_fd = CreateUDPSocket(client_addr);
-
- ASSERT_NE(-1, server_fd);
- ASSERT_NE(-1, client_fd);
-
- {
- std::array<char, 512> write_buffer;
- for (size_t i = 0; i < write_buffer.size(); i++) {
- write_buffer[i] = static_cast<char>(i);
- }
- auto res = QuicSocketUtils::WritePacket(client_fd, write_buffer.data(),
- write_buffer.size(),
- QuicIpAddress(), server_addr);
- ASSERT_EQ(WRITE_STATUS_OK, res.status)
- << "Failed to write with error " << res.error_code;
- EXPECT_EQ(512, res.bytes_written);
- }
-
- fd_set read_fds;
- FD_ZERO(&read_fds);
- FD_SET(server_fd, &read_fds);
-
- timeval select_timeout;
- select_timeout.tv_sec = 5;
- select_timeout.tv_usec = 0;
-
- int select_rc =
- select(1 + server_fd, &read_fds, nullptr, nullptr, &select_timeout);
- EXPECT_EQ(select_rc, 1) << "server_fd didn't become read selectable: "
- << errno;
-
- {
- std::array<char, 1024> read_buffer;
- QuicIpAddress target_server_addr;
- auto walltimestamp = QuicWallTime::Zero();
- QuicSocketAddress remote_addr;
- int bytes_read = QuicSocketUtils::ReadPacket(
- server_fd, read_buffer.data(), read_buffer.size(), nullptr,
- &target_server_addr, &walltimestamp, &remote_addr);
- EXPECT_EQ(512, bytes_read);
- for (int i = 0; i < bytes_read; i++) {
- EXPECT_EQ(static_cast<char>(i), read_buffer[i]);
- }
- }
-}
-
-} // namespace
-} // namespace test
-} // namespace quic
diff --git a/chromium/net/quic/platform/impl/quic_stream_buffer_allocator_impl.h b/chromium/net/quic/platform/impl/quic_stream_buffer_allocator_impl.h
index 8c2ecbf697c..f622c0cf526 100644
--- a/chromium/net/quic/platform/impl/quic_stream_buffer_allocator_impl.h
+++ b/chromium/net/quic/platform/impl/quic_stream_buffer_allocator_impl.h
@@ -13,5 +13,4 @@ using QuicStreamBufferAllocatorImpl = SimpleBufferAllocator;
} // namespace quic
-#endif /* NET_QUIC_PLATFORM_IMPL_QUIC_STREAM_BUFFER_ALLOCATOR_IMPL_H_ \
- */
+#endif // NET_QUIC_PLATFORM_IMPL_QUIC_STREAM_BUFFER_ALLOCATOR_IMPL_H_
diff --git a/chromium/net/quic/platform/impl/quic_test_impl.h b/chromium/net/quic/platform/impl/quic_test_impl.h
index 8ce1924bda0..0d9825fbae7 100644
--- a/chromium/net/quic/platform/impl/quic_test_impl.h
+++ b/chromium/net/quic/platform/impl/quic_test_impl.h
@@ -66,15 +66,6 @@ class ScopedEnvironmentForThreadsImpl {
std::string QuicGetTestMemoryCachePathImpl();
-#if GTEST_HAS_DEATH_TEST && !defined(NDEBUG)
-#define EXPECT_QUIC_DEBUG_DEATH_IMPL(condition, message) \
- EXPECT_DEBUG_DEATH(condition, message)
-#else
-#define EXPECT_QUIC_DEBUG_DEATH_IMPL(condition, message) \
- do { \
- } while (0)
-#endif
-
#define QUIC_SLOW_TEST_IMPL(name) DISABLED_##name
#endif // NET_QUIC_PLATFORM_IMPL_QUIC_TEST_IMPL_H_
diff --git a/chromium/net/quic/platform/impl/quic_testvalue_impl.h b/chromium/net/quic/platform/impl/quic_testvalue_impl.h
deleted file mode 100644
index e24ca0b1cdc..00000000000
--- a/chromium/net/quic/platform/impl/quic_testvalue_impl.h
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) 2020 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef NET_QUIC_PLATFORM_IMPL_QUIC_TESTVALUE_IMPL_H_
-#define NET_QUIC_PLATFORM_IMPL_QUIC_TESTVALUE_IMPL_H_
-
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
-
-namespace quic {
-
-template <class T>
-void AdjustTestValueImpl(absl::string_view label, T* var) {}
-
-} // namespace quic
-
-#endif // NET_QUIC_PLATFORM_IMPL_QUIC_TESTVALUE_IMPL_H_