summaryrefslogtreecommitdiffstats
path: root/net/quic/quic_framer.cc
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-24 05:55:04 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-24 05:55:04 +0000
commit8f547ea7edbf6bfd0d94dea2d9a250af0bc422ab (patch)
tree760d5072fdc4de5ea31e3a1bd7c0b71c38ee37b6 /net/quic/quic_framer.cc
parente76b24bcc99c731d5150be1d745756c0c536a138 (diff)
downloadchromium_src-8f547ea7edbf6bfd0d94dea2d9a250af0bc422ab.zip
chromium_src-8f547ea7edbf6bfd0d94dea2d9a250af0bc422ab.tar.gz
chromium_src-8f547ea7edbf6bfd0d94dea2d9a250af0bc422ab.tar.bz2
Land Recent QUIC changes.
Remove unused arguments from QuicDispatcher::CreateQuicSession. Merge internal change: 53968573 Adding the ability to simulate delay on the network as well as packet reordering in order to improve QUIC testing. Merge internal change: 53935720 Remove FLAGS_gfe2_reloadable_flag_acks_do_not_instigate_acks Merge internal change: 53924964 Added FramePackingAckResponse to QuicConnectionTest. Remove Aes128Gcm12Encrypter::IsSupported() as it is always true. Merge internal change: 53924418 Removing QUIC_VERSION_9. Merge internal change: 53923913 Plumb a mechanism for tests to specify a GUID for the client to use in QuicTestClient. Also fix a bug where the test client's auto-reconnect feature would trigger an assertion failure. Merge internal change: 53908646 Remove undefined and unused method StringToQuicTag Merge internal change: 53897915 Add tracking of stream bytes sent and received to the QuicConnectionStats. Merge internal change: 53871937 R=rch@chromium.org Review URL: https://codereview.chromium.org/38813002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230655 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/quic/quic_framer.cc')
-rw-r--r--net/quic/quic_framer.cc267
1 files changed, 59 insertions, 208 deletions
diff --git a/net/quic/quic_framer.cc b/net/quic/quic_framer.cc
index 24bde81..02ca896 100644
--- a/net/quic/quic_framer.cc
+++ b/net/quic/quic_framer.cc
@@ -72,16 +72,6 @@ const uint8 kQuicFrameTypeStreamMask = 0x80;
const uint8 kQuicFrameTypeAckMask = 0x40;
const uint8 kQuicFrameTypeCongestionFeedbackMask = 0x20;
-// Mask to determine if it's a special frame type(Stream, Ack, or
-// Congestion Control) by checking if the first bit is 0, then shifting right.
-// TODO(jri): Remove kQuicFrameType0BitMask constant from v. 10 onwards.
-// Replaced by kQuicFrameTypeStream defined above.
-const uint8 kQuicFrameType0BitMask = 0x01;
-
-// Default frame type shift and mask.
-const uint8 kQuicDefaultFrameTypeShift = 3;
-const uint8 kQuicDefaultFrameTypeMask = 0x07;
-
// Stream frame relative shifts and masks for interpreting the stream flags.
// StreamID may be 1, 2, 3, or 4 bytes.
const uint8 kQuicStreamIdShift = 2;
@@ -936,11 +926,9 @@ bool QuicFramer::ProcessFrameData() {
return RaiseError(QUIC_INVALID_FRAME_DATA);
}
- // TODO(jri): Remove this entire if block when support for
- // QUIC version < 10 removed.
- if (version() < QUIC_VERSION_10) {
- // Special frame type processing for QUIC version < 10.
- if ((frame_type & kQuicFrameType0BitMask) == 0) {
+ if (frame_type & kQuicFrameTypeSpecialMask) {
+ // Stream Frame
+ if (frame_type & kQuicFrameTypeStreamMask) {
QuicStreamFrame frame;
if (!ProcessStreamFrame(frame_type, &frame)) {
return RaiseError(QUIC_INVALID_STREAM_DATA);
@@ -953,8 +941,8 @@ bool QuicFramer::ProcessFrameData() {
continue;
}
- frame_type >>= 1;
- if ((frame_type & kQuicFrameType0BitMask) == 0) {
+ // Ack Frame
+ if (frame_type & kQuicFrameTypeAckMask) {
QuicAckFrame frame;
if (!ProcessAckFrame(&frame)) {
return RaiseError(QUIC_INVALID_ACK_DATA);
@@ -967,8 +955,8 @@ bool QuicFramer::ProcessFrameData() {
continue;
}
- frame_type >>= 1;
- if ((frame_type & kQuicFrameType0BitMask) == 0) {
+ // Congestion Feedback Frame
+ if (frame_type & kQuicFrameTypeCongestionFeedbackMask) {
QuicCongestionFeedbackFrame frame;
if (!ProcessQuicCongestionFeedbackFrame(&frame)) {
return RaiseError(QUIC_INVALID_CONGESTION_FEEDBACK_DATA);
@@ -981,178 +969,70 @@ bool QuicFramer::ProcessFrameData() {
continue;
}
- frame_type >>= 1;
- switch (frame_type) {
- // STREAM_FRAME, ACK_FRAME, and CONGESTION_FEEDBACK_FRAME are handled
- // above.
- case PADDING_FRAME_OLD:
- // We're done with the packet.
- return true;
-
- case RST_STREAM_FRAME_OLD: {
- QuicRstStreamFrame frame;
- if (!ProcessRstStreamFrame(&frame)) {
- return RaiseError(QUIC_INVALID_RST_STREAM_DATA);
- }
- if (!visitor_->OnRstStreamFrame(frame)) {
- DLOG(INFO) << "Visitor asked to stop further processing.";
- // Returning true since there was no parsing error.
- return true;
- }
- continue;
- }
-
- case CONNECTION_CLOSE_FRAME_OLD: {
- QuicConnectionCloseFrame frame;
- if (!ProcessConnectionCloseFrame(&frame)) {
- return RaiseError(QUIC_INVALID_CONNECTION_CLOSE_DATA);
- }
+ // This was a special frame type that did not match any
+ // of the known ones. Error.
+ set_detailed_error("Illegal frame type.");
+ DLOG(WARNING) << "Illegal frame type: "
+ << static_cast<int>(frame_type);
+ return RaiseError(QUIC_INVALID_FRAME_DATA);
+ }
- if (!visitor_->OnAckFrame(frame.ack_frame)) {
- DLOG(INFO) << "Visitor asked to stop further processing.";
- // Returning true since there was no parsing error.
- return true;
- }
+ switch (frame_type) {
+ case PADDING_FRAME:
+ // We're done with the packet.
+ return true;
- if (!visitor_->OnConnectionCloseFrame(frame)) {
- DLOG(INFO) << "Visitor asked to stop further processing.";
- // Returning true since there was no parsing error.
- return true;
- }
- continue;
+ case RST_STREAM_FRAME: {
+ QuicRstStreamFrame frame;
+ if (!ProcessRstStreamFrame(&frame)) {
+ return RaiseError(QUIC_INVALID_RST_STREAM_DATA);
}
-
- case GOAWAY_FRAME_OLD: {
- QuicGoAwayFrame goaway_frame;
- if (!ProcessGoAwayFrame(&goaway_frame)) {
- return RaiseError(QUIC_INVALID_GOAWAY_DATA);
- }
- if (!visitor_->OnGoAwayFrame(goaway_frame)) {
- DLOG(INFO) << "Visitor asked to stop further processing.";
- // Returning true since there was no parsing error.
- return true;
- }
- continue;
+ if (!visitor_->OnRstStreamFrame(frame)) {
+ DLOG(INFO) << "Visitor asked to stop further processing.";
+ // Returning true since there was no parsing error.
+ return true;
}
-
- set_detailed_error("Illegal frame type.");
- DLOG(WARNING) << "Illegal frame type: "
- << static_cast<int>(frame_type);
- return RaiseError(QUIC_INVALID_FRAME_DATA);
+ continue;
}
- } else {
- // TODO(jri): Retain this else block when support for
- // QUIC version < 10 removed. Remove above if block.
-
- // Special frame type processing for QUIC version >= 10.
- if (frame_type & kQuicFrameTypeSpecialMask) {
- // Stream Frame
- if (frame_type & kQuicFrameTypeStreamMask) {
- QuicStreamFrame frame;
- if (!ProcessStreamFrame(frame_type, &frame)) {
- return RaiseError(QUIC_INVALID_STREAM_DATA);
- }
- if (!visitor_->OnStreamFrame(frame)) {
- DLOG(INFO) << "Visitor asked to stop further processing.";
- // Returning true since there was no parsing error.
- return true;
- }
- continue;
- }
- // Ack Frame
- if (frame_type & kQuicFrameTypeAckMask) {
- QuicAckFrame frame;
- if (!ProcessAckFrame(&frame)) {
- return RaiseError(QUIC_INVALID_ACK_DATA);
- }
- if (!visitor_->OnAckFrame(frame)) {
- DLOG(INFO) << "Visitor asked to stop further processing.";
- // Returning true since there was no parsing error.
- return true;
- }
- continue;
+ case CONNECTION_CLOSE_FRAME: {
+ QuicConnectionCloseFrame frame;
+ if (!ProcessConnectionCloseFrame(&frame)) {
+ return RaiseError(QUIC_INVALID_CONNECTION_CLOSE_DATA);
}
- // Congestion Feedback Frame
- if (frame_type & kQuicFrameTypeCongestionFeedbackMask) {
- QuicCongestionFeedbackFrame frame;
- if (!ProcessQuicCongestionFeedbackFrame(&frame)) {
- return RaiseError(QUIC_INVALID_CONGESTION_FEEDBACK_DATA);
- }
- if (!visitor_->OnCongestionFeedbackFrame(frame)) {
- DLOG(INFO) << "Visitor asked to stop further processing.";
- // Returning true since there was no parsing error.
- return true;
- }
- continue;
+ if (!visitor_->OnAckFrame(frame.ack_frame)) {
+ DLOG(INFO) << "Visitor asked to stop further processing.";
+ // Returning true since there was no parsing error.
+ return true;
}
- // This was a special frame type that did not match any
- // of the known ones. Error.
- set_detailed_error("Illegal frame type.");
- DLOG(WARNING) << "Illegal frame type: "
- << static_cast<int>(frame_type);
- return RaiseError(QUIC_INVALID_FRAME_DATA);
- }
-
- switch (frame_type) {
- case PADDING_FRAME:
- // We're done with the packet.
+ if (!visitor_->OnConnectionCloseFrame(frame)) {
+ DLOG(INFO) << "Visitor asked to stop further processing.";
+ // Returning true since there was no parsing error.
return true;
-
- case RST_STREAM_FRAME: {
- QuicRstStreamFrame frame;
- if (!ProcessRstStreamFrame(&frame)) {
- return RaiseError(QUIC_INVALID_RST_STREAM_DATA);
- }
- if (!visitor_->OnRstStreamFrame(frame)) {
- DLOG(INFO) << "Visitor asked to stop further processing.";
- // Returning true since there was no parsing error.
- return true;
- }
- continue;
}
+ continue;
+ }
- case CONNECTION_CLOSE_FRAME: {
- QuicConnectionCloseFrame frame;
- if (!ProcessConnectionCloseFrame(&frame)) {
- return RaiseError(QUIC_INVALID_CONNECTION_CLOSE_DATA);
- }
-
- if (!visitor_->OnAckFrame(frame.ack_frame)) {
- DLOG(INFO) << "Visitor asked to stop further processing.";
- // Returning true since there was no parsing error.
- return true;
- }
-
- if (!visitor_->OnConnectionCloseFrame(frame)) {
- DLOG(INFO) << "Visitor asked to stop further processing.";
- // Returning true since there was no parsing error.
- return true;
- }
- continue;
+ case GOAWAY_FRAME: {
+ QuicGoAwayFrame goaway_frame;
+ if (!ProcessGoAwayFrame(&goaway_frame)) {
+ return RaiseError(QUIC_INVALID_GOAWAY_DATA);
}
-
- case GOAWAY_FRAME: {
- QuicGoAwayFrame goaway_frame;
- if (!ProcessGoAwayFrame(&goaway_frame)) {
- return RaiseError(QUIC_INVALID_GOAWAY_DATA);
- }
- if (!visitor_->OnGoAwayFrame(goaway_frame)) {
- DLOG(INFO) << "Visitor asked to stop further processing.";
- // Returning true since there was no parsing error.
- return true;
- }
- continue;
+ if (!visitor_->OnGoAwayFrame(goaway_frame)) {
+ DLOG(INFO) << "Visitor asked to stop further processing.";
+ // Returning true since there was no parsing error.
+ return true;
}
-
- default:
- set_detailed_error("Illegal frame type.");
- DLOG(WARNING) << "Illegal frame type: "
- << static_cast<int>(frame_type);
- return RaiseError(QUIC_INVALID_FRAME_DATA);
+ continue;
}
+
+ default:
+ set_detailed_error("Illegal frame type.");
+ DLOG(WARNING) << "Illegal frame type: "
+ << static_cast<int>(frame_type);
+ return RaiseError(QUIC_INVALID_FRAME_DATA);
}
}
@@ -1163,12 +1043,7 @@ bool QuicFramer::ProcessStreamFrame(uint8 frame_type,
QuicStreamFrame* frame) {
uint8 stream_flags = frame_type;
- // TODO(jri): Remove if block after support for ver. < 10 removed.
- if (version() < QUIC_VERSION_10) {
- stream_flags >>= 1;
- } else {
- stream_flags &= ~kQuicFrameTypeStreamMask;
- }
+ stream_flags &= ~kQuicFrameTypeStreamMask;
// Read from right to left: StreamID, Offset, Data Length, Fin.
const uint8 stream_id_length = (stream_flags & kQuicStreamIDLengthMask) + 1;
@@ -1716,45 +1591,21 @@ bool QuicFramer::AppendTypeByte(const QuicFrame& frame,
// stream id 2 bits.
type_byte <<= kQuicStreamIdShift;
type_byte |= GetStreamIdSize(frame.stream_frame->stream_id) - 1;
-
- // TODO(jri): Remove if block when support for QUIC ver. < 10 removed.
- if (version() < QUIC_VERSION_10) {
- type_byte <<= 1; // Leaves the last bit as a 0.
- } else {
- type_byte |= kQuicFrameTypeStreamMask; // Set Stream Frame Type to 1.
- }
+ type_byte |= kQuicFrameTypeStreamMask; // Set Stream Frame Type to 1.
break;
}
case ACK_FRAME: {
// TODO(ianswett): Use extra 5 bits in the ack framing.
- // TODO(jri): Remove if block when support for QUIC ver. < 10 removed.
- if (version() < QUIC_VERSION_10) {
- type_byte = 0x01;
- } else {
- type_byte = kQuicFrameTypeAckMask;
- }
+ type_byte = kQuicFrameTypeAckMask;
break;
}
case CONGESTION_FEEDBACK_FRAME: {
// TODO(ianswett): Use extra 5 bits in the congestion feedback framing.
- // TODO(jri): Remove if block when support for QUIC ver. < 10 removed.
- if (version() < QUIC_VERSION_10) {
- type_byte = 0x03;
- } else {
- type_byte = kQuicFrameTypeCongestionFeedbackMask;
- }
+ type_byte = kQuicFrameTypeCongestionFeedbackMask;
break;
}
default:
type_byte = frame.type;
- // TODO(jri): Remove if block when support for QUIC ver. < 10 removed.
- if (version() < QUIC_VERSION_10) {
- if (type_byte > 0) {
- type_byte += 3;
- }
- type_byte = (type_byte << kQuicDefaultFrameTypeShift) |
- kQuicDefaultFrameTypeMask;
- }
break;
}