1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/third_party/quiche/src/quic/test_tools/quic_connection_peer.h"
#include "net/third_party/quiche/src/quic/core/congestion_control/send_algorithm_interface.h"
#include "net/third_party/quiche/src/quic/core/quic_packet_writer.h"
#include "net/third_party/quiche/src/quic/core/quic_received_packet_manager.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
#include "net/third_party/quiche/src/quic/test_tools/quic_framer_peer.h"
#include "net/third_party/quiche/src/quic/test_tools/quic_packet_generator_peer.h"
#include "net/third_party/quiche/src/quic/test_tools/quic_sent_packet_manager_peer.h"
namespace quic {
namespace test {
// static
void QuicConnectionPeer::SetSendAlgorithm(
QuicConnection* connection,
SendAlgorithmInterface* send_algorithm) {
GetSentPacketManager(connection)->SetSendAlgorithm(send_algorithm);
}
// static
void QuicConnectionPeer::SetLossAlgorithm(
QuicConnection* connection,
LossDetectionInterface* loss_algorithm) {
GetSentPacketManager(connection)->loss_algorithm_ = loss_algorithm;
}
// static
void QuicConnectionPeer::PopulateStopWaitingFrame(
QuicConnection* connection,
QuicStopWaitingFrame* stop_waiting) {
connection->PopulateStopWaitingFrame(stop_waiting);
}
// static
QuicConnectionVisitorInterface* QuicConnectionPeer::GetVisitor(
QuicConnection* connection) {
return connection->visitor_;
}
// static
QuicPacketCreator* QuicConnectionPeer::GetPacketCreator(
QuicConnection* connection) {
return QuicPacketGeneratorPeer::GetPacketCreator(
&connection->packet_generator_);
}
// static
QuicPacketGenerator* QuicConnectionPeer::GetPacketGenerator(
QuicConnection* connection) {
return &connection->packet_generator_;
}
// static
QuicSentPacketManager* QuicConnectionPeer::GetSentPacketManager(
QuicConnection* connection) {
return &connection->sent_packet_manager_;
}
// static
QuicTime::Delta QuicConnectionPeer::GetNetworkTimeout(
QuicConnection* connection) {
return connection->idle_network_timeout_;
}
// static
void QuicConnectionPeer::SetPerspective(QuicConnection* connection,
Perspective perspective) {
connection->perspective_ = perspective;
QuicFramerPeer::SetPerspective(&connection->framer_, perspective);
}
// static
void QuicConnectionPeer::SetSelfAddress(QuicConnection* connection,
const QuicSocketAddress& self_address) {
connection->self_address_ = self_address;
}
// static
void QuicConnectionPeer::SetPeerAddress(QuicConnection* connection,
const QuicSocketAddress& peer_address) {
connection->peer_address_ = peer_address;
}
// static
void QuicConnectionPeer::SetDirectPeerAddress(
QuicConnection* connection,
const QuicSocketAddress& direct_peer_address) {
connection->direct_peer_address_ = direct_peer_address;
}
// static
void QuicConnectionPeer::SetEffectivePeerAddress(
QuicConnection* connection,
const QuicSocketAddress& effective_peer_address) {
connection->effective_peer_address_ = effective_peer_address;
}
// static
bool QuicConnectionPeer::IsSilentCloseEnabled(QuicConnection* connection) {
return connection->idle_timeout_connection_close_behavior_ ==
ConnectionCloseBehavior::SILENT_CLOSE;
}
// static
void QuicConnectionPeer::SwapCrypters(QuicConnection* connection,
QuicFramer* framer) {
QuicFramerPeer::SwapCrypters(framer, &connection->framer_);
}
// static
void QuicConnectionPeer::SetCurrentPacket(QuicConnection* connection,
QuicStringPiece current_packet) {
connection->current_packet_data_ = current_packet.data();
connection->last_size_ = current_packet.size();
}
// static
QuicConnectionHelperInterface* QuicConnectionPeer::GetHelper(
QuicConnection* connection) {
return connection->helper_;
}
// static
QuicAlarmFactory* QuicConnectionPeer::GetAlarmFactory(
QuicConnection* connection) {
return connection->alarm_factory_;
}
// static
QuicFramer* QuicConnectionPeer::GetFramer(QuicConnection* connection) {
return &connection->framer_;
}
// static
QuicAlarm* QuicConnectionPeer::GetAckAlarm(QuicConnection* connection) {
return connection->ack_alarm_.get();
}
// static
QuicAlarm* QuicConnectionPeer::GetPingAlarm(QuicConnection* connection) {
return connection->ping_alarm_.get();
}
// static
QuicAlarm* QuicConnectionPeer::GetRetransmissionAlarm(
QuicConnection* connection) {
return connection->retransmission_alarm_.get();
}
// static
QuicAlarm* QuicConnectionPeer::GetSendAlarm(QuicConnection* connection) {
return connection->send_alarm_.get();
}
// static
QuicAlarm* QuicConnectionPeer::GetTimeoutAlarm(QuicConnection* connection) {
return connection->timeout_alarm_.get();
}
// static
QuicAlarm* QuicConnectionPeer::GetMtuDiscoveryAlarm(
QuicConnection* connection) {
return connection->mtu_discovery_alarm_.get();
}
// static
QuicAlarm* QuicConnectionPeer::GetPathDegradingAlarm(
QuicConnection* connection) {
return connection->path_degrading_alarm_.get();
}
// static
QuicAlarm* QuicConnectionPeer::GetProcessUndecryptablePacketsAlarm(
QuicConnection* connection) {
return connection->process_undecryptable_packets_alarm_.get();
}
// static
QuicPacketWriter* QuicConnectionPeer::GetWriter(QuicConnection* connection) {
return connection->writer_;
}
// static
void QuicConnectionPeer::SetWriter(QuicConnection* connection,
QuicPacketWriter* writer,
bool owns_writer) {
if (connection->owns_writer_) {
delete connection->writer_;
}
connection->writer_ = writer;
connection->owns_writer_ = owns_writer;
}
// static
void QuicConnectionPeer::TearDownLocalConnectionState(
QuicConnection* connection) {
connection->connected_ = false;
}
// static
QuicEncryptedPacket* QuicConnectionPeer::GetConnectionClosePacket(
QuicConnection* connection) {
if (connection->termination_packets_ == nullptr ||
connection->termination_packets_->empty()) {
return nullptr;
}
return (*connection->termination_packets_)[0].get();
}
// static
QuicPacketHeader* QuicConnectionPeer::GetLastHeader(
QuicConnection* connection) {
return &connection->last_header_;
}
// static
QuicConnectionStats* QuicConnectionPeer::GetStats(QuicConnection* connection) {
return &connection->stats_;
}
// static
QuicPacketCount QuicConnectionPeer::GetPacketsBetweenMtuProbes(
QuicConnection* connection) {
if (connection->mtu_discovery_v2_) {
return connection->mtu_discoverer_.packets_between_probes();
}
return connection->packets_between_mtu_probes_;
}
// static
void QuicConnectionPeer::SetPacketsBetweenMtuProbes(QuicConnection* connection,
QuicPacketCount packets) {
connection->packets_between_mtu_probes_ = packets;
}
// static
void QuicConnectionPeer::SetNextMtuProbeAt(QuicConnection* connection,
QuicPacketNumber number) {
connection->next_mtu_probe_at_ = number;
}
// static
void QuicConnectionPeer::ReInitializeMtuDiscoverer(
QuicConnection* connection,
QuicPacketCount packets_between_probes_base,
QuicPacketNumber next_probe_at) {
connection->mtu_discoverer_ =
QuicConnectionMtuDiscoverer(packets_between_probes_base, next_probe_at);
}
// static
void QuicConnectionPeer::SetAckMode(QuicConnection* connection,
AckMode ack_mode) {
for (auto& received_packet_manager :
connection->uber_received_packet_manager_.received_packet_managers_) {
received_packet_manager.ack_mode_ = ack_mode;
}
}
// static
void QuicConnectionPeer::SetFastAckAfterQuiescence(
QuicConnection* connection,
bool fast_ack_after_quiescence) {
for (auto& received_packet_manager :
connection->uber_received_packet_manager_.received_packet_managers_) {
received_packet_manager.fast_ack_after_quiescence_ =
fast_ack_after_quiescence;
}
}
// static
void QuicConnectionPeer::SetAckDecimationDelay(QuicConnection* connection,
float ack_decimation_delay) {
for (auto& received_packet_manager :
connection->uber_received_packet_manager_.received_packet_managers_) {
received_packet_manager.ack_decimation_delay_ = ack_decimation_delay;
}
}
// static
bool QuicConnectionPeer::HasRetransmittableFrames(QuicConnection* connection,
uint64_t packet_number) {
return QuicSentPacketManagerPeer::HasRetransmittableFrames(
GetSentPacketManager(connection), packet_number);
}
// static
bool QuicConnectionPeer::GetNoStopWaitingFrames(QuicConnection* connection) {
return connection->no_stop_waiting_frames_;
}
// static
void QuicConnectionPeer::SetNoStopWaitingFrames(QuicConnection* connection,
bool no_stop_waiting_frames) {
connection->no_stop_waiting_frames_ = no_stop_waiting_frames;
}
// static
void QuicConnectionPeer::SetMaxTrackedPackets(
QuicConnection* connection,
QuicPacketCount max_tracked_packets) {
connection->max_tracked_packets_ = max_tracked_packets;
}
// static
void QuicConnectionPeer::SetSessionDecidesWhatToWrite(
QuicConnection* connection) {
connection->sent_packet_manager_.SetSessionDecideWhatToWrite(true);
connection->packet_generator_.SetCanSetTransmissionType(true);
}
// static
void QuicConnectionPeer::SetNegotiatedVersion(QuicConnection* connection) {
connection->version_negotiated_ = true;
}
// static
void QuicConnectionPeer::SetMaxConsecutiveNumPacketsWithNoRetransmittableFrames(
QuicConnection* connection,
size_t new_value) {
connection->max_consecutive_num_packets_with_no_retransmittable_frames_ =
new_value;
}
// static
bool QuicConnectionPeer::SupportsReleaseTime(QuicConnection* connection) {
return connection->supports_release_time_;
}
// static
QuicConnection::PacketContent QuicConnectionPeer::GetCurrentPacketContent(
QuicConnection* connection) {
return connection->current_packet_content_;
}
// static
void QuicConnectionPeer::SetLastHeaderFormat(QuicConnection* connection,
PacketHeaderFormat format) {
connection->last_header_.form = format;
}
// static
void QuicConnectionPeer::AddBytesReceived(QuicConnection* connection,
size_t length) {
if (connection->EnforceAntiAmplificationLimit()) {
connection->bytes_received_before_address_validation_ += length;
}
}
// static
void QuicConnectionPeer::SetAddressValidated(QuicConnection* connection) {
connection->address_validated_ = true;
}
// static
void QuicConnectionPeer::SendConnectionClosePacket(QuicConnection* connection,
QuicErrorCode error,
const std::string& details) {
connection->SendConnectionClosePacket(error, details);
}
} // namespace test
} // namespace quic
|