Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: net/quic/quic_framer.cc

Issue 1037403004: Land Recent QUIC Changes until 03/27/2015 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_framer.h ('k') | net/quic/quic_http_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "net/quic/crypto/crypto_protocol.h" 11 #include "net/quic/crypto/crypto_protocol.h"
12 #include "net/quic/crypto/quic_decrypter.h" 12 #include "net/quic/crypto/quic_decrypter.h"
13 #include "net/quic/crypto/quic_encrypter.h" 13 #include "net/quic/crypto/quic_encrypter.h"
14 #include "net/quic/quic_data_reader.h" 14 #include "net/quic/quic_data_reader.h"
15 #include "net/quic/quic_data_writer.h" 15 #include "net/quic/quic_data_writer.h"
16 #include "net/quic/quic_flags.h" 16 #include "net/quic/quic_flags.h"
17 #include "net/quic/quic_socket_address_coder.h" 17 #include "net/quic/quic_socket_address_coder.h"
18 #include "net/quic/quic_utils.h"
18 19
19 using base::StringPiece; 20 using base::StringPiece;
20 using std::map; 21 using std::map;
21 using std::max; 22 using std::max;
22 using std::min; 23 using std::min;
23 using std::numeric_limits; 24 using std::numeric_limits;
24 using std::string; 25 using std::string;
25 26
26 namespace net { 27 namespace net {
27 28
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 } 739 }
739 if (!writer->WriteUInt64(header.public_header.connection_id)) { 740 if (!writer->WriteUInt64(header.public_header.connection_id)) {
740 return false; 741 return false;
741 } 742 }
742 break; 743 break;
743 } 744 }
744 last_serialized_connection_id_ = header.public_header.connection_id; 745 last_serialized_connection_id_ = header.public_header.connection_id;
745 746
746 if (header.public_header.version_flag) { 747 if (header.public_header.version_flag) {
747 DCHECK_EQ(Perspective::IS_CLIENT, perspective_); 748 DCHECK_EQ(Perspective::IS_CLIENT, perspective_);
748 writer->WriteUInt32(QuicVersionToQuicTag(quic_version_)); 749 QuicTag tag = QuicVersionToQuicTag(quic_version_);
750 writer->WriteUInt32(tag);
751 DVLOG(1) << "version = " << quic_version_
752 << ", tag = '" << QuicUtils::TagToString(tag) << "'";
749 } 753 }
750 754
751 if (!AppendPacketSequenceNumber(header.public_header.sequence_number_length, 755 if (!AppendPacketSequenceNumber(header.public_header.sequence_number_length,
752 header.packet_sequence_number, writer)) { 756 header.packet_sequence_number, writer)) {
753 return false; 757 return false;
754 } 758 }
755 759
756 uint8 private_flags = 0; 760 uint8 private_flags = 0;
757 if (header.entropy_flag) { 761 if (header.entropy_flag) {
758 private_flags |= PACKET_PRIVATE_FLAGS_ENTROPY; 762 private_flags |= PACKET_PRIVATE_FLAGS_ENTROPY;
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 return alternative_decrypter_.get(); 1606 return alternative_decrypter_.get();
1603 } 1607 }
1604 1608
1605 void QuicFramer::SetEncrypter(EncryptionLevel level, 1609 void QuicFramer::SetEncrypter(EncryptionLevel level,
1606 QuicEncrypter* encrypter) { 1610 QuicEncrypter* encrypter) {
1607 DCHECK_GE(level, 0); 1611 DCHECK_GE(level, 0);
1608 DCHECK_LT(level, NUM_ENCRYPTION_LEVELS); 1612 DCHECK_LT(level, NUM_ENCRYPTION_LEVELS);
1609 encrypter_[level].reset(encrypter); 1613 encrypter_[level].reset(encrypter);
1610 } 1614 }
1611 1615
1612 const QuicEncrypter* QuicFramer::encrypter(EncryptionLevel level) const {
1613 DCHECK_GE(level, 0);
1614 DCHECK_LT(level, NUM_ENCRYPTION_LEVELS);
1615 DCHECK(encrypter_[level].get() != nullptr);
1616 return encrypter_[level].get();
1617 }
1618
1619 QuicEncryptedPacket* QuicFramer::EncryptPacket( 1616 QuicEncryptedPacket* QuicFramer::EncryptPacket(
1620 EncryptionLevel level, 1617 EncryptionLevel level,
1621 QuicPacketSequenceNumber packet_sequence_number, 1618 QuicPacketSequenceNumber packet_sequence_number,
1622 const QuicPacket& packet) { 1619 const QuicPacket& packet) {
1623 DCHECK(encrypter_[level].get() != nullptr); 1620 DCHECK(encrypter_[level].get() != nullptr);
1624 1621
1625 // Allocate a large enough buffer for the header and the encrypted data. 1622 // Allocate a large enough buffer for the header and the encrypted data.
1626 const size_t encrypted_len = 1623 const size_t encrypted_len =
1627 encrypter_[level]->GetCiphertextSize(packet.Plaintext().length()); 1624 encrypter_[level]->GetCiphertextSize(packet.Plaintext().length());
1628 StringPiece header_data = packet.BeforePlaintext(); 1625 StringPiece header_data = packet.BeforePlaintext();
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
2214 2211
2215 bool QuicFramer::RaiseError(QuicErrorCode error) { 2212 bool QuicFramer::RaiseError(QuicErrorCode error) {
2216 DVLOG(1) << "Error detail: " << detailed_error_; 2213 DVLOG(1) << "Error detail: " << detailed_error_;
2217 set_error(error); 2214 set_error(error);
2218 visitor_->OnError(this); 2215 visitor_->OnError(this);
2219 reader_.reset(nullptr); 2216 reader_.reset(nullptr);
2220 return false; 2217 return false;
2221 } 2218 }
2222 2219
2223 } // namespace net 2220 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer.h ('k') | net/quic/quic_http_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698