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" | 39 #include "base/strings/utf_string_conversions.h" |
41 #include "net/quic/core/quic_framer.h" | 40 #include "net/quic/core/quic_framer.h" |
42 #include "net/quic/core/quic_utils.h" | 41 #include "net/quic/core/quic_utils.h" |
| 42 #include "net/quic/platform/api/quic_text_utils.h" |
43 | 43 |
44 using std::cerr; | 44 using std::cerr; |
45 using std::string; | 45 using std::string; |
46 | 46 |
47 // If set, specify the QUIC version to use. | 47 // If set, specify the QUIC version to use. |
48 string FLAGS_quic_version = ""; | 48 string FLAGS_quic_version = ""; |
49 | 49 |
50 namespace { | 50 namespace { |
51 | 51 |
52 string ArgToString(base::CommandLine::StringType arg) { | 52 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); | 96 DCHECK_EQ(ENCRYPTION_NONE, level); |
97 cerr << "OnDecryptedPacket\n"; | 97 cerr << "OnDecryptedPacket\n"; |
98 } | 98 } |
99 bool OnPacketHeader(const QuicPacketHeader& header) override { | 99 bool OnPacketHeader(const QuicPacketHeader& header) override { |
100 cerr << "OnPacketHeader\n"; | 100 cerr << "OnPacketHeader\n"; |
101 return true; | 101 return true; |
102 } | 102 } |
103 bool OnStreamFrame(const QuicStreamFrame& frame) override { | 103 bool OnStreamFrame(const QuicStreamFrame& frame) override { |
104 cerr << "OnStreamFrame: " << frame; | 104 cerr << "OnStreamFrame: " << frame; |
105 cerr << " data: { " | 105 cerr << " data: { " |
106 << QuicUtils::HexEncode(frame.data_buffer, frame.data_length) | 106 << QuicTextUtils::HexEncode(frame.data_buffer, frame.data_length) |
107 << " }\n"; | 107 << " }\n"; |
108 return true; | 108 return true; |
109 } | 109 } |
110 bool OnAckFrame(const QuicAckFrame& frame) override { | 110 bool OnAckFrame(const QuicAckFrame& frame) override { |
111 cerr << "OnAckFrame: " << frame; | 111 cerr << "OnAckFrame: " << frame; |
112 return true; | 112 return true; |
113 } | 113 } |
114 bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) override { | 114 bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) override { |
115 cerr << "OnStopWaitingFrame: " << frame; | 115 cerr << "OnStopWaitingFrame: " << frame; |
116 return true; | 116 return true; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 net::Perspective perspective; | 174 net::Perspective perspective; |
175 if (perspective_string == "client") { | 175 if (perspective_string == "client") { |
176 perspective = net::Perspective::IS_CLIENT; | 176 perspective = net::Perspective::IS_CLIENT; |
177 } else if (perspective_string == "server") { | 177 } else if (perspective_string == "server") { |
178 perspective = net::Perspective::IS_SERVER; | 178 perspective = net::Perspective::IS_SERVER; |
179 } else { | 179 } else { |
180 cerr << "Invalid perspective. " << perspective_string | 180 cerr << "Invalid perspective. " << perspective_string |
181 << " Usage: " << args[0] << " client|server <hex>\n"; | 181 << " Usage: " << args[0] << " client|server <hex>\n"; |
182 return 1; | 182 return 1; |
183 } | 183 } |
184 string hex = net::QuicUtils::HexDecode(ArgToString(args[1])); | 184 string hex = net::QuicTextUtils::HexDecode(argv[2]); |
185 net::QuicVersionVector versions = net::AllSupportedVersions(); | 185 net::QuicVersionVector versions = net::AllSupportedVersions(); |
186 // Fake a time since we're not actually generating acks. | 186 // Fake a time since we're not actually generating acks. |
187 net::QuicTime start(net::QuicTime::Zero()); | 187 net::QuicTime start(net::QuicTime::Zero()); |
188 net::QuicFramer framer(versions, start, perspective); | 188 net::QuicFramer framer(versions, start, perspective); |
189 if (!FLAGS_quic_version.empty()) { | 189 if (!FLAGS_quic_version.empty()) { |
190 for (net::QuicVersion version : versions) { | 190 for (net::QuicVersion version : versions) { |
191 if (net::QuicVersionToString(version) == FLAGS_quic_version) { | 191 if (net::QuicVersionToString(version) == FLAGS_quic_version) { |
192 framer.set_version(version); | 192 framer.set_version(version); |
193 } | 193 } |
194 } | 194 } |
195 } | 195 } |
196 net::QuicPacketPrinter visitor(&framer); | 196 net::QuicPacketPrinter visitor(&framer); |
197 framer.set_visitor(&visitor); | 197 framer.set_visitor(&visitor); |
198 net::QuicEncryptedPacket encrypted(hex.c_str(), hex.length()); | 198 net::QuicEncryptedPacket encrypted(hex.c_str(), hex.length()); |
199 return framer.ProcessPacket(encrypted); | 199 return framer.ProcessPacket(encrypted); |
200 } | 200 } |
OLD | NEW |