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

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

Issue 2603723002: Add a new QUIC platform API for text utilities. (Closed)
Patch Set: Tests Created 3 years, 11 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
OLDNEW
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 // Dumps the contents of a QUIC crypto handshake message in a human readable 5 // Dumps the contents of a QUIC crypto handshake message in a human readable
6 // format. 6 // format.
7 // 7 //
8 // Usage: crypto_message_printer_bin <hex of message> 8 // Usage: crypto_message_printer_bin <hex of message>
9 9
10 #include <iostream> 10 #include <iostream>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "net/quic/core/crypto/crypto_framer.h" 13 #include "net/quic/core/crypto/crypto_framer.h"
14 #include "net/quic/core/quic_utils.h" 14 #include "net/quic/platform/api/quic_text_utils.h"
15 15
16 using std::cerr; 16 using std::cerr;
17 using std::cout; 17 using std::cout;
18 using std::endl; 18 using std::endl;
19 19
20 namespace net { 20 namespace net {
21 21
22 class CryptoMessagePrinter : public net::CryptoFramerVisitorInterface { 22 class CryptoMessagePrinter : public net::CryptoFramerVisitorInterface {
23 public: 23 public:
24 void OnHandshakeMessage(const CryptoHandshakeMessage& message) override { 24 void OnHandshakeMessage(const CryptoHandshakeMessage& message) override {
(...skipping 12 matching lines...) Expand all
37 base::CommandLine::Init(argc, argv); 37 base::CommandLine::Init(argc, argv);
38 38
39 if (argc != 2) { 39 if (argc != 2) {
40 cerr << "Usage: " << argv[0] << " <hex of message>\n"; 40 cerr << "Usage: " << argv[0] << " <hex of message>\n";
41 return 1; 41 return 1;
42 } 42 }
43 43
44 net::CryptoMessagePrinter printer; 44 net::CryptoMessagePrinter printer;
45 net::CryptoFramer framer; 45 net::CryptoFramer framer;
46 framer.set_visitor(&printer); 46 framer.set_visitor(&printer);
47 std::string input = net::QuicUtils::HexDecode(argv[1]); 47 std::string input = net::QuicTextUtils::HexDecode(argv[1]);
48 if (!framer.ProcessInput(input)) { 48 if (!framer.ProcessInput(input)) {
49 return 1; 49 return 1;
50 } 50 }
51 if (framer.InputBytesRemaining() != 0) { 51 if (framer.InputBytesRemaining() != 0) {
52 cerr << "Input partially consumed. " << framer.InputBytesRemaining() 52 cerr << "Input partially consumed. " << framer.InputBytesRemaining()
53 << " bytes remaining." << endl; 53 << " bytes remaining." << endl;
54 return 2; 54 return 2;
55 } 55 }
56 return 0; 56 return 0;
57 } 57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698