| 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 #ifndef NET_QUIC_QUIC_FRAMER_H_ | 5 #ifndef NET_QUIC_QUIC_FRAMER_H_ |
| 6 #define NET_QUIC_QUIC_FRAMER_H_ | 6 #define NET_QUIC_QUIC_FRAMER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 // Called when a PATH_CLOSED frame has been sent/received on |path_id|. | 340 // Called when a PATH_CLOSED frame has been sent/received on |path_id|. |
| 341 void OnPathClosed(QuicPathId path_id); | 341 void OnPathClosed(QuicPathId path_id); |
| 342 | 342 |
| 343 QuicTag last_version_tag() { return last_version_tag_; } | 343 QuicTag last_version_tag() { return last_version_tag_; } |
| 344 | 344 |
| 345 private: | 345 private: |
| 346 friend class test::QuicFramerPeer; | 346 friend class test::QuicFramerPeer; |
| 347 | 347 |
| 348 typedef std::map<QuicPacketNumber, uint8_t> NackRangeMap; | 348 typedef std::map<QuicPacketNumber, uint8_t> NackRangeMap; |
| 349 | 349 |
| 350 // TODO(rch): Rename this to remove "New" from the name here, and elsewhere. | 350 struct AckFrameInfo { |
| 351 struct NewAckFrameInfo { | 351 AckFrameInfo(); |
| 352 NewAckFrameInfo(); | 352 AckFrameInfo(const AckFrameInfo& other); |
| 353 NewAckFrameInfo(const NewAckFrameInfo& other); | 353 ~AckFrameInfo(); |
| 354 ~NewAckFrameInfo(); | |
| 355 | 354 |
| 356 // The maximum ack block length. | 355 // The maximum ack block length. |
| 357 QuicPacketNumber max_block_length; | 356 QuicPacketNumber max_block_length; |
| 358 // Length of first ack block. | 357 // Length of first ack block. |
| 359 QuicPacketNumber first_block_length; | 358 QuicPacketNumber first_block_length; |
| 360 // Number of ACK blocks needed for the ACK frame. | 359 // Number of ACK blocks needed for the ACK frame. |
| 361 size_t num_ack_blocks; | 360 size_t num_ack_blocks; |
| 362 }; | 361 }; |
| 363 | 362 |
| 364 bool ProcessDataPacket(QuicDataReader* reader, | 363 bool ProcessDataPacket(QuicDataReader* reader, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 383 | 382 |
| 384 bool ProcessPathId(QuicDataReader* reader, QuicPathId* path_id); | 383 bool ProcessPathId(QuicDataReader* reader, QuicPathId* path_id); |
| 385 bool ProcessPacketSequenceNumber(QuicDataReader* reader, | 384 bool ProcessPacketSequenceNumber(QuicDataReader* reader, |
| 386 QuicPacketNumberLength packet_number_length, | 385 QuicPacketNumberLength packet_number_length, |
| 387 QuicPacketNumber base_packet_number, | 386 QuicPacketNumber base_packet_number, |
| 388 QuicPacketNumber* packet_number); | 387 QuicPacketNumber* packet_number); |
| 389 bool ProcessFrameData(QuicDataReader* reader, const QuicPacketHeader& header); | 388 bool ProcessFrameData(QuicDataReader* reader, const QuicPacketHeader& header); |
| 390 bool ProcessStreamFrame(QuicDataReader* reader, | 389 bool ProcessStreamFrame(QuicDataReader* reader, |
| 391 uint8_t frame_type, | 390 uint8_t frame_type, |
| 392 QuicStreamFrame* frame); | 391 QuicStreamFrame* frame); |
| 393 bool ProcessNewAckFrame(QuicDataReader* reader, | 392 bool ProcessAckFrame(QuicDataReader* reader, |
| 394 uint8_t frame_type, | 393 uint8_t frame_type, |
| 395 QuicAckFrame* frame); | 394 QuicAckFrame* frame); |
| 396 bool ProcessTimestampsInAckFrame(QuicDataReader* reader, QuicAckFrame* frame); | 395 bool ProcessTimestampsInAckFrame(QuicDataReader* reader, QuicAckFrame* frame); |
| 397 bool ProcessStopWaitingFrame(QuicDataReader* reader, | 396 bool ProcessStopWaitingFrame(QuicDataReader* reader, |
| 398 const QuicPacketHeader& public_header, | 397 const QuicPacketHeader& public_header, |
| 399 QuicStopWaitingFrame* stop_waiting); | 398 QuicStopWaitingFrame* stop_waiting); |
| 400 bool ProcessRstStreamFrame(QuicDataReader* reader, QuicRstStreamFrame* frame); | 399 bool ProcessRstStreamFrame(QuicDataReader* reader, QuicRstStreamFrame* frame); |
| 401 bool ProcessConnectionCloseFrame(QuicDataReader* reader, | 400 bool ProcessConnectionCloseFrame(QuicDataReader* reader, |
| 402 QuicConnectionCloseFrame* frame); | 401 QuicConnectionCloseFrame* frame); |
| 403 bool ProcessGoAwayFrame(QuicDataReader* reader, QuicGoAwayFrame* frame); | 402 bool ProcessGoAwayFrame(QuicDataReader* reader, QuicGoAwayFrame* frame); |
| 404 bool ProcessWindowUpdateFrame(QuicDataReader* reader, | 403 bool ProcessWindowUpdateFrame(QuicDataReader* reader, |
| 405 QuicWindowUpdateFrame* frame); | 404 QuicWindowUpdateFrame* frame); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 435 const QuicTime::Delta CalculateTimestampFromWire(uint32_t time_delta_us); | 434 const QuicTime::Delta CalculateTimestampFromWire(uint32_t time_delta_us); |
| 436 | 435 |
| 437 // Computes the wire size in bytes of time stamps in |ack|. | 436 // Computes the wire size in bytes of time stamps in |ack|. |
| 438 size_t GetAckFrameTimeStampSize(const QuicAckFrame& ack); | 437 size_t GetAckFrameTimeStampSize(const QuicAckFrame& ack); |
| 439 | 438 |
| 440 // Computes the wire size in bytes of the |ack| frame. | 439 // Computes the wire size in bytes of the |ack| frame. |
| 441 size_t GetAckFrameSize(const QuicAckFrame& ack, | 440 size_t GetAckFrameSize(const QuicAckFrame& ack, |
| 442 QuicPacketNumberLength packet_number_length); | 441 QuicPacketNumberLength packet_number_length); |
| 443 | 442 |
| 444 // Computes the wire size in bytes of the |ack| frame. | 443 // Computes the wire size in bytes of the |ack| frame. |
| 445 size_t GetNewAckFrameSize(const QuicAckFrame& ack); | 444 size_t GetAckFrameSize(const QuicAckFrame& ack); |
| 446 | 445 |
| 447 // Computes the wire size in bytes of the payload of |frame|. | 446 // Computes the wire size in bytes of the payload of |frame|. |
| 448 size_t ComputeFrameLength(const QuicFrame& frame, | 447 size_t ComputeFrameLength(const QuicFrame& frame, |
| 449 bool last_frame_in_packet, | 448 bool last_frame_in_packet, |
| 450 QuicPacketNumberLength packet_number_length); | 449 QuicPacketNumberLength packet_number_length); |
| 451 | 450 |
| 452 static bool AppendPacketSequenceNumber( | 451 static bool AppendPacketSequenceNumber( |
| 453 QuicPacketNumberLength packet_number_length, | 452 QuicPacketNumberLength packet_number_length, |
| 454 QuicPacketNumber packet_number, | 453 QuicPacketNumber packet_number, |
| 455 QuicDataWriter* writer); | 454 QuicDataWriter* writer); |
| 456 | 455 |
| 457 // Appends a single ACK block to |writer| and returns true if the block was | 456 // Appends a single ACK block to |writer| and returns true if the block was |
| 458 // successfully appended. | 457 // successfully appended. |
| 459 static bool AppendAckBlock(uint8_t gap, | 458 static bool AppendAckBlock(uint8_t gap, |
| 460 QuicPacketNumberLength length_length, | 459 QuicPacketNumberLength length_length, |
| 461 QuicPacketNumber length, | 460 QuicPacketNumber length, |
| 462 QuicDataWriter* writer); | 461 QuicDataWriter* writer); |
| 463 | 462 |
| 464 static uint8_t GetSequenceNumberFlags( | 463 static uint8_t GetSequenceNumberFlags( |
| 465 QuicPacketNumberLength packet_number_length); | 464 QuicPacketNumberLength packet_number_length); |
| 466 | 465 |
| 467 static NewAckFrameInfo GetNewAckFrameInfo(const QuicAckFrame& frame); | 466 static AckFrameInfo GetAckFrameInfo(const QuicAckFrame& frame); |
| 468 | 467 |
| 469 // The Append* methods attempt to write the provided header or frame using the | 468 // The Append* methods attempt to write the provided header or frame using the |
| 470 // |writer|, and return true if successful. | 469 // |writer|, and return true if successful. |
| 471 | 470 |
| 472 bool AppendNewAckFrameAndTypeByte(const QuicAckFrame& frame, | 471 bool AppendAckFrameAndTypeByte(const QuicAckFrame& frame, |
| 473 QuicDataWriter* builder); | 472 QuicDataWriter* builder); |
| 474 bool AppendTimestampToAckFrame(const QuicAckFrame& frame, | 473 bool AppendTimestampToAckFrame(const QuicAckFrame& frame, |
| 475 QuicDataWriter* builder); | 474 QuicDataWriter* builder); |
| 476 bool AppendStopWaitingFrame(const QuicPacketHeader& header, | 475 bool AppendStopWaitingFrame(const QuicPacketHeader& header, |
| 477 const QuicStopWaitingFrame& frame, | 476 const QuicStopWaitingFrame& frame, |
| 478 QuicDataWriter* builder); | 477 QuicDataWriter* builder); |
| 479 bool AppendRstStreamFrame(const QuicRstStreamFrame& frame, | 478 bool AppendRstStreamFrame(const QuicRstStreamFrame& frame, |
| 480 QuicDataWriter* builder); | 479 QuicDataWriter* builder); |
| 481 bool AppendConnectionCloseFrame(const QuicConnectionCloseFrame& frame, | 480 bool AppendConnectionCloseFrame(const QuicConnectionCloseFrame& frame, |
| 482 QuicDataWriter* builder); | 481 QuicDataWriter* builder); |
| 483 bool AppendGoAwayFrame(const QuicGoAwayFrame& frame, QuicDataWriter* writer); | 482 bool AppendGoAwayFrame(const QuicGoAwayFrame& frame, QuicDataWriter* writer); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 QuicTime::Delta last_timestamp_; | 548 QuicTime::Delta last_timestamp_; |
| 550 // The diversification nonce from the last received packet. | 549 // The diversification nonce from the last received packet. |
| 551 DiversificationNonce last_nonce_; | 550 DiversificationNonce last_nonce_; |
| 552 | 551 |
| 553 DISALLOW_COPY_AND_ASSIGN(QuicFramer); | 552 DISALLOW_COPY_AND_ASSIGN(QuicFramer); |
| 554 }; | 553 }; |
| 555 | 554 |
| 556 } // namespace net | 555 } // namespace net |
| 557 | 556 |
| 558 #endif // NET_QUIC_QUIC_FRAMER_H_ | 557 #endif // NET_QUIC_QUIC_FRAMER_H_ |
| OLD | NEW |