| 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 #ifndef NET_QUIC_QUIC_FRAMER_H_ | 5 #ifndef NET_QUIC_QUIC_FRAMER_H_ |
| 6 #define NET_QUIC_QUIC_FRAMER_H_ | 6 #define NET_QUIC_QUIC_FRAMER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 // Called only when |is_server_| is false and a version negotiation packet has | 76 // Called only when |is_server_| is false and a version negotiation packet has |
| 77 // been parsed. | 77 // been parsed. |
| 78 virtual void OnVersionNegotiationPacket( | 78 virtual void OnVersionNegotiationPacket( |
| 79 const QuicVersionNegotiationPacket& packet) = 0; | 79 const QuicVersionNegotiationPacket& packet) = 0; |
| 80 | 80 |
| 81 // Called when a lost packet has been recovered via FEC, | 81 // Called when a lost packet has been recovered via FEC, |
| 82 // before it has been processed. | 82 // before it has been processed. |
| 83 virtual void OnRevivedPacket() = 0; | 83 virtual void OnRevivedPacket() = 0; |
| 84 | 84 |
| 85 // Called when the public header has been parsed, but has not been |
| 86 // authenticated. If it returns false, framing for this packet will cease. |
| 87 virtual bool OnUnauthenticatedPublicHeader( |
| 88 const QuicPacketPublicHeader& header) = 0; |
| 89 |
| 85 // Called when the unauthenticated portion of the header has been parsed. | 90 // Called when the unauthenticated portion of the header has been parsed. |
| 86 // If OnUnauthenticatedHeader returns false, framing for this packet will | 91 // If OnUnauthenticatedHeader returns false, framing for this packet will |
| 87 // cease. | 92 // cease. |
| 88 virtual bool OnUnauthenticatedHeader(const QuicPacketHeader& header) = 0; | 93 virtual bool OnUnauthenticatedHeader(const QuicPacketHeader& header) = 0; |
| 89 | 94 |
| 90 // Called when the complete header of a packet had been parsed. | 95 // Called when the complete header of a packet had been parsed. |
| 91 // If OnPacketHeader returns false, framing for this packet will cease. | 96 // If OnPacketHeader returns false, framing for this packet will cease. |
| 92 virtual bool OnPacketHeader(const QuicPacketHeader& header) = 0; | 97 virtual bool OnPacketHeader(const QuicPacketHeader& header) = 0; |
| 93 | 98 |
| 94 // Called when a data packet is parsed that is part of an FEC group. | 99 // Called when a data packet is parsed that is part of an FEC group. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // version in |supported_versions|. | 165 // version in |supported_versions|. |
| 161 QuicFramer(const QuicVersionVector& supported_versions, | 166 QuicFramer(const QuicVersionVector& supported_versions, |
| 162 QuicTime creation_time, | 167 QuicTime creation_time, |
| 163 bool is_server); | 168 bool is_server); |
| 164 | 169 |
| 165 virtual ~QuicFramer(); | 170 virtual ~QuicFramer(); |
| 166 | 171 |
| 167 // Returns true if |version| is a supported protocol version. | 172 // Returns true if |version| is a supported protocol version. |
| 168 bool IsSupportedVersion(const QuicVersion version) const; | 173 bool IsSupportedVersion(const QuicVersion version) const; |
| 169 | 174 |
| 170 // Returns true if the version flag is set in the public flags. | |
| 171 static bool HasVersionFlag(const QuicEncryptedPacket& packet); | |
| 172 | |
| 173 // Set callbacks to be called from the framer. A visitor must be set, or | 175 // Set callbacks to be called from the framer. A visitor must be set, or |
| 174 // else the framer will likely crash. It is acceptable for the visitor | 176 // else the framer will likely crash. It is acceptable for the visitor |
| 175 // to do nothing. If this is called multiple times, only the last visitor | 177 // to do nothing. If this is called multiple times, only the last visitor |
| 176 // will be used. | 178 // will be used. |
| 177 void set_visitor(QuicFramerVisitorInterface* visitor) { | 179 void set_visitor(QuicFramerVisitorInterface* visitor) { |
| 178 visitor_ = visitor; | 180 visitor_ = visitor; |
| 179 } | 181 } |
| 180 | 182 |
| 181 // Set a builder to be called from the framer when building FEC protected | 183 // Set a builder to be called from the framer when building FEC protected |
| 182 // packets. If this is called multiple times, only the last builder | 184 // packets. If this is called multiple times, only the last builder |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 QuicEncryptedPacket* EncryptPacket(EncryptionLevel level, | 334 QuicEncryptedPacket* EncryptPacket(EncryptionLevel level, |
| 333 QuicPacketSequenceNumber sequence_number, | 335 QuicPacketSequenceNumber sequence_number, |
| 334 const QuicPacket& packet); | 336 const QuicPacket& packet); |
| 335 | 337 |
| 336 // Returns the maximum length of plaintext that can be encrypted | 338 // Returns the maximum length of plaintext that can be encrypted |
| 337 // to ciphertext no larger than |ciphertext_size|. | 339 // to ciphertext no larger than |ciphertext_size|. |
| 338 size_t GetMaxPlaintextSize(size_t ciphertext_size); | 340 size_t GetMaxPlaintextSize(size_t ciphertext_size); |
| 339 | 341 |
| 340 const std::string& detailed_error() { return detailed_error_; } | 342 const std::string& detailed_error() { return detailed_error_; } |
| 341 | 343 |
| 342 // Read the full 8 byte guid from a packet header. | |
| 343 // Return true on success, else false. | |
| 344 static bool ReadGuidFromPacket(const QuicEncryptedPacket& packet, | |
| 345 QuicGuid* guid); | |
| 346 | |
| 347 // The minimum sequence number length required to represent |sequence_number|. | 344 // The minimum sequence number length required to represent |sequence_number|. |
| 348 static QuicSequenceNumberLength GetMinSequenceNumberLength( | 345 static QuicSequenceNumberLength GetMinSequenceNumberLength( |
| 349 QuicPacketSequenceNumber sequence_number); | 346 QuicPacketSequenceNumber sequence_number); |
| 350 | 347 |
| 351 void SetSupportedVersions(const QuicVersionVector& versions) { | 348 void SetSupportedVersions(const QuicVersionVector& versions) { |
| 352 supported_versions_ = versions; | 349 supported_versions_ = versions; |
| 353 quic_version_ = versions[0]; | 350 quic_version_ = versions[0]; |
| 354 } | 351 } |
| 355 | 352 |
| 356 private: | 353 private: |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 // The time this frames was created. Time written to the wire will be | 491 // The time this frames was created. Time written to the wire will be |
| 495 // written as a delta from this value. | 492 // written as a delta from this value. |
| 496 QuicTime creation_time_; | 493 QuicTime creation_time_; |
| 497 | 494 |
| 498 DISALLOW_COPY_AND_ASSIGN(QuicFramer); | 495 DISALLOW_COPY_AND_ASSIGN(QuicFramer); |
| 499 }; | 496 }; |
| 500 | 497 |
| 501 } // namespace net | 498 } // namespace net |
| 502 | 499 |
| 503 #endif // NET_QUIC_QUIC_FRAMER_H_ | 500 #endif // NET_QUIC_QUIC_FRAMER_H_ |
| OLD | NEW |