// 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. // clang-format off // Dumps out the decryptable contents of a QUIC packet in a human-readable way. // If the packet is null encrypted, this will dump full packet contents. // Otherwise it will dump the header, and fail with an error that the // packet is undecryptable. // // Usage: quic_packet_printer server|client <hex dump of packet> // // Example input: // quic_packet_printer server 0c6b810308320f24c004a939a38a2e3fd6ca589917f200400201b80b0100501c0700060003023d0000001c00556e656e637279707465642073747265616d2064617461207365656e // // Example output: // OnPacket // OnUnauthenticatedPublicHeader // OnUnauthenticatedHeader: { connection_id: 13845207862000976235, connection_id_length:8, packet_number_length:1, multipath_flag: 0, reset_flag: 0, version_flag: 0, path_id: , packet_number: 4 } // OnDecryptedPacket // OnPacketHeader // OnAckFrame: largest_observed: 1 ack_delay_time: 3000 missing_packets: [ ] is_truncated: 0 received_packets: [ 1 at 466016 ] // OnStopWaitingFrame // OnConnectionCloseFrame: error_code { 61 } error_details { Unencrypted stream data seen } // clang-format on #include <iostream> #include <memory> #include <optional> #include <string> #include <vector> #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" #include "quiche/quic/core/quic_framer.h" #include "quiche/quic/core/quic_types.h" #include "quiche/quic/core/quic_utils.h" #include "quiche/quic/platform/api/quic_flags.h" #include "quiche/common/platform/api/quiche_command_line_flags.h" #include "quiche/common/quiche_text_utils.h" DEFINE_QUICHE_COMMAND_LINE_FLAG(…); namespace quic { class QuicPacketPrinter : public QuicFramerVisitorInterface { … }; } // namespace quic int main(int argc, char* argv[]) { … }