OLD | NEW |
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 #include "net/quic/core/quic_packets.h" | 5 #include "net/quic/core/quic_packets.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "net/quic/core/quic_flags.h" | 8 #include "net/quic/core/quic_flags.h" |
9 #include "net/quic/core/quic_utils.h" | 9 #include "net/quic/core/quic_utils.h" |
10 #include "net/quic/core/quic_versions.h" | 10 #include "net/quic/core/quic_versions.h" |
| 11 #include "net/quic/platform/api/quic_str_cat.h" |
| 12 #include "net/quic/platform/api/quic_text_utils.h" |
11 | 13 |
12 using base::StringPiece; | 14 using base::StringPiece; |
13 using std::string; | 15 using std::string; |
14 | 16 |
15 namespace net { | 17 namespace net { |
16 | 18 |
17 size_t GetPacketHeaderSize(QuicVersion version, | 19 size_t GetPacketHeaderSize(QuicVersion version, |
18 const QuicPacketHeader& header) { | 20 const QuicPacketHeader& header) { |
19 return GetPacketHeaderSize(version, header.public_header.connection_id_length, | 21 return GetPacketHeaderSize(version, header.public_header.connection_id_length, |
20 header.public_header.version_flag, | 22 header.public_header.version_flag, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 << ", version_flag: " << header.public_header.version_flag; | 92 << ", version_flag: " << header.public_header.version_flag; |
91 if (header.public_header.version_flag) { | 93 if (header.public_header.version_flag) { |
92 os << ", version:"; | 94 os << ", version:"; |
93 for (size_t i = 0; i < header.public_header.versions.size(); ++i) { | 95 for (size_t i = 0; i < header.public_header.versions.size(); ++i) { |
94 os << " "; | 96 os << " "; |
95 os << QuicVersionToString(header.public_header.versions[i]); | 97 os << QuicVersionToString(header.public_header.versions[i]); |
96 } | 98 } |
97 } | 99 } |
98 if (header.public_header.nonce != nullptr) { | 100 if (header.public_header.nonce != nullptr) { |
99 os << ", diversification_nonce: " | 101 os << ", diversification_nonce: " |
100 << QuicUtils::HexEncode(StringPiece(header.public_header.nonce->data(), | 102 << QuicTextUtils::HexEncode( |
101 header.public_header.nonce->size())); | 103 StringPiece(header.public_header.nonce->data(), |
| 104 header.public_header.nonce->size())); |
102 } | 105 } |
103 os << ", path_id: " << static_cast<int>(header.path_id) | 106 os << ", path_id: " << static_cast<int>(header.path_id) |
104 << ", packet_number: " << header.packet_number << " }\n"; | 107 << ", packet_number: " << header.packet_number << " }\n"; |
105 return os; | 108 return os; |
106 } | 109 } |
107 | 110 |
108 QuicData::QuicData(const char* buffer, size_t length) | 111 QuicData::QuicData(const char* buffer, size_t length) |
109 : buffer_(buffer), length_(length), owns_buffer_(false) {} | 112 : buffer_(buffer), length_(length), owns_buffer_(false) {} |
110 | 113 |
111 QuicData::QuicData(const char* buffer, size_t length, bool owns_buffer) | 114 QuicData::QuicData(const char* buffer, size_t length, bool owns_buffer) |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 serialized_packet->encrypted_length = 0; | 241 serialized_packet->encrypted_length = 0; |
239 } | 242 } |
240 | 243 |
241 char* CopyBuffer(const SerializedPacket& packet) { | 244 char* CopyBuffer(const SerializedPacket& packet) { |
242 char* dst_buffer = new char[packet.encrypted_length]; | 245 char* dst_buffer = new char[packet.encrypted_length]; |
243 memcpy(dst_buffer, packet.encrypted_buffer, packet.encrypted_length); | 246 memcpy(dst_buffer, packet.encrypted_buffer, packet.encrypted_length); |
244 return dst_buffer; | 247 return dst_buffer; |
245 } | 248 } |
246 | 249 |
247 } // namespace net | 250 } // namespace net |
OLD | NEW |