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 | |
QUICHE team | 5be974e | 2020-12-29 18:35:24 -0500 | [diff] [blame] | 5 | #include "quic/test_tools/quic_connection_peer.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 6 | |
vasilvv | 5f225b0 | 2020-10-08 11:49:09 -0400 | [diff] [blame] | 7 | #include "absl/strings/string_view.h" |
QUICHE team | 5be974e | 2020-12-29 18:35:24 -0500 | [diff] [blame] | 8 | #include "quic/core/congestion_control/send_algorithm_interface.h" |
| 9 | #include "quic/core/quic_packet_writer.h" |
| 10 | #include "quic/core/quic_received_packet_manager.h" |
| 11 | #include "quic/platform/api/quic_flags.h" |
danzh | 9cb85b7 | 2020-12-30 07:17:09 -0800 | [diff] [blame] | 12 | #include "quic/platform/api/quic_socket_address.h" |
haoyuewang | e3c51d9 | 2021-03-08 07:35:03 -0800 | [diff] [blame] | 13 | #include "quic/test_tools/quic_connection_id_manager_peer.h" |
QUICHE team | 5be974e | 2020-12-29 18:35:24 -0500 | [diff] [blame] | 14 | #include "quic/test_tools/quic_framer_peer.h" |
| 15 | #include "quic/test_tools/quic_sent_packet_manager_peer.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 16 | |
| 17 | namespace quic { |
| 18 | namespace test { |
| 19 | |
| 20 | // static |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 21 | void QuicConnectionPeer::SetSendAlgorithm( |
| 22 | QuicConnection* connection, |
| 23 | SendAlgorithmInterface* send_algorithm) { |
| 24 | GetSentPacketManager(connection)->SetSendAlgorithm(send_algorithm); |
| 25 | } |
| 26 | |
| 27 | // static |
| 28 | void QuicConnectionPeer::SetLossAlgorithm( |
| 29 | QuicConnection* connection, |
| 30 | LossDetectionInterface* loss_algorithm) { |
| 31 | GetSentPacketManager(connection)->loss_algorithm_ = loss_algorithm; |
| 32 | } |
| 33 | |
| 34 | // static |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 35 | void QuicConnectionPeer::PopulateStopWaitingFrame( |
| 36 | QuicConnection* connection, |
| 37 | QuicStopWaitingFrame* stop_waiting) { |
| 38 | connection->PopulateStopWaitingFrame(stop_waiting); |
| 39 | } |
| 40 | |
| 41 | // static |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 42 | QuicPacketCreator* QuicConnectionPeer::GetPacketCreator( |
| 43 | QuicConnection* connection) { |
fayang | 4245c21 | 2019-11-05 13:33:46 -0800 | [diff] [blame] | 44 | return &connection->packet_creator_; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | // static |
| 48 | QuicSentPacketManager* QuicConnectionPeer::GetSentPacketManager( |
| 49 | QuicConnection* connection) { |
| 50 | return &connection->sent_packet_manager_; |
| 51 | } |
| 52 | |
| 53 | // static |
| 54 | QuicTime::Delta QuicConnectionPeer::GetNetworkTimeout( |
| 55 | QuicConnection* connection) { |
fayang | 3a58dc4 | 2020-06-29 11:27:14 -0700 | [diff] [blame] | 56 | return connection->idle_network_detector_.idle_network_timeout_; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | // static |
| 60 | void QuicConnectionPeer::SetPerspective(QuicConnection* connection, |
| 61 | Perspective perspective) { |
| 62 | connection->perspective_ = perspective; |
| 63 | QuicFramerPeer::SetPerspective(&connection->framer_, perspective); |
| 64 | } |
| 65 | |
| 66 | // static |
| 67 | void QuicConnectionPeer::SetSelfAddress(QuicConnection* connection, |
| 68 | const QuicSocketAddress& self_address) { |
danzh | 37b722e | 2021-02-17 11:09:08 -0800 | [diff] [blame] | 69 | connection->default_path_.self_address = self_address; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | // static |
| 73 | void QuicConnectionPeer::SetPeerAddress(QuicConnection* connection, |
| 74 | const QuicSocketAddress& peer_address) { |
wub | 6e9174e | 2021-02-17 14:28:29 -0800 | [diff] [blame] | 75 | connection->UpdatePeerAddress(peer_address); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | // static |
| 79 | void QuicConnectionPeer::SetDirectPeerAddress( |
| 80 | QuicConnection* connection, |
| 81 | const QuicSocketAddress& direct_peer_address) { |
| 82 | connection->direct_peer_address_ = direct_peer_address; |
| 83 | } |
| 84 | |
| 85 | // static |
| 86 | void QuicConnectionPeer::SetEffectivePeerAddress( |
| 87 | QuicConnection* connection, |
| 88 | const QuicSocketAddress& effective_peer_address) { |
danzh | 37b722e | 2021-02-17 11:09:08 -0800 | [diff] [blame] | 89 | connection->default_path_.peer_address = effective_peer_address; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | // static |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 93 | void QuicConnectionPeer::SwapCrypters(QuicConnection* connection, |
| 94 | QuicFramer* framer) { |
| 95 | QuicFramerPeer::SwapCrypters(framer, &connection->framer_); |
| 96 | } |
| 97 | |
| 98 | // static |
vasilvv | 5f225b0 | 2020-10-08 11:49:09 -0400 | [diff] [blame] | 99 | void QuicConnectionPeer::SetCurrentPacket(QuicConnection* connection, |
| 100 | absl::string_view current_packet) { |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 101 | connection->current_packet_data_ = current_packet.data(); |
| 102 | connection->last_size_ = current_packet.size(); |
| 103 | } |
| 104 | |
| 105 | // static |
| 106 | QuicConnectionHelperInterface* QuicConnectionPeer::GetHelper( |
| 107 | QuicConnection* connection) { |
| 108 | return connection->helper_; |
| 109 | } |
| 110 | |
| 111 | // static |
| 112 | QuicAlarmFactory* QuicConnectionPeer::GetAlarmFactory( |
| 113 | QuicConnection* connection) { |
| 114 | return connection->alarm_factory_; |
| 115 | } |
| 116 | |
| 117 | // static |
| 118 | QuicFramer* QuicConnectionPeer::GetFramer(QuicConnection* connection) { |
| 119 | return &connection->framer_; |
| 120 | } |
| 121 | |
| 122 | // static |
| 123 | QuicAlarm* QuicConnectionPeer::GetAckAlarm(QuicConnection* connection) { |
| 124 | return connection->ack_alarm_.get(); |
| 125 | } |
| 126 | |
| 127 | // static |
| 128 | QuicAlarm* QuicConnectionPeer::GetPingAlarm(QuicConnection* connection) { |
| 129 | return connection->ping_alarm_.get(); |
| 130 | } |
| 131 | |
| 132 | // static |
| 133 | QuicAlarm* QuicConnectionPeer::GetRetransmissionAlarm( |
| 134 | QuicConnection* connection) { |
| 135 | return connection->retransmission_alarm_.get(); |
| 136 | } |
| 137 | |
| 138 | // static |
| 139 | QuicAlarm* QuicConnectionPeer::GetSendAlarm(QuicConnection* connection) { |
| 140 | return connection->send_alarm_.get(); |
| 141 | } |
| 142 | |
| 143 | // static |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 144 | QuicAlarm* QuicConnectionPeer::GetMtuDiscoveryAlarm( |
| 145 | QuicConnection* connection) { |
| 146 | return connection->mtu_discovery_alarm_.get(); |
| 147 | } |
| 148 | |
| 149 | // static |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 150 | QuicAlarm* QuicConnectionPeer::GetProcessUndecryptablePacketsAlarm( |
| 151 | QuicConnection* connection) { |
| 152 | return connection->process_undecryptable_packets_alarm_.get(); |
| 153 | } |
| 154 | |
| 155 | // static |
mattm | 072a7e3 | 2020-10-09 16:16:56 -0700 | [diff] [blame] | 156 | QuicAlarm* QuicConnectionPeer::GetDiscardPreviousOneRttKeysAlarm( |
| 157 | QuicConnection* connection) { |
| 158 | return connection->discard_previous_one_rtt_keys_alarm_.get(); |
| 159 | } |
| 160 | |
| 161 | // static |
mattm | ad5eb5d | 2020-12-03 16:12:15 -0800 | [diff] [blame] | 162 | QuicAlarm* QuicConnectionPeer::GetDiscardZeroRttDecryptionKeysAlarm( |
| 163 | QuicConnection* connection) { |
| 164 | return connection->discard_zero_rtt_decryption_keys_alarm_.get(); |
| 165 | } |
| 166 | |
| 167 | // static |
haoyuewang | e3c51d9 | 2021-03-08 07:35:03 -0800 | [diff] [blame] | 168 | QuicAlarm* QuicConnectionPeer::GetRetirePeerIssuedConnectionIdAlarm( |
| 169 | QuicConnection* connection) { |
| 170 | if (connection->peer_issued_cid_manager_ == nullptr) { |
| 171 | return nullptr; |
| 172 | } |
| 173 | return QuicConnectionIdManagerPeer::GetRetirePeerIssuedConnectionIdAlarm( |
| 174 | connection->peer_issued_cid_manager_.get()); |
| 175 | } |
| 176 | // static |
| 177 | QuicAlarm* QuicConnectionPeer::GetRetireSelfIssuedConnectionIdAlarm( |
| 178 | QuicConnection* connection) { |
| 179 | if (connection->self_issued_cid_manager_ == nullptr) { |
| 180 | return nullptr; |
| 181 | } |
| 182 | return QuicConnectionIdManagerPeer::GetRetireSelfIssuedConnectionIdAlarm( |
| 183 | connection->self_issued_cid_manager_.get()); |
| 184 | } |
| 185 | |
| 186 | // static |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 187 | QuicPacketWriter* QuicConnectionPeer::GetWriter(QuicConnection* connection) { |
| 188 | return connection->writer_; |
| 189 | } |
| 190 | |
| 191 | // static |
| 192 | void QuicConnectionPeer::SetWriter(QuicConnection* connection, |
| 193 | QuicPacketWriter* writer, |
| 194 | bool owns_writer) { |
| 195 | if (connection->owns_writer_) { |
| 196 | delete connection->writer_; |
| 197 | } |
| 198 | connection->writer_ = writer; |
| 199 | connection->owns_writer_ = owns_writer; |
| 200 | } |
| 201 | |
| 202 | // static |
| 203 | void QuicConnectionPeer::TearDownLocalConnectionState( |
| 204 | QuicConnection* connection) { |
| 205 | connection->connected_ = false; |
| 206 | } |
| 207 | |
| 208 | // static |
| 209 | QuicEncryptedPacket* QuicConnectionPeer::GetConnectionClosePacket( |
| 210 | QuicConnection* connection) { |
| 211 | if (connection->termination_packets_ == nullptr || |
| 212 | connection->termination_packets_->empty()) { |
| 213 | return nullptr; |
| 214 | } |
| 215 | return (*connection->termination_packets_)[0].get(); |
| 216 | } |
| 217 | |
| 218 | // static |
| 219 | QuicPacketHeader* QuicConnectionPeer::GetLastHeader( |
| 220 | QuicConnection* connection) { |
| 221 | return &connection->last_header_; |
| 222 | } |
| 223 | |
| 224 | // static |
| 225 | QuicConnectionStats* QuicConnectionPeer::GetStats(QuicConnection* connection) { |
| 226 | return &connection->stats_; |
| 227 | } |
| 228 | |
| 229 | // static |
| 230 | QuicPacketCount QuicConnectionPeer::GetPacketsBetweenMtuProbes( |
| 231 | QuicConnection* connection) { |
wub | 173916e | 2019-11-27 14:36:24 -0800 | [diff] [blame] | 232 | return connection->mtu_discoverer_.packets_between_probes(); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | // static |
wub | f76cf2a | 2019-10-11 18:49:07 -0700 | [diff] [blame] | 236 | void QuicConnectionPeer::ReInitializeMtuDiscoverer( |
| 237 | QuicConnection* connection, |
| 238 | QuicPacketCount packets_between_probes_base, |
| 239 | QuicPacketNumber next_probe_at) { |
| 240 | connection->mtu_discoverer_ = |
| 241 | QuicConnectionMtuDiscoverer(packets_between_probes_base, next_probe_at); |
| 242 | } |
| 243 | |
| 244 | // static |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 245 | void QuicConnectionPeer::SetAckDecimationDelay(QuicConnection* connection, |
| 246 | float ack_decimation_delay) { |
fayang | 5f46430 | 2019-06-20 12:57:33 -0700 | [diff] [blame] | 247 | for (auto& received_packet_manager : |
| 248 | connection->uber_received_packet_manager_.received_packet_managers_) { |
| 249 | received_packet_manager.ack_decimation_delay_ = ack_decimation_delay; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 250 | } |
| 251 | } |
| 252 | |
| 253 | // static |
| 254 | bool QuicConnectionPeer::HasRetransmittableFrames(QuicConnection* connection, |
| 255 | uint64_t packet_number) { |
| 256 | return QuicSentPacketManagerPeer::HasRetransmittableFrames( |
| 257 | GetSentPacketManager(connection), packet_number); |
| 258 | } |
| 259 | |
| 260 | // static |
| 261 | bool QuicConnectionPeer::GetNoStopWaitingFrames(QuicConnection* connection) { |
| 262 | return connection->no_stop_waiting_frames_; |
| 263 | } |
| 264 | |
| 265 | // static |
| 266 | void QuicConnectionPeer::SetNoStopWaitingFrames(QuicConnection* connection, |
| 267 | bool no_stop_waiting_frames) { |
| 268 | connection->no_stop_waiting_frames_ = no_stop_waiting_frames; |
| 269 | } |
| 270 | |
| 271 | // static |
| 272 | void QuicConnectionPeer::SetMaxTrackedPackets( |
| 273 | QuicConnection* connection, |
| 274 | QuicPacketCount max_tracked_packets) { |
| 275 | connection->max_tracked_packets_ = max_tracked_packets; |
| 276 | } |
| 277 | |
| 278 | // static |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 279 | void QuicConnectionPeer::SetNegotiatedVersion(QuicConnection* connection) { |
fayang | 8aba1ff | 2019-06-21 12:00:54 -0700 | [diff] [blame] | 280 | connection->version_negotiated_ = true; |
wub | 256b2d6 | 2019-11-25 08:46:55 -0800 | [diff] [blame] | 281 | if (connection->perspective() == Perspective::IS_SERVER && |
| 282 | !QuicFramerPeer::infer_packet_header_type_from_version( |
| 283 | &connection->framer_)) { |
| 284 | connection->framer_.InferPacketHeaderTypeFromVersion(); |
| 285 | } |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | // static |
| 289 | void QuicConnectionPeer::SetMaxConsecutiveNumPacketsWithNoRetransmittableFrames( |
| 290 | QuicConnection* connection, |
| 291 | size_t new_value) { |
| 292 | connection->max_consecutive_num_packets_with_no_retransmittable_frames_ = |
| 293 | new_value; |
| 294 | } |
| 295 | |
| 296 | // static |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 297 | bool QuicConnectionPeer::SupportsReleaseTime(QuicConnection* connection) { |
| 298 | return connection->supports_release_time_; |
| 299 | } |
| 300 | |
| 301 | // static |
| 302 | QuicConnection::PacketContent QuicConnectionPeer::GetCurrentPacketContent( |
| 303 | QuicConnection* connection) { |
| 304 | return connection->current_packet_content_; |
| 305 | } |
| 306 | |
QUICHE team | 8c1daa2 | 2019-03-13 08:33:41 -0700 | [diff] [blame] | 307 | // static |
| 308 | void QuicConnectionPeer::SetLastHeaderFormat(QuicConnection* connection, |
| 309 | PacketHeaderFormat format) { |
| 310 | connection->last_header_.form = format; |
| 311 | } |
| 312 | |
fayang | 5f13505 | 2019-08-22 17:59:40 -0700 | [diff] [blame] | 313 | // static |
| 314 | void QuicConnectionPeer::AddBytesReceived(QuicConnection* connection, |
| 315 | size_t length) { |
| 316 | if (connection->EnforceAntiAmplificationLimit()) { |
danzh | 37b722e | 2021-02-17 11:09:08 -0800 | [diff] [blame] | 317 | connection->default_path_.bytes_received_before_address_validation += |
| 318 | length; |
fayang | 5f13505 | 2019-08-22 17:59:40 -0700 | [diff] [blame] | 319 | } |
| 320 | } |
| 321 | |
| 322 | // static |
| 323 | void QuicConnectionPeer::SetAddressValidated(QuicConnection* connection) { |
danzh | 37b722e | 2021-02-17 11:09:08 -0800 | [diff] [blame] | 324 | connection->default_path_.validated = true; |
fayang | 5f13505 | 2019-08-22 17:59:40 -0700 | [diff] [blame] | 325 | } |
| 326 | |
dschinazi | dce90b0 | 2019-10-14 18:19:54 -0700 | [diff] [blame] | 327 | // static |
mattm | 55006b0 | 2021-01-14 15:09:54 -0800 | [diff] [blame] | 328 | void QuicConnectionPeer::SendConnectionClosePacket( |
| 329 | QuicConnection* connection, |
| 330 | QuicIetfTransportErrorCodes ietf_error, |
| 331 | QuicErrorCode error, |
| 332 | const std::string& details) { |
| 333 | connection->SendConnectionClosePacket(error, ietf_error, details); |
dschinazi | dce90b0 | 2019-10-14 18:19:54 -0700 | [diff] [blame] | 334 | } |
| 335 | |
rch | d672c6d | 2019-11-27 15:30:54 -0800 | [diff] [blame] | 336 | // static |
| 337 | size_t QuicConnectionPeer::GetNumEncryptionLevels(QuicConnection* connection) { |
| 338 | size_t count = 0; |
| 339 | for (EncryptionLevel level : |
| 340 | {ENCRYPTION_INITIAL, ENCRYPTION_HANDSHAKE, ENCRYPTION_ZERO_RTT, |
| 341 | ENCRYPTION_FORWARD_SECURE}) { |
| 342 | if (connection->framer_.HasEncrypterOfEncryptionLevel(level)) { |
| 343 | ++count; |
| 344 | } |
| 345 | } |
| 346 | return count; |
| 347 | } |
| 348 | |
fayang | b59c6f1 | 2020-03-23 15:06:14 -0700 | [diff] [blame] | 349 | // static |
| 350 | QuicNetworkBlackholeDetector& QuicConnectionPeer::GetBlackholeDetector( |
| 351 | QuicConnection* connection) { |
| 352 | return connection->blackhole_detector_; |
| 353 | } |
| 354 | |
| 355 | // static |
| 356 | QuicAlarm* QuicConnectionPeer::GetBlackholeDetectorAlarm( |
| 357 | QuicConnection* connection) { |
| 358 | return connection->blackhole_detector_.alarm_.get(); |
| 359 | } |
| 360 | |
| 361 | // static |
| 362 | QuicTime QuicConnectionPeer::GetPathDegradingDeadline( |
| 363 | QuicConnection* connection) { |
| 364 | return connection->blackhole_detector_.path_degrading_deadline_; |
| 365 | } |
| 366 | |
| 367 | // static |
| 368 | QuicTime QuicConnectionPeer::GetBlackholeDetectionDeadline( |
| 369 | QuicConnection* connection) { |
| 370 | return connection->blackhole_detector_.blackhole_deadline_; |
| 371 | } |
| 372 | |
fayang | b9c8844 | 2020-03-26 07:03:57 -0700 | [diff] [blame] | 373 | // static |
wub | 8add68a | 2020-07-27 12:07:38 -0700 | [diff] [blame] | 374 | QuicTime QuicConnectionPeer::GetPathMtuReductionDetectionDeadline( |
| 375 | QuicConnection* connection) { |
| 376 | return connection->blackhole_detector_.path_mtu_reduction_deadline_; |
| 377 | } |
| 378 | |
| 379 | // static |
fayang | 001c828 | 2020-07-29 12:39:29 -0700 | [diff] [blame] | 380 | QuicTime QuicConnectionPeer::GetIdleNetworkDeadline( |
| 381 | QuicConnection* connection) { |
| 382 | return connection->idle_network_detector_.GetIdleNetworkDeadline(); |
| 383 | } |
| 384 | |
| 385 | // static |
fayang | b9c8844 | 2020-03-26 07:03:57 -0700 | [diff] [blame] | 386 | QuicAlarm* QuicConnectionPeer::GetIdleNetworkDetectorAlarm( |
| 387 | QuicConnection* connection) { |
| 388 | return connection->idle_network_detector_.alarm_.get(); |
| 389 | } |
| 390 | |
dschinazi | 39e5e55 | 2020-05-06 13:55:24 -0700 | [diff] [blame] | 391 | // static |
fayang | 001c828 | 2020-07-29 12:39:29 -0700 | [diff] [blame] | 392 | QuicIdleNetworkDetector& QuicConnectionPeer::GetIdleNetworkDetector( |
| 393 | QuicConnection* connection) { |
| 394 | return connection->idle_network_detector_; |
| 395 | } |
| 396 | |
| 397 | // static |
dschinazi | 39e5e55 | 2020-05-06 13:55:24 -0700 | [diff] [blame] | 398 | void QuicConnectionPeer::SetServerConnectionId( |
| 399 | QuicConnection* connection, |
| 400 | const QuicConnectionId& server_connection_id) { |
haoyuewang | 16ef03b | 2021-06-30 07:59:53 -0700 | [diff] [blame] | 401 | connection->default_path_.server_connection_id = server_connection_id; |
dschinazi | 39e5e55 | 2020-05-06 13:55:24 -0700 | [diff] [blame] | 402 | connection->InstallInitialCrypters(server_connection_id); |
| 403 | } |
| 404 | |
fayang | 750b54f | 2020-06-18 06:26:54 -0700 | [diff] [blame] | 405 | // static |
| 406 | size_t QuicConnectionPeer::NumUndecryptablePackets(QuicConnection* connection) { |
| 407 | return connection->undecryptable_packets_.size(); |
| 408 | } |
| 409 | |
danzh | 8a27a1a | 2020-09-02 10:26:28 -0700 | [diff] [blame] | 410 | // static |
danzh | 9cb85b7 | 2020-12-30 07:17:09 -0800 | [diff] [blame] | 411 | size_t QuicConnectionPeer::NumPendingPathChallengesToResponse( |
danzh | 8a27a1a | 2020-09-02 10:26:28 -0700 | [diff] [blame] | 412 | QuicConnection* connection) { |
danzh | 9cb85b7 | 2020-12-30 07:17:09 -0800 | [diff] [blame] | 413 | return connection->pending_path_challenge_payloads_.size(); |
danzh | 8a27a1a | 2020-09-02 10:26:28 -0700 | [diff] [blame] | 414 | } |
| 415 | |
renjietang | 052df7c | 2020-10-13 14:46:09 -0700 | [diff] [blame] | 416 | void QuicConnectionPeer::SetConnectionClose(QuicConnection* connection) { |
| 417 | connection->connected_ = false; |
| 418 | } |
| 419 | |
fayang | 29ce0bd | 2020-10-29 08:28:44 -0700 | [diff] [blame] | 420 | // static |
| 421 | void QuicConnectionPeer::SendPing(QuicConnection* connection) { |
| 422 | connection->SendPingAtLevel(connection->encryption_level()); |
| 423 | } |
| 424 | |
danzh | e6211dc | 2020-11-19 09:19:00 -0800 | [diff] [blame] | 425 | // static |
| 426 | void QuicConnectionPeer::SetLastPacketDestinationAddress( |
| 427 | QuicConnection* connection, |
| 428 | const QuicSocketAddress& address) { |
fayang | aee86fb | 2021-06-02 12:06:08 -0700 | [diff] [blame] | 429 | connection->last_received_packet_info_.destination_address = address; |
danzh | e6211dc | 2020-11-19 09:19:00 -0800 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | // static |
| 433 | QuicPathValidator* QuicConnectionPeer::path_validator( |
| 434 | QuicConnection* connection) { |
| 435 | return &connection->path_validator_; |
| 436 | } |
| 437 | |
danzh | 9cb85b7 | 2020-12-30 07:17:09 -0800 | [diff] [blame] | 438 | // static |
danzh | a4b519c | 2021-02-05 12:10:55 -0800 | [diff] [blame] | 439 | QuicByteCount QuicConnectionPeer::BytesSentOnAlternativePath( |
danzh | 9cb85b7 | 2020-12-30 07:17:09 -0800 | [diff] [blame] | 440 | QuicConnection* connection) { |
danzh | a4b519c | 2021-02-05 12:10:55 -0800 | [diff] [blame] | 441 | return connection->alternative_path_.bytes_sent_before_address_validation; |
danzh | 9cb85b7 | 2020-12-30 07:17:09 -0800 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | // static |
danzh | a4b519c | 2021-02-05 12:10:55 -0800 | [diff] [blame] | 445 | QuicByteCount QuicConnectionPeer::BytesReceivedOnAlternativePath( |
danzh | 9cb85b7 | 2020-12-30 07:17:09 -0800 | [diff] [blame] | 446 | QuicConnection* connection) { |
danzh | a4b519c | 2021-02-05 12:10:55 -0800 | [diff] [blame] | 447 | return connection->alternative_path_.bytes_received_before_address_validation; |
danzh | 9cb85b7 | 2020-12-30 07:17:09 -0800 | [diff] [blame] | 448 | } |
| 449 | |
danzh | 3b63070 | 2021-01-12 14:15:23 -0800 | [diff] [blame] | 450 | // static |
haoyuewang | 5c49d3e | 2021-04-08 07:33:33 -0700 | [diff] [blame] | 451 | QuicConnectionId QuicConnectionPeer::GetClientConnectionIdOnAlternativePath( |
| 452 | const QuicConnection* connection) { |
| 453 | return connection->alternative_path_.client_connection_id; |
| 454 | } |
| 455 | |
| 456 | // static |
| 457 | QuicConnectionId QuicConnectionPeer::GetServerConnectionIdOnAlternativePath( |
| 458 | const QuicConnection* connection) { |
| 459 | return connection->alternative_path_.server_connection_id; |
| 460 | } |
| 461 | |
| 462 | // static |
danzh | a25ed9d | 2021-02-19 12:40:26 -0800 | [diff] [blame] | 463 | bool QuicConnectionPeer::IsAlternativePathValidated( |
| 464 | QuicConnection* connection) { |
| 465 | return connection->alternative_path_.validated; |
| 466 | } |
| 467 | |
| 468 | // static |
danzh | a4b519c | 2021-02-05 12:10:55 -0800 | [diff] [blame] | 469 | bool QuicConnectionPeer::IsAlternativePath( |
danzh | 3b63070 | 2021-01-12 14:15:23 -0800 | [diff] [blame] | 470 | QuicConnection* connection, |
| 471 | const QuicSocketAddress& self_address, |
| 472 | const QuicSocketAddress& peer_address) { |
danzh | a4b519c | 2021-02-05 12:10:55 -0800 | [diff] [blame] | 473 | return connection->IsAlternativePath(self_address, peer_address); |
danzh | 3b63070 | 2021-01-12 14:15:23 -0800 | [diff] [blame] | 474 | } |
| 475 | |
danzh | a25ed9d | 2021-02-19 12:40:26 -0800 | [diff] [blame] | 476 | // static |
| 477 | QuicByteCount QuicConnectionPeer::BytesReceivedBeforeAddressValidation( |
| 478 | QuicConnection* connection) { |
| 479 | return connection->default_path_.bytes_received_before_address_validation; |
| 480 | } |
| 481 | |
haoyuewang | e3c51d9 | 2021-03-08 07:35:03 -0800 | [diff] [blame] | 482 | // static |
haoyuewang | e3c51d9 | 2021-03-08 07:35:03 -0800 | [diff] [blame] | 483 | void QuicConnectionPeer::ResetPeerIssuedConnectionIdManager( |
| 484 | QuicConnection* connection) { |
| 485 | connection->peer_issued_cid_manager_ = nullptr; |
| 486 | } |
haoyuewang | b9142bc | 2021-04-13 06:28:22 -0700 | [diff] [blame] | 487 | |
| 488 | // static |
| 489 | QuicConnection::PathState* QuicConnectionPeer::GetDefaultPath( |
| 490 | QuicConnection* connection) { |
| 491 | return &connection->default_path_; |
| 492 | } |
| 493 | |
| 494 | // static |
| 495 | QuicConnection::PathState* QuicConnectionPeer::GetAlternativePath( |
| 496 | QuicConnection* connection) { |
| 497 | return &connection->alternative_path_; |
| 498 | } |
| 499 | |
haoyuewang | dc60baf | 2021-04-19 14:03:14 -0700 | [diff] [blame] | 500 | // static |
| 501 | void QuicConnectionPeer::RetirePeerIssuedConnectionIdsNoLongerOnPath( |
| 502 | QuicConnection* connection) { |
| 503 | connection->RetirePeerIssuedConnectionIdsNoLongerOnPath(); |
| 504 | } |
| 505 | |
haoyuewang | b25dd21 | 2021-05-05 07:33:07 -0700 | [diff] [blame] | 506 | // static |
| 507 | bool QuicConnectionPeer::HasUnusedPeerIssuedConnectionId( |
| 508 | const QuicConnection* connection) { |
| 509 | return connection->peer_issued_cid_manager_->HasUnusedConnectionId(); |
| 510 | } |
| 511 | |
| 512 | // static |
| 513 | bool QuicConnectionPeer::HasSelfIssuedConnectionIdToConsume( |
| 514 | const QuicConnection* connection) { |
| 515 | return connection->self_issued_cid_manager_->HasConnectionIdToConsume(); |
| 516 | } |
| 517 | |
haoyuewang | 095051f | 2021-07-16 12:11:35 -0700 | [diff] [blame] | 518 | // static |
| 519 | QuicSelfIssuedConnectionIdManager* |
| 520 | QuicConnectionPeer::GetSelfIssuedConnectionIdManager( |
| 521 | QuicConnection* connection) { |
| 522 | return connection->self_issued_cid_manager_.get(); |
| 523 | } |
| 524 | |
haoyuewang | 7711cc8 | 2021-09-07 12:26:00 -0700 | [diff] [blame] | 525 | // static |
| 526 | std::unique_ptr<QuicSelfIssuedConnectionIdManager> |
| 527 | QuicConnectionPeer::MakeSelfIssuedConnectionIdManager( |
| 528 | QuicConnection* connection) { |
| 529 | return connection->MakeSelfIssuedConnectionIdManager(); |
| 530 | } |
| 531 | |
haoyuewang | 063d88c | 2021-10-21 15:06:26 -0700 | [diff] [blame] | 532 | // static |
| 533 | void QuicConnectionPeer::SetLastDecryptedLevel(QuicConnection* connection, |
| 534 | EncryptionLevel level) { |
| 535 | connection->last_decrypted_packet_level_ = level; |
| 536 | } |
| 537 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 538 | } // namespace test |
| 539 | } // namespace quic |