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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/crypto_message_printer_bin.cc
diff --git a/net/tools/quic/crypto_message_printer_bin.cc b/net/tools/quic/crypto_message_printer_bin.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e6813c4a3c6f02ec6acda06d8ee093994bab130e
--- /dev/null
+++ b/net/tools/quic/crypto_message_printer_bin.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Dumps the contents of a QUIC crypto handshake message in a human readable
+// format.
+//
+// Usage: crypto_message_printer_bin <hex of message>
+
+#include <iostream>
+
+#include "base/command_line.h"
+#include "net/quic/crypto/crypto_framer.h"
+#include "net/quic/quic_utils.h"
+
+using std::cerr;
+using std::cout;
+using std::endl;
+
+namespace net {
+
+class CryptoMessagePrinter : public net::CryptoFramerVisitorInterface {
+ public:
+ void OnHandshakeMessage(const CryptoHandshakeMessage& message) override {
+ cout << message.DebugString() << endl;
+ }
+
+ void OnError(CryptoFramer* framer) override {
+ cerr << "Error code: " << framer->error() << endl;
+ cerr << "Error details: " << framer->error_detail() << endl;
+ }
+};
+
+} // namespace net
+
+int main(int argc, char* argv[]) {
+ base::CommandLine::Init(argc, argv);
+
+ if (argc != 2) {
+ cerr << "Usage: " << argv[0] << " <hex of message>\n";
+ return 1;
+ }
+
+ net::CryptoMessagePrinter printer;
+ net::CryptoFramer framer;
+ framer.set_visitor(&printer);
+ std::string input = net::QuicUtils::HexDecode(argv[1]);
+ if (!framer.ProcessInput(input)) {
+ return 1;
+ }
+ if (framer.InputBytesRemaining() != 0) {
+ cerr << "Input partially consumed. " << framer.InputBytesRemaining()
+ << " bytes remaining." << endl;
+ return 2;
+ }
+ return 0;
+}
« 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