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_QUIC_CONFIG_H_ | 5 #ifndef NET_QUIC_CORE_QUIC_CONFIG_H_ |
6 #define NET_QUIC_CORE_QUIC_CONFIG_H_ | 6 #define NET_QUIC_CORE_QUIC_CONFIG_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "net/base/net_export.h" | |
14 #include "net/quic/core/quic_packets.h" | 13 #include "net/quic/core/quic_packets.h" |
15 #include "net/quic/core/quic_time.h" | 14 #include "net/quic/core/quic_time.h" |
| 15 #include "net/quic/platform/api/quic_export.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 namespace test { | 19 namespace test { |
20 class QuicConfigPeer; | 20 class QuicConfigPeer; |
21 } // namespace test | 21 } // namespace test |
22 | 22 |
23 class CryptoHandshakeMessage; | 23 class CryptoHandshakeMessage; |
24 | 24 |
25 // Describes whether or not a given QuicTag is required or optional in the | 25 // Describes whether or not a given QuicTag is required or optional in the |
26 // handshake message. | 26 // handshake message. |
27 enum QuicConfigPresence { | 27 enum QuicConfigPresence { |
28 // This negotiable value can be absent from the handshake message. Default | 28 // This negotiable value can be absent from the handshake message. Default |
29 // value is selected as the negotiated value in such a case. | 29 // value is selected as the negotiated value in such a case. |
30 PRESENCE_OPTIONAL, | 30 PRESENCE_OPTIONAL, |
31 // This negotiable value is required in the handshake message otherwise the | 31 // This negotiable value is required in the handshake message otherwise the |
32 // Process*Hello function returns an error. | 32 // Process*Hello function returns an error. |
33 PRESENCE_REQUIRED, | 33 PRESENCE_REQUIRED, |
34 }; | 34 }; |
35 | 35 |
36 // Whether the CryptoHandshakeMessage is from the client or server. | 36 // Whether the CryptoHandshakeMessage is from the client or server. |
37 enum HelloType { | 37 enum HelloType { |
38 CLIENT, | 38 CLIENT, |
39 SERVER, | 39 SERVER, |
40 }; | 40 }; |
41 | 41 |
42 // An abstract base class that stores a value that can be sent in CHLO/SHLO | 42 // An abstract base class that stores a value that can be sent in CHLO/SHLO |
43 // message. These values can be OPTIONAL or REQUIRED, depending on |presence_|. | 43 // message. These values can be OPTIONAL or REQUIRED, depending on |presence_|. |
44 class NET_EXPORT_PRIVATE QuicConfigValue { | 44 class QUIC_EXPORT_PRIVATE QuicConfigValue { |
45 public: | 45 public: |
46 QuicConfigValue(QuicTag tag, QuicConfigPresence presence); | 46 QuicConfigValue(QuicTag tag, QuicConfigPresence presence); |
47 virtual ~QuicConfigValue(); | 47 virtual ~QuicConfigValue(); |
48 | 48 |
49 // Serialises tag name and value(s) to |out|. | 49 // Serialises tag name and value(s) to |out|. |
50 virtual void ToHandshakeMessage(CryptoHandshakeMessage* out) const = 0; | 50 virtual void ToHandshakeMessage(CryptoHandshakeMessage* out) const = 0; |
51 | 51 |
52 // Selects a mutually acceptable value from those offered in |peer_hello| | 52 // Selects a mutually acceptable value from those offered in |peer_hello| |
53 // and those defined in the subclass. | 53 // and those defined in the subclass. |
54 virtual QuicErrorCode ProcessPeerHello( | 54 virtual QuicErrorCode ProcessPeerHello( |
55 const CryptoHandshakeMessage& peer_hello, | 55 const CryptoHandshakeMessage& peer_hello, |
56 HelloType hello_type, | 56 HelloType hello_type, |
57 std::string* error_details) = 0; | 57 std::string* error_details) = 0; |
58 | 58 |
59 protected: | 59 protected: |
60 const QuicTag tag_; | 60 const QuicTag tag_; |
61 const QuicConfigPresence presence_; | 61 const QuicConfigPresence presence_; |
62 }; | 62 }; |
63 | 63 |
64 class NET_EXPORT_PRIVATE QuicNegotiableValue : public QuicConfigValue { | 64 class QUIC_EXPORT_PRIVATE QuicNegotiableValue : public QuicConfigValue { |
65 public: | 65 public: |
66 QuicNegotiableValue(QuicTag tag, QuicConfigPresence presence); | 66 QuicNegotiableValue(QuicTag tag, QuicConfigPresence presence); |
67 ~QuicNegotiableValue() override; | 67 ~QuicNegotiableValue() override; |
68 | 68 |
69 bool negotiated() const { return negotiated_; } | 69 bool negotiated() const { return negotiated_; } |
70 | 70 |
71 protected: | 71 protected: |
72 void set_negotiated(bool negotiated) { negotiated_ = negotiated; } | 72 void set_negotiated(bool negotiated) { negotiated_ = negotiated; } |
73 | 73 |
74 private: | 74 private: |
75 bool negotiated_; | 75 bool negotiated_; |
76 }; | 76 }; |
77 | 77 |
78 class NET_EXPORT_PRIVATE QuicNegotiableUint32 : public QuicNegotiableValue { | 78 class QUIC_EXPORT_PRIVATE QuicNegotiableUint32 : public QuicNegotiableValue { |
79 // TODO(fayang): some negotiated values use uint32 as bool (e.g., silent | 79 // TODO(fayang): some negotiated values use uint32 as bool (e.g., silent |
80 // close). Consider adding a QuicNegotiableBool type. | 80 // close). Consider adding a QuicNegotiableBool type. |
81 public: | 81 public: |
82 // Default and max values default to 0. | 82 // Default and max values default to 0. |
83 QuicNegotiableUint32(QuicTag name, QuicConfigPresence presence); | 83 QuicNegotiableUint32(QuicTag name, QuicConfigPresence presence); |
84 ~QuicNegotiableUint32() override; | 84 ~QuicNegotiableUint32() override; |
85 | 85 |
86 // Sets the maximum possible value that can be achieved after negotiation and | 86 // Sets the maximum possible value that can be achieved after negotiation and |
87 // also the default values to be assumed if PRESENCE_OPTIONAL and the *HLO msg | 87 // also the default values to be assumed if PRESENCE_OPTIONAL and the *HLO msg |
88 // doesn't contain a value corresponding to |name_|. |max| is serialised via | 88 // doesn't contain a value corresponding to |name_|. |max| is serialised via |
(...skipping 19 matching lines...) Expand all Loading... |
108 HelloType hello_type, | 108 HelloType hello_type, |
109 std::string* error_details) override; | 109 std::string* error_details) override; |
110 | 110 |
111 private: | 111 private: |
112 uint32_t max_value_; | 112 uint32_t max_value_; |
113 uint32_t default_value_; | 113 uint32_t default_value_; |
114 uint32_t negotiated_value_; | 114 uint32_t negotiated_value_; |
115 }; | 115 }; |
116 | 116 |
117 // Stores uint32_t from CHLO or SHLO messages that are not negotiated. | 117 // Stores uint32_t from CHLO or SHLO messages that are not negotiated. |
118 class NET_EXPORT_PRIVATE QuicFixedUint32 : public QuicConfigValue { | 118 class QUIC_EXPORT_PRIVATE QuicFixedUint32 : public QuicConfigValue { |
119 public: | 119 public: |
120 QuicFixedUint32(QuicTag name, QuicConfigPresence presence); | 120 QuicFixedUint32(QuicTag name, QuicConfigPresence presence); |
121 ~QuicFixedUint32() override; | 121 ~QuicFixedUint32() override; |
122 | 122 |
123 bool HasSendValue() const; | 123 bool HasSendValue() const; |
124 | 124 |
125 uint32_t GetSendValue() const; | 125 uint32_t GetSendValue() const; |
126 | 126 |
127 void SetSendValue(uint32_t value); | 127 void SetSendValue(uint32_t value); |
128 | 128 |
(...skipping 12 matching lines...) Expand all Loading... |
141 std::string* error_details) override; | 141 std::string* error_details) override; |
142 | 142 |
143 private: | 143 private: |
144 uint32_t send_value_; | 144 uint32_t send_value_; |
145 bool has_send_value_; | 145 bool has_send_value_; |
146 uint32_t receive_value_; | 146 uint32_t receive_value_; |
147 bool has_receive_value_; | 147 bool has_receive_value_; |
148 }; | 148 }; |
149 | 149 |
150 // Stores tag from CHLO or SHLO messages that are not negotiated. | 150 // Stores tag from CHLO or SHLO messages that are not negotiated. |
151 class NET_EXPORT_PRIVATE QuicFixedTagVector : public QuicConfigValue { | 151 class QUIC_EXPORT_PRIVATE QuicFixedTagVector : public QuicConfigValue { |
152 public: | 152 public: |
153 QuicFixedTagVector(QuicTag name, QuicConfigPresence presence); | 153 QuicFixedTagVector(QuicTag name, QuicConfigPresence presence); |
154 QuicFixedTagVector(const QuicFixedTagVector& other); | 154 QuicFixedTagVector(const QuicFixedTagVector& other); |
155 ~QuicFixedTagVector() override; | 155 ~QuicFixedTagVector() override; |
156 | 156 |
157 bool HasSendValues() const; | 157 bool HasSendValues() const; |
158 | 158 |
159 QuicTagVector GetSendValues() const; | 159 QuicTagVector GetSendValues() const; |
160 | 160 |
161 void SetSendValues(const QuicTagVector& values); | 161 void SetSendValues(const QuicTagVector& values); |
(...skipping 15 matching lines...) Expand all Loading... |
177 std::string* error_details) override; | 177 std::string* error_details) override; |
178 | 178 |
179 private: | 179 private: |
180 QuicTagVector send_values_; | 180 QuicTagVector send_values_; |
181 bool has_send_values_; | 181 bool has_send_values_; |
182 QuicTagVector receive_values_; | 182 QuicTagVector receive_values_; |
183 bool has_receive_values_; | 183 bool has_receive_values_; |
184 }; | 184 }; |
185 | 185 |
186 // Stores QuicSocketAddress from CHLO or SHLO messages that are not negotiated. | 186 // Stores QuicSocketAddress from CHLO or SHLO messages that are not negotiated. |
187 class NET_EXPORT_PRIVATE QuicFixedSocketAddress : public QuicConfigValue { | 187 class QUIC_EXPORT_PRIVATE QuicFixedSocketAddress : public QuicConfigValue { |
188 public: | 188 public: |
189 QuicFixedSocketAddress(QuicTag tag, QuicConfigPresence presence); | 189 QuicFixedSocketAddress(QuicTag tag, QuicConfigPresence presence); |
190 ~QuicFixedSocketAddress() override; | 190 ~QuicFixedSocketAddress() override; |
191 | 191 |
192 bool HasSendValue() const; | 192 bool HasSendValue() const; |
193 | 193 |
194 const QuicSocketAddress& GetSendValue() const; | 194 const QuicSocketAddress& GetSendValue() const; |
195 | 195 |
196 void SetSendValue(const QuicSocketAddress& value); | 196 void SetSendValue(const QuicSocketAddress& value); |
197 | 197 |
(...skipping 11 matching lines...) Expand all Loading... |
209 | 209 |
210 private: | 210 private: |
211 QuicSocketAddress send_value_; | 211 QuicSocketAddress send_value_; |
212 bool has_send_value_; | 212 bool has_send_value_; |
213 QuicSocketAddress receive_value_; | 213 QuicSocketAddress receive_value_; |
214 bool has_receive_value_; | 214 bool has_receive_value_; |
215 }; | 215 }; |
216 | 216 |
217 // QuicConfig contains non-crypto configuration options that are negotiated in | 217 // QuicConfig contains non-crypto configuration options that are negotiated in |
218 // the crypto handshake. | 218 // the crypto handshake. |
219 class NET_EXPORT_PRIVATE QuicConfig { | 219 class QUIC_EXPORT_PRIVATE QuicConfig { |
220 public: | 220 public: |
221 QuicConfig(); | 221 QuicConfig(); |
222 QuicConfig(const QuicConfig& other); | 222 QuicConfig(const QuicConfig& other); |
223 ~QuicConfig(); | 223 ~QuicConfig(); |
224 | 224 |
225 void SetConnectionOptionsToSend(const QuicTagVector& connection_options); | 225 void SetConnectionOptionsToSend(const QuicTagVector& connection_options); |
226 | 226 |
227 bool HasReceivedConnectionOptions() const; | 227 bool HasReceivedConnectionOptions() const; |
228 | 228 |
229 // Sets initial received connection options. All received connection options | 229 // Sets initial received connection options. All received connection options |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 // Force HOL blocking for measurement purposes. | 441 // Force HOL blocking for measurement purposes. |
442 QuicFixedUint32 force_hol_blocking_; | 442 QuicFixedUint32 force_hol_blocking_; |
443 | 443 |
444 // Whether support HTTP/2 SETTINGS_MAX_HEADER_LIST_SIZE SETTINGS frame. | 444 // Whether support HTTP/2 SETTINGS_MAX_HEADER_LIST_SIZE SETTINGS frame. |
445 QuicFixedUint32 support_max_header_list_size_; | 445 QuicFixedUint32 support_max_header_list_size_; |
446 }; | 446 }; |
447 | 447 |
448 } // namespace net | 448 } // namespace net |
449 | 449 |
450 #endif // NET_QUIC_CORE_QUIC_CONFIG_H_ | 450 #endif // NET_QUIC_CORE_QUIC_CONFIG_H_ |
OLD | NEW |