QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef QUICHE_QUIC_TEST_TOOLS_QUIC_CONNECTION_PEER_H_ |
| 6 | #define QUICHE_QUIC_TEST_TOOLS_QUIC_CONNECTION_PEER_H_ |
| 7 | |
danzh | 9cb85b7 | 2020-12-30 07:17:09 -0800 | [diff] [blame] | 8 | #include <cstddef> |
vasilvv | 5f225b0 | 2020-10-08 11:49:09 -0400 | [diff] [blame] | 9 | #include "absl/strings/string_view.h" |
QUICHE team | 5be974e | 2020-12-29 18:35:24 -0500 | [diff] [blame] | 10 | #include "quic/core/quic_connection.h" |
haoyuewang | e3c51d9 | 2021-03-08 07:35:03 -0800 | [diff] [blame] | 11 | #include "quic/core/quic_connection_id.h" |
QUICHE team | 5be974e | 2020-12-29 18:35:24 -0500 | [diff] [blame] | 12 | #include "quic/core/quic_connection_stats.h" |
| 13 | #include "quic/core/quic_packets.h" |
danzh | 9cb85b7 | 2020-12-30 07:17:09 -0800 | [diff] [blame] | 14 | #include "quic/core/quic_types.h" |
QUICHE team | 5be974e | 2020-12-29 18:35:24 -0500 | [diff] [blame] | 15 | #include "quic/platform/api/quic_socket_address.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 16 | |
| 17 | namespace quic { |
| 18 | |
| 19 | struct QuicPacketHeader; |
| 20 | class QuicAlarm; |
| 21 | class QuicConnectionHelperInterface; |
| 22 | class QuicConnectionVisitorInterface; |
| 23 | class QuicEncryptedPacket; |
| 24 | class QuicFramer; |
| 25 | class QuicPacketCreator; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 26 | class QuicPacketWriter; |
| 27 | class QuicSentPacketManager; |
| 28 | class SendAlgorithmInterface; |
| 29 | |
| 30 | namespace test { |
| 31 | |
| 32 | // Peer to make public a number of otherwise private QuicConnection methods. |
| 33 | class QuicConnectionPeer { |
| 34 | public: |
| 35 | QuicConnectionPeer() = delete; |
| 36 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 37 | static void SetSendAlgorithm(QuicConnection* connection, |
| 38 | SendAlgorithmInterface* send_algorithm); |
| 39 | |
| 40 | static void SetLossAlgorithm(QuicConnection* connection, |
| 41 | LossDetectionInterface* loss_algorithm); |
| 42 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 43 | static void PopulateStopWaitingFrame(QuicConnection* connection, |
| 44 | QuicStopWaitingFrame* stop_waiting); |
| 45 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 46 | static QuicPacketCreator* GetPacketCreator(QuicConnection* connection); |
| 47 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 48 | static QuicSentPacketManager* GetSentPacketManager( |
| 49 | QuicConnection* connection); |
| 50 | |
| 51 | static QuicTime::Delta GetNetworkTimeout(QuicConnection* connection); |
| 52 | |
| 53 | static void SetPerspective(QuicConnection* connection, |
| 54 | Perspective perspective); |
| 55 | |
| 56 | static void SetSelfAddress(QuicConnection* connection, |
| 57 | const QuicSocketAddress& self_address); |
| 58 | |
| 59 | static void SetPeerAddress(QuicConnection* connection, |
| 60 | const QuicSocketAddress& peer_address); |
| 61 | |
| 62 | static void SetDirectPeerAddress( |
| 63 | QuicConnection* connection, |
| 64 | const QuicSocketAddress& direct_peer_address); |
| 65 | |
| 66 | static void SetEffectivePeerAddress( |
| 67 | QuicConnection* connection, |
| 68 | const QuicSocketAddress& effective_peer_address); |
| 69 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 70 | static void SwapCrypters(QuicConnection* connection, QuicFramer* framer); |
| 71 | |
| 72 | static void SetCurrentPacket(QuicConnection* connection, |
vasilvv | 5f225b0 | 2020-10-08 11:49:09 -0400 | [diff] [blame] | 73 | absl::string_view current_packet); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 74 | |
| 75 | static QuicConnectionHelperInterface* GetHelper(QuicConnection* connection); |
| 76 | |
| 77 | static QuicAlarmFactory* GetAlarmFactory(QuicConnection* connection); |
| 78 | |
| 79 | static QuicFramer* GetFramer(QuicConnection* connection); |
| 80 | |
| 81 | static QuicAlarm* GetAckAlarm(QuicConnection* connection); |
| 82 | static QuicAlarm* GetPingAlarm(QuicConnection* connection); |
| 83 | static QuicAlarm* GetRetransmissionAlarm(QuicConnection* connection); |
| 84 | static QuicAlarm* GetSendAlarm(QuicConnection* connection); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 85 | static QuicAlarm* GetMtuDiscoveryAlarm(QuicConnection* connection); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 86 | static QuicAlarm* GetProcessUndecryptablePacketsAlarm( |
| 87 | QuicConnection* connection); |
mattm | 072a7e3 | 2020-10-09 16:16:56 -0700 | [diff] [blame] | 88 | static QuicAlarm* GetDiscardPreviousOneRttKeysAlarm( |
| 89 | QuicConnection* connection); |
mattm | ad5eb5d | 2020-12-03 16:12:15 -0800 | [diff] [blame] | 90 | static QuicAlarm* GetDiscardZeroRttDecryptionKeysAlarm( |
| 91 | QuicConnection* connection); |
haoyuewang | e3c51d9 | 2021-03-08 07:35:03 -0800 | [diff] [blame] | 92 | static QuicAlarm* GetRetirePeerIssuedConnectionIdAlarm( |
| 93 | QuicConnection* connection); |
| 94 | static QuicAlarm* GetRetireSelfIssuedConnectionIdAlarm( |
| 95 | QuicConnection* connection); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 96 | |
| 97 | static QuicPacketWriter* GetWriter(QuicConnection* connection); |
| 98 | // If |owns_writer| is true, takes ownership of |writer|. |
| 99 | static void SetWriter(QuicConnection* connection, |
| 100 | QuicPacketWriter* writer, |
| 101 | bool owns_writer); |
| 102 | static void TearDownLocalConnectionState(QuicConnection* connection); |
| 103 | static QuicEncryptedPacket* GetConnectionClosePacket( |
| 104 | QuicConnection* connection); |
| 105 | |
| 106 | static QuicPacketHeader* GetLastHeader(QuicConnection* connection); |
| 107 | |
| 108 | static QuicConnectionStats* GetStats(QuicConnection* connection); |
| 109 | |
| 110 | static QuicPacketCount GetPacketsBetweenMtuProbes(QuicConnection* connection); |
| 111 | |
wub | f76cf2a | 2019-10-11 18:49:07 -0700 | [diff] [blame] | 112 | static void ReInitializeMtuDiscoverer( |
| 113 | QuicConnection* connection, |
| 114 | QuicPacketCount packets_between_probes_base, |
| 115 | QuicPacketNumber next_probe_at); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 116 | static void SetAckDecimationDelay(QuicConnection* connection, |
| 117 | float ack_decimation_delay); |
| 118 | static bool HasRetransmittableFrames(QuicConnection* connection, |
| 119 | uint64_t packet_number); |
| 120 | static bool GetNoStopWaitingFrames(QuicConnection* connection); |
| 121 | static void SetNoStopWaitingFrames(QuicConnection* connection, |
| 122 | bool no_stop_waiting_frames); |
| 123 | static void SetMaxTrackedPackets(QuicConnection* connection, |
| 124 | QuicPacketCount max_tracked_packets); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 125 | static void SetNegotiatedVersion(QuicConnection* connection); |
| 126 | static void SetMaxConsecutiveNumPacketsWithNoRetransmittableFrames( |
| 127 | QuicConnection* connection, |
| 128 | size_t new_value); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 129 | static bool SupportsReleaseTime(QuicConnection* connection); |
| 130 | static QuicConnection::PacketContent GetCurrentPacketContent( |
| 131 | QuicConnection* connection); |
QUICHE team | 8c1daa2 | 2019-03-13 08:33:41 -0700 | [diff] [blame] | 132 | static void SetLastHeaderFormat(QuicConnection* connection, |
| 133 | PacketHeaderFormat format); |
fayang | 5f13505 | 2019-08-22 17:59:40 -0700 | [diff] [blame] | 134 | static void AddBytesReceived(QuicConnection* connection, size_t length); |
| 135 | static void SetAddressValidated(QuicConnection* connection); |
dschinazi | dce90b0 | 2019-10-14 18:19:54 -0700 | [diff] [blame] | 136 | |
| 137 | static void SendConnectionClosePacket(QuicConnection* connection, |
mattm | 55006b0 | 2021-01-14 15:09:54 -0800 | [diff] [blame] | 138 | QuicIetfTransportErrorCodes ietf_error, |
dschinazi | dce90b0 | 2019-10-14 18:19:54 -0700 | [diff] [blame] | 139 | QuicErrorCode error, |
| 140 | const std::string& details); |
rch | d672c6d | 2019-11-27 15:30:54 -0800 | [diff] [blame] | 141 | |
| 142 | static size_t GetNumEncryptionLevels(QuicConnection* connection); |
fayang | b59c6f1 | 2020-03-23 15:06:14 -0700 | [diff] [blame] | 143 | |
| 144 | static QuicNetworkBlackholeDetector& GetBlackholeDetector( |
| 145 | QuicConnection* connection); |
| 146 | |
| 147 | static QuicAlarm* GetBlackholeDetectorAlarm(QuicConnection* connection); |
| 148 | |
| 149 | static QuicTime GetPathDegradingDeadline(QuicConnection* connection); |
| 150 | |
| 151 | static QuicTime GetBlackholeDetectionDeadline(QuicConnection* connection); |
fayang | b9c8844 | 2020-03-26 07:03:57 -0700 | [diff] [blame] | 152 | |
wub | 8add68a | 2020-07-27 12:07:38 -0700 | [diff] [blame] | 153 | static QuicTime GetPathMtuReductionDetectionDeadline( |
| 154 | QuicConnection* connection); |
| 155 | |
fayang | b9c8844 | 2020-03-26 07:03:57 -0700 | [diff] [blame] | 156 | static QuicAlarm* GetIdleNetworkDetectorAlarm(QuicConnection* connection); |
dschinazi | 39e5e55 | 2020-05-06 13:55:24 -0700 | [diff] [blame] | 157 | |
fayang | 001c828 | 2020-07-29 12:39:29 -0700 | [diff] [blame] | 158 | static QuicTime GetIdleNetworkDeadline(QuicConnection* connection); |
| 159 | |
| 160 | static QuicIdleNetworkDetector& GetIdleNetworkDetector( |
| 161 | QuicConnection* connection); |
| 162 | |
dschinazi | 39e5e55 | 2020-05-06 13:55:24 -0700 | [diff] [blame] | 163 | static void SetServerConnectionId( |
| 164 | QuicConnection* connection, |
| 165 | const QuicConnectionId& server_connection_id); |
fayang | 750b54f | 2020-06-18 06:26:54 -0700 | [diff] [blame] | 166 | |
| 167 | static size_t NumUndecryptablePackets(QuicConnection* connection); |
danzh | 8a27a1a | 2020-09-02 10:26:28 -0700 | [diff] [blame] | 168 | |
danzh | 9cb85b7 | 2020-12-30 07:17:09 -0800 | [diff] [blame] | 169 | static size_t NumPendingPathChallengesToResponse(QuicConnection* connection); |
renjietang | 052df7c | 2020-10-13 14:46:09 -0700 | [diff] [blame] | 170 | |
| 171 | static void SetConnectionClose(QuicConnection* connection); |
fayang | 29ce0bd | 2020-10-29 08:28:44 -0700 | [diff] [blame] | 172 | |
| 173 | static void SendPing(QuicConnection* connection); |
danzh | e6211dc | 2020-11-19 09:19:00 -0800 | [diff] [blame] | 174 | |
| 175 | static void SetLastPacketDestinationAddress(QuicConnection* connection, |
| 176 | const QuicSocketAddress& address); |
| 177 | |
| 178 | static QuicPathValidator* path_validator(QuicConnection* connection); |
danzh | 9cb85b7 | 2020-12-30 07:17:09 -0800 | [diff] [blame] | 179 | |
danzh | a4b519c | 2021-02-05 12:10:55 -0800 | [diff] [blame] | 180 | static QuicByteCount BytesSentOnAlternativePath(QuicConnection* connection); |
| 181 | |
| 182 | static QuicByteCount BytesReceivedOnAlternativePath( |
danzh | 9cb85b7 | 2020-12-30 07:17:09 -0800 | [diff] [blame] | 183 | QuicConnection* connection); |
| 184 | |
haoyuewang | 5c49d3e | 2021-04-08 07:33:33 -0700 | [diff] [blame] | 185 | static QuicConnectionId GetClientConnectionIdOnAlternativePath( |
| 186 | const QuicConnection* connection); |
| 187 | |
| 188 | static QuicConnectionId GetServerConnectionIdOnAlternativePath( |
| 189 | const QuicConnection* connection); |
| 190 | |
danzh | a4b519c | 2021-02-05 12:10:55 -0800 | [diff] [blame] | 191 | static bool IsAlternativePath(QuicConnection* connection, |
| 192 | const QuicSocketAddress& self_address, |
| 193 | const QuicSocketAddress& peer_address); |
danzh | a25ed9d | 2021-02-19 12:40:26 -0800 | [diff] [blame] | 194 | |
| 195 | static bool IsAlternativePathValidated(QuicConnection* connection); |
| 196 | |
| 197 | static QuicByteCount BytesReceivedBeforeAddressValidation( |
| 198 | QuicConnection* connection); |
haoyuewang | e3c51d9 | 2021-03-08 07:35:03 -0800 | [diff] [blame] | 199 | |
| 200 | static void EnableMultipleConnectionIdSupport(QuicConnection* connection); |
| 201 | |
| 202 | static void ResetPeerIssuedConnectionIdManager(QuicConnection* connection); |
haoyuewang | b9142bc | 2021-04-13 06:28:22 -0700 | [diff] [blame] | 203 | |
| 204 | static QuicConnection::PathState* GetDefaultPath(QuicConnection* connection); |
| 205 | |
| 206 | static QuicConnection::PathState* GetAlternativePath( |
| 207 | QuicConnection* connection); |
haoyuewang | dc60baf | 2021-04-19 14:03:14 -0700 | [diff] [blame] | 208 | |
| 209 | static void RetirePeerIssuedConnectionIdsNoLongerOnPath( |
| 210 | QuicConnection* connection); |
haoyuewang | b25dd21 | 2021-05-05 07:33:07 -0700 | [diff] [blame] | 211 | |
| 212 | static bool HasUnusedPeerIssuedConnectionId(const QuicConnection* connection); |
| 213 | |
| 214 | static bool HasSelfIssuedConnectionIdToConsume( |
| 215 | const QuicConnection* connection); |
haoyuewang | 095051f | 2021-07-16 12:11:35 -0700 | [diff] [blame] | 216 | |
| 217 | static QuicSelfIssuedConnectionIdManager* GetSelfIssuedConnectionIdManager( |
| 218 | QuicConnection* connection); |
haoyuewang | 7711cc8 | 2021-09-07 12:26:00 -0700 | [diff] [blame] | 219 | |
| 220 | static std::unique_ptr<QuicSelfIssuedConnectionIdManager> |
| 221 | MakeSelfIssuedConnectionIdManager(QuicConnection* connection); |
haoyuewang | 063d88c | 2021-10-21 15:06:26 -0700 | [diff] [blame] | 222 | |
| 223 | static void SetLastDecryptedLevel(QuicConnection* connection, |
| 224 | EncryptionLevel level); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 225 | }; |
| 226 | |
| 227 | } // namespace test |
| 228 | |
| 229 | } // namespace quic |
| 230 | |
| 231 | #endif // QUICHE_QUIC_TEST_TOOLS_QUIC_CONNECTION_PEER_H_ |