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/quic_framer.h" | 5 #include "net/quic/quic_framer.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 return false; | 1487 return false; |
1488 } | 1488 } |
1489 | 1489 |
1490 uint32_t error_code; | 1490 uint32_t error_code; |
1491 if (!reader->ReadUInt32(&error_code)) { | 1491 if (!reader->ReadUInt32(&error_code)) { |
1492 set_detailed_error("Unable to read rst stream error code."); | 1492 set_detailed_error("Unable to read rst stream error code."); |
1493 return false; | 1493 return false; |
1494 } | 1494 } |
1495 | 1495 |
1496 if (error_code >= QUIC_STREAM_LAST_ERROR) { | 1496 if (error_code >= QUIC_STREAM_LAST_ERROR) { |
1497 set_detailed_error("Invalid rst stream error code."); | 1497 if (FLAGS_quic_ignore_invalid_error_code) { |
1498 return false; | 1498 // Ignore invalid stream error code if any. |
| 1499 error_code = QUIC_STREAM_LAST_ERROR; |
| 1500 } else { |
| 1501 set_detailed_error("Invalid rst stream error code."); |
| 1502 return false; |
| 1503 } |
1499 } | 1504 } |
1500 | 1505 |
1501 frame->error_code = static_cast<QuicRstStreamErrorCode>(error_code); | 1506 frame->error_code = static_cast<QuicRstStreamErrorCode>(error_code); |
1502 return true; | 1507 return true; |
1503 } | 1508 } |
1504 | 1509 |
1505 bool QuicFramer::ProcessConnectionCloseFrame(QuicDataReader* reader, | 1510 bool QuicFramer::ProcessConnectionCloseFrame(QuicDataReader* reader, |
1506 QuicConnectionCloseFrame* frame) { | 1511 QuicConnectionCloseFrame* frame) { |
1507 uint32_t error_code; | 1512 uint32_t error_code; |
1508 if (!reader->ReadUInt32(&error_code)) { | 1513 if (!reader->ReadUInt32(&error_code)) { |
1509 set_detailed_error("Unable to read connection close error code."); | 1514 set_detailed_error("Unable to read connection close error code."); |
1510 return false; | 1515 return false; |
1511 } | 1516 } |
1512 | 1517 |
1513 if (error_code >= QUIC_LAST_ERROR) { | 1518 if (error_code >= QUIC_LAST_ERROR) { |
1514 set_detailed_error("Invalid error code."); | 1519 if (FLAGS_quic_ignore_invalid_error_code) { |
1515 return false; | 1520 // Ignore invalid QUIC error code if any. |
| 1521 error_code = QUIC_LAST_ERROR; |
| 1522 } else { |
| 1523 set_detailed_error("Invalid error code."); |
| 1524 return false; |
| 1525 } |
1516 } | 1526 } |
1517 | 1527 |
1518 frame->error_code = static_cast<QuicErrorCode>(error_code); | 1528 frame->error_code = static_cast<QuicErrorCode>(error_code); |
1519 | 1529 |
1520 StringPiece error_details; | 1530 StringPiece error_details; |
1521 if (!reader->ReadStringPiece16(&error_details)) { | 1531 if (!reader->ReadStringPiece16(&error_details)) { |
1522 set_detailed_error("Unable to read connection close error details."); | 1532 set_detailed_error("Unable to read connection close error details."); |
1523 return false; | 1533 return false; |
1524 } | 1534 } |
1525 frame->error_details = error_details.as_string(); | 1535 frame->error_details = error_details.as_string(); |
1526 | 1536 |
1527 return true; | 1537 return true; |
1528 } | 1538 } |
1529 | 1539 |
1530 bool QuicFramer::ProcessGoAwayFrame(QuicDataReader* reader, | 1540 bool QuicFramer::ProcessGoAwayFrame(QuicDataReader* reader, |
1531 QuicGoAwayFrame* frame) { | 1541 QuicGoAwayFrame* frame) { |
1532 uint32_t error_code; | 1542 uint32_t error_code; |
1533 if (!reader->ReadUInt32(&error_code)) { | 1543 if (!reader->ReadUInt32(&error_code)) { |
1534 set_detailed_error("Unable to read go away error code."); | 1544 set_detailed_error("Unable to read go away error code."); |
1535 return false; | 1545 return false; |
1536 } | 1546 } |
1537 frame->error_code = static_cast<QuicErrorCode>(error_code); | |
1538 | 1547 |
1539 if (error_code >= QUIC_LAST_ERROR) { | 1548 if (error_code >= QUIC_LAST_ERROR) { |
1540 set_detailed_error("Invalid error code."); | 1549 if (FLAGS_quic_ignore_invalid_error_code) { |
1541 return false; | 1550 // Ignore invalid QUIC error code if any. |
| 1551 error_code = QUIC_LAST_ERROR; |
| 1552 } else { |
| 1553 set_detailed_error("Invalid error code."); |
| 1554 return false; |
| 1555 } |
1542 } | 1556 } |
| 1557 frame->error_code = static_cast<QuicErrorCode>(error_code); |
1543 | 1558 |
1544 uint32_t stream_id; | 1559 uint32_t stream_id; |
1545 if (!reader->ReadUInt32(&stream_id)) { | 1560 if (!reader->ReadUInt32(&stream_id)) { |
1546 set_detailed_error("Unable to read last good stream id."); | 1561 set_detailed_error("Unable to read last good stream id."); |
1547 return false; | 1562 return false; |
1548 } | 1563 } |
1549 frame->last_good_stream_id = static_cast<QuicStreamId>(stream_id); | 1564 frame->last_good_stream_id = static_cast<QuicStreamId>(stream_id); |
1550 | 1565 |
1551 StringPiece reason_phrase; | 1566 StringPiece reason_phrase; |
1552 if (!reader->ReadStringPiece16(&reason_phrase)) { | 1567 if (!reader->ReadStringPiece16(&reason_phrase)) { |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2241 | 2256 |
2242 bool QuicFramer::RaiseError(QuicErrorCode error) { | 2257 bool QuicFramer::RaiseError(QuicErrorCode error) { |
2243 DVLOG(1) << "Error: " << QuicUtils::ErrorToString(error) | 2258 DVLOG(1) << "Error: " << QuicUtils::ErrorToString(error) |
2244 << " detail: " << detailed_error_; | 2259 << " detail: " << detailed_error_; |
2245 set_error(error); | 2260 set_error(error); |
2246 visitor_->OnError(this); | 2261 visitor_->OnError(this); |
2247 return false; | 2262 return false; |
2248 } | 2263 } |
2249 | 2264 |
2250 } // namespace net | 2265 } // namespace net |
OLD | NEW |