| 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" |
| 11 #include "net/quic/quic_blocked_writer_interface.h" | 11 #include "net/quic/quic_blocked_writer_interface.h" |
| 12 #include "net/quic/quic_flags.h" | 12 #include "net/quic/quic_flags.h" |
| 13 #include "net/quic/quic_utils.h" | 13 #include "net/quic/quic_utils.h" |
| 14 #include "net/tools/epoll_server/epoll_server.h" | |
| 15 #include "net/tools/quic/quic_default_packet_writer.h" | |
| 16 #include "net/tools/quic/quic_epoll_connection_helper.h" | |
| 17 #include "net/tools/quic/quic_per_connection_packet_writer.h" | 14 #include "net/tools/quic/quic_per_connection_packet_writer.h" |
| 18 #include "net/tools/quic/quic_socket_utils.h" | |
| 19 #include "net/tools/quic/quic_time_wait_list_manager.h" | 15 #include "net/tools/quic/quic_time_wait_list_manager.h" |
| 20 | 16 |
| 21 namespace net { | 17 namespace net { |
| 22 | 18 |
| 23 namespace tools { | 19 namespace tools { |
| 24 | 20 |
| 25 using base::StringPiece; | 21 using base::StringPiece; |
| 26 | 22 |
| 27 namespace { | 23 namespace { |
| 28 | 24 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 Perspective::IS_SERVER), | 182 Perspective::IS_SERVER), |
| 187 framer_visitor_(new QuicFramerVisitor(this)) { | 183 framer_visitor_(new QuicFramerVisitor(this)) { |
| 188 framer_.set_visitor(framer_visitor_.get()); | 184 framer_.set_visitor(framer_visitor_.get()); |
| 189 } | 185 } |
| 190 | 186 |
| 191 QuicDispatcher::~QuicDispatcher() { | 187 QuicDispatcher::~QuicDispatcher() { |
| 192 STLDeleteValues(&session_map_); | 188 STLDeleteValues(&session_map_); |
| 193 STLDeleteElements(&closed_session_list_); | 189 STLDeleteElements(&closed_session_list_); |
| 194 } | 190 } |
| 195 | 191 |
| 196 void QuicDispatcher::Initialize(int fd) { | 192 void QuicDispatcher::InitializeWithWriter(QuicPacketWriter* writer) { |
| 197 DCHECK(writer_ == nullptr); | 193 DCHECK(writer_ == nullptr); |
| 198 writer_.reset(CreateWriter(fd)); | 194 writer_.reset(writer); |
| 199 time_wait_list_manager_.reset(CreateQuicTimeWaitListManager()); | 195 time_wait_list_manager_.reset(CreateQuicTimeWaitListManager()); |
| 200 } | 196 } |
| 201 | 197 |
| 202 void QuicDispatcher::ProcessPacket(const IPEndPoint& server_address, | 198 void QuicDispatcher::ProcessPacket(const IPEndPoint& server_address, |
| 203 const IPEndPoint& client_address, | 199 const IPEndPoint& client_address, |
| 204 const QuicEncryptedPacket& packet) { | 200 const QuicEncryptedPacket& packet) { |
| 205 current_server_address_ = server_address; | 201 current_server_address_ = server_address; |
| 206 current_client_address_ = client_address; | 202 current_client_address_ = client_address; |
| 207 current_packet_ = &packet; | 203 current_packet_ = &packet; |
| 208 // ProcessPacket will cause the packet to be dispatched in | 204 // ProcessPacket will cause the packet to be dispatched in |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 void QuicDispatcher::OnConnectionAddedToTimeWaitList( | 390 void QuicDispatcher::OnConnectionAddedToTimeWaitList( |
| 395 QuicConnectionId connection_id) { | 391 QuicConnectionId connection_id) { |
| 396 DVLOG(1) << "Connection " << connection_id << " added to time wait list."; | 392 DVLOG(1) << "Connection " << connection_id << " added to time wait list."; |
| 397 } | 393 } |
| 398 | 394 |
| 399 void QuicDispatcher::OnConnectionRemovedFromTimeWaitList( | 395 void QuicDispatcher::OnConnectionRemovedFromTimeWaitList( |
| 400 QuicConnectionId connection_id) { | 396 QuicConnectionId connection_id) { |
| 401 DVLOG(1) << "Connection " << connection_id << " removed from time wait list."; | 397 DVLOG(1) << "Connection " << connection_id << " removed from time wait list."; |
| 402 } | 398 } |
| 403 | 399 |
| 404 QuicPacketWriter* QuicDispatcher::CreateWriter(int fd) { | |
| 405 return new QuicDefaultPacketWriter(fd); | |
| 406 } | |
| 407 | |
| 408 QuicServerSession* QuicDispatcher::CreateQuicSession( | 400 QuicServerSession* QuicDispatcher::CreateQuicSession( |
| 409 QuicConnectionId connection_id, | 401 QuicConnectionId connection_id, |
| 410 const IPEndPoint& server_address, | 402 const IPEndPoint& server_address, |
| 411 const IPEndPoint& client_address) { | 403 const IPEndPoint& client_address) { |
| 412 // The QuicServerSession takes ownership of |connection| below. | 404 // The QuicServerSession takes ownership of |connection| below. |
| 413 QuicConnection* connection = new QuicConnection( | 405 QuicConnection* connection = new QuicConnection( |
| 414 connection_id, client_address, helper_.get(), connection_writer_factory_, | 406 connection_id, client_address, helper_.get(), connection_writer_factory_, |
| 415 /* owns_writer= */ true, Perspective::IS_SERVER, | 407 /* owns_writer= */ true, Perspective::IS_SERVER, |
| 416 crypto_config_.HasProofSource(), supported_versions_); | 408 crypto_config_.HasProofSource(), supported_versions_); |
| 417 | 409 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 437 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( | 429 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( |
| 438 header.connection_id)); | 430 header.connection_id)); |
| 439 | 431 |
| 440 // Continue parsing the packet to extract the sequence number. Then | 432 // Continue parsing the packet to extract the sequence number. Then |
| 441 // send it to the time wait manager in OnUnathenticatedHeader. | 433 // send it to the time wait manager in OnUnathenticatedHeader. |
| 442 return true; | 434 return true; |
| 443 } | 435 } |
| 444 | 436 |
| 445 } // namespace tools | 437 } // namespace tools |
| 446 } // namespace net | 438 } // namespace net |
| OLD | NEW |