1 // Copyright 2023 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef QUICHE_QUIC_TEST_TOOLS_IP_PACKET_GENERATION_H_ 6 #define QUICHE_QUIC_TEST_TOOLS_IP_PACKET_GENERATION_H_ 7 8 #include <string> 9 10 #include "absl/strings/string_view.h" 11 #include "quiche/quic/platform/api/quic_socket_address.h" 12 #include "quiche/common/quiche_ip_address.h" 13 14 namespace quic::test { 15 16 enum class IpPacketPayloadType { 17 kUdp, 18 }; 19 20 // Create an IP packet, appropriate for sending to a raw IP socket. 21 std::string CreateIpPacket( 22 const quiche::QuicheIpAddress& source_address, 23 const quiche::QuicheIpAddress& destination_address, 24 absl::string_view payload, 25 IpPacketPayloadType payload_type = IpPacketPayloadType::kUdp); 26 27 // Create a UDP packet, appropriate for sending to a raw UDP socket or including 28 // as the payload of an IP packet. 29 std::string CreateUdpPacket(const QuicSocketAddress& source_address, 30 const QuicSocketAddress& destination_address, 31 absl::string_view payload); 32 33 } // namespace quic::test 34 35 #endif // QUICHE_QUIC_TEST_TOOLS_IP_PACKET_GENERATION_H_ 36