OLD | NEW |
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/tools/quic/quic_dispatcher.h" | 5 #include "net/tools/quic/quic_dispatcher.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 | 8 |
9 #include "base/debug/stack_trace.h" | 9 #include "base/debug/stack_trace.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 const QuicPacketPublicHeader& header) { | 210 const QuicPacketPublicHeader& header) { |
211 // Port zero is only allowed for unidirectional UDP, so is disallowed by QUIC. | 211 // Port zero is only allowed for unidirectional UDP, so is disallowed by QUIC. |
212 // Given that we can't even send a reply rejecting the packet, just black hole | 212 // Given that we can't even send a reply rejecting the packet, just black hole |
213 // it. | 213 // it. |
214 if (current_client_address_.port() == 0) { | 214 if (current_client_address_.port() == 0) { |
215 return false; | 215 return false; |
216 } | 216 } |
217 | 217 |
218 // The session that we have identified as the one to which this packet | 218 // The session that we have identified as the one to which this packet |
219 // belongs. | 219 // belongs. |
220 QuicSession* session = nullptr; | 220 QuicServerSession* session = nullptr; |
221 QuicConnectionId connection_id = header.connection_id; | 221 QuicConnectionId connection_id = header.connection_id; |
222 SessionMap::iterator it = session_map_.find(connection_id); | 222 SessionMap::iterator it = session_map_.find(connection_id); |
223 if (it == session_map_.end()) { | 223 if (it == session_map_.end()) { |
224 if (time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)) { | 224 if (time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)) { |
225 return HandlePacketForTimeWait(header); | 225 return HandlePacketForTimeWait(header); |
226 } | 226 } |
227 | 227 |
228 // The packet has an unknown connection ID. | 228 // The packet has an unknown connection ID. |
229 // If the packet is a public reset, there is nothing we must do or can do. | 229 // If the packet is a public reset, there is nothing we must do or can do. |
230 if (header.reset_flag) { | 230 if (header.reset_flag) { |
(...skipping 26 matching lines...) Expand all Loading... |
257 } | 257 } |
258 | 258 |
259 session->connection()->ProcessUdpPacket( | 259 session->connection()->ProcessUdpPacket( |
260 current_server_address_, current_client_address_, *current_packet_); | 260 current_server_address_, current_client_address_, *current_packet_); |
261 | 261 |
262 // Do not parse the packet further. The session methods called above have | 262 // Do not parse the packet further. The session methods called above have |
263 // processed it completely. | 263 // processed it completely. |
264 return false; | 264 return false; |
265 } | 265 } |
266 | 266 |
267 QuicSession* QuicDispatcher::AdditionalValidityChecksThenCreateSession( | 267 QuicServerSession* QuicDispatcher::AdditionalValidityChecksThenCreateSession( |
268 const QuicPacketPublicHeader& header, | 268 const QuicPacketPublicHeader& header, |
269 QuicConnectionId connection_id) { | 269 QuicConnectionId connection_id) { |
270 QuicSession* session = CreateQuicSession( | 270 QuicServerSession* session = CreateQuicSession( |
271 connection_id, current_server_address_, current_client_address_); | 271 connection_id, current_server_address_, current_client_address_); |
272 | 272 |
273 if (session == nullptr) { | 273 if (session == nullptr) { |
274 DVLOG(1) << "Failed to create session for " << connection_id; | 274 DVLOG(1) << "Failed to create session for " << connection_id; |
275 | 275 |
276 if (!framer_.IsSupportedVersion(header.versions.front())) { | 276 if (!framer_.IsSupportedVersion(header.versions.front())) { |
277 // TODO(ianswett): Produce packet saying "no supported version". | 277 // TODO(ianswett): Produce packet saying "no supported version". |
278 return nullptr; | 278 return nullptr; |
279 } | 279 } |
280 | 280 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 blocked_writer->OnCanWrite(); | 333 blocked_writer->OnCanWrite(); |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 bool QuicDispatcher::HasPendingWrites() const { | 337 bool QuicDispatcher::HasPendingWrites() const { |
338 return !write_blocked_list_.empty(); | 338 return !write_blocked_list_.empty(); |
339 } | 339 } |
340 | 340 |
341 void QuicDispatcher::Shutdown() { | 341 void QuicDispatcher::Shutdown() { |
342 while (!session_map_.empty()) { | 342 while (!session_map_.empty()) { |
343 QuicSession* session = session_map_.begin()->second; | 343 QuicServerSession* session = session_map_.begin()->second; |
344 session->connection()->SendConnectionClose(QUIC_PEER_GOING_AWAY); | 344 session->connection()->SendConnectionClose(QUIC_PEER_GOING_AWAY); |
345 // Validate that the session removes itself from the session map on close. | 345 // Validate that the session removes itself from the session map on close. |
346 DCHECK(session_map_.empty() || session_map_.begin()->second != session); | 346 DCHECK(session_map_.empty() || session_map_.begin()->second != session); |
347 } | 347 } |
348 DeleteSessions(); | 348 DeleteSessions(); |
349 } | 349 } |
350 | 350 |
351 void QuicDispatcher::OnConnectionClosed(QuicConnectionId connection_id, | 351 void QuicDispatcher::OnConnectionClosed(QuicConnectionId connection_id, |
352 QuicErrorCode error) { | 352 QuicErrorCode error) { |
353 SessionMap::iterator it = session_map_.find(connection_id); | 353 SessionMap::iterator it = session_map_.find(connection_id); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 | 391 |
392 void QuicDispatcher::OnConnectionRemovedFromTimeWaitList( | 392 void QuicDispatcher::OnConnectionRemovedFromTimeWaitList( |
393 QuicConnectionId connection_id) { | 393 QuicConnectionId connection_id) { |
394 DVLOG(1) << "Connection " << connection_id << " removed from time wait list."; | 394 DVLOG(1) << "Connection " << connection_id << " removed from time wait list."; |
395 } | 395 } |
396 | 396 |
397 QuicPacketWriter* QuicDispatcher::CreateWriter(int fd) { | 397 QuicPacketWriter* QuicDispatcher::CreateWriter(int fd) { |
398 return new QuicDefaultPacketWriter(fd); | 398 return new QuicDefaultPacketWriter(fd); |
399 } | 399 } |
400 | 400 |
401 QuicSession* QuicDispatcher::CreateQuicSession( | 401 QuicServerSession* QuicDispatcher::CreateQuicSession( |
402 QuicConnectionId connection_id, | 402 QuicConnectionId connection_id, |
403 const IPEndPoint& server_address, | 403 const IPEndPoint& server_address, |
404 const IPEndPoint& client_address) { | 404 const IPEndPoint& client_address) { |
405 // The QuicSession takes ownership of |connection| below. | 405 // The QuicServerSession takes ownership of |connection| below. |
406 QuicConnection* connection = new QuicConnection( | 406 QuicConnection* connection = new QuicConnection( |
407 connection_id, client_address, helper_.get(), connection_writer_factory_, | 407 connection_id, client_address, helper_.get(), connection_writer_factory_, |
408 /* owns_writer= */ true, Perspective::IS_SERVER, | 408 /* owns_writer= */ true, Perspective::IS_SERVER, |
409 crypto_config_.HasProofSource(), supported_versions_); | 409 crypto_config_.HasProofSource(), supported_versions_); |
410 | 410 |
411 QuicServerSession* session = new QuicServerSession(config_, connection, this); | 411 QuicServerSession* session = new QuicServerSession(config_, connection, this); |
412 session->InitializeSession(&crypto_config_); | 412 session->InitializeSession(&crypto_config_); |
413 return session; | 413 return session; |
414 } | 414 } |
415 | 415 |
(...skipping 14 matching lines...) Expand all Loading... |
430 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( | 430 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( |
431 header.connection_id)); | 431 header.connection_id)); |
432 | 432 |
433 // Continue parsing the packet to extract the sequence number. Then | 433 // Continue parsing the packet to extract the sequence number. Then |
434 // send it to the time wait manager in OnUnathenticatedHeader. | 434 // send it to the time wait manager in OnUnathenticatedHeader. |
435 return true; | 435 return true; |
436 } | 436 } |
437 | 437 |
438 } // namespace tools | 438 } // namespace tools |
439 } // namespace net | 439 } // namespace net |
OLD | NEW |