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 // A server side dispatcher which dispatches a given client's data to their | 5 // A server side dispatcher which dispatches a given client's data to their |
6 // stream. | 6 // stream. |
7 | 7 |
8 #ifndef NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ | 8 #ifndef NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ |
9 #define NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ | 9 #define NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <unordered_map> | 12 #include <unordered_map> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
17 #include "net/base/linked_hash_map.h" | 17 #include "net/base/linked_hash_map.h" |
18 #include "net/quic/crypto/quic_compressed_certs_cache.h" | 18 #include "net/quic/crypto/quic_compressed_certs_cache.h" |
19 #include "net/quic/crypto/quic_random.h" | 19 #include "net/quic/crypto/quic_random.h" |
20 #include "net/quic/quic_blocked_writer_interface.h" | 20 #include "net/quic/quic_blocked_writer_interface.h" |
| 21 #include "net/quic/quic_buffered_packet_store.h" |
21 #include "net/quic/quic_connection.h" | 22 #include "net/quic/quic_connection.h" |
22 #include "net/quic/quic_protocol.h" | 23 #include "net/quic/quic_protocol.h" |
23 #include "net/quic/quic_server_session_base.h" | 24 #include "net/quic/quic_server_session_base.h" |
24 #include "net/tools/quic/quic_process_packet_interface.h" | 25 #include "net/tools/quic/quic_process_packet_interface.h" |
25 #include "net/tools/quic/quic_time_wait_list_manager.h" | 26 #include "net/tools/quic/quic_time_wait_list_manager.h" |
26 | 27 |
27 namespace net { | 28 namespace net { |
28 | 29 |
29 class QuicConfig; | 30 class QuicConfig; |
30 class QuicCryptoServerConfig; | 31 class QuicCryptoServerConfig; |
31 class QuicServerSessionBase; | 32 class QuicServerSessionBase; |
32 | 33 |
33 namespace test { | 34 namespace test { |
34 class QuicDispatcherPeer; | 35 class QuicDispatcherPeer; |
35 } // namespace test | 36 } // namespace test |
36 | 37 |
37 class QuicDispatcher : public QuicServerSessionBase::Visitor, | 38 class QuicDispatcher : public QuicServerSessionBase::Visitor, |
38 public ProcessPacketInterface, | 39 public ProcessPacketInterface, |
39 public QuicBlockedWriterInterface, | 40 public QuicBlockedWriterInterface, |
40 public QuicFramerVisitorInterface { | 41 public QuicFramerVisitorInterface, |
| 42 public QuicBufferedPacketStore::VisitorInterface { |
41 public: | 43 public: |
42 // Ideally we'd have a linked_hash_set: the boolean is unused. | 44 // Ideally we'd have a linked_hash_set: the boolean is unused. |
43 typedef linked_hash_map<QuicBlockedWriterInterface*, | 45 typedef linked_hash_map<QuicBlockedWriterInterface*, |
44 bool, | 46 bool, |
45 QuicBlockedWriterInterfacePtrHash> | 47 QuicBlockedWriterInterfacePtrHash> |
46 WriteBlockedList; | 48 WriteBlockedList; |
47 | 49 |
48 QuicDispatcher(const QuicConfig& config, | 50 QuicDispatcher(const QuicConfig& config, |
49 const QuicCryptoServerConfig* crypto_config, | 51 const QuicCryptoServerConfig* crypto_config, |
50 const QuicVersionVector& supported_versions, | 52 const QuicVersionVector& supported_versions, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 bool OnPaddingFrame(const QuicPaddingFrame& frame) override; | 134 bool OnPaddingFrame(const QuicPaddingFrame& frame) override; |
133 bool OnPingFrame(const QuicPingFrame& frame) override; | 135 bool OnPingFrame(const QuicPingFrame& frame) override; |
134 bool OnRstStreamFrame(const QuicRstStreamFrame& frame) override; | 136 bool OnRstStreamFrame(const QuicRstStreamFrame& frame) override; |
135 bool OnConnectionCloseFrame(const QuicConnectionCloseFrame& frame) override; | 137 bool OnConnectionCloseFrame(const QuicConnectionCloseFrame& frame) override; |
136 bool OnGoAwayFrame(const QuicGoAwayFrame& frame) override; | 138 bool OnGoAwayFrame(const QuicGoAwayFrame& frame) override; |
137 bool OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override; | 139 bool OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override; |
138 bool OnBlockedFrame(const QuicBlockedFrame& frame) override; | 140 bool OnBlockedFrame(const QuicBlockedFrame& frame) override; |
139 bool OnPathCloseFrame(const QuicPathCloseFrame& frame) override; | 141 bool OnPathCloseFrame(const QuicPathCloseFrame& frame) override; |
140 void OnPacketComplete() override; | 142 void OnPacketComplete() override; |
141 | 143 |
| 144 // QuicBufferedPacketStore::VisitorInterface |
| 145 void OnExpiredPackets(QuicConnectionId connection_id, |
| 146 QuicBufferedPacketStore::BufferedPacketList |
| 147 early_arrived_packets) override; |
| 148 |
142 protected: | 149 protected: |
143 virtual QuicServerSessionBase* CreateQuicSession( | 150 virtual QuicServerSessionBase* CreateQuicSession( |
144 QuicConnectionId connection_id, | 151 QuicConnectionId connection_id, |
145 const IPEndPoint& client_address); | 152 const IPEndPoint& client_address); |
146 | 153 |
147 // Called when a connection is rejected statelessly. | 154 // Called when a connection is rejected statelessly. |
148 virtual void OnConnectionRejectedStatelessly(); | 155 virtual void OnConnectionRejectedStatelessly(); |
149 | 156 |
150 // Called when a connection is closed statelessly. | 157 // Called when a connection is closed statelessly. |
151 virtual void OnConnectionClosedStatelessly(QuicErrorCode error); | 158 virtual void OnConnectionClosedStatelessly(QuicErrorCode error); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 275 |
269 // Creates alarms. | 276 // Creates alarms. |
270 std::unique_ptr<QuicAlarmFactory> alarm_factory_; | 277 std::unique_ptr<QuicAlarmFactory> alarm_factory_; |
271 | 278 |
272 // An alarm which deletes closed sessions. | 279 // An alarm which deletes closed sessions. |
273 std::unique_ptr<QuicAlarm> delete_sessions_alarm_; | 280 std::unique_ptr<QuicAlarm> delete_sessions_alarm_; |
274 | 281 |
275 // The writer to write to the socket with. | 282 // The writer to write to the socket with. |
276 std::unique_ptr<QuicPacketWriter> writer_; | 283 std::unique_ptr<QuicPacketWriter> writer_; |
277 | 284 |
| 285 // Undecryptable packets which are buffered until a connection can be |
| 286 // created to handle them. |
| 287 QuicBufferedPacketStore buffered_packets_; |
| 288 |
278 // This vector contains QUIC versions which we currently support. | 289 // This vector contains QUIC versions which we currently support. |
279 // This should be ordered such that the highest supported version is the first | 290 // This should be ordered such that the highest supported version is the first |
280 // element, with subsequent elements in descending order (versions can be | 291 // element, with subsequent elements in descending order (versions can be |
281 // skipped as necessary). | 292 // skipped as necessary). |
282 QuicVersionVector supported_versions_; | 293 QuicVersionVector supported_versions_; |
283 | 294 |
284 // FLAGS_quic_disable_pre_30 | 295 // FLAGS_quic_disable_pre_30 |
285 bool disable_quic_pre_30_; | 296 bool disable_quic_pre_30_; |
286 // The list of versions that may be supported by this dispatcher. | 297 // The list of versions that may be supported by this dispatcher. |
287 // |supported_versions| is derived from this list and |disable_quic_pre_30_|. | 298 // |supported_versions| is derived from this list and |disable_quic_pre_30_|. |
(...skipping 10 matching lines...) Expand all Loading... |
298 // The last error set by SetLastError(), which is called by | 309 // The last error set by SetLastError(), which is called by |
299 // framer_visitor_->OnError(). | 310 // framer_visitor_->OnError(). |
300 QuicErrorCode last_error_; | 311 QuicErrorCode last_error_; |
301 | 312 |
302 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); | 313 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); |
303 }; | 314 }; |
304 | 315 |
305 } // namespace net | 316 } // namespace net |
306 | 317 |
307 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ | 318 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ |
OLD | NEW |