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

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

Issue 15074007: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for windows Created 7 years, 7 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/quic_client_session_test.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 "net/quic/crypto/crypto_handshake.h" 11 #include "net/quic/crypto/crypto_handshake.h"
11 #include "net/quic/crypto/crypto_utils.h" 12 #include "net/quic/crypto/crypto_utils.h"
13 #include "net/quic/quic_protocol.h"
12 #include "net/quic/quic_time.h" 14 #include "net/quic/quic_time.h"
15 #include "net/quic/quic_utils.h"
13 16
14 namespace net { 17 namespace net {
15 18
16 // QuicNegotiatedParameters contains non-crypto parameters that are agreed upon 19 class NET_EXPORT_PRIVATE QuicNegotiableValue {
17 // during the crypto handshake.
18 class NET_EXPORT_PRIVATE QuicNegotiatedParameters {
19 public: 20 public:
20 QuicNegotiatedParameters(); 21 enum Presence {
22 // This negotiable value can be absent from the handshake message. Default
23 // value is selected as the negotiated value in such a case.
24 PRESENCE_OPTIONAL,
25 // This negotiable value is required in the handshake message otherwise the
26 // Process*Hello function returns an error.
27 PRESENCE_REQUIRED,
28 };
21 29
22 QuicTag congestion_control; 30 QuicNegotiableValue(QuicTag tag, Presence presence);
23 QuicTime::Delta idle_connection_state_lifetime; 31
24 QuicTime::Delta keepalive_timeout; 32 bool negotiated() const {
33 return negotiated_;
34 }
35
36 protected:
37 const QuicTag tag_;
38 const Presence presence_;
39 bool negotiated_;
40 };
41
42 class NET_EXPORT_PRIVATE QuicNegotiableUint32 : public QuicNegotiableValue {
43 public:
44 QuicNegotiableUint32(QuicTag name, Presence presence);
45
46 // 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
48 // doesn't contain a value corresponding to |name_|. |max| is serialised via
49 // ToHandshakeMessage call if |negotiated_| is false.
50 void set(uint32 max, uint32 default_value);
51
52 // Returns the value negotiated if |negotiated_| is true, otherwise returns
53 // default_value_ (used to set default values before negotiation finishes).
54 uint32 GetUint32() const;
55
56 // Serialises |name_| and value to |out|. If |negotiated_| is true then
57 // |negotiated_value_| is serialised, otherwise |max_value_| is serialised.
58 void ToHandshakeMessage(CryptoHandshakeMessage* out) const;
59
60 // Sets |negotiated_value_| to the minimum of |max_value_| and the
61 // corresponding value from |client_hello|. If the corresponding value is
62 // missing and PRESENCE_OPTIONAL then |negotiated_value_| is set to
63 // |default_value_|.
64 QuicErrorCode ProcessClientHello(const CryptoHandshakeMessage& client_hello,
65 std::string* error_details);
66
67 // Sets the |negotiated_value_| to the corresponding value from
68 // |server_hello|. Returns error if the value received in |server_hello| is
69 // greater than |max_value_|. If the corresponding value is missing and
70 // PRESENCE_OPTIONAL then |negotiated_value_| is set to |0|,
71 QuicErrorCode ProcessServerHello(const CryptoHandshakeMessage& server_hello,
72 std::string* error_details);
73
74 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_;
83 uint32 default_value_;
84 uint32 negotiated_value_;
85 };
86
87 class NET_EXPORT_PRIVATE QuicNegotiableTag : public QuicNegotiableValue {
88 public:
89 QuicNegotiableTag(QuicTag name, Presence presence);
90 ~QuicNegotiableTag();
91
92 // Sets the possible values that |negotiated_tag_| can take after negotiation
93 // and the default value that |negotiated_tag_| takes if OPTIONAL and *HLO
94 // msg doesn't contain tag |name_|.
95 void set(const QuicTagVector& possible_values, QuicTag default_value);
96
97 // Returns the negotiated tag if |negotiated_| is true, otherwise returns
98 // |default_value_| (used to set default values before negotiation finishes).
99 QuicTag GetTag() const;
100
101 // Serialises |name_| and vector (either possible or negotiated) to |out|. If
102 // |negotiated_| is true then |negotiated_tag_| is serialised, otherwise
103 // |possible_values_| is serialised.
104 void ToHandshakeMessage(CryptoHandshakeMessage* out) const;
105
106 // Selects the tag common to both tags in |client_hello| for |name_| and
107 // |possible_values_| with preference to tag in |possible_values_|. The
108 // selected tag is set as |negotiated_tag_|.
109 QuicErrorCode ProcessClientHello(const CryptoHandshakeMessage& client_hello,
110 std::string* error_details);
111
112 // 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
114 // |possible_values_|.
115 QuicErrorCode ProcessServerHello(const CryptoHandshakeMessage& server_hello,
116 std::string* error_details);
117
118 private:
119 // 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
121 // to |possible_values_|.
122 QuicErrorCode ReadVector(const CryptoHandshakeMessage& msg,
123 const QuicTag** out,
124 size_t* out_length,
125 std::string* error_details) const;
126
127 QuicTag negotiated_tag_;
128 QuicTagVector possible_values_;
129 QuicTag default_value_;
25 }; 130 };
26 131
27 // QuicConfig contains non-crypto configuration options that are negotiated in 132 // QuicConfig contains non-crypto configuration options that are negotiated in
28 // the crypto handshake. 133 // the crypto handshake.
29 class NET_EXPORT_PRIVATE QuicConfig { 134 class NET_EXPORT_PRIVATE QuicConfig {
30 public: 135 public:
31 QuicConfig(); 136 QuicConfig();
32 ~QuicConfig(); 137 ~QuicConfig();
33 138
139 void set_congestion_control(const QuicTagVector& congestion_control,
140 QuicTag default_congestion_control);
141
142 QuicTag congestion_control() const;
143
34 void set_idle_connection_state_lifetime( 144 void set_idle_connection_state_lifetime(
35 QuicTime::Delta idle_connection_state_lifetime) { 145 QuicTime::Delta max_idle_connection_state_lifetime,
36 idle_connection_state_lifetime_ = idle_connection_state_lifetime; 146 QuicTime::Delta default_idle_conection_state_lifetime);
37 } 147
148 QuicTime::Delta idle_connection_state_lifetime() const;
149
150 QuicTime::Delta keepalive_timeout() const;
151
152 void set_max_streams_per_connection(size_t max_streams,
153 size_t default_streams);
154
155 uint32 max_streams_per_connection() const;
156
157 bool negotiated();
38 158
39 // SetDefaults sets the members to sensible, default values. 159 // SetDefaults sets the members to sensible, default values.
40 void SetDefaults(); 160 void SetDefaults();
41 161
42 // SetFromMessage extracts the non-crypto configuration from |msg| and sets
43 // the members of this object to match. This is expected to be called in the
44 // case of a server which is loading a server config. The server config
45 // contains the non-crypto parameters and so the server will need to keep its
46 // QuicConfig in sync with the server config that it'll be sending to
47 // clients.
48 bool SetFromHandshakeMessage(const CryptoHandshakeMessage& scfg);
49
50 // ToHandshakeMessage serializes the settings in this object as a series of 162 // ToHandshakeMessage serializes the settings in this object as a series of
51 // tags /value pairs and adds them to |out|. 163 // tags /value pairs and adds them to |out|.
52 void ToHandshakeMessage(CryptoHandshakeMessage* out) const; 164 void ToHandshakeMessage(CryptoHandshakeMessage* out) const;
53 165
54 QuicErrorCode ProcessFinalPeerHandshake( 166 // Calls ProcessClientHello on each negotiable parameter. On failure returns
55 const CryptoHandshakeMessage& peer_handshake, 167 // the corresponding QuicErrorCode and sets detailed error in |error_details|.
56 CryptoUtils::Priority priority, 168 QuicErrorCode ProcessClientHello(const CryptoHandshakeMessage& client_hello,
57 QuicNegotiatedParameters* out_params, 169 std::string* error_details);
58 std::string* error_details) const; 170
171 // Calls ProcessServerHello on each negotiable parameter. On failure returns
172 // the corresponding QuicErrorCode and sets detailed error in |error_details|.
173 QuicErrorCode ProcessServerHello(const CryptoHandshakeMessage& server_hello,
174 std::string* error_details);
59 175
60 private: 176 private:
61 // Congestion control feedback type. 177 // Congestion control feedback type.
62 QuicTagVector congestion_control_; 178 QuicNegotiableTag congestion_control_;
63 // Idle connection state lifetime 179 // Idle connection state lifetime
64 QuicTime::Delta idle_connection_state_lifetime_; 180 QuicNegotiableUint32 idle_connection_state_lifetime_seconds_;
65 // Keepalive timeout, or 0 to turn off keepalive probes 181 // Keepalive timeout, or 0 to turn off keepalive probes
66 QuicTime::Delta keepalive_timeout_; 182 QuicNegotiableUint32 keepalive_timeout_seconds_;
183 // Maximum number of streams that the connection can support.
184 QuicNegotiableUint32 max_streams_per_connection_;
67 }; 185 };
68 186
69 } // namespace net 187 } // namespace net
70 188
71 #endif // NET_QUIC_QUIC_CONFIG_H_ 189 #endif // NET_QUIC_QUIC_CONFIG_H_
OLDNEW
« no previous file with comments | « net/quic/quic_client_session_test.cc ('k') | net/quic/quic_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698