Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "net/quic/quic_config.h" |
| 6 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 7 | #include <algorithm> |
| 8 | |
| 9 | #include "base/logging.h" |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 10 | #include "net/quic/crypto/crypto_handshake_message.h" |
| 11 | #include "net/quic/crypto/crypto_protocol.h" |
Ben Murdoch | e5d81f5 | 2014-04-03 12:29:45 +0100 | [diff] [blame] | 12 | #include "net/quic/quic_flags.h" |
Torne (Richard Coles) | a3f6a49 | 2013-12-18 16:25:09 +0000 | [diff] [blame] | 13 | #include "net/quic/quic_sent_packet_manager.h" |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 14 | #include "net/quic/quic_utils.h" |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 15 | |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 16 | using std::min; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 17 | using std::string; |
| 18 | |
| 19 | namespace net { |
| 20 | |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 21 | // Reads the value corresponding to |name_| from |msg| into |out|. If the |
| 22 | // |name_| is absent in |msg| and |presence| is set to OPTIONAL |out| is set |
| 23 | // to |default_value|. |
| 24 | QuicErrorCode ReadUint32(const CryptoHandshakeMessage& msg, |
| 25 | QuicTag tag, |
| 26 | QuicConfigPresence presence, |
| 27 | uint32 default_value, |
| 28 | uint32* out, |
| 29 | string* error_details) { |
| 30 | DCHECK(error_details != NULL); |
| 31 | QuicErrorCode error = msg.GetUint32(tag, out); |
| 32 | switch (error) { |
| 33 | case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND: |
| 34 | if (presence == PRESENCE_REQUIRED) { |
| 35 | *error_details = "Missing " + QuicUtils::TagToString(tag); |
| 36 | break; |
| 37 | } |
| 38 | error = QUIC_NO_ERROR; |
| 39 | *out = default_value; |
| 40 | break; |
| 41 | case QUIC_NO_ERROR: |
| 42 | break; |
| 43 | default: |
| 44 | *error_details = "Bad " + QuicUtils::TagToString(tag); |
| 45 | break; |
| 46 | } |
| 47 | return error; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 48 | } |
| 49 | |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 50 | |
| 51 | QuicConfigValue::QuicConfigValue(QuicTag tag, |
| 52 | QuicConfigPresence presence) |
| 53 | : tag_(tag), |
| 54 | presence_(presence) { |
| 55 | } |
| 56 | QuicConfigValue::~QuicConfigValue() {} |
| 57 | |
| 58 | QuicNegotiableValue::QuicNegotiableValue(QuicTag tag, |
| 59 | QuicConfigPresence presence) |
| 60 | : QuicConfigValue(tag, presence), |
| 61 | negotiated_(false) { |
| 62 | } |
| 63 | QuicNegotiableValue::~QuicNegotiableValue() {} |
| 64 | |
| 65 | QuicNegotiableUint32::QuicNegotiableUint32(QuicTag tag, |
| 66 | QuicConfigPresence presence) |
Torne (Richard Coles) | 0f1bc08 | 2013-11-06 12:27:47 +0000 | [diff] [blame] | 67 | : QuicNegotiableValue(tag, presence), |
| 68 | max_value_(0), |
| 69 | default_value_(0) { |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 70 | } |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 71 | QuicNegotiableUint32::~QuicNegotiableUint32() {} |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 72 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 73 | void QuicNegotiableUint32::set(uint32 max, uint32 default_value) { |
| 74 | DCHECK_LE(default_value, max); |
| 75 | max_value_ = max; |
| 76 | default_value_ = default_value; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 77 | } |
| 78 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 79 | uint32 QuicNegotiableUint32::GetUint32() const { |
| 80 | if (negotiated_) { |
| 81 | return negotiated_value_; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 82 | } |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 83 | return default_value_; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 84 | } |
| 85 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 86 | void QuicNegotiableUint32::ToHandshakeMessage( |
| 87 | CryptoHandshakeMessage* out) const { |
| 88 | if (negotiated_) { |
| 89 | out->SetValue(tag_, negotiated_value_); |
| 90 | } else { |
| 91 | out->SetValue(tag_, max_value_); |
| 92 | } |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 93 | } |
| 94 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 95 | QuicErrorCode QuicNegotiableUint32::ProcessPeerHello( |
| 96 | const CryptoHandshakeMessage& peer_hello, |
| 97 | HelloType hello_type, |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 98 | string* error_details) { |
| 99 | DCHECK(!negotiated_); |
| 100 | DCHECK(error_details != NULL); |
| 101 | uint32 value; |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 102 | QuicErrorCode error = ReadUint32(peer_hello, |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 103 | tag_, |
| 104 | presence_, |
| 105 | default_value_, |
| 106 | &value, |
| 107 | error_details); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 108 | if (error != QUIC_NO_ERROR) { |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 109 | return error; |
| 110 | } |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 111 | if (hello_type == SERVER && value > max_value_) { |
Torne (Richard Coles) | f8ee788 | 2014-06-20 14:52:04 +0100 | [diff] [blame] | 112 | *error_details = |
| 113 | "Invalid value received for " + QuicUtils::TagToString(tag_); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 114 | return QUIC_INVALID_NEGOTIATED_VALUE; |
| 115 | } |
| 116 | |
| 117 | negotiated_ = true; |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 118 | negotiated_value_ = min(value, max_value_); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 119 | return QUIC_NO_ERROR; |
| 120 | } |
| 121 | |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 122 | QuicNegotiableTag::QuicNegotiableTag(QuicTag tag, QuicConfigPresence presence) |
Torne (Richard Coles) | f2477e0 | 2013-11-28 11:55:43 +0000 | [diff] [blame] | 123 | : QuicNegotiableValue(tag, presence), |
| 124 | negotiated_tag_(0), |
| 125 | default_value_(0) { |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | QuicNegotiableTag::~QuicNegotiableTag() {} |
| 129 | |
| 130 | void QuicNegotiableTag::set(const QuicTagVector& possible, |
| 131 | QuicTag default_value) { |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 132 | DCHECK(ContainsQuicTag(possible, default_value)); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 133 | possible_values_ = possible; |
| 134 | default_value_ = default_value; |
| 135 | } |
| 136 | |
| 137 | QuicTag QuicNegotiableTag::GetTag() const { |
| 138 | if (negotiated_) { |
| 139 | return negotiated_tag_; |
| 140 | } |
| 141 | return default_value_; |
| 142 | } |
| 143 | |
| 144 | void QuicNegotiableTag::ToHandshakeMessage(CryptoHandshakeMessage* out) const { |
| 145 | if (negotiated_) { |
| 146 | // Because of the way we serialize and parse handshake messages we can |
| 147 | // serialize this as value and still parse it as a vector. |
| 148 | out->SetValue(tag_, negotiated_tag_); |
| 149 | } else { |
| 150 | out->SetVector(tag_, possible_values_); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | QuicErrorCode QuicNegotiableTag::ReadVector( |
| 155 | const CryptoHandshakeMessage& msg, |
| 156 | const QuicTag** out, |
| 157 | size_t* out_length, |
| 158 | string* error_details) const { |
| 159 | DCHECK(error_details != NULL); |
| 160 | QuicErrorCode error = msg.GetTaglist(tag_, out, out_length); |
| 161 | switch (error) { |
| 162 | case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND: |
| 163 | if (presence_ == PRESENCE_REQUIRED) { |
| 164 | *error_details = "Missing " + QuicUtils::TagToString(tag_); |
| 165 | break; |
| 166 | } |
| 167 | error = QUIC_NO_ERROR; |
| 168 | *out_length = 1; |
| 169 | *out = &default_value_; |
| 170 | |
| 171 | case QUIC_NO_ERROR: |
| 172 | break; |
| 173 | default: |
| 174 | *error_details = "Bad " + QuicUtils::TagToString(tag_); |
| 175 | break; |
| 176 | } |
| 177 | return error; |
| 178 | } |
| 179 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 180 | QuicErrorCode QuicNegotiableTag::ProcessPeerHello( |
| 181 | const CryptoHandshakeMessage& peer_hello, |
| 182 | HelloType hello_type, |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 183 | string* error_details) { |
| 184 | DCHECK(!negotiated_); |
| 185 | DCHECK(error_details != NULL); |
| 186 | const QuicTag* received_tags; |
| 187 | size_t received_tags_length; |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 188 | QuicErrorCode error = ReadVector(peer_hello, &received_tags, |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 189 | &received_tags_length, error_details); |
| 190 | if (error != QUIC_NO_ERROR) { |
| 191 | return error; |
| 192 | } |
| 193 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 194 | if (hello_type == SERVER) { |
| 195 | if (received_tags_length != 1 || |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 196 | !ContainsQuicTag(possible_values_, *received_tags)) { |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 197 | *error_details = "Invalid " + QuicUtils::TagToString(tag_); |
| 198 | return QUIC_INVALID_NEGOTIATED_VALUE; |
| 199 | } |
| 200 | negotiated_tag_ = *received_tags; |
| 201 | } else { |
| 202 | QuicTag negotiated_tag; |
| 203 | if (!QuicUtils::FindMutualTag(possible_values_, |
| 204 | received_tags, |
| 205 | received_tags_length, |
| 206 | QuicUtils::LOCAL_PRIORITY, |
| 207 | &negotiated_tag, |
| 208 | NULL)) { |
| 209 | *error_details = "Unsupported " + QuicUtils::TagToString(tag_); |
| 210 | return QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP; |
| 211 | } |
| 212 | negotiated_tag_ = negotiated_tag; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 213 | } |
| 214 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 215 | negotiated_ = true; |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 216 | return QUIC_NO_ERROR; |
| 217 | } |
| 218 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 219 | QuicFixedUint32::QuicFixedUint32(QuicTag tag, QuicConfigPresence presence) |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 220 | : QuicConfigValue(tag, presence), |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 221 | has_send_value_(false), |
| 222 | has_receive_value_(false) { |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 223 | } |
| 224 | QuicFixedUint32::~QuicFixedUint32() {} |
| 225 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 226 | bool QuicFixedUint32::HasSendValue() const { |
| 227 | return has_send_value_; |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 228 | } |
| 229 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 230 | uint32 QuicFixedUint32::GetSendValue() const { |
Torne (Richard Coles) | f8ee788 | 2014-06-20 14:52:04 +0100 | [diff] [blame] | 231 | LOG_IF(DFATAL, !has_send_value_) |
| 232 | << "No send value to get for tag:" << QuicUtils::TagToString(tag_); |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 233 | return send_value_; |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 234 | } |
| 235 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 236 | void QuicFixedUint32::SetSendValue(uint32 value) { |
| 237 | has_send_value_ = true; |
| 238 | send_value_ = value; |
| 239 | } |
| 240 | |
| 241 | bool QuicFixedUint32::HasReceivedValue() const { |
| 242 | return has_receive_value_; |
| 243 | } |
| 244 | |
| 245 | uint32 QuicFixedUint32::GetReceivedValue() const { |
| 246 | LOG_IF(DFATAL, !has_receive_value_) |
Torne (Richard Coles) | f8ee788 | 2014-06-20 14:52:04 +0100 | [diff] [blame] | 247 | << "No receive value to get for tag:" << QuicUtils::TagToString(tag_); |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 248 | return receive_value_; |
| 249 | } |
| 250 | |
| 251 | void QuicFixedUint32::SetReceivedValue(uint32 value) { |
| 252 | has_receive_value_ = true; |
| 253 | receive_value_ = value; |
| 254 | } |
| 255 | |
| 256 | void QuicFixedUint32::ToHandshakeMessage(CryptoHandshakeMessage* out) const { |
| 257 | if (has_send_value_) { |
| 258 | out->SetValue(tag_, send_value_); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | QuicErrorCode QuicFixedUint32::ProcessPeerHello( |
| 263 | const CryptoHandshakeMessage& peer_hello, |
| 264 | HelloType hello_type, |
| 265 | string* error_details) { |
| 266 | DCHECK(error_details != NULL); |
| 267 | QuicErrorCode error = peer_hello.GetUint32(tag_, &receive_value_); |
| 268 | switch (error) { |
| 269 | case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND: |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 270 | if (presence_ == PRESENCE_OPTIONAL) { |
| 271 | return QUIC_NO_ERROR; |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 272 | } |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 273 | *error_details = "Missing " + QuicUtils::TagToString(tag_); |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 274 | break; |
| 275 | case QUIC_NO_ERROR: |
| 276 | has_receive_value_ = true; |
| 277 | break; |
| 278 | default: |
| 279 | *error_details = "Bad " + QuicUtils::TagToString(tag_); |
| 280 | break; |
| 281 | } |
| 282 | return error; |
| 283 | } |
| 284 | |
| 285 | QuicFixedTag::QuicFixedTag(QuicTag name, |
| 286 | QuicConfigPresence presence) |
| 287 | : QuicConfigValue(name, presence), |
| 288 | has_send_value_(false), |
| 289 | has_receive_value_(false) { |
| 290 | } |
| 291 | |
| 292 | QuicFixedTag::~QuicFixedTag() {} |
| 293 | |
| 294 | bool QuicFixedTag::HasSendValue() const { |
| 295 | return has_send_value_; |
| 296 | } |
| 297 | |
| 298 | uint32 QuicFixedTag::GetSendValue() const { |
Torne (Richard Coles) | f8ee788 | 2014-06-20 14:52:04 +0100 | [diff] [blame] | 299 | LOG_IF(DFATAL, !has_send_value_) |
| 300 | << "No send value to get for tag:" << QuicUtils::TagToString(tag_); |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 301 | return send_value_; |
| 302 | } |
| 303 | |
| 304 | void QuicFixedTag::SetSendValue(uint32 value) { |
| 305 | has_send_value_ = true; |
| 306 | send_value_ = value; |
| 307 | } |
| 308 | |
| 309 | bool QuicFixedTag::HasReceivedValue() const { |
| 310 | return has_receive_value_; |
| 311 | } |
| 312 | |
| 313 | uint32 QuicFixedTag::GetReceivedValue() const { |
| 314 | LOG_IF(DFATAL, !has_receive_value_) |
Torne (Richard Coles) | f8ee788 | 2014-06-20 14:52:04 +0100 | [diff] [blame] | 315 | << "No receive value to get for tag:" << QuicUtils::TagToString(tag_); |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 316 | return receive_value_; |
| 317 | } |
| 318 | |
| 319 | void QuicFixedTag::SetReceivedValue(uint32 value) { |
| 320 | has_receive_value_ = true; |
| 321 | receive_value_ = value; |
| 322 | } |
| 323 | |
| 324 | void QuicFixedTag::ToHandshakeMessage(CryptoHandshakeMessage* out) const { |
| 325 | if (has_send_value_) { |
| 326 | out->SetValue(tag_, send_value_); |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | QuicErrorCode QuicFixedTag::ProcessPeerHello( |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 331 | const CryptoHandshakeMessage& peer_hello, |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 332 | HelloType hello_type, |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 333 | string* error_details) { |
| 334 | DCHECK(error_details != NULL); |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 335 | QuicErrorCode error = peer_hello.GetUint32(tag_, &receive_value_); |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 336 | switch (error) { |
| 337 | case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND: |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 338 | if (presence_ == PRESENCE_OPTIONAL) { |
| 339 | return QUIC_NO_ERROR; |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 340 | } |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 341 | *error_details = "Missing " + QuicUtils::TagToString(tag_); |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 342 | break; |
| 343 | case QUIC_NO_ERROR: |
| 344 | has_receive_value_ = true; |
| 345 | break; |
| 346 | default: |
| 347 | *error_details = "Bad " + QuicUtils::TagToString(tag_); |
| 348 | break; |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 349 | } |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 350 | return error; |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 351 | } |
| 352 | |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 353 | QuicFixedTagVector::QuicFixedTagVector(QuicTag name, |
| 354 | QuicConfigPresence presence) |
| 355 | : QuicConfigValue(name, presence), |
| 356 | has_send_values_(false), |
| 357 | has_receive_values_(false) { |
| 358 | } |
| 359 | |
| 360 | QuicFixedTagVector::~QuicFixedTagVector() {} |
| 361 | |
| 362 | bool QuicFixedTagVector::HasSendValues() const { |
| 363 | return has_send_values_; |
| 364 | } |
| 365 | |
| 366 | QuicTagVector QuicFixedTagVector::GetSendValues() const { |
Torne (Richard Coles) | f8ee788 | 2014-06-20 14:52:04 +0100 | [diff] [blame] | 367 | LOG_IF(DFATAL, !has_send_values_) |
| 368 | << "No send values to get for tag:" << QuicUtils::TagToString(tag_); |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 369 | return send_values_; |
| 370 | } |
| 371 | |
| 372 | void QuicFixedTagVector::SetSendValues(const QuicTagVector& values) { |
| 373 | has_send_values_ = true; |
| 374 | send_values_ = values; |
| 375 | } |
| 376 | |
| 377 | bool QuicFixedTagVector::HasReceivedValues() const { |
| 378 | return has_receive_values_; |
| 379 | } |
| 380 | |
| 381 | QuicTagVector QuicFixedTagVector::GetReceivedValues() const { |
| 382 | LOG_IF(DFATAL, !has_receive_values_) |
Torne (Richard Coles) | f8ee788 | 2014-06-20 14:52:04 +0100 | [diff] [blame] | 383 | << "No receive value to get for tag:" << QuicUtils::TagToString(tag_); |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 384 | return receive_values_; |
| 385 | } |
| 386 | |
| 387 | void QuicFixedTagVector::SetReceivedValues(const QuicTagVector& values) { |
| 388 | has_receive_values_ = true; |
| 389 | receive_values_ = values; |
| 390 | } |
| 391 | |
| 392 | void QuicFixedTagVector::ToHandshakeMessage(CryptoHandshakeMessage* out) const { |
| 393 | if (has_send_values_) { |
| 394 | out->SetVector(tag_, send_values_); |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | QuicErrorCode QuicFixedTagVector::ProcessPeerHello( |
| 399 | const CryptoHandshakeMessage& peer_hello, |
| 400 | HelloType hello_type, |
| 401 | string* error_details) { |
| 402 | DCHECK(error_details != NULL); |
| 403 | const QuicTag* received_tags; |
| 404 | size_t received_tags_length; |
| 405 | QuicErrorCode error = |
| 406 | peer_hello.GetTaglist(tag_, &received_tags, &received_tags_length); |
| 407 | switch (error) { |
| 408 | case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND: |
| 409 | if (presence_ == PRESENCE_OPTIONAL) { |
| 410 | return QUIC_NO_ERROR; |
| 411 | } |
| 412 | *error_details = "Missing " + QuicUtils::TagToString(tag_); |
| 413 | break; |
| 414 | case QUIC_NO_ERROR: |
Ben Murdoch | 116680a | 2014-07-20 18:25:52 -0700 | [diff] [blame] | 415 | DVLOG(1) << "Received Connection Option tags from receiver."; |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 416 | has_receive_values_ = true; |
| 417 | for (size_t i = 0; i < received_tags_length; ++i) { |
| 418 | receive_values_.push_back(received_tags[i]); |
| 419 | } |
| 420 | break; |
| 421 | default: |
| 422 | *error_details = "Bad " + QuicUtils::TagToString(tag_); |
| 423 | break; |
| 424 | } |
| 425 | return error; |
| 426 | } |
| 427 | |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 428 | QuicConfig::QuicConfig() |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 429 | : congestion_feedback_(kCGST, PRESENCE_REQUIRED), |
Ben Murdoch | 116680a | 2014-07-20 18:25:52 -0700 | [diff] [blame] | 430 | connection_options_(kCOPT, PRESENCE_OPTIONAL), |
Ben Murdoch | e5d81f5 | 2014-04-03 12:29:45 +0100 | [diff] [blame] | 431 | loss_detection_(kLOSS, PRESENCE_OPTIONAL), |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 432 | idle_connection_state_lifetime_seconds_(kICSL, PRESENCE_REQUIRED), |
| 433 | keepalive_timeout_seconds_(kKATO, PRESENCE_OPTIONAL), |
| 434 | max_streams_per_connection_(kMSPC, PRESENCE_REQUIRED), |
| 435 | max_time_before_crypto_handshake_(QuicTime::Delta::Zero()), |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 436 | initial_congestion_window_(kSWND, PRESENCE_OPTIONAL), |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 437 | initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL), |
Torne (Richard Coles) | 5f1c943 | 2014-08-12 13:47:38 +0100 | [diff] [blame] | 438 | // TODO(rjshade): Make this PRESENCE_REQUIRED when QUIC_VERSION_16 is |
| 439 | // retired. |
Torne (Richard Coles) | 6d86b77 | 2014-06-25 10:30:53 +0100 | [diff] [blame] | 440 | initial_flow_control_window_bytes_(kIFCW, PRESENCE_OPTIONAL), |
| 441 | // TODO(rjshade): Make this PRESENCE_REQUIRED when retiring |
| 442 | // QUIC_VERSION_19. |
| 443 | initial_stream_flow_control_window_bytes_(kSFCW, PRESENCE_OPTIONAL), |
| 444 | // TODO(rjshade): Make this PRESENCE_REQUIRED when retiring |
| 445 | // QUIC_VERSION_19. |
Torne (Richard Coles) | 6e8cce6 | 2014-08-19 13:00:08 +0100 | [diff] [blame^] | 446 | initial_session_flow_control_window_bytes_(kCFCW, PRESENCE_OPTIONAL), |
| 447 | socket_receive_buffer_(kSRBF, PRESENCE_OPTIONAL) { |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | QuicConfig::~QuicConfig() {} |
| 451 | |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 452 | void QuicConfig::set_congestion_feedback( |
| 453 | const QuicTagVector& congestion_feedback, |
| 454 | QuicTag default_congestion_feedback) { |
| 455 | congestion_feedback_.set(congestion_feedback, default_congestion_feedback); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 456 | } |
| 457 | |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 458 | QuicTag QuicConfig::congestion_feedback() const { |
| 459 | return congestion_feedback_.GetTag(); |
| 460 | } |
| 461 | |
Ben Murdoch | 116680a | 2014-07-20 18:25:52 -0700 | [diff] [blame] | 462 | void QuicConfig::SetConnectionOptionsToSend( |
| 463 | const QuicTagVector& connection_options) { |
| 464 | connection_options_.SetSendValues(connection_options); |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 465 | } |
| 466 | |
Ben Murdoch | 116680a | 2014-07-20 18:25:52 -0700 | [diff] [blame] | 467 | bool QuicConfig::HasReceivedConnectionOptions() const { |
| 468 | return connection_options_.HasReceivedValues(); |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 469 | } |
| 470 | |
Ben Murdoch | 116680a | 2014-07-20 18:25:52 -0700 | [diff] [blame] | 471 | QuicTagVector QuicConfig::ReceivedConnectionOptions() const { |
| 472 | return connection_options_.GetReceivedValues(); |
| 473 | } |
| 474 | |
| 475 | bool QuicConfig::HasSendConnectionOptions() const { |
| 476 | return connection_options_.HasSendValues(); |
| 477 | } |
| 478 | |
| 479 | QuicTagVector QuicConfig::SendConnectionOptions() const { |
| 480 | return connection_options_.GetSendValues(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 481 | } |
| 482 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 483 | void QuicConfig::SetLossDetectionToSend(QuicTag loss_detection) { |
| 484 | loss_detection_.SetSendValue(loss_detection); |
Ben Murdoch | e5d81f5 | 2014-04-03 12:29:45 +0100 | [diff] [blame] | 485 | } |
| 486 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 487 | bool QuicConfig::HasReceivedLossDetection() const { |
| 488 | return loss_detection_.HasReceivedValue(); |
| 489 | } |
| 490 | |
| 491 | QuicTag QuicConfig::ReceivedLossDetection() const { |
| 492 | return loss_detection_.GetReceivedValue(); |
Ben Murdoch | e5d81f5 | 2014-04-03 12:29:45 +0100 | [diff] [blame] | 493 | } |
| 494 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 495 | void QuicConfig::set_idle_connection_state_lifetime( |
| 496 | QuicTime::Delta max_idle_connection_state_lifetime, |
| 497 | QuicTime::Delta default_idle_conection_state_lifetime) { |
| 498 | idle_connection_state_lifetime_seconds_.set( |
| 499 | max_idle_connection_state_lifetime.ToSeconds(), |
| 500 | default_idle_conection_state_lifetime.ToSeconds()); |
| 501 | } |
| 502 | |
| 503 | QuicTime::Delta QuicConfig::idle_connection_state_lifetime() const { |
| 504 | return QuicTime::Delta::FromSeconds( |
| 505 | idle_connection_state_lifetime_seconds_.GetUint32()); |
| 506 | } |
| 507 | |
| 508 | QuicTime::Delta QuicConfig::keepalive_timeout() const { |
| 509 | return QuicTime::Delta::FromSeconds( |
| 510 | keepalive_timeout_seconds_.GetUint32()); |
| 511 | } |
| 512 | |
| 513 | void QuicConfig::set_max_streams_per_connection(size_t max_streams, |
| 514 | size_t default_streams) { |
| 515 | max_streams_per_connection_.set(max_streams, default_streams); |
| 516 | } |
| 517 | |
| 518 | uint32 QuicConfig::max_streams_per_connection() const { |
| 519 | return max_streams_per_connection_.GetUint32(); |
| 520 | } |
| 521 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 522 | void QuicConfig::set_max_time_before_crypto_handshake( |
| 523 | QuicTime::Delta max_time_before_crypto_handshake) { |
| 524 | max_time_before_crypto_handshake_ = max_time_before_crypto_handshake; |
| 525 | } |
| 526 | |
| 527 | QuicTime::Delta QuicConfig::max_time_before_crypto_handshake() const { |
| 528 | return max_time_before_crypto_handshake_; |
| 529 | } |
| 530 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 531 | void QuicConfig::SetInitialCongestionWindowToSend(size_t initial_window) { |
| 532 | initial_congestion_window_.SetSendValue(initial_window); |
Torne (Richard Coles) | 0f1bc08 | 2013-11-06 12:27:47 +0000 | [diff] [blame] | 533 | } |
| 534 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 535 | bool QuicConfig::HasReceivedInitialCongestionWindow() const { |
| 536 | return initial_congestion_window_.HasReceivedValue(); |
Torne (Richard Coles) | 0f1bc08 | 2013-11-06 12:27:47 +0000 | [diff] [blame] | 537 | } |
| 538 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 539 | uint32 QuicConfig::ReceivedInitialCongestionWindow() const { |
| 540 | return initial_congestion_window_.GetReceivedValue(); |
Torne (Richard Coles) | 0f1bc08 | 2013-11-06 12:27:47 +0000 | [diff] [blame] | 541 | } |
| 542 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 543 | void QuicConfig::SetInitialRoundTripTimeUsToSend(size_t rtt) { |
| 544 | initial_round_trip_time_us_.SetSendValue(rtt); |
Torne (Richard Coles) | 0f1bc08 | 2013-11-06 12:27:47 +0000 | [diff] [blame] | 545 | } |
| 546 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 547 | bool QuicConfig::HasReceivedInitialRoundTripTimeUs() const { |
| 548 | return initial_round_trip_time_us_.HasReceivedValue(); |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 549 | } |
| 550 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 551 | uint32 QuicConfig::ReceivedInitialRoundTripTimeUs() const { |
| 552 | return initial_round_trip_time_us_.GetReceivedValue(); |
| 553 | } |
| 554 | |
| 555 | void QuicConfig::SetInitialFlowControlWindowToSend(uint32 window_bytes) { |
Torne (Richard Coles) | f8ee788 | 2014-06-20 14:52:04 +0100 | [diff] [blame] | 556 | if (window_bytes < kDefaultFlowControlSendWindow) { |
| 557 | LOG(DFATAL) << "Initial flow control receive window (" << window_bytes |
| 558 | << ") cannot be set lower than default (" |
| 559 | << kDefaultFlowControlSendWindow << ")."; |
| 560 | window_bytes = kDefaultFlowControlSendWindow; |
| 561 | } |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 562 | initial_flow_control_window_bytes_.SetSendValue(window_bytes); |
| 563 | } |
| 564 | |
Torne (Richard Coles) | f8ee788 | 2014-06-20 14:52:04 +0100 | [diff] [blame] | 565 | uint32 QuicConfig::GetInitialFlowControlWindowToSend() const { |
| 566 | return initial_flow_control_window_bytes_.GetSendValue(); |
| 567 | } |
| 568 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 569 | bool QuicConfig::HasReceivedInitialFlowControlWindowBytes() const { |
Torne (Richard Coles) | f8ee788 | 2014-06-20 14:52:04 +0100 | [diff] [blame] | 570 | return initial_flow_control_window_bytes_.HasReceivedValue(); |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | uint32 QuicConfig::ReceivedInitialFlowControlWindowBytes() const { |
| 574 | return initial_flow_control_window_bytes_.GetReceivedValue(); |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 575 | } |
| 576 | |
Torne (Richard Coles) | 6d86b77 | 2014-06-25 10:30:53 +0100 | [diff] [blame] | 577 | void QuicConfig::SetInitialStreamFlowControlWindowToSend(uint32 window_bytes) { |
| 578 | if (window_bytes < kDefaultFlowControlSendWindow) { |
| 579 | LOG(DFATAL) << "Initial stream flow control receive window (" |
| 580 | << window_bytes << ") cannot be set lower than default (" |
| 581 | << kDefaultFlowControlSendWindow << ")."; |
| 582 | window_bytes = kDefaultFlowControlSendWindow; |
| 583 | } |
| 584 | initial_stream_flow_control_window_bytes_.SetSendValue(window_bytes); |
| 585 | } |
| 586 | |
| 587 | uint32 QuicConfig::GetInitialStreamFlowControlWindowToSend() const { |
| 588 | return initial_stream_flow_control_window_bytes_.GetSendValue(); |
| 589 | } |
| 590 | |
| 591 | bool QuicConfig::HasReceivedInitialStreamFlowControlWindowBytes() const { |
| 592 | return initial_stream_flow_control_window_bytes_.HasReceivedValue(); |
| 593 | } |
| 594 | |
| 595 | uint32 QuicConfig::ReceivedInitialStreamFlowControlWindowBytes() const { |
| 596 | return initial_stream_flow_control_window_bytes_.GetReceivedValue(); |
| 597 | } |
| 598 | |
| 599 | void QuicConfig::SetInitialSessionFlowControlWindowToSend(uint32 window_bytes) { |
| 600 | if (window_bytes < kDefaultFlowControlSendWindow) { |
| 601 | LOG(DFATAL) << "Initial session flow control receive window (" |
| 602 | << window_bytes << ") cannot be set lower than default (" |
| 603 | << kDefaultFlowControlSendWindow << ")."; |
| 604 | window_bytes = kDefaultFlowControlSendWindow; |
| 605 | } |
| 606 | initial_session_flow_control_window_bytes_.SetSendValue(window_bytes); |
| 607 | } |
| 608 | |
| 609 | uint32 QuicConfig::GetInitialSessionFlowControlWindowToSend() const { |
| 610 | return initial_session_flow_control_window_bytes_.GetSendValue(); |
| 611 | } |
| 612 | |
| 613 | bool QuicConfig::HasReceivedInitialSessionFlowControlWindowBytes() const { |
| 614 | return initial_session_flow_control_window_bytes_.HasReceivedValue(); |
| 615 | } |
| 616 | |
| 617 | uint32 QuicConfig::ReceivedInitialSessionFlowControlWindowBytes() const { |
| 618 | return initial_session_flow_control_window_bytes_.GetReceivedValue(); |
| 619 | } |
| 620 | |
Torne (Richard Coles) | 6e8cce6 | 2014-08-19 13:00:08 +0100 | [diff] [blame^] | 621 | void QuicConfig::SetSocketReceiveBufferToSend(uint32 tcp_receive_window) { |
| 622 | socket_receive_buffer_.SetSendValue(tcp_receive_window); |
| 623 | } |
| 624 | |
| 625 | uint32 QuicConfig::GetSocketReceiveBufferToSend() const { |
| 626 | return socket_receive_buffer_.GetSendValue(); |
| 627 | } |
| 628 | |
| 629 | bool QuicConfig::HasReceivedSocketReceiveBuffer() const { |
| 630 | return socket_receive_buffer_.HasReceivedValue(); |
| 631 | } |
| 632 | |
| 633 | uint32 QuicConfig::ReceivedSocketReceiveBuffer() const { |
| 634 | return socket_receive_buffer_.GetReceivedValue(); |
| 635 | } |
| 636 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 637 | bool QuicConfig::negotiated() { |
Torne (Richard Coles) | 0f1bc08 | 2013-11-06 12:27:47 +0000 | [diff] [blame] | 638 | // TODO(ianswett): Add the negotiated parameters once and iterate over all |
| 639 | // of them in negotiated, ToHandshakeMessage, ProcessClientHello, and |
| 640 | // ProcessServerHello. |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 641 | return congestion_feedback_.negotiated() && |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 642 | idle_connection_state_lifetime_seconds_.negotiated() && |
| 643 | keepalive_timeout_seconds_.negotiated() && |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 644 | max_streams_per_connection_.negotiated(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | void QuicConfig::SetDefaults() { |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 648 | QuicTagVector congestion_feedback; |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 649 | congestion_feedback.push_back(kQBIC); |
| 650 | congestion_feedback_.set(congestion_feedback, kQBIC); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 651 | idle_connection_state_lifetime_seconds_.set(kDefaultTimeoutSecs, |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 652 | kDefaultInitialTimeoutSecs); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 653 | // kKATO is optional. Return 0 if not negotiated. |
| 654 | keepalive_timeout_seconds_.set(0, 0); |
| 655 | max_streams_per_connection_.set(kDefaultMaxStreamsPerConnection, |
| 656 | kDefaultMaxStreamsPerConnection); |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 657 | max_time_before_crypto_handshake_ = QuicTime::Delta::FromSeconds( |
| 658 | kDefaultMaxTimeForCryptoHandshakeSecs); |
Torne (Richard Coles) | f8ee788 | 2014-06-20 14:52:04 +0100 | [diff] [blame] | 659 | |
| 660 | SetInitialFlowControlWindowToSend(kDefaultFlowControlSendWindow); |
Torne (Richard Coles) | 6d86b77 | 2014-06-25 10:30:53 +0100 | [diff] [blame] | 661 | SetInitialStreamFlowControlWindowToSend(kDefaultFlowControlSendWindow); |
| 662 | SetInitialSessionFlowControlWindowToSend(kDefaultFlowControlSendWindow); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const { |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 666 | congestion_feedback_.ToHandshakeMessage(out); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 667 | idle_connection_state_lifetime_seconds_.ToHandshakeMessage(out); |
| 668 | keepalive_timeout_seconds_.ToHandshakeMessage(out); |
| 669 | max_streams_per_connection_.ToHandshakeMessage(out); |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 670 | initial_congestion_window_.ToHandshakeMessage(out); |
Torne (Richard Coles) | 0f1bc08 | 2013-11-06 12:27:47 +0000 | [diff] [blame] | 671 | initial_round_trip_time_us_.ToHandshakeMessage(out); |
Ben Murdoch | e5d81f5 | 2014-04-03 12:29:45 +0100 | [diff] [blame] | 672 | loss_detection_.ToHandshakeMessage(out); |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 673 | initial_flow_control_window_bytes_.ToHandshakeMessage(out); |
Torne (Richard Coles) | 6d86b77 | 2014-06-25 10:30:53 +0100 | [diff] [blame] | 674 | initial_stream_flow_control_window_bytes_.ToHandshakeMessage(out); |
| 675 | initial_session_flow_control_window_bytes_.ToHandshakeMessage(out); |
Torne (Richard Coles) | 6e8cce6 | 2014-08-19 13:00:08 +0100 | [diff] [blame^] | 676 | socket_receive_buffer_.ToHandshakeMessage(out); |
Ben Murdoch | 116680a | 2014-07-20 18:25:52 -0700 | [diff] [blame] | 677 | connection_options_.ToHandshakeMessage(out); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 678 | } |
| 679 | |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 680 | QuicErrorCode QuicConfig::ProcessPeerHello( |
| 681 | const CryptoHandshakeMessage& peer_hello, |
| 682 | HelloType hello_type, |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 683 | string* error_details) { |
| 684 | DCHECK(error_details != NULL); |
| 685 | |
| 686 | QuicErrorCode error = QUIC_NO_ERROR; |
| 687 | if (error == QUIC_NO_ERROR) { |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 688 | error = congestion_feedback_.ProcessPeerHello( |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 689 | peer_hello, hello_type, error_details); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 690 | } |
| 691 | if (error == QUIC_NO_ERROR) { |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 692 | error = idle_connection_state_lifetime_seconds_.ProcessPeerHello( |
| 693 | peer_hello, hello_type, error_details); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 694 | } |
| 695 | if (error == QUIC_NO_ERROR) { |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 696 | error = keepalive_timeout_seconds_.ProcessPeerHello( |
| 697 | peer_hello, hello_type, error_details); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 698 | } |
| 699 | if (error == QUIC_NO_ERROR) { |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 700 | error = max_streams_per_connection_.ProcessPeerHello( |
| 701 | peer_hello, hello_type, error_details); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 702 | } |
Torne (Richard Coles) | 0f1bc08 | 2013-11-06 12:27:47 +0000 | [diff] [blame] | 703 | if (error == QUIC_NO_ERROR) { |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 704 | error = initial_congestion_window_.ProcessPeerHello( |
| 705 | peer_hello, hello_type, error_details); |
Torne (Richard Coles) | 0f1bc08 | 2013-11-06 12:27:47 +0000 | [diff] [blame] | 706 | } |
| 707 | if (error == QUIC_NO_ERROR) { |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 708 | error = initial_round_trip_time_us_.ProcessPeerHello( |
| 709 | peer_hello, hello_type, error_details); |
Torne (Richard Coles) | 0f1bc08 | 2013-11-06 12:27:47 +0000 | [diff] [blame] | 710 | } |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 711 | if (error == QUIC_NO_ERROR) { |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 712 | error = initial_flow_control_window_bytes_.ProcessPeerHello( |
| 713 | peer_hello, hello_type, error_details); |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 714 | } |
Ben Murdoch | e5d81f5 | 2014-04-03 12:29:45 +0100 | [diff] [blame] | 715 | if (error == QUIC_NO_ERROR) { |
Torne (Richard Coles) | 6d86b77 | 2014-06-25 10:30:53 +0100 | [diff] [blame] | 716 | error = initial_stream_flow_control_window_bytes_.ProcessPeerHello( |
| 717 | peer_hello, hello_type, error_details); |
| 718 | } |
| 719 | if (error == QUIC_NO_ERROR) { |
| 720 | error = initial_session_flow_control_window_bytes_.ProcessPeerHello( |
| 721 | peer_hello, hello_type, error_details); |
| 722 | } |
| 723 | if (error == QUIC_NO_ERROR) { |
Torne (Richard Coles) | 6e8cce6 | 2014-08-19 13:00:08 +0100 | [diff] [blame^] | 724 | error = socket_receive_buffer_.ProcessPeerHello( |
| 725 | peer_hello, hello_type, error_details); |
| 726 | } |
| 727 | if (error == QUIC_NO_ERROR) { |
Ben Murdoch | 0529e5d | 2014-04-24 10:50:13 +0100 | [diff] [blame] | 728 | error = loss_detection_.ProcessPeerHello( |
| 729 | peer_hello, hello_type, error_details); |
Ben Murdoch | e5d81f5 | 2014-04-03 12:29:45 +0100 | [diff] [blame] | 730 | } |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 731 | if (error == QUIC_NO_ERROR) { |
Ben Murdoch | 116680a | 2014-07-20 18:25:52 -0700 | [diff] [blame] | 732 | error = connection_options_.ProcessPeerHello( |
Torne (Richard Coles) | 46d4c2b | 2014-06-09 12:00:27 +0100 | [diff] [blame] | 733 | peer_hello, hello_type, error_details); |
| 734 | } |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 735 | return error; |
| 736 | } |
| 737 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 738 | } // namespace net |