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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 void QuicUtils::ClearSerializedPacket(SerializedPacket* serialized_packet) { | 457 void QuicUtils::ClearSerializedPacket(SerializedPacket* serialized_packet) { |
458 if (serialized_packet->retransmittable_frames != nullptr) { | 458 if (serialized_packet->retransmittable_frames != nullptr) { |
459 DeleteFrames(serialized_packet->retransmittable_frames); | 459 DeleteFrames(serialized_packet->retransmittable_frames); |
460 } | 460 } |
461 delete serialized_packet->retransmittable_frames; | 461 delete serialized_packet->retransmittable_frames; |
462 delete serialized_packet->packet; | 462 delete serialized_packet->packet; |
463 serialized_packet->retransmittable_frames = nullptr; | 463 serialized_packet->retransmittable_frames = nullptr; |
464 serialized_packet->packet = nullptr; | 464 serialized_packet->packet = nullptr; |
465 } | 465 } |
466 | 466 |
| 467 // static |
| 468 uint64_t QuicUtils::PackPathIdAndPacketNumber(QuicPathId path_id, |
| 469 QuicPacketNumber packet_number) { |
| 470 // Setting the nonce below relies on QuicPathId and QuicPacketNumber being |
| 471 // specific sizes. |
| 472 static_assert(sizeof(path_id) == 1, "Size of QuicPathId changed."); |
| 473 static_assert(sizeof(packet_number) == 8, |
| 474 "Size of QuicPacketNumber changed."); |
| 475 // Use path_id and lower 7 bytes of packet_number as lower 8 bytes of nonce. |
| 476 uint64_t path_id_packet_number = |
| 477 (static_cast<uint64_t>(path_id) << 56) | packet_number; |
| 478 DCHECK(path_id != kDefaultPathId || path_id_packet_number == packet_number); |
| 479 return path_id_packet_number; |
| 480 } |
| 481 |
467 } // namespace net | 482 } // namespace net |
OLD | NEW |