| 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/core/quic_framer.h" | 5 #include "net/quic/core/quic_framer.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 // The visitor suppresses further processing of the packet. | 636 // The visitor suppresses further processing of the packet. |
| 637 return true; | 637 return true; |
| 638 } | 638 } |
| 639 | 639 |
| 640 if (packet.length() > kMaxPacketSize) { | 640 if (packet.length() > kMaxPacketSize) { |
| 641 // If the packet has gotten this far, it should not be too large. | 641 // If the packet has gotten this far, it should not be too large. |
| 642 QUIC_BUG << "Packet too large:" << packet.length(); | 642 QUIC_BUG << "Packet too large:" << packet.length(); |
| 643 return RaiseError(QUIC_PACKET_TOO_LARGE); | 643 return RaiseError(QUIC_PACKET_TOO_LARGE); |
| 644 } | 644 } |
| 645 | 645 |
| 646 DCHECK(!header.fec_flag); | |
| 647 // Handle the payload. | 646 // Handle the payload. |
| 648 if (!ProcessFrameData(&reader, header)) { | 647 if (!ProcessFrameData(&reader, header)) { |
| 649 DCHECK_NE(QUIC_NO_ERROR, error_); // ProcessFrameData sets the error. | 648 DCHECK_NE(QUIC_NO_ERROR, error_); // ProcessFrameData sets the error. |
| 650 DLOG(WARNING) << "Unable to process frame data."; | 649 DLOG(WARNING) << "Unable to process frame data."; |
| 651 return false; | 650 return false; |
| 652 } | 651 } |
| 653 | 652 |
| 654 visitor_->OnPacketComplete(); | 653 visitor_->OnPacketComplete(); |
| 655 return true; | 654 return true; |
| 656 } | 655 } |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 } | 1094 } |
| 1096 | 1095 |
| 1097 bool QuicFramer::ProcessAuthenticatedHeader(QuicDataReader* reader, | 1096 bool QuicFramer::ProcessAuthenticatedHeader(QuicDataReader* reader, |
| 1098 QuicPacketHeader* header) { | 1097 QuicPacketHeader* header) { |
| 1099 uint8_t private_flags; | 1098 uint8_t private_flags; |
| 1100 if (!reader->ReadBytes(&private_flags, 1)) { | 1099 if (!reader->ReadBytes(&private_flags, 1)) { |
| 1101 set_detailed_error("Unable to read private flags."); | 1100 set_detailed_error("Unable to read private flags."); |
| 1102 return RaiseError(QUIC_INVALID_PACKET_HEADER); | 1101 return RaiseError(QUIC_INVALID_PACKET_HEADER); |
| 1103 } | 1102 } |
| 1104 | 1103 |
| 1105 if (private_flags > PACKET_PRIVATE_FLAGS_MAX_VERSION_32) { | 1104 if (private_flags > PACKET_PRIVATE_FLAGS_MAX) { |
| 1106 set_detailed_error("Illegal private flags value."); | 1105 set_detailed_error("Illegal private flags value."); |
| 1107 return RaiseError(QUIC_INVALID_PACKET_HEADER); | 1106 return RaiseError(QUIC_INVALID_PACKET_HEADER); |
| 1108 } | 1107 } |
| 1109 | 1108 |
| 1110 header->entropy_flag = (private_flags & PACKET_PRIVATE_FLAGS_ENTROPY) != 0; | 1109 header->entropy_flag = (private_flags & PACKET_PRIVATE_FLAGS_ENTROPY) != 0; |
| 1111 header->fec_flag = (private_flags & PACKET_PRIVATE_FLAGS_FEC) != 0; | |
| 1112 | |
| 1113 if ((private_flags & PACKET_PRIVATE_FLAGS_FEC_GROUP) != 0) { | |
| 1114 uint8_t first_fec_protected_packet_offset; | |
| 1115 if (!reader->ReadBytes(&first_fec_protected_packet_offset, 1)) { | |
| 1116 set_detailed_error("Unable to read first fec protected packet offset."); | |
| 1117 return RaiseError(QUIC_INVALID_PACKET_HEADER); | |
| 1118 } | |
| 1119 if (first_fec_protected_packet_offset >= header->packet_number) { | |
| 1120 set_detailed_error( | |
| 1121 "First fec protected packet offset must be less " | |
| 1122 "than the packet number."); | |
| 1123 return RaiseError(QUIC_INVALID_PACKET_HEADER); | |
| 1124 } | |
| 1125 } | |
| 1126 | |
| 1127 header->entropy_hash = GetPacketEntropyHash(*header); | 1110 header->entropy_hash = GetPacketEntropyHash(*header); |
| 1128 return true; | 1111 return true; |
| 1129 } | 1112 } |
| 1130 | 1113 |
| 1131 bool QuicFramer::ProcessPathId(QuicDataReader* reader, QuicPathId* path_id) { | 1114 bool QuicFramer::ProcessPathId(QuicDataReader* reader, QuicPathId* path_id) { |
| 1132 if (!reader->ReadBytes(path_id, 1)) { | 1115 if (!reader->ReadBytes(path_id, 1)) { |
| 1133 return false; | 1116 return false; |
| 1134 } | 1117 } |
| 1135 | 1118 |
| 1136 return true; | 1119 return true; |
| (...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2590 | 2573 |
| 2591 bool QuicFramer::RaiseError(QuicErrorCode error) { | 2574 bool QuicFramer::RaiseError(QuicErrorCode error) { |
| 2592 DVLOG(1) << "Error: " << QuicUtils::ErrorToString(error) | 2575 DVLOG(1) << "Error: " << QuicUtils::ErrorToString(error) |
| 2593 << " detail: " << detailed_error_; | 2576 << " detail: " << detailed_error_; |
| 2594 set_error(error); | 2577 set_error(error); |
| 2595 visitor_->OnError(this); | 2578 visitor_->OnError(this); |
| 2596 return false; | 2579 return false; |
| 2597 } | 2580 } |
| 2598 | 2581 |
| 2599 } // namespace net | 2582 } // namespace net |
| OLD | NEW |