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 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 // This method is called by OnUnauthenticatedHeader on packets not associated | 190 // This method is called by OnUnauthenticatedHeader on packets not associated |
191 // with a known connection ID. It applies validity checks and returns a | 191 // with a known connection ID. It applies validity checks and returns a |
192 // QuicPacketFate to tell what should be done with the packet. | 192 // QuicPacketFate to tell what should be done with the packet. |
193 virtual QuicPacketFate ValidityChecks(const QuicPacketHeader& header); | 193 virtual QuicPacketFate ValidityChecks(const QuicPacketHeader& header); |
194 | 194 |
195 // Create and return the time wait list manager for this dispatcher, which | 195 // Create and return the time wait list manager for this dispatcher, which |
196 // will be owned by the dispatcher as time_wait_list_manager_ | 196 // will be owned by the dispatcher as time_wait_list_manager_ |
197 virtual QuicTimeWaitListManager* CreateQuicTimeWaitListManager(); | 197 virtual QuicTimeWaitListManager* CreateQuicTimeWaitListManager(); |
198 | 198 |
199 // Called when |current_packet_| is a data packet that has arrived before | 199 // Called when |connection_id| doesn't have an open connection yet, to buffer |
200 // the CHLO or it is any kind of packet while a CHLO on same connection has | 200 // |current_packet_| until it can be delivered to the connection. |
201 // already been in the buffer. | |
202 void BufferEarlyPacket(QuicConnectionId connection_id); | 201 void BufferEarlyPacket(QuicConnectionId connection_id); |
203 | 202 |
204 // Called when |current_packet_| is a CHLO packet. Creates a new connection | 203 // Called when |current_packet_| is a CHLO packet. Creates a new connection |
205 // and delivers any buffered packets for that connection id. | 204 // and delivers any buffered packets for that connection id. |
206 void ProcessChlo(); | 205 void ProcessChlo(); |
207 | 206 |
208 QuicTimeWaitListManager* time_wait_list_manager() { | 207 QuicTimeWaitListManager* time_wait_list_manager() { |
209 return time_wait_list_manager_.get(); | 208 return time_wait_list_manager_.get(); |
210 } | 209 } |
211 | 210 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 265 |
267 // Called when BufferEarlyPacket() fail to buffer the packet. | 266 // Called when BufferEarlyPacket() fail to buffer the packet. |
268 virtual void OnBufferPacketFailure( | 267 virtual void OnBufferPacketFailure( |
269 QuicBufferedPacketStore::EnqueuePacketResult result, | 268 QuicBufferedPacketStore::EnqueuePacketResult result, |
270 QuicConnectionId connection_id); | 269 QuicConnectionId connection_id); |
271 | 270 |
272 private: | 271 private: |
273 friend class net::test::QuicDispatcherPeer; | 272 friend class net::test::QuicDispatcherPeer; |
274 friend class StatelessRejectorProcessDoneCallback; | 273 friend class StatelessRejectorProcessDoneCallback; |
275 | 274 |
| 275 typedef std::unordered_set<QuicConnectionId> QuicConnectionIdSet; |
| 276 |
276 // Removes the session from the session map and write blocked list, and adds | 277 // Removes the session from the session map and write blocked list, and adds |
277 // the ConnectionId to the time-wait list. If |session_closed_statelessly| is | 278 // the ConnectionId to the time-wait list. If |session_closed_statelessly| is |
278 // true, any future packets for the ConnectionId will be black-holed. | 279 // true, any future packets for the ConnectionId will be black-holed. |
279 void CleanUpSession(SessionMap::iterator it, bool session_closed_statelessly); | 280 void CleanUpSession(SessionMap::iterator it, bool session_closed_statelessly); |
280 | 281 |
281 bool HandlePacketForTimeWait(const QuicPacketPublicHeader& header); | 282 bool HandlePacketForTimeWait(const QuicPacketPublicHeader& header); |
282 | 283 |
283 // Attempts to reject the connection statelessly, if stateless rejects are | 284 // Attempts to reject the connection statelessly, if stateless rejects are |
284 // possible and if the current packet contains a CHLO message. Determines a | 285 // possible and if the current packet contains a CHLO message. Determines a |
285 // fate which describes what subsequent processing should be performed on the | 286 // fate which describes what subsequent processing should be performed on the |
286 // packets, like ValidityChecks, and invokes ProcessUnauthenticatedHeaderFate. | 287 // packets, like ValidityChecks, and invokes ProcessUnauthenticatedHeaderFate. |
287 void MaybeRejectStatelessly(QuicConnectionId connection_id, | 288 void MaybeRejectStatelessly(QuicConnectionId connection_id, |
288 const QuicPacketHeader& header); | 289 const QuicPacketHeader& header); |
289 | 290 |
290 // Deliver |packets| to |session| for further processing. | 291 // Deliver |packets| to |session| for further processing. |
291 void DeliverPacketsToSession( | 292 void DeliverPacketsToSession( |
292 const std::list<QuicBufferedPacketStore::BufferedPacket>& packets, | 293 const std::list<QuicBufferedPacketStore::BufferedPacket>& packets, |
293 QuicServerSessionBase* session); | 294 QuicServerSessionBase* session); |
294 | 295 |
295 // Perform the appropriate actions on the current packet based on |fate| - | 296 // Perform the appropriate actions on the current packet based on |fate| - |
296 // either process, buffer, or drop it. | 297 // either process, buffer, or drop it. |
297 void ProcessUnauthenticatedHeaderFate(QuicPacketFate fate, | 298 void ProcessUnauthenticatedHeaderFate(QuicPacketFate fate, |
298 QuicConnectionId connection_id, | 299 QuicConnectionId connection_id, |
299 QuicPacketNumber packet_number); | 300 QuicPacketNumber packet_number); |
300 | 301 |
301 // Invoked when StatelessRejector::Process completes. | 302 // Invoked when StatelessRejector::Process completes. |
302 void OnStatelessRejectorProcessDone( | 303 void OnStatelessRejectorProcessDone( |
303 std::unique_ptr<StatelessRejector> rejector, | 304 std::unique_ptr<StatelessRejector> rejector, |
| 305 const IPEndPoint& current_client_address, |
| 306 const IPEndPoint& current_server_address, |
| 307 std::unique_ptr<QuicReceivedPacket> current_packet, |
| 308 QuicPacketNumber packet_number, |
| 309 QuicVersion first_version); |
| 310 |
| 311 // Examine the state of the rejector and decide what to do with the current |
| 312 // packet. |
| 313 void ProcessStatelessRejectorState( |
| 314 std::unique_ptr<StatelessRejector> rejector, |
304 QuicPacketNumber packet_number, | 315 QuicPacketNumber packet_number, |
305 QuicVersion first_version); | 316 QuicVersion first_version); |
306 | 317 |
307 void set_new_sessions_allowed_per_event_loop( | 318 void set_new_sessions_allowed_per_event_loop( |
308 int16_t new_sessions_allowed_per_event_loop) { | 319 int16_t new_sessions_allowed_per_event_loop) { |
309 new_sessions_allowed_per_event_loop_ = new_sessions_allowed_per_event_loop; | 320 new_sessions_allowed_per_event_loop_ = new_sessions_allowed_per_event_loop; |
310 } | 321 } |
311 | 322 |
312 const QuicConfig& config_; | 323 const QuicConfig& config_; |
313 | 324 |
(...skipping 25 matching lines...) Expand all Loading... |
339 // An alarm which deletes closed sessions. | 350 // An alarm which deletes closed sessions. |
340 std::unique_ptr<QuicAlarm> delete_sessions_alarm_; | 351 std::unique_ptr<QuicAlarm> delete_sessions_alarm_; |
341 | 352 |
342 // The writer to write to the socket with. | 353 // The writer to write to the socket with. |
343 std::unique_ptr<QuicPacketWriter> writer_; | 354 std::unique_ptr<QuicPacketWriter> writer_; |
344 | 355 |
345 // Packets which are buffered until a connection can be created to handle | 356 // Packets which are buffered until a connection can be created to handle |
346 // them. | 357 // them. |
347 QuicBufferedPacketStore buffered_packets_; | 358 QuicBufferedPacketStore buffered_packets_; |
348 | 359 |
| 360 // Set of connection IDs for which asynchronous CHLO processing is in |
| 361 // progress, making it necessary to buffer any other packets which arrive on |
| 362 // that connection until CHLO processing is complete. |
| 363 QuicConnectionIdSet temporarily_buffered_connections_; |
| 364 |
349 // Information about the packet currently being handled. | 365 // Information about the packet currently being handled. |
350 IPEndPoint current_client_address_; | 366 IPEndPoint current_client_address_; |
351 IPEndPoint current_server_address_; | 367 IPEndPoint current_server_address_; |
352 const QuicReceivedPacket* current_packet_; | 368 const QuicReceivedPacket* current_packet_; |
353 QuicConnectionId current_connection_id_; | 369 QuicConnectionId current_connection_id_; |
354 | 370 |
355 // Used to get the supported versions based on flag. Does not own. | 371 // Used to get the supported versions based on flag. Does not own. |
356 QuicVersionManager* version_manager_; | 372 QuicVersionManager* version_manager_; |
357 | 373 |
358 QuicFramer framer_; | 374 QuicFramer framer_; |
359 | 375 |
360 // The last error set by SetLastError(), which is called by | 376 // The last error set by SetLastError(), which is called by |
361 // framer_visitor_->OnError(). | 377 // framer_visitor_->OnError(). |
362 QuicErrorCode last_error_; | 378 QuicErrorCode last_error_; |
363 | 379 |
364 // A backward counter of how many new sessions can be create within current | 380 // A backward counter of how many new sessions can be create within current |
365 // event loop. When reaches 0, it means can't create sessions for now. | 381 // event loop. When reaches 0, it means can't create sessions for now. |
366 int16_t new_sessions_allowed_per_event_loop_; | 382 int16_t new_sessions_allowed_per_event_loop_; |
367 | 383 |
368 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); | 384 DISALLOW_COPY_AND_ASSIGN(QuicDispatcher); |
369 }; | 385 }; |
370 | 386 |
371 } // namespace net | 387 } // namespace net |
372 | 388 |
373 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ | 389 #endif // NET_TOOLS_QUIC_QUIC_DISPATCHER_H_ |
OLD | NEW |