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

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

Issue 1983183002: Landing Recent QUIC changes until 5/14/2016 02:25:25 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: "first try to fix link error for win_clang build" 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/quic/test_tools/quic_test_utils.cc ('k') | net/tools/quic/end_to_end_test.cc » ('j') | 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 CryptoMessagePrinter : public net::CryptoFramerVisitorInterface {
23 public:
24 void OnHandshakeMessage(const CryptoHandshakeMessage& message) override {
25 cout << message.DebugString() << endl;
26 }
27
28 void OnError(CryptoFramer* framer) override {
29 cerr << "Error code: " << framer->error() << endl;
30 cerr << "Error details: " << framer->error_detail() << endl;
31 }
32 };
33
34 } // namespace net
35
36 int main(int argc, char* argv[]) {
37 base::CommandLine::Init(argc, argv);
38
39 if (argc != 2) {
40 cerr << "Usage: " << argv[0] << " <hex of message>\n";
41 return 1;
42 }
43
44 net::CryptoMessagePrinter printer;
45 net::CryptoFramer framer;
46 framer.set_visitor(&printer);
47 std::string input = net::QuicUtils::HexDecode(argv[1]);
48 if (!framer.ProcessInput(input)) {
49 return 1;
50 }
51 if (framer.InputBytesRemaining() != 0) {
52 cerr << "Input partially consumed. " << framer.InputBytesRemaining()
53 << " bytes remaining." << endl;
54 return 2;
55 }
56 return 0;
57 }
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.cc ('k') | net/tools/quic/end_to_end_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698