| 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_packet_creator.h" | 5 #include "net/quic/core/quic_packet_creator.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstdint> | 8 #include <cstdint> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 } | 616 } |
| 617 | 617 |
| 618 bool QuicPacketCreator::IncludeNonceInPublicHeader() { | 618 bool QuicPacketCreator::IncludeNonceInPublicHeader() { |
| 619 return have_diversification_nonce_ && | 619 return have_diversification_nonce_ && |
| 620 packet_.encryption_level == ENCRYPTION_INITIAL; | 620 packet_.encryption_level == ENCRYPTION_INITIAL; |
| 621 } | 621 } |
| 622 | 622 |
| 623 void QuicPacketCreator::AddPendingPadding(QuicByteCount size) { | 623 void QuicPacketCreator::AddPendingPadding(QuicByteCount size) { |
| 624 pending_padding_bytes_ += size; | 624 pending_padding_bytes_ += size; |
| 625 } | 625 } |
| 626 #undef ENDPOINT |
| 626 | 627 |
| 627 bool QuicPacketCreator::StreamFrameStartsWithChlo( | 628 bool QuicPacketCreator::StreamFrameStartsWithChlo( |
| 628 QuicIOVector iov, | 629 QuicIOVector iov, |
| 629 size_t iov_offset, | 630 size_t iov_offset, |
| 630 const QuicStreamFrame& frame) const { | 631 const QuicStreamFrame& frame) const { |
| 631 if (!framer_->HasDataProducer()) { | 632 if (!framer_->HasDataProducer()) { |
| 632 return frame.stream_id == kCryptoStreamId && | 633 return frame.stream_id == kCryptoStreamId && |
| 633 frame.data_length >= sizeof(kCHLO) && | 634 frame.data_length >= sizeof(kCHLO) && |
| 634 strncmp(frame.data_buffer, reinterpret_cast<const char*>(&kCHLO), | 635 strncmp(frame.data_buffer, reinterpret_cast<const char*>(&kCHLO), |
| 635 sizeof(kCHLO)) == 0; | 636 sizeof(kCHLO)) == 0; |
| 636 } | 637 } |
| 637 | 638 |
| 638 if (framer_->perspective() == Perspective::IS_SERVER || | 639 if (framer_->perspective() == Perspective::IS_SERVER || |
| 639 frame.stream_id != kCryptoStreamId || iov_offset != 0 || | 640 frame.stream_id != kCryptoStreamId || iov_offset != 0 || |
| 640 frame.data_length < sizeof(kCHLO)) { | 641 frame.data_length < sizeof(kCHLO)) { |
| 641 return false; | 642 return false; |
| 642 } | 643 } |
| 643 | 644 |
| 644 if (iov.iov[0].iov_len < sizeof(kCHLO)) { | 645 if (iov.iov[0].iov_len < sizeof(kCHLO)) { |
| 645 QUIC_BUG << "iov length " << iov.iov[0].iov_len << " is less than " | 646 QUIC_BUG << "iov length " << iov.iov[0].iov_len << " is less than " |
| 646 << sizeof(kCHLO); | 647 << sizeof(kCHLO); |
| 647 return false; | 648 return false; |
| 648 } | 649 } |
| 649 return strncmp(reinterpret_cast<const char*>(iov.iov[0].iov_base), | 650 return strncmp(reinterpret_cast<const char*>(iov.iov[0].iov_base), |
| 650 reinterpret_cast<const char*>(&kCHLO), sizeof(kCHLO)) == 0; | 651 reinterpret_cast<const char*>(&kCHLO), sizeof(kCHLO)) == 0; |
| 651 } | 652 } |
| 652 | 653 |
| 653 } // namespace net | 654 } // namespace net |
| OLD | NEW |