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_CRYPTO_CRYPTO_FRAMER_H_ | 5 #ifndef NET_QUIC_CRYPTO_CRYPTO_FRAMER_H_ |
6 #define NET_QUIC_CRYPTO_CRYPTO_FRAMER_H_ | 6 #define NET_QUIC_CRYPTO_CRYPTO_FRAMER_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <utility> | 11 #include <utility> |
9 #include <vector> | 12 #include <vector> |
10 | 13 |
11 #include "base/basictypes.h" | |
12 #include "base/logging.h" | 14 #include "base/logging.h" |
13 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
14 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
15 #include "net/quic/crypto/crypto_handshake_message.h" | 17 #include "net/quic/crypto/crypto_handshake_message.h" |
16 #include "net/quic/quic_protocol.h" | 18 #include "net/quic/quic_protocol.h" |
17 | 19 |
18 namespace net { | 20 namespace net { |
19 | 21 |
20 class CryptoFramer; | 22 class CryptoFramer; |
21 class QuicData; | 23 class QuicData; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 private: | 74 private: |
73 // Clears per-message state. Does not clear the visitor. | 75 // Clears per-message state. Does not clear the visitor. |
74 void Clear(); | 76 void Clear(); |
75 | 77 |
76 // Process does does the work of |ProcessInput|, but returns an error code, | 78 // Process does does the work of |ProcessInput|, but returns an error code, |
77 // doesn't set error_ and doesn't call |visitor_->OnError()|. | 79 // doesn't set error_ and doesn't call |visitor_->OnError()|. |
78 QuicErrorCode Process(base::StringPiece input); | 80 QuicErrorCode Process(base::StringPiece input); |
79 | 81 |
80 static bool WritePadTag(QuicDataWriter* writer, | 82 static bool WritePadTag(QuicDataWriter* writer, |
81 size_t pad_length, | 83 size_t pad_length, |
82 uint32* end_offset); | 84 uint32_t* end_offset); |
83 | 85 |
84 // Represents the current state of the parsing state machine. | 86 // Represents the current state of the parsing state machine. |
85 enum CryptoFramerState { | 87 enum CryptoFramerState { |
86 STATE_READING_TAG, | 88 STATE_READING_TAG, |
87 STATE_READING_NUM_ENTRIES, | 89 STATE_READING_NUM_ENTRIES, |
88 STATE_READING_TAGS_AND_LENGTHS, | 90 STATE_READING_TAGS_AND_LENGTHS, |
89 STATE_READING_VALUES | 91 STATE_READING_VALUES |
90 }; | 92 }; |
91 | 93 |
92 // Visitor to invoke when messages are parsed. | 94 // Visitor to invoke when messages are parsed. |
93 CryptoFramerVisitorInterface* visitor_; | 95 CryptoFramerVisitorInterface* visitor_; |
94 // Last error. | 96 // Last error. |
95 QuicErrorCode error_; | 97 QuicErrorCode error_; |
96 // Remaining unparsed data. | 98 // Remaining unparsed data. |
97 std::string buffer_; | 99 std::string buffer_; |
98 // Current state of the parsing. | 100 // Current state of the parsing. |
99 CryptoFramerState state_; | 101 CryptoFramerState state_; |
100 // The message currently being parsed. | 102 // The message currently being parsed. |
101 CryptoHandshakeMessage message_; | 103 CryptoHandshakeMessage message_; |
102 // Number of entires in the message currently being parsed. | 104 // Number of entires in the message currently being parsed. |
103 uint16 num_entries_; | 105 uint16_t num_entries_; |
104 // tags_and_lengths_ contains the tags that are currently being parsed and | 106 // tags_and_lengths_ contains the tags that are currently being parsed and |
105 // their lengths. | 107 // their lengths. |
106 std::vector<std::pair<QuicTag, size_t>> tags_and_lengths_; | 108 std::vector<std::pair<QuicTag, size_t>> tags_and_lengths_; |
107 // Cumulative length of all values in the message currently being parsed. | 109 // Cumulative length of all values in the message currently being parsed. |
108 size_t values_len_; | 110 size_t values_len_; |
109 }; | 111 }; |
110 | 112 |
111 } // namespace net | 113 } // namespace net |
112 | 114 |
113 #endif // NET_QUIC_CRYPTO_CRYPTO_FRAMER_H_ | 115 #endif // NET_QUIC_CRYPTO_CRYPTO_FRAMER_H_ |
OLD | NEW |