| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // clang-format off | 5 // clang-format off |
| 6 | 6 |
| 7 // Dumps out the decryptable contents of a QUIC packet in a human-readable way. | 7 // Dumps out the decryptable contents of a QUIC packet in a human-readable way. |
| 8 // If the packet is null encrypted, this will dump full packet contents. | 8 // If the packet is null encrypted, this will dump full packet contents. |
| 9 // Otherwise it will dump the public header, and fail with an error that the | 9 // Otherwise it will dump the public header, and fail with an error that the |
| 10 // packet is undecryptable. | 10 // packet is undecryptable. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // OnStopWaitingFrame | 29 // OnStopWaitingFrame |
| 30 // OnConnectionCloseFrame: error_code { 61 } error_details { Unencrypted stream | 30 // OnConnectionCloseFrame: error_code { 61 } error_details { Unencrypted stream |
| 31 // data seen } | 31 // data seen } |
| 32 | 32 |
| 33 // clang-format on | 33 // clang-format on |
| 34 | 34 |
| 35 #include <iostream> | 35 #include <iostream> |
| 36 #include <string> | 36 #include <string> |
| 37 | 37 |
| 38 #include "base/command_line.h" | 38 #include "base/command_line.h" |
| 39 #include "base/strings/string_number_conversions.h" | |
| 40 #include "base/strings/utf_string_conversions.h" | |
| 41 #include "net/quic/core/quic_framer.h" | 39 #include "net/quic/core/quic_framer.h" |
| 42 #include "net/quic/core/quic_utils.h" | 40 #include "net/quic/core/quic_utils.h" |
| 41 #include "net/quic/platform/api/quic_text_utils.h" |
| 43 | 42 |
| 44 using std::cerr; | 43 using std::cerr; |
| 45 using std::string; | 44 using std::string; |
| 46 | 45 |
| 47 // If set, specify the QUIC version to use. | 46 // If set, specify the QUIC version to use. |
| 48 string FLAGS_quic_version = ""; | 47 string FLAGS_quic_version = ""; |
| 49 | 48 |
| 50 namespace { | 49 namespace { |
| 51 | 50 |
| 52 string ArgToString(base::CommandLine::StringType arg) { | 51 string ArgToString(base::CommandLine::StringType arg) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 DCHECK_EQ(ENCRYPTION_NONE, level); | 95 DCHECK_EQ(ENCRYPTION_NONE, level); |
| 97 cerr << "OnDecryptedPacket\n"; | 96 cerr << "OnDecryptedPacket\n"; |
| 98 } | 97 } |
| 99 bool OnPacketHeader(const QuicPacketHeader& header) override { | 98 bool OnPacketHeader(const QuicPacketHeader& header) override { |
| 100 cerr << "OnPacketHeader\n"; | 99 cerr << "OnPacketHeader\n"; |
| 101 return true; | 100 return true; |
| 102 } | 101 } |
| 103 bool OnStreamFrame(const QuicStreamFrame& frame) override { | 102 bool OnStreamFrame(const QuicStreamFrame& frame) override { |
| 104 cerr << "OnStreamFrame: " << frame; | 103 cerr << "OnStreamFrame: " << frame; |
| 105 cerr << " data: { " | 104 cerr << " data: { " |
| 106 << QuicUtils::HexEncode(frame.data_buffer, frame.data_length) | 105 << QuicTextUtils::HexEncode(frame.data_buffer, frame.data_length) |
| 107 << " }\n"; | 106 << " }\n"; |
| 108 return true; | 107 return true; |
| 109 } | 108 } |
| 110 bool OnAckFrame(const QuicAckFrame& frame) override { | 109 bool OnAckFrame(const QuicAckFrame& frame) override { |
| 111 cerr << "OnAckFrame: " << frame; | 110 cerr << "OnAckFrame: " << frame; |
| 112 return true; | 111 return true; |
| 113 } | 112 } |
| 114 bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) override { | 113 bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) override { |
| 115 cerr << "OnStopWaitingFrame: " << frame; | 114 cerr << "OnStopWaitingFrame: " << frame; |
| 116 return true; | 115 return true; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 net::Perspective perspective; | 173 net::Perspective perspective; |
| 175 if (perspective_string == "client") { | 174 if (perspective_string == "client") { |
| 176 perspective = net::Perspective::IS_CLIENT; | 175 perspective = net::Perspective::IS_CLIENT; |
| 177 } else if (perspective_string == "server") { | 176 } else if (perspective_string == "server") { |
| 178 perspective = net::Perspective::IS_SERVER; | 177 perspective = net::Perspective::IS_SERVER; |
| 179 } else { | 178 } else { |
| 180 cerr << "Invalid perspective. " << perspective_string | 179 cerr << "Invalid perspective. " << perspective_string |
| 181 << " Usage: " << args[0] << " client|server <hex>\n"; | 180 << " Usage: " << args[0] << " client|server <hex>\n"; |
| 182 return 1; | 181 return 1; |
| 183 } | 182 } |
| 184 string hex = net::QuicUtils::HexDecode(ArgToString(args[1])); | 183 string hex = net::QuicTextUtils::HexDecode(argv[2]); |
| 185 net::QuicVersionVector versions = net::AllSupportedVersions(); | 184 net::QuicVersionVector versions = net::AllSupportedVersions(); |
| 186 // Fake a time since we're not actually generating acks. | 185 // Fake a time since we're not actually generating acks. |
| 187 net::QuicTime start(net::QuicTime::Zero()); | 186 net::QuicTime start(net::QuicTime::Zero()); |
| 188 net::QuicFramer framer(versions, start, perspective); | 187 net::QuicFramer framer(versions, start, perspective); |
| 189 if (!FLAGS_quic_version.empty()) { | 188 if (!FLAGS_quic_version.empty()) { |
| 190 for (net::QuicVersion version : versions) { | 189 for (net::QuicVersion version : versions) { |
| 191 if (net::QuicVersionToString(version) == FLAGS_quic_version) { | 190 if (net::QuicVersionToString(version) == FLAGS_quic_version) { |
| 192 framer.set_version(version); | 191 framer.set_version(version); |
| 193 } | 192 } |
| 194 } | 193 } |
| 195 } | 194 } |
| 196 net::QuicPacketPrinter visitor(&framer); | 195 net::QuicPacketPrinter visitor(&framer); |
| 197 framer.set_visitor(&visitor); | 196 framer.set_visitor(&visitor); |
| 198 net::QuicEncryptedPacket encrypted(hex.c_str(), hex.length()); | 197 net::QuicEncryptedPacket encrypted(hex.c_str(), hex.length()); |
| 199 return framer.ProcessPacket(encrypted); | 198 return framer.ProcessPacket(encrypted); |
| 200 } | 199 } |
| OLD | NEW |