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

Side by Side Diff: net/quic/quic_crypto_stream.cc

Issue 13976007: Land Recent QUIC Changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated copyright notice Created 7 years, 8 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_crypto_stream.h ('k') | net/quic/quic_http_stream_test.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) 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 #include "net/quic/quic_crypto_stream.h" 5 #include "net/quic/quic_crypto_stream.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
10 #include "net/quic/crypto/crypto_handshake.h" 10 #include "net/quic/crypto/crypto_handshake.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 session()->OnCryptoHandshakeComplete(error); 54 session()->OnCryptoHandshakeComplete(error);
55 } 55 }
56 56
57 void QuicCryptoStream::SendHandshakeMessage( 57 void QuicCryptoStream::SendHandshakeMessage(
58 const CryptoHandshakeMessage& message) { 58 const CryptoHandshakeMessage& message) {
59 const QuicData& data = message.GetSerialized(); 59 const QuicData& data = message.GetSerialized();
60 // TODO(wtc): check the return value. 60 // TODO(wtc): check the return value.
61 WriteData(string(data.data(), data.length()), false); 61 WriteData(string(data.data(), data.length()), false);
62 } 62 }
63 63
64 QuicNegotiatedParameters::QuicNegotiatedParameters()
65 : idle_connection_state_lifetime(QuicTime::Delta::Zero()),
66 keepalive_timeout(QuicTime::Delta::Zero()) {
67 }
68
69 QuicConfig::QuicConfig()
70 : idle_connection_state_lifetime_(QuicTime::Delta::Zero()),
71 keepalive_timeout_(QuicTime::Delta::Zero()) {
72 }
73
74 QuicConfig::~QuicConfig() {
75 }
76
77 void QuicConfig::SetDefaults() {
78 idle_connection_state_lifetime_ = QuicTime::Delta::FromSeconds(300);
79 keepalive_timeout_ = QuicTime::Delta::Zero();
80 congestion_control_.clear();
81 congestion_control_.push_back(kQBIC);
82 }
83
84 bool QuicConfig::SetFromHandshakeMessage(const CryptoHandshakeMessage& scfg) {
85 const CryptoTag* cgst;
86 size_t num_cgst;
87 QuicErrorCode error;
88
89 error = scfg.GetTaglist(kCGST, &cgst, &num_cgst);
90 if (error != QUIC_NO_ERROR) {
91 return false;
92 }
93
94 congestion_control_.assign(cgst, cgst + num_cgst);
95
96 uint32 idle;
97 error = scfg.GetUint32(kICSL, &idle);
98 if (error != QUIC_NO_ERROR) {
99 return false;
100 }
101
102 idle_connection_state_lifetime_ = QuicTime::Delta::FromSeconds(idle);
103
104 keepalive_timeout_ = QuicTime::Delta::Zero();
105
106 uint32 keepalive;
107 error = scfg.GetUint32(kKATO, &keepalive);
108 // KATO is optional.
109 if (error == QUIC_NO_ERROR) {
110 keepalive_timeout_ = QuicTime::Delta::FromSeconds(keepalive);
111 }
112
113 return true;
114 }
115
116 void QuicConfig::ToHandshakeMessage(CryptoHandshakeMessage* out) const {
117 out->SetValue(
118 kICSL, static_cast<uint32>(idle_connection_state_lifetime_.ToSeconds()));
119 out->SetValue(kKATO, static_cast<uint32>(keepalive_timeout_.ToSeconds()));
120 out->SetVector(kCGST, congestion_control_);
121 }
122
123 QuicErrorCode QuicConfig::ProcessFinalPeerHandshake(
124 const CryptoHandshakeMessage& msg,
125 CryptoUtils::Priority priority,
126 QuicNegotiatedParameters* out_params,
127 string* error_details) const {
128 const CryptoTag* their_congestion_controls;
129 size_t num_their_congestion_controls;
130 QuicErrorCode error;
131
132 error = msg.GetTaglist(kCGST, &their_congestion_controls,
133 &num_their_congestion_controls);
134 if (error != QUIC_NO_ERROR) {
135 if (error_details) {
136 *error_details = "Missing CGST";
137 }
138 return error;
139 }
140
141 if (!CryptoUtils::FindMutualTag(congestion_control_,
142 their_congestion_controls,
143 num_their_congestion_controls,
144 priority,
145 &out_params->congestion_control,
146 NULL)) {
147 if (error_details) {
148 *error_details = "Unsuported CGST";
149 }
150 return QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP;
151 }
152
153 uint32 idle;
154 error = msg.GetUint32(kICSL, &idle);
155 if (error != QUIC_NO_ERROR) {
156 if (error_details) {
157 *error_details = "Missing ICSL";
158 }
159 return error;
160 }
161
162 out_params->idle_connection_state_lifetime = QuicTime::Delta::FromSeconds(
163 std::min(static_cast<uint32>(idle_connection_state_lifetime_.ToSeconds()),
164 idle));
165
166 uint32 keepalive;
167 error = msg.GetUint32(kKATO, &keepalive);
168 switch (error) {
169 case QUIC_NO_ERROR:
170 out_params->keepalive_timeout = QuicTime::Delta::FromSeconds(
171 std::min(static_cast<uint32>(keepalive_timeout_.ToSeconds()),
172 keepalive));
173 break;
174 case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND:
175 // KATO is optional.
176 out_params->keepalive_timeout = QuicTime::Delta::Zero();
177 break;
178 default:
179 if (error_details) {
180 *error_details = "Bad KATO";
181 }
182 return error;
183 }
184
185 return QUIC_NO_ERROR;
186 }
187
188 } // namespace net 64 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_stream.h ('k') | net/quic/quic_http_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698