| 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/basictypes.h" | 9 #include "base/basictypes.h" | 
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" | 
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 470     return nullptr; | 470     return nullptr; | 
| 471   } | 471   } | 
| 472 | 472 | 
| 473   if (!writer.WriteBytes(reset_serialized.data(), reset_serialized.length())) { | 473   if (!writer.WriteBytes(reset_serialized.data(), reset_serialized.length())) { | 
| 474     return nullptr; | 474     return nullptr; | 
| 475   } | 475   } | 
| 476 | 476 | 
| 477   return new QuicEncryptedPacket(buffer.release(), len, true); | 477   return new QuicEncryptedPacket(buffer.release(), len, true); | 
| 478 } | 478 } | 
| 479 | 479 | 
|  | 480 // static | 
| 480 QuicEncryptedPacket* QuicFramer::BuildVersionNegotiationPacket( | 481 QuicEncryptedPacket* QuicFramer::BuildVersionNegotiationPacket( | 
| 481     const QuicPacketPublicHeader& header, | 482     QuicConnectionId connection_id, | 
| 482     const QuicVersionVector& supported_versions) { | 483     const QuicVersionVector& versions) { | 
| 483   DCHECK(header.version_flag); | 484   DCHECK(!versions.empty()); | 
| 484   size_t len = GetVersionNegotiationPacketSize(supported_versions.size()); | 485   size_t len = GetVersionNegotiationPacketSize(versions.size()); | 
| 485   scoped_ptr<char[]> buffer(new char[len]); | 486   scoped_ptr<char[]> buffer(new char[len]); | 
| 486   QuicDataWriter writer(len, buffer.get()); | 487   QuicDataWriter writer(len, buffer.get()); | 
| 487 | 488 | 
| 488   uint8 flags = static_cast<uint8>(PACKET_PUBLIC_FLAGS_VERSION | | 489   uint8 flags = static_cast<uint8>(PACKET_PUBLIC_FLAGS_VERSION | | 
| 489                                    PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID); | 490                                    PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID); | 
| 490   if (!writer.WriteUInt8(flags)) { | 491   if (!writer.WriteUInt8(flags)) { | 
| 491     return nullptr; | 492     return nullptr; | 
| 492   } | 493   } | 
| 493 | 494 | 
| 494   if (!writer.WriteUInt64(header.connection_id)) { | 495   if (!writer.WriteUInt64(connection_id)) { | 
| 495     return nullptr; | 496     return nullptr; | 
| 496   } | 497   } | 
| 497 | 498 | 
| 498   for (size_t i = 0; i < supported_versions.size(); ++i) { | 499   for (QuicVersion version : versions) { | 
| 499     if (!writer.WriteUInt32(QuicVersionToQuicTag(supported_versions[i]))) { | 500     if (!writer.WriteUInt32(QuicVersionToQuicTag(version))) { | 
| 500       return nullptr; | 501       return nullptr; | 
| 501     } | 502     } | 
| 502   } | 503   } | 
| 503 | 504 | 
| 504   return new QuicEncryptedPacket(buffer.release(), len, true); | 505   return new QuicEncryptedPacket(buffer.release(), len, true); | 
| 505 } | 506 } | 
| 506 | 507 | 
| 507 bool QuicFramer::ProcessPacket(const QuicEncryptedPacket& packet) { | 508 bool QuicFramer::ProcessPacket(const QuicEncryptedPacket& packet) { | 
| 508   QuicDataReader reader(packet.data(), packet.length()); | 509   QuicDataReader reader(packet.data(), packet.length()); | 
| 509 | 510 | 
| (...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2193 | 2194 | 
| 2194 bool QuicFramer::RaiseError(QuicErrorCode error) { | 2195 bool QuicFramer::RaiseError(QuicErrorCode error) { | 
| 2195   DVLOG(1) << "Error: " << QuicUtils::ErrorToString(error) | 2196   DVLOG(1) << "Error: " << QuicUtils::ErrorToString(error) | 
| 2196            << " detail: " << detailed_error_; | 2197            << " detail: " << detailed_error_; | 
| 2197   set_error(error); | 2198   set_error(error); | 
| 2198   visitor_->OnError(this); | 2199   visitor_->OnError(this); | 
| 2199   return false; | 2200   return false; | 
| 2200 } | 2201 } | 
| 2201 | 2202 | 
| 2202 }  // namespace net | 2203 }  // namespace net | 
| OLD | NEW | 
|---|