| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_CORE_CRYPTO_CRYPTO_HANDSHAKE_MESSAGE_H_ | 5 #ifndef NET_QUIC_CORE_CRYPTO_CRYPTO_HANDSHAKE_MESSAGE_H_ |
| 6 #define NET_QUIC_CORE_CRYPTO_CRYPTO_HANDSHAKE_MESSAGE_H_ | 6 #define NET_QUIC_CORE_CRYPTO_CRYPTO_HANDSHAKE_MESSAGE_H_ |
| 7 | 7 |
| 8 #include <cstddef> | 8 #include <cstddef> |
| 9 #include <cstdint> | 9 #include <cstdint> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/strings/string_piece.h" | |
| 15 #include "net/quic/core/quic_packets.h" | 14 #include "net/quic/core/quic_packets.h" |
| 16 #include "net/quic/platform/api/quic_export.h" | 15 #include "net/quic/platform/api/quic_export.h" |
| 16 #include "net/quic/platform/api/quic_string_piece.h" |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 | 19 |
| 20 // An intermediate format of a handshake message that's convenient for a | 20 // An intermediate format of a handshake message that's convenient for a |
| 21 // CryptoFramer to serialize from or parse into. | 21 // CryptoFramer to serialize from or parse into. |
| 22 class QUIC_EXPORT_PRIVATE CryptoHandshakeMessage { | 22 class QUIC_EXPORT_PRIVATE CryptoHandshakeMessage { |
| 23 public: | 23 public: |
| 24 CryptoHandshakeMessage(); | 24 CryptoHandshakeMessage(); |
| 25 CryptoHandshakeMessage(const CryptoHandshakeMessage& other); | 25 CryptoHandshakeMessage(const CryptoHandshakeMessage& other); |
| 26 CryptoHandshakeMessage(CryptoHandshakeMessage&& other); | 26 CryptoHandshakeMessage(CryptoHandshakeMessage&& other); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Returns the message tag. | 62 // Returns the message tag. |
| 63 QuicTag tag() const { return tag_; } | 63 QuicTag tag() const { return tag_; } |
| 64 // Sets the message tag. | 64 // Sets the message tag. |
| 65 void set_tag(QuicTag tag) { tag_ = tag; } | 65 void set_tag(QuicTag tag) { tag_ = tag; } |
| 66 | 66 |
| 67 const QuicTagValueMap& tag_value_map() const { return tag_value_map_; } | 67 const QuicTagValueMap& tag_value_map() const { return tag_value_map_; } |
| 68 | 68 |
| 69 void SetStringPiece(QuicTag tag, base::StringPiece value); | 69 void SetStringPiece(QuicTag tag, QuicStringPiece value); |
| 70 | 70 |
| 71 // Erase removes a tag/value, if present, from the message. | 71 // Erase removes a tag/value, if present, from the message. |
| 72 void Erase(QuicTag tag); | 72 void Erase(QuicTag tag); |
| 73 | 73 |
| 74 // GetTaglist finds an element with the given tag containing zero or more | 74 // GetTaglist finds an element with the given tag containing zero or more |
| 75 // tags. If such a tag doesn't exist, it returns an error code. Otherwise it | 75 // tags. If such a tag doesn't exist, it returns an error code. Otherwise it |
| 76 // sets |out_tags| and |out_len| to point to the array of tags and returns | 76 // sets |out_tags| and |out_len| to point to the array of tags and returns |
| 77 // QUIC_NO_ERROR. The array points into the CryptoHandshakeMessage and is | 77 // QUIC_NO_ERROR. The array points into the CryptoHandshakeMessage and is |
| 78 // valid only for as long as the CryptoHandshakeMessage exists and is not | 78 // valid only for as long as the CryptoHandshakeMessage exists and is not |
| 79 // modified. | 79 // modified. |
| 80 QuicErrorCode GetTaglist(QuicTag tag, | 80 QuicErrorCode GetTaglist(QuicTag tag, |
| 81 const QuicTag** out_tags, | 81 const QuicTag** out_tags, |
| 82 size_t* out_len) const; | 82 size_t* out_len) const; |
| 83 | 83 |
| 84 bool GetStringPiece(QuicTag tag, base::StringPiece* out) const; | 84 bool GetStringPiece(QuicTag tag, QuicStringPiece* out) const; |
| 85 bool HasStringPiece(QuicTag tag) const; | 85 bool HasStringPiece(QuicTag tag) const; |
| 86 | 86 |
| 87 // GetNthValue24 interprets the value with the given tag to be a series of | 87 // GetNthValue24 interprets the value with the given tag to be a series of |
| 88 // 24-bit, length prefixed values and it returns the subvalue with the given | 88 // 24-bit, length prefixed values and it returns the subvalue with the given |
| 89 // index. | 89 // index. |
| 90 QuicErrorCode GetNthValue24(QuicTag tag, | 90 QuicErrorCode GetNthValue24(QuicTag tag, |
| 91 unsigned index, | 91 unsigned index, |
| 92 base::StringPiece* out) const; | 92 QuicStringPiece* out) const; |
| 93 QuicErrorCode GetUint32(QuicTag tag, uint32_t* out) const; | 93 QuicErrorCode GetUint32(QuicTag tag, uint32_t* out) const; |
| 94 QuicErrorCode GetUint64(QuicTag tag, uint64_t* out) const; | 94 QuicErrorCode GetUint64(QuicTag tag, uint64_t* out) const; |
| 95 | 95 |
| 96 // size returns 4 (message tag) + 2 (uint16_t, number of entries) + | 96 // size returns 4 (message tag) + 2 (uint16_t, number of entries) + |
| 97 // (4 (tag) + 4 (end offset))*tag_value_map_.size() + ∑ value sizes. | 97 // (4 (tag) + 4 (end offset))*tag_value_map_.size() + ∑ value sizes. |
| 98 size_t size() const; | 98 size_t size() const; |
| 99 | 99 |
| 100 // set_minimum_size sets the minimum number of bytes that the message should | 100 // set_minimum_size sets the minimum number of bytes that the message should |
| 101 // consume. The CryptoFramer will add a PAD tag as needed when serializing in | 101 // consume. The CryptoFramer will add a PAD tag as needed when serializing in |
| 102 // order to ensure this. Setting a value of 0 disables padding. | 102 // order to ensure this. Setting a value of 0 disables padding. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 130 size_t minimum_size_; | 130 size_t minimum_size_; |
| 131 | 131 |
| 132 // The serialized form of the handshake message. This member is constructed | 132 // The serialized form of the handshake message. This member is constructed |
| 133 // lasily. | 133 // lasily. |
| 134 mutable std::unique_ptr<QuicData> serialized_; | 134 mutable std::unique_ptr<QuicData> serialized_; |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 } // namespace net | 137 } // namespace net |
| 138 | 138 |
| 139 #endif // NET_QUIC_CORE_CRYPTO_CRYPTO_HANDSHAKE_MESSAGE_H_ | 139 #endif // NET_QUIC_CORE_CRYPTO_CRYPTO_HANDSHAKE_MESSAGE_H_ |
| OLD | NEW |