Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: net/tools/quic/crypto_message_printer_bin.cc

Issue 1982823002: Add a command line tool for printing QUIC crypto handshake messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include newly added file Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/net.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Dumps the contents of a QUIC crypto handshake message in a human readable
6 // format.
7 //
8 // Usage: crypto_message_printer_bin <hex of message>
9
10 #include <iostream>
11
12 #include "base/command_line.h"
13 #include "net/quic/crypto/crypto_framer.h"
14 #include "net/quic/quic_utils.h"
15
16 using std::cerr;
17 using std::cout;
18 using std::endl;
19
20 namespace net {
21
22 class NET_EXPORT_PRIVATE CryptoMessagePrinter
23 : public net::CryptoFramerVisitorInterface {
24 public:
25 void OnHandshakeMessage(const CryptoHandshakeMessage& message) override {
26 cout << message.DebugString() << endl;
27 }
28
29 void OnError(CryptoFramer* framer) override {
30 cerr << "Error code: " << framer->error() << endl;
31 cerr << "Error details: " << framer->error_detail() << endl;
32 }
33 };
34
35 } // namespace net
36
37 int main(int argc, char* argv[]) {
38 base::CommandLine::Init(argc, argv);
39
40 if (argc != 2) {
41 cerr << "Usage: " << argv[0] << " <hex of message>\n";
42 return 1;
43 }
44
45 net::CryptoMessagePrinter printer;
46 net::CryptoFramer framer;
47 framer.set_visitor(&printer);
48 std::string input = net::QuicUtils::HexDecode(argv[1]);
49 if (!framer.ProcessInput(input)) {
50 return 1;
51 }
52 if (framer.InputBytesRemaining() != 0) {
53 cerr << "Input partially consumed. " << framer.InputBytesRemaining()
54 << " bytes remaining." << endl;
55 return 2;
56 }
57 return 0;
58 }
OLDNEW
« no previous file with comments | « net/net.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698