Chromium Code Reviews| Index: net/quic/crypto/source_address_token.cc |
| diff --git a/net/quic/crypto/source_address_token.cc b/net/quic/crypto/source_address_token.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d664a082cb23d0ac7600d13a3c0fd90b1e0045ba |
| --- /dev/null |
| +++ b/net/quic/crypto/source_address_token.cc |
| @@ -0,0 +1,46 @@ |
| +// Copyright (c) 2013 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. |
| + |
| +#include "net/quic/crypto/source_address_token.h" |
| + |
| +#include <vector> |
| + |
| +#include "base/strings/string_number_conversions.h" |
| +#include "base/strings/string_split.h" |
| + |
| +using std::string; |
| +using std::vector; |
| + |
| +namespace net { |
| + |
| +SourceAddressToken::SourceAddressToken() { |
|
Nico
2015/03/08 02:41:40
This doesn't set timestamp_. Is that intentional?
ramant (doing other things)
2015/03/08 23:26:53
Good point. Will upload a change asap.
thanks
ram
ramant (doing other things)
2015/03/09 00:01:46
Uploaded https://codereview.chromium.org/985383003
|
| +} |
| + |
| +SourceAddressToken::~SourceAddressToken() { |
| +} |
| + |
| +string SourceAddressToken::SerializeAsString() const { |
| + return ip_ + " " + base::Int64ToString(timestamp_); |
| +} |
| + |
| +bool SourceAddressToken::ParseFromArray(unsigned char* plaintext, |
| + size_t plaintext_length) { |
| + string data(reinterpret_cast<const char*>(plaintext), plaintext_length); |
| + vector<string> results; |
| + base::SplitString(data, ' ', &results); |
| + if (results.size() < 2) { |
| + return false; |
| + } |
| + |
| + int64 timestamp; |
| + if (!base::StringToInt64(results[1], ×tamp)) { |
| + return false; |
| + } |
| + |
| + ip_ = results[0]; |
| + timestamp_ = timestamp; |
| + return true; |
| +} |
| + |
| +} // namespace net |