Index: net/quic/quic_utils.cc |
diff --git a/net/quic/quic_utils.cc b/net/quic/quic_utils.cc |
index 2c1c24e68114a3d95de02211034f678bffeca352..2213f0bfa8ffb55e1314a6579aaffb061baf73a8 100644 |
--- a/net/quic/quic_utils.cc |
+++ b/net/quic/quic_utils.cc |
@@ -464,4 +464,19 @@ void QuicUtils::ClearSerializedPacket(SerializedPacket* serialized_packet) { |
serialized_packet->packet = nullptr; |
} |
+// static |
+uint64_t QuicUtils::PackPathIdAndPacketNumber(QuicPathId path_id, |
+ QuicPacketNumber packet_number) { |
+ // Setting the nonce below relies on QuicPathId and QuicPacketNumber being |
+ // specific sizes. |
+ static_assert(sizeof(path_id) == 1, "Size of QuicPathId changed."); |
+ static_assert(sizeof(packet_number) == 8, |
+ "Size of QuicPacketNumber changed."); |
+ // Use path_id and lower 7 bytes of packet_number as lower 8 bytes of nonce. |
+ uint64_t path_id_packet_number = |
+ (static_cast<uint64_t>(path_id) << 56) | packet_number; |
+ DCHECK(path_id != kDefaultPathId || path_id_packet_number == packet_number); |
+ return path_id_packet_number; |
+} |
+ |
} // namespace net |