| 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 "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "net/quic/crypto/crypto_framer.h" | 9 #include "net/quic/crypto/crypto_framer.h" |
| 10 #include "net/quic/crypto/crypto_handshake_message.h" | 10 #include "net/quic/crypto/crypto_handshake_message.h" |
| (...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1521 set_detailed_error("Unable to read rst stream sent byte offset."); | 1521 set_detailed_error("Unable to read rst stream sent byte offset."); |
| 1522 return false; | 1522 return false; |
| 1523 } | 1523 } |
| 1524 | 1524 |
| 1525 uint32 error_code; | 1525 uint32 error_code; |
| 1526 if (!reader_->ReadUInt32(&error_code)) { | 1526 if (!reader_->ReadUInt32(&error_code)) { |
| 1527 set_detailed_error("Unable to read rst stream error code."); | 1527 set_detailed_error("Unable to read rst stream error code."); |
| 1528 return false; | 1528 return false; |
| 1529 } | 1529 } |
| 1530 | 1530 |
| 1531 if (error_code >= QUIC_STREAM_LAST_ERROR || | 1531 if (error_code >= QUIC_STREAM_LAST_ERROR) { |
| 1532 error_code < QUIC_STREAM_NO_ERROR) { | |
| 1533 set_detailed_error("Invalid rst stream error code."); | 1532 set_detailed_error("Invalid rst stream error code."); |
| 1534 return false; | 1533 return false; |
| 1535 } | 1534 } |
| 1536 | 1535 |
| 1537 frame->error_code = static_cast<QuicRstStreamErrorCode>(error_code); | 1536 frame->error_code = static_cast<QuicRstStreamErrorCode>(error_code); |
| 1538 | 1537 |
| 1539 StringPiece error_details; | 1538 StringPiece error_details; |
| 1540 if (!reader_->ReadStringPiece16(&error_details)) { | 1539 if (!reader_->ReadStringPiece16(&error_details)) { |
| 1541 set_detailed_error("Unable to read rst stream error details."); | 1540 set_detailed_error("Unable to read rst stream error details."); |
| 1542 return false; | 1541 return false; |
| 1543 } | 1542 } |
| 1544 frame->error_details = error_details.as_string(); | 1543 frame->error_details = error_details.as_string(); |
| 1545 | 1544 |
| 1546 return true; | 1545 return true; |
| 1547 } | 1546 } |
| 1548 | 1547 |
| 1549 bool QuicFramer::ProcessConnectionCloseFrame(QuicConnectionCloseFrame* frame) { | 1548 bool QuicFramer::ProcessConnectionCloseFrame(QuicConnectionCloseFrame* frame) { |
| 1550 uint32 error_code; | 1549 uint32 error_code; |
| 1551 if (!reader_->ReadUInt32(&error_code)) { | 1550 if (!reader_->ReadUInt32(&error_code)) { |
| 1552 set_detailed_error("Unable to read connection close error code."); | 1551 set_detailed_error("Unable to read connection close error code."); |
| 1553 return false; | 1552 return false; |
| 1554 } | 1553 } |
| 1555 | 1554 |
| 1556 if (error_code >= QUIC_LAST_ERROR || | 1555 if (error_code >= QUIC_LAST_ERROR) { |
| 1557 error_code < QUIC_NO_ERROR) { | |
| 1558 set_detailed_error("Invalid error code."); | 1556 set_detailed_error("Invalid error code."); |
| 1559 return false; | 1557 return false; |
| 1560 } | 1558 } |
| 1561 | 1559 |
| 1562 frame->error_code = static_cast<QuicErrorCode>(error_code); | 1560 frame->error_code = static_cast<QuicErrorCode>(error_code); |
| 1563 | 1561 |
| 1564 StringPiece error_details; | 1562 StringPiece error_details; |
| 1565 if (!reader_->ReadStringPiece16(&error_details)) { | 1563 if (!reader_->ReadStringPiece16(&error_details)) { |
| 1566 set_detailed_error("Unable to read connection close error details."); | 1564 set_detailed_error("Unable to read connection close error details."); |
| 1567 return false; | 1565 return false; |
| 1568 } | 1566 } |
| 1569 frame->error_details = error_details.as_string(); | 1567 frame->error_details = error_details.as_string(); |
| 1570 | 1568 |
| 1571 return true; | 1569 return true; |
| 1572 } | 1570 } |
| 1573 | 1571 |
| 1574 bool QuicFramer::ProcessGoAwayFrame(QuicGoAwayFrame* frame) { | 1572 bool QuicFramer::ProcessGoAwayFrame(QuicGoAwayFrame* frame) { |
| 1575 uint32 error_code; | 1573 uint32 error_code; |
| 1576 if (!reader_->ReadUInt32(&error_code)) { | 1574 if (!reader_->ReadUInt32(&error_code)) { |
| 1577 set_detailed_error("Unable to read go away error code."); | 1575 set_detailed_error("Unable to read go away error code."); |
| 1578 return false; | 1576 return false; |
| 1579 } | 1577 } |
| 1580 frame->error_code = static_cast<QuicErrorCode>(error_code); | 1578 frame->error_code = static_cast<QuicErrorCode>(error_code); |
| 1581 | 1579 |
| 1582 if (error_code >= QUIC_LAST_ERROR || | 1580 if (error_code >= QUIC_LAST_ERROR) { |
| 1583 error_code < QUIC_NO_ERROR) { | |
| 1584 set_detailed_error("Invalid error code."); | 1581 set_detailed_error("Invalid error code."); |
| 1585 return false; | 1582 return false; |
| 1586 } | 1583 } |
| 1587 | 1584 |
| 1588 uint32 stream_id; | 1585 uint32 stream_id; |
| 1589 if (!reader_->ReadUInt32(&stream_id)) { | 1586 if (!reader_->ReadUInt32(&stream_id)) { |
| 1590 set_detailed_error("Unable to read last good stream id."); | 1587 set_detailed_error("Unable to read last good stream id."); |
| 1591 return false; | 1588 return false; |
| 1592 } | 1589 } |
| 1593 frame->last_good_stream_id = static_cast<QuicStreamId>(stream_id); | 1590 frame->last_good_stream_id = static_cast<QuicStreamId>(stream_id); |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2316 | 2313 |
| 2317 bool QuicFramer::RaiseError(QuicErrorCode error) { | 2314 bool QuicFramer::RaiseError(QuicErrorCode error) { |
| 2318 DVLOG(1) << "Error detail: " << detailed_error_; | 2315 DVLOG(1) << "Error detail: " << detailed_error_; |
| 2319 set_error(error); | 2316 set_error(error); |
| 2320 visitor_->OnError(this); | 2317 visitor_->OnError(this); |
| 2321 reader_.reset(nullptr); | 2318 reader_.reset(nullptr); |
| 2322 return false; | 2319 return false; |
| 2323 } | 2320 } |
| 2324 | 2321 |
| 2325 } // namespace net | 2322 } // namespace net |
| OLD | NEW |