Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: net/quic/quic_packet_creator.h

Issue 1904213002: QUIC: support diversified keys with version 33. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hkdf
Patch Set: Rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_framer_test.cc ('k') | net/quic/quic_packet_creator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Accumulates frames for the next packet until more frames no longer fit or 5 // Accumulates frames for the next packet until more frames no longer fit or
6 // it's time to create a packet from them. If multipath enabled, only creates 6 // it's time to create a packet from them. If multipath enabled, only creates
7 // packets on one path at the same time. Currently, next packet number is 7 // packets on one path at the same time. Currently, next packet number is
8 // tracked per-path. 8 // tracked per-path.
9 9
10 #ifndef NET_QUIC_QUIC_PACKET_CREATOR_H_ 10 #ifndef NET_QUIC_QUIC_PACKET_CREATOR_H_
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 QuicFramer* framer, 65 QuicFramer* framer,
66 QuicRandom* random_generator, 66 QuicRandom* random_generator,
67 QuicBufferAllocator* buffer_allocator, 67 QuicBufferAllocator* buffer_allocator,
68 DelegateInterface* delegate); 68 DelegateInterface* delegate);
69 69
70 ~QuicPacketCreator(); 70 ~QuicPacketCreator();
71 71
72 // Makes the framer not serialize the protocol version in sent packets. 72 // Makes the framer not serialize the protocol version in sent packets.
73 void StopSendingVersion(); 73 void StopSendingVersion();
74 74
75 // SetDiversificationNonce sets the nonce that will be sent in each public
76 // header of packets encrypted at the initial encryption level. Should only
77 // be called by servers.
78 void SetDiversificationNonce(const DiversificationNonce nonce);
79
75 // Update the packet number length to use in future packets as soon as it 80 // Update the packet number length to use in future packets as soon as it
76 // can be safely changed. 81 // can be safely changed.
77 // TODO(fayang): Directly set packet number length instead of compute it in 82 // TODO(fayang): Directly set packet number length instead of compute it in
78 // creator. 83 // creator.
79 void UpdatePacketNumberLength(QuicPacketNumber least_packet_awaited_by_peer, 84 void UpdatePacketNumberLength(QuicPacketNumber least_packet_awaited_by_peer,
80 QuicPacketCount max_packets_in_flight); 85 QuicPacketCount max_packets_in_flight);
81 86
82 // The overhead the framing will add for a packet with one frame. 87 // The overhead the framing will add for a packet with one frame.
83 static size_t StreamFramePacketOverhead( 88 static size_t StreamFramePacketOverhead(
84 QuicConnectionIdLength connection_id_length, 89 QuicConnectionIdLength connection_id_length,
85 bool include_version, 90 bool include_version,
86 bool include_path_id, 91 bool include_path_id,
92 bool include_diversification_nonce,
87 QuicPacketNumberLength packet_number_length, 93 QuicPacketNumberLength packet_number_length,
88 QuicStreamOffset offset); 94 QuicStreamOffset offset);
89 95
90 // Returns false and flushes all pending frames if current open packet is 96 // Returns false and flushes all pending frames if current open packet is
91 // full. 97 // full.
92 // If current packet is not full, converts a raw payload into a stream frame 98 // If current packet is not full, converts a raw payload into a stream frame
93 // that fits into the open packet and adds it to the packet. 99 // that fits into the open packet and adds it to the packet.
94 // The payload begins at |iov_offset| into the |iov|. 100 // The payload begins at |iov_offset| into the |iov|.
95 bool ConsumeData(QuicStreamId id, 101 bool ConsumeData(QuicStreamId id,
96 QuicIOVector iov, 102 QuicIOVector iov,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // Fails if |buffer_len| isn't long enough for the encrypted packet. 260 // Fails if |buffer_len| isn't long enough for the encrypted packet.
255 void SerializePacket(char* encrypted_buffer, size_t buffer_len); 261 void SerializePacket(char* encrypted_buffer, size_t buffer_len);
256 262
257 // Called after a new SerialiedPacket is created to call the delegate's 263 // Called after a new SerialiedPacket is created to call the delegate's
258 // OnSerializedPacket and reset state. 264 // OnSerializedPacket and reset state.
259 void OnSerializedPacket(); 265 void OnSerializedPacket();
260 266
261 // Clears all fields of packet_ that should be cleared between serializations. 267 // Clears all fields of packet_ that should be cleared between serializations.
262 void ClearPacket(); 268 void ClearPacket();
263 269
270 // Returns true if a diversification nonce should be included in the current
271 // packet's public header.
272 bool IncludeNonceInPublicHeader();
273
264 // Does not own these delegates or the framer. 274 // Does not own these delegates or the framer.
265 DelegateInterface* delegate_; 275 DelegateInterface* delegate_;
266 DebugDelegate* debug_delegate_; 276 DebugDelegate* debug_delegate_;
267 QuicFramer* framer_; 277 QuicFramer* framer_;
268 278
269 std::unique_ptr<QuicRandomBoolSource> random_bool_source_; 279 std::unique_ptr<QuicRandomBoolSource> random_bool_source_;
270 QuicBufferAllocator* const buffer_allocator_; 280 QuicBufferAllocator* const buffer_allocator_;
271 281
272 // Controls whether version should be included while serializing the packet. 282 // Controls whether version should be included while serializing the packet.
273 bool send_version_in_packet_; 283 bool send_version_in_packet_;
274 // Controls whether path id should be included while serializing the packet. 284 // Controls whether path id should be included while serializing the packet.
275 bool send_path_id_in_packet_; 285 bool send_path_id_in_packet_;
276 // Staging variable to hold next packet number length. When sequence 286 // Staging variable to hold next packet number length. When sequence
277 // number length is to be changed, this variable holds the new length until 287 // number length is to be changed, this variable holds the new length until
278 // a packet boundary, when the creator's packet_number_length_ can be changed 288 // a packet boundary, when the creator's packet_number_length_ can be changed
279 // to this new value. 289 // to this new value.
280 QuicPacketNumberLength next_packet_number_length_; 290 QuicPacketNumberLength next_packet_number_length_;
291 // If true, then |nonce_for_public_header_| will be included in the public
292 // header of all packets created at the initial encryption level.
293 bool have_diversification_nonce_;
294 DiversificationNonce diversification_nonce_;
281 // Maximum length including headers and encryption (UDP payload length.) 295 // Maximum length including headers and encryption (UDP payload length.)
282 QuicByteCount max_packet_length_; 296 QuicByteCount max_packet_length_;
283 size_t max_plaintext_size_; 297 size_t max_plaintext_size_;
284 // Length of connection_id to send over the wire. 298 // Length of connection_id to send over the wire.
285 QuicConnectionIdLength connection_id_length_; 299 QuicConnectionIdLength connection_id_length_;
286 300
287 // Frames to be added to the next SerializedPacket 301 // Frames to be added to the next SerializedPacket
288 QuicFrames queued_frames_; 302 QuicFrames queued_frames_;
289 303
290 // packet_size should never be read directly, use PacketSize() instead. 304 // packet_size should never be read directly, use PacketSize() instead.
291 // TODO(ianswett): Move packet_size_ into SerializedPacket once 305 // TODO(ianswett): Move packet_size_ into SerializedPacket once
292 // QuicEncryptedPacket has been flattened into SerializedPacket. 306 // QuicEncryptedPacket has been flattened into SerializedPacket.
293 size_t packet_size_; 307 size_t packet_size_;
294 QuicConnectionId connection_id_; 308 QuicConnectionId connection_id_;
295 309
296 // Packet used to invoke OnSerializedPacket. 310 // Packet used to invoke OnSerializedPacket.
297 SerializedPacket packet_; 311 SerializedPacket packet_;
298 312
299 // Map mapping path_id to last sent packet number on the path. 313 // Map mapping path_id to last sent packet number on the path.
300 std::unordered_map<QuicPathId, QuicPacketNumber> multipath_packet_number_; 314 std::unordered_map<QuicPathId, QuicPacketNumber> multipath_packet_number_;
301 315
302 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator); 316 DISALLOW_COPY_AND_ASSIGN(QuicPacketCreator);
303 }; 317 };
304 318
305 } // namespace net 319 } // namespace net
306 320
307 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_ 321 #endif // NET_QUIC_QUIC_PACKET_CREATOR_H_
OLDNEW
« no previous file with comments | « net/quic/quic_framer_test.cc ('k') | net/quic/quic_packet_creator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698