Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: net/quic/quic_config.h

Issue 188333003: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compilation error - added NET_EXPORT_PRIVATE to QuicFixedUint32 Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/crypto/quic_crypto_server_config.cc ('k') | net/quic/quic_config.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_QUIC_CONFIG_H_ 5 #ifndef NET_QUIC_QUIC_CONFIG_H_
6 #define NET_QUIC_QUIC_CONFIG_H_ 6 #define NET_QUIC_QUIC_CONFIG_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "net/quic/quic_protocol.h" 11 #include "net/quic/quic_protocol.h"
12 #include "net/quic/quic_time.h" 12 #include "net/quic/quic_time.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 class CryptoHandshakeMessage; 16 class CryptoHandshakeMessage;
17 17
18 class NET_EXPORT_PRIVATE QuicNegotiableValue { 18 // Describes whether or not a given QuicTag is required or optional in the
19 // handshake message.
20 enum QuicConfigPresence {
21 // This value can be absent from the handshake message. Default value is
22 // selected as the negotiated value in such a case.
23 PRESENCE_OPTIONAL,
24 // This value is required in the handshake message otherwise the Process*Hello
25 // function returns an error.
26 PRESENCE_REQUIRED,
27 };
28
29 // An abstract base class that stores a value that can be sent in CHLO/SHLO
30 // message. These values can be OPTIONAL or REQUIRED, depending on |presence_|.
31 class NET_EXPORT_PRIVATE QuicConfigValue {
19 public: 32 public:
20 enum Presence { 33 QuicConfigValue(QuicTag tag, QuicConfigPresence presence);
21 // This negotiable value can be absent from the handshake message. Default 34 virtual ~QuicConfigValue();
22 // value is selected as the negotiated value in such a case.
23 PRESENCE_OPTIONAL,
24 // This negotiable value is required in the handshake message otherwise the
25 // Process*Hello function returns an error.
26 PRESENCE_REQUIRED,
27 };
28 35
29 QuicNegotiableValue(QuicTag tag, Presence presence); 36 // Serialises tag name and value(s) to |out|.
37 virtual void ToHandshakeMessage(CryptoHandshakeMessage* out) const = 0;
38
39 // Selects a mutually acceptable value from those offered in |client_hello|
40 // and those defined in the subclass.
41 virtual QuicErrorCode ProcessClientHello(
42 const CryptoHandshakeMessage& client_hello,
43 std::string* error_details) = 0;
44
45 // Selects a mutually acceptable value from those offered in |server_hello|
46 // and those defined in the subclass.
47 virtual QuicErrorCode ProcessServerHello(
48 const CryptoHandshakeMessage& server_hello,
49 std::string* error_details) = 0;
50
51 protected:
52 const QuicTag tag_;
53 const QuicConfigPresence presence_;
54 };
55
56 class NET_EXPORT_PRIVATE QuicNegotiableValue : public QuicConfigValue {
57 public:
58 QuicNegotiableValue(QuicTag tag, QuicConfigPresence presence);
59 virtual ~QuicNegotiableValue();
30 60
31 bool negotiated() const { 61 bool negotiated() const {
32 return negotiated_; 62 return negotiated_;
33 } 63 }
34 64
35 protected: 65 protected:
36 const QuicTag tag_;
37 const Presence presence_;
38 bool negotiated_; 66 bool negotiated_;
39 }; 67 };
40 68
41 class NET_EXPORT_PRIVATE QuicNegotiableUint32 : public QuicNegotiableValue { 69 class NET_EXPORT_PRIVATE QuicNegotiableUint32 : public QuicNegotiableValue {
42 public: 70 public:
43 // Default and max values default to 0. 71 // Default and max values default to 0.
44 QuicNegotiableUint32(QuicTag name, Presence presence); 72 QuicNegotiableUint32(QuicTag name, QuicConfigPresence presence);
73 virtual ~QuicNegotiableUint32();
45 74
46 // Sets the maximum possible value that can be achieved after negotiation and 75 // Sets the maximum possible value that can be achieved after negotiation and
47 // also the default values to be assumed if PRESENCE_OPTIONAL and the *HLO msg 76 // also the default values to be assumed if PRESENCE_OPTIONAL and the *HLO msg
48 // doesn't contain a value corresponding to |name_|. |max| is serialised via 77 // doesn't contain a value corresponding to |name_|. |max| is serialised via
49 // ToHandshakeMessage call if |negotiated_| is false. 78 // ToHandshakeMessage call if |negotiated_| is false.
50 void set(uint32 max, uint32 default_value); 79 void set(uint32 max, uint32 default_value);
51 80
52 // Returns the value negotiated if |negotiated_| is true, otherwise returns 81 // Returns the value negotiated if |negotiated_| is true, otherwise returns
53 // default_value_ (used to set default values before negotiation finishes). 82 // default_value_ (used to set default values before negotiation finishes).
54 uint32 GetUint32() const; 83 uint32 GetUint32() const;
55 84
56 // Serialises |name_| and value to |out|. If |negotiated_| is true then 85 // Serialises |name_| and value to |out|. If |negotiated_| is true then
57 // |negotiated_value_| is serialised, otherwise |max_value_| is serialised. 86 // |negotiated_value_| is serialised, otherwise |max_value_| is serialised.
58 void ToHandshakeMessage(CryptoHandshakeMessage* out) const; 87 virtual void ToHandshakeMessage(CryptoHandshakeMessage* out) const OVERRIDE;
59 88
60 // Sets |negotiated_value_| to the minimum of |max_value_| and the 89 // Sets |negotiated_value_| to the minimum of |max_value_| and the
61 // corresponding value from |client_hello|. If the corresponding value is 90 // corresponding value from |client_hello|. If the corresponding value is
62 // missing and PRESENCE_OPTIONAL then |negotiated_value_| is set to 91 // missing and PRESENCE_OPTIONAL then |negotiated_value_| is set to
63 // |default_value_|. 92 // |default_value_|.
64 QuicErrorCode ProcessClientHello(const CryptoHandshakeMessage& client_hello, 93 virtual QuicErrorCode ProcessClientHello(
65 std::string* error_details); 94 const CryptoHandshakeMessage& client_hello,
95 std::string* error_details) OVERRIDE;
66 96
67 // Sets the |negotiated_value_| to the corresponding value from 97 // Sets the |negotiated_value_| to the corresponding value from
68 // |server_hello|. Returns error if the value received in |server_hello| is 98 // |server_hello|. Returns error if the value received in |server_hello| is
69 // greater than |max_value_|. If the corresponding value is missing and 99 // greater than |max_value_|. If the corresponding value is missing and
70 // PRESENCE_OPTIONAL then |negotiated_value_| is set to |0|, 100 // PRESENCE_OPTIONAL then |negotiated_value_| is set to |0|,
71 QuicErrorCode ProcessServerHello(const CryptoHandshakeMessage& server_hello, 101 virtual QuicErrorCode ProcessServerHello(
72 std::string* error_details); 102 const CryptoHandshakeMessage& server_hello,
103 std::string* error_details) OVERRIDE;
73 104
74 private: 105 private:
75 // Reads the value corresponding to |name_| from |msg| into |out|. If the
76 // |name_| is absent in |msg| and |presence_| is set to OPTIONAL |out| is set
77 // to |max_value_|.
78 QuicErrorCode ReadUint32(const CryptoHandshakeMessage& msg,
79 uint32* out,
80 std::string* error_details) const;
81
82 uint32 max_value_; 106 uint32 max_value_;
83 uint32 default_value_; 107 uint32 default_value_;
84 uint32 negotiated_value_; 108 uint32 negotiated_value_;
85 }; 109 };
86 110
87 class NET_EXPORT_PRIVATE QuicNegotiableTag : public QuicNegotiableValue { 111 class NET_EXPORT_PRIVATE QuicNegotiableTag : public QuicNegotiableValue {
88 public: 112 public:
89 QuicNegotiableTag(QuicTag name, Presence presence); 113 QuicNegotiableTag(QuicTag name, QuicConfigPresence presence);
90 ~QuicNegotiableTag(); 114 virtual ~QuicNegotiableTag();
91 115
92 // Sets the possible values that |negotiated_tag_| can take after negotiation 116 // Sets the possible values that |negotiated_tag_| can take after negotiation
93 // and the default value that |negotiated_tag_| takes if OPTIONAL and *HLO 117 // and the default value that |negotiated_tag_| takes if OPTIONAL and *HLO
94 // msg doesn't contain tag |name_|. 118 // msg doesn't contain tag |name_|.
95 void set(const QuicTagVector& possible_values, QuicTag default_value); 119 void set(const QuicTagVector& possible_values, QuicTag default_value);
96 120
97 // Returns the negotiated tag if |negotiated_| is true, otherwise returns 121 // Returns the negotiated tag if |negotiated_| is true, otherwise returns
98 // |default_value_| (used to set default values before negotiation finishes). 122 // |default_value_| (used to set default values before negotiation finishes).
99 QuicTag GetTag() const; 123 QuicTag GetTag() const;
100 124
101 // Serialises |name_| and vector (either possible or negotiated) to |out|. If 125 // Serialises |name_| and vector (either possible or negotiated) to |out|. If
102 // |negotiated_| is true then |negotiated_tag_| is serialised, otherwise 126 // |negotiated_| is true then |negotiated_tag_| is serialised, otherwise
103 // |possible_values_| is serialised. 127 // |possible_values_| is serialised.
104 void ToHandshakeMessage(CryptoHandshakeMessage* out) const; 128 virtual void ToHandshakeMessage(CryptoHandshakeMessage* out) const OVERRIDE;
105 129
106 // Selects the tag common to both tags in |client_hello| for |name_| and 130 // Selects the tag common to both tags in |client_hello| for |name_| and
107 // |possible_values_| with preference to tag in |possible_values_|. The 131 // |possible_values_| with preference to tag in |possible_values_|. The
108 // selected tag is set as |negotiated_tag_|. 132 // selected tag is set as |negotiated_tag_|.
109 QuicErrorCode ProcessClientHello(const CryptoHandshakeMessage& client_hello, 133 virtual QuicErrorCode ProcessClientHello(
110 std::string* error_details); 134 const CryptoHandshakeMessage& client_hello,
135 std::string* error_details) OVERRIDE;
111 136
112 // Sets the value for |name_| tag in |server_hello| as |negotiated_value_|. 137 // Sets the value for |name_| tag in |server_hello| as |negotiated_value_|.
113 // Returns error if the value received in |server_hello| isn't present in 138 // Returns error if the value received in |server_hello| isn't present in
114 // |possible_values_|. 139 // |possible_values_|.
115 QuicErrorCode ProcessServerHello(const CryptoHandshakeMessage& server_hello, 140 virtual QuicErrorCode ProcessServerHello(
116 std::string* error_details); 141 const CryptoHandshakeMessage& server_hello,
142 std::string* error_details) OVERRIDE;
117 143
118 private: 144 private:
119 // Reads the vector corresponding to |name_| from |msg| into |out|. If the 145 // Reads the vector corresponding to |name_| from |msg| into |out|. If the
120 // |name_| is absent in |msg| and |presence_| is set to OPTIONAL |out| is set 146 // |name_| is absent in |msg| and |presence_| is set to OPTIONAL |out| is set
121 // to |possible_values_|. 147 // to |possible_values_|.
122 QuicErrorCode ReadVector(const CryptoHandshakeMessage& msg, 148 QuicErrorCode ReadVector(const CryptoHandshakeMessage& msg,
123 const QuicTag** out, 149 const QuicTag** out,
124 size_t* out_length, 150 size_t* out_length,
125 std::string* error_details) const; 151 std::string* error_details) const;
126 152
127 QuicTag negotiated_tag_; 153 QuicTag negotiated_tag_;
128 QuicTagVector possible_values_; 154 QuicTagVector possible_values_;
129 QuicTag default_value_; 155 QuicTag default_value_;
130 }; 156 };
131 157
158 // Stores uint32 from CHLO or SHLO messages that are not negotiated.
159 class NET_EXPORT_PRIVATE QuicFixedUint32 : public QuicConfigValue {
160 public:
161 QuicFixedUint32(QuicTag name,
162 QuicConfigPresence presence,
163 uint32 default_value);
164 virtual ~QuicFixedUint32();
165
166 // Returns the value in the *HLO message (or the default if not).
167 uint32 GetUint32() const;
168
169 void set_value(uint32 value) { value_ = value; }
170
171 // Serialises |name_| and |value_| to |out|.
172 virtual void ToHandshakeMessage(CryptoHandshakeMessage* out) const OVERRIDE;
173
174 // Sets |value_| to the corresponding value from |client_hello_| if it exists.
175 virtual QuicErrorCode ProcessClientHello(
176 const CryptoHandshakeMessage& client_hello,
177 std::string* error_details) OVERRIDE;
178
179 // Sets |value_| to the corresponding value from |server_hello_| if it exists.
180 virtual QuicErrorCode ProcessServerHello(
181 const CryptoHandshakeMessage& server_hello,
182 std::string* error_details) OVERRIDE;
183
184 private:
185 uint32 value_;
186 };
187
132 // QuicConfig contains non-crypto configuration options that are negotiated in 188 // QuicConfig contains non-crypto configuration options that are negotiated in
133 // the crypto handshake. 189 // the crypto handshake.
134 class NET_EXPORT_PRIVATE QuicConfig { 190 class NET_EXPORT_PRIVATE QuicConfig {
135 public: 191 public:
136 QuicConfig(); 192 QuicConfig();
137 ~QuicConfig(); 193 ~QuicConfig();
138 194
139 void set_congestion_control(const QuicTagVector& congestion_control, 195 void set_congestion_control(const QuicTagVector& congestion_control,
140 QuicTag default_congestion_control); 196 QuicTag default_congestion_control);
141 197
(...skipping 22 matching lines...) Expand all
164 void set_server_initial_congestion_window(size_t max_initial_window, 220 void set_server_initial_congestion_window(size_t max_initial_window,
165 size_t default_initial_window); 221 size_t default_initial_window);
166 222
167 uint32 server_initial_congestion_window() const; 223 uint32 server_initial_congestion_window() const;
168 224
169 // Sets an estimated initial round trip time in us. 225 // Sets an estimated initial round trip time in us.
170 void set_initial_round_trip_time_us(size_t max_rtt, size_t default_rtt); 226 void set_initial_round_trip_time_us(size_t max_rtt, size_t default_rtt);
171 227
172 uint32 initial_round_trip_time_us() const; 228 uint32 initial_round_trip_time_us() const;
173 229
230 void set_peer_initial_flow_control_window_bytes(uint32 window);
231
232 uint32 peer_initial_flow_control_window_bytes() const;
233
174 bool negotiated(); 234 bool negotiated();
175 235
176 // SetDefaults sets the members to sensible, default values. 236 // SetDefaults sets the members to sensible, default values.
177 void SetDefaults(); 237 void SetDefaults();
178 238
179 // Enabled pacing. 239 // Enabled pacing.
180 void EnablePacing(bool enable_pacing); 240 void EnablePacing(bool enable_pacing);
181 241
182 // ToHandshakeMessage serializes the settings in this object as a series of 242 // ToHandshakeMessage serializes the settings in this object as a series of
183 // tags /value pairs and adds them to |out|. 243 // tags /value pairs and adds them to |out|.
(...skipping 18 matching lines...) Expand all
202 QuicNegotiableUint32 keepalive_timeout_seconds_; 262 QuicNegotiableUint32 keepalive_timeout_seconds_;
203 // Maximum number of streams that the connection can support. 263 // Maximum number of streams that the connection can support.
204 QuicNegotiableUint32 max_streams_per_connection_; 264 QuicNegotiableUint32 max_streams_per_connection_;
205 // Maximum time till the session can be alive before crypto handshake is 265 // Maximum time till the session can be alive before crypto handshake is
206 // finished. (Not negotiated). 266 // finished. (Not negotiated).
207 QuicTime::Delta max_time_before_crypto_handshake_; 267 QuicTime::Delta max_time_before_crypto_handshake_;
208 // Initial congestion window in packets. 268 // Initial congestion window in packets.
209 QuicNegotiableUint32 server_initial_congestion_window_; 269 QuicNegotiableUint32 server_initial_congestion_window_;
210 // Initial round trip time estimate in microseconds. 270 // Initial round trip time estimate in microseconds.
211 QuicNegotiableUint32 initial_round_trip_time_us_; 271 QuicNegotiableUint32 initial_round_trip_time_us_;
272 // Peer's initial flow control receive window in bytes.
273 QuicFixedUint32 peer_initial_flow_control_window_bytes_;
212 }; 274 };
213 275
214 } // namespace net 276 } // namespace net
215 277
216 #endif // NET_QUIC_QUIC_CONFIG_H_ 278 #endif // NET_QUIC_QUIC_CONFIG_H_
OLDNEW
« no previous file with comments | « net/quic/crypto/quic_crypto_server_config.cc ('k') | net/quic/quic_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698