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/quic_utils.h" | 5 #include "net/quic/quic_utils.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 RETURN_STRING_LITERAL(QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP); | 244 RETURN_STRING_LITERAL(QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP); |
245 RETURN_STRING_LITERAL(QUIC_CRYPTO_MESSAGE_INDEX_NOT_FOUND); | 245 RETURN_STRING_LITERAL(QUIC_CRYPTO_MESSAGE_INDEX_NOT_FOUND); |
246 RETURN_STRING_LITERAL(QUIC_INVALID_STREAM_ID); | 246 RETURN_STRING_LITERAL(QUIC_INVALID_STREAM_ID); |
247 RETURN_STRING_LITERAL(QUIC_INVALID_PRIORITY); | 247 RETURN_STRING_LITERAL(QUIC_INVALID_PRIORITY); |
248 RETURN_STRING_LITERAL(QUIC_TOO_MANY_OPEN_STREAMS); | 248 RETURN_STRING_LITERAL(QUIC_TOO_MANY_OPEN_STREAMS); |
249 RETURN_STRING_LITERAL(QUIC_PUBLIC_RESET); | 249 RETURN_STRING_LITERAL(QUIC_PUBLIC_RESET); |
250 RETURN_STRING_LITERAL(QUIC_INVALID_VERSION); | 250 RETURN_STRING_LITERAL(QUIC_INVALID_VERSION); |
251 RETURN_STRING_LITERAL(QUIC_INVALID_HEADER_ID); | 251 RETURN_STRING_LITERAL(QUIC_INVALID_HEADER_ID); |
252 RETURN_STRING_LITERAL(QUIC_INVALID_NEGOTIATED_VALUE); | 252 RETURN_STRING_LITERAL(QUIC_INVALID_NEGOTIATED_VALUE); |
253 RETURN_STRING_LITERAL(QUIC_DECOMPRESSION_FAILURE); | 253 RETURN_STRING_LITERAL(QUIC_DECOMPRESSION_FAILURE); |
254 RETURN_STRING_LITERAL(QUIC_CONNECTION_TIMED_OUT); | 254 RETURN_STRING_LITERAL(QUIC_NETWORK_IDLE_TIMEOUT); |
255 RETURN_STRING_LITERAL(QUIC_CONNECTION_OVERALL_TIMED_OUT); | 255 RETURN_STRING_LITERAL(QUIC_HANDSHAKE_TIMEOUT); |
256 RETURN_STRING_LITERAL(QUIC_ERROR_MIGRATING_ADDRESS); | 256 RETURN_STRING_LITERAL(QUIC_ERROR_MIGRATING_ADDRESS); |
257 RETURN_STRING_LITERAL(QUIC_PACKET_WRITE_ERROR); | 257 RETURN_STRING_LITERAL(QUIC_PACKET_WRITE_ERROR); |
258 RETURN_STRING_LITERAL(QUIC_PACKET_READ_ERROR); | 258 RETURN_STRING_LITERAL(QUIC_PACKET_READ_ERROR); |
259 RETURN_STRING_LITERAL(QUIC_INVALID_STREAM_FRAME); | 259 RETURN_STRING_LITERAL(QUIC_INVALID_STREAM_FRAME); |
260 RETURN_STRING_LITERAL(QUIC_INVALID_HEADERS_STREAM_DATA); | 260 RETURN_STRING_LITERAL(QUIC_INVALID_HEADERS_STREAM_DATA); |
261 RETURN_STRING_LITERAL(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA); | 261 RETURN_STRING_LITERAL(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA); |
262 RETURN_STRING_LITERAL(QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA); | 262 RETURN_STRING_LITERAL(QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA); |
263 RETURN_STRING_LITERAL(QUIC_FLOW_CONTROL_INVALID_WINDOW); | 263 RETURN_STRING_LITERAL(QUIC_FLOW_CONTROL_INVALID_WINDOW); |
264 RETURN_STRING_LITERAL(QUIC_CONNECTION_IP_POOLED); | 264 RETURN_STRING_LITERAL(QUIC_CONNECTION_IP_POOLED); |
265 RETURN_STRING_LITERAL(QUIC_PROOF_INVALID); | 265 RETURN_STRING_LITERAL(QUIC_PROOF_INVALID); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 delete it->stream_frame; | 452 delete it->stream_frame; |
453 it = frames->erase(it); | 453 it = frames->erase(it); |
454 } | 454 } |
455 } | 455 } |
456 | 456 |
457 // static | 457 // static |
458 void QuicUtils::ClearSerializedPacket(SerializedPacket* serialized_packet) { | 458 void QuicUtils::ClearSerializedPacket(SerializedPacket* serialized_packet) { |
459 if (!serialized_packet->retransmittable_frames.empty()) { | 459 if (!serialized_packet->retransmittable_frames.empty()) { |
460 DeleteFrames(&serialized_packet->retransmittable_frames); | 460 DeleteFrames(&serialized_packet->retransmittable_frames); |
461 } | 461 } |
462 delete serialized_packet->packet; | 462 serialized_packet->encrypted_buffer = nullptr; |
463 serialized_packet->packet = nullptr; | 463 serialized_packet->encrypted_length = 0; |
464 } | 464 } |
465 | 465 |
466 // static | 466 // static |
467 uint64_t QuicUtils::PackPathIdAndPacketNumber(QuicPathId path_id, | 467 uint64_t QuicUtils::PackPathIdAndPacketNumber(QuicPathId path_id, |
468 QuicPacketNumber packet_number) { | 468 QuicPacketNumber packet_number) { |
469 // Setting the nonce below relies on QuicPathId and QuicPacketNumber being | 469 // Setting the nonce below relies on QuicPathId and QuicPacketNumber being |
470 // specific sizes. | 470 // specific sizes. |
471 static_assert(sizeof(path_id) == 1, "Size of QuicPathId changed."); | 471 static_assert(sizeof(path_id) == 1, "Size of QuicPathId changed."); |
472 static_assert(sizeof(packet_number) == 8, | 472 static_assert(sizeof(packet_number) == 8, |
473 "Size of QuicPacketNumber changed."); | 473 "Size of QuicPacketNumber changed."); |
474 // Use path_id and lower 7 bytes of packet_number as lower 8 bytes of nonce. | 474 // Use path_id and lower 7 bytes of packet_number as lower 8 bytes of nonce. |
475 uint64_t path_id_packet_number = | 475 uint64_t path_id_packet_number = |
476 (static_cast<uint64_t>(path_id) << 56) | packet_number; | 476 (static_cast<uint64_t>(path_id) << 56) | packet_number; |
477 DCHECK(path_id != kDefaultPathId || path_id_packet_number == packet_number); | 477 DCHECK(path_id != kDefaultPathId || path_id_packet_number == packet_number); |
478 return path_id_packet_number; | 478 return path_id_packet_number; |
479 } | 479 } |
480 | 480 |
| 481 char* QuicUtils::CopyBuffer(const SerializedPacket& packet) { |
| 482 char* dst_buffer = new char[packet.encrypted_length]; |
| 483 memcpy(dst_buffer, packet.encrypted_buffer, packet.encrypted_length); |
| 484 return dst_buffer; |
| 485 } |
| 486 |
481 } // namespace net | 487 } // namespace net |
OLD | NEW |