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 // Handles packets for connection_ids in time wait state by discarding the | 5 // Handles packets for connection_ids in time wait state by discarding the |
6 // packet and sending the clients a public reset packet with exponential | 6 // packet and sending the clients a public reset packet with exponential |
7 // backoff. | 7 // backoff. |
8 | 8 |
9 #ifndef NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ | 9 #ifndef NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ |
10 #define NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ | 10 #define NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ |
11 | 11 |
12 #include <stddef.h> | 12 #include <stddef.h> |
13 | 13 |
14 #include <deque> | 14 #include <deque> |
15 #include <memory> | 15 #include <memory> |
16 | 16 |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "net/base/linked_hash_map.h" | 18 #include "net/base/linked_hash_map.h" |
19 #include "net/quic/core/quic_blocked_writer_interface.h" | 19 #include "net/quic/core/quic_blocked_writer_interface.h" |
20 #include "net/quic/core/quic_connection.h" | 20 #include "net/quic/core/quic_connection.h" |
21 #include "net/quic/core/quic_framer.h" | 21 #include "net/quic/core/quic_framer.h" |
22 #include "net/quic/core/quic_packet_writer.h" | 22 #include "net/quic/core/quic_packet_writer.h" |
23 #include "net/quic/core/quic_protocol.h" | 23 #include "net/quic/core/quic_protocol.h" |
24 #include "net/quic/core/quic_server_session_base.h" | 24 #include "net/quic/core/quic_session.h" |
25 | 25 |
26 namespace net { | 26 namespace net { |
27 | 27 |
28 namespace test { | 28 namespace test { |
29 class QuicDispatcherPeer; | 29 class QuicDispatcherPeer; |
30 class QuicTimeWaitListManagerPeer; | 30 class QuicTimeWaitListManagerPeer; |
31 } // namespace test | 31 } // namespace test |
32 | 32 |
33 // Maintains a list of all connection_ids that have been recently closed. A | 33 // Maintains a list of all connection_ids that have been recently closed. A |
34 // connection_id lives in this state for time_wait_period_. All packets received | 34 // connection_id lives in this state for time_wait_period_. All packets received |
35 // for connection_ids in this state are handed over to the | 35 // for connection_ids in this state are handed over to the |
36 // QuicTimeWaitListManager by the QuicDispatcher. Decides whether to send a | 36 // QuicTimeWaitListManager by the QuicDispatcher. Decides whether to send a |
37 // public reset packet, a copy of the previously sent connection close packet, | 37 // public reset packet, a copy of the previously sent connection close packet, |
38 // or nothing to the client which sent a packet with the connection_id in time | 38 // or nothing to the client which sent a packet with the connection_id in time |
39 // wait state. After the connection_id expires its time wait period, a new | 39 // wait state. After the connection_id expires its time wait period, a new |
40 // connection/session will be created if a packet is received for this | 40 // connection/session will be created if a packet is received for this |
41 // connection_id. | 41 // connection_id. |
42 class QuicTimeWaitListManager : public QuicBlockedWriterInterface { | 42 class QuicTimeWaitListManager : public QuicBlockedWriterInterface { |
43 public: | 43 public: |
| 44 class Visitor : public QuicSession::Visitor { |
| 45 public: |
| 46 // Called after the given connection is added to the time-wait std::list. |
| 47 virtual void OnConnectionAddedToTimeWaitList( |
| 48 QuicConnectionId connection_id) = 0; |
| 49 }; |
| 50 |
44 // writer - the entity that writes to the socket. (Owned by the dispatcher) | 51 // writer - the entity that writes to the socket. (Owned by the dispatcher) |
45 // visitor - the entity that manages blocked writers. (The dispatcher) | 52 // visitor - the entity that manages blocked writers. (The dispatcher) |
46 // helper - provides a clock (Owned by the dispatcher) | 53 // helper - provides a clock (Owned by the dispatcher) |
47 // alarm_factory - used to run clean up alarms. (Owned by the dispatcher) | 54 // alarm_factory - used to run clean up alarms. (Owned by the dispatcher) |
48 QuicTimeWaitListManager(QuicPacketWriter* writer, | 55 QuicTimeWaitListManager(QuicPacketWriter* writer, |
49 QuicServerSessionBase::Visitor* visitor, | 56 Visitor* visitor, |
50 QuicConnectionHelperInterface* helper, | 57 QuicConnectionHelperInterface* helper, |
51 QuicAlarmFactory* alarm_factory); | 58 QuicAlarmFactory* alarm_factory); |
52 ~QuicTimeWaitListManager() override; | 59 ~QuicTimeWaitListManager() override; |
53 | 60 |
54 // Adds the given connection_id to time wait state for time_wait_period_. | 61 // Adds the given connection_id to time wait state for time_wait_period_. |
55 // If |termination_packets| are provided, copies of these packets will be sent | 62 // If |termination_packets| are provided, copies of these packets will be sent |
56 // when a packet with this connection ID is processed. If no termination | 63 // when a packet with this connection ID is processed. If no termination |
57 // packets are provided, then a PUBLIC_RESET will be sent with the specified | 64 // packets are provided, then a PUBLIC_RESET will be sent with the specified |
58 // |version|. Any termination packets will be move from |termination_packets| | 65 // |version|. Any termination packets will be move from |termination_packets| |
59 // and will become owned by the manager. If |connection_rejected_statelessly| | 66 // and will become owned by the manager. If |connection_rejected_statelessly| |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // time wait state. | 196 // time wait state. |
190 std::unique_ptr<QuicAlarm> connection_id_clean_up_alarm_; | 197 std::unique_ptr<QuicAlarm> connection_id_clean_up_alarm_; |
191 | 198 |
192 // Clock to efficiently measure approximate time. | 199 // Clock to efficiently measure approximate time. |
193 const QuicClock* clock_; | 200 const QuicClock* clock_; |
194 | 201 |
195 // Interface that writes given buffer to the socket. | 202 // Interface that writes given buffer to the socket. |
196 QuicPacketWriter* writer_; | 203 QuicPacketWriter* writer_; |
197 | 204 |
198 // Interface that manages blocked writers. | 205 // Interface that manages blocked writers. |
199 QuicServerSessionBase::Visitor* visitor_; | 206 Visitor* visitor_; |
200 | 207 |
201 DISALLOW_COPY_AND_ASSIGN(QuicTimeWaitListManager); | 208 DISALLOW_COPY_AND_ASSIGN(QuicTimeWaitListManager); |
202 }; | 209 }; |
203 | 210 |
204 } // namespace net | 211 } // namespace net |
205 | 212 |
206 #endif // NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ | 213 #endif // NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ |
OLD | NEW |