blob: 9eaf8f19e7cf4938e193ef1becca2f1b01ab023d [file] [log] [blame]
// Copyright (c) 2016 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.
// Decodes the packet HandshakeFailureReason from the chromium histogram
// Net.QuicClientHelloRejectReasons
#include <iostream>
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "net/third_party/quic/core/crypto/crypto_handshake.h"
#include "net/third_party/quic/core/crypto/crypto_utils.h"
using base::CommandLine;
using quic::HandshakeFailureReason;
using quic::CryptoUtils;
using quic::MAX_FAILURE_REASON;
int main(int argc, char* argv[]) {
CommandLine::Init(argc, argv);
CommandLine* line = CommandLine::ForCurrentProcess();
const CommandLine::StringVector& args = line->GetArgs();
if (args.size() != 1) {
std::cerr << "Missing argument (Usage: " << argv[0] << " <packed_reason>\n";
return 1;
}
uint32_t packed_error = 0;
if (!base::StringToUint(args[0], &packed_error)) {
std::cerr << "Unable to parse: " << args[0] << "\n";
return 2;
}
for (int i = 1; i < MAX_FAILURE_REASON; ++i) {
if ((packed_error & (1 << (i - 1))) == 0) {
continue;
}
HandshakeFailureReason reason = static_cast<HandshakeFailureReason>(i);
std::cout << CryptoUtils::HandshakeFailureReasonToString(reason) << "\n";
}
return 0;
}