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 #include "net/quic/core/quic_packets.h" | 5 #include "net/quic/core/quic_packets.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "net/quic/core/quic_flags.h" | 9 #include "net/quic/core/quic_flags.h" |
10 #include "net/quic/core/quic_utils.h" | 10 #include "net/quic/core/quic_utils.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 202 } |
203 | 203 |
204 StringPiece QuicPacket::Plaintext(QuicVersion version) const { | 204 StringPiece QuicPacket::Plaintext(QuicVersion version) const { |
205 const size_t start_of_encrypted_data = GetStartOfEncryptedData( | 205 const size_t start_of_encrypted_data = GetStartOfEncryptedData( |
206 version, connection_id_length_, includes_version_, includes_path_id_, | 206 version, connection_id_length_, includes_version_, includes_path_id_, |
207 includes_diversification_nonce_, packet_number_length_); | 207 includes_diversification_nonce_, packet_number_length_); |
208 return StringPiece(data() + start_of_encrypted_data, | 208 return StringPiece(data() + start_of_encrypted_data, |
209 length() - start_of_encrypted_data); | 209 length() - start_of_encrypted_data); |
210 } | 210 } |
211 | 211 |
212 AckListenerWrapper::AckListenerWrapper(QuicAckListenerInterface* listener, | |
213 QuicPacketLength data_length) | |
214 : ack_listener(listener), length(data_length) { | |
215 DCHECK(listener != nullptr); | |
216 } | |
217 | |
218 AckListenerWrapper::AckListenerWrapper(const AckListenerWrapper& other) = | |
219 default; | |
220 | |
221 AckListenerWrapper::~AckListenerWrapper() {} | |
222 | |
223 SerializedPacket::SerializedPacket(QuicPathId path_id, | 212 SerializedPacket::SerializedPacket(QuicPathId path_id, |
224 QuicPacketNumber packet_number, | 213 QuicPacketNumber packet_number, |
225 QuicPacketNumberLength packet_number_length, | 214 QuicPacketNumberLength packet_number_length, |
226 const char* encrypted_buffer, | 215 const char* encrypted_buffer, |
227 QuicPacketLength encrypted_length, | 216 QuicPacketLength encrypted_length, |
228 bool has_ack, | 217 bool has_ack, |
229 bool has_stop_waiting) | 218 bool has_stop_waiting) |
230 : encrypted_buffer(encrypted_buffer), | 219 : encrypted_buffer(encrypted_buffer), |
231 encrypted_length(encrypted_length), | 220 encrypted_length(encrypted_length), |
232 has_crypto_handshake(NOT_HANDSHAKE), | 221 has_crypto_handshake(NOT_HANDSHAKE), |
233 num_padding_bytes(0), | 222 num_padding_bytes(0), |
234 path_id(path_id), | 223 path_id(path_id), |
235 packet_number(packet_number), | 224 packet_number(packet_number), |
236 packet_number_length(packet_number_length), | 225 packet_number_length(packet_number_length), |
237 encryption_level(ENCRYPTION_NONE), | 226 encryption_level(ENCRYPTION_NONE), |
238 has_ack(has_ack), | 227 has_ack(has_ack), |
239 has_stop_waiting(has_stop_waiting), | 228 has_stop_waiting(has_stop_waiting), |
240 transmission_type(NOT_RETRANSMISSION), | 229 transmission_type(NOT_RETRANSMISSION), |
241 original_path_id(kInvalidPathId), | 230 original_path_id(kInvalidPathId), |
242 original_packet_number(0) {} | 231 original_packet_number(0) {} |
243 | 232 |
244 SerializedPacket::SerializedPacket(const SerializedPacket& other) = default; | 233 SerializedPacket::SerializedPacket(const SerializedPacket& other) = default; |
245 | 234 |
246 SerializedPacket::~SerializedPacket() {} | 235 SerializedPacket::~SerializedPacket() {} |
247 | 236 |
248 TransmissionInfo::TransmissionInfo() | |
249 : encryption_level(ENCRYPTION_NONE), | |
250 packet_number_length(PACKET_1BYTE_PACKET_NUMBER), | |
251 bytes_sent(0), | |
252 sent_time(QuicTime::Zero()), | |
253 transmission_type(NOT_RETRANSMISSION), | |
254 in_flight(false), | |
255 is_unackable(false), | |
256 has_crypto_handshake(false), | |
257 num_padding_bytes(0), | |
258 retransmission(0) {} | |
259 | |
260 void ClearSerializedPacket(SerializedPacket* serialized_packet) { | 237 void ClearSerializedPacket(SerializedPacket* serialized_packet) { |
261 if (!serialized_packet->retransmittable_frames.empty()) { | 238 if (!serialized_packet->retransmittable_frames.empty()) { |
262 DeleteFrames(&serialized_packet->retransmittable_frames); | 239 DeleteFrames(&serialized_packet->retransmittable_frames); |
263 } | 240 } |
264 serialized_packet->encrypted_buffer = nullptr; | 241 serialized_packet->encrypted_buffer = nullptr; |
265 serialized_packet->encrypted_length = 0; | 242 serialized_packet->encrypted_length = 0; |
266 } | 243 } |
267 | 244 |
268 char* CopyBuffer(const SerializedPacket& packet) { | 245 char* CopyBuffer(const SerializedPacket& packet) { |
269 char* dst_buffer = new char[packet.encrypted_length]; | 246 char* dst_buffer = new char[packet.encrypted_length]; |
270 memcpy(dst_buffer, packet.encrypted_buffer, packet.encrypted_length); | 247 memcpy(dst_buffer, packet.encrypted_buffer, packet.encrypted_length); |
271 return dst_buffer; | 248 return dst_buffer; |
272 } | 249 } |
273 | 250 |
274 TransmissionInfo::TransmissionInfo(EncryptionLevel level, | |
275 QuicPacketNumberLength packet_number_length, | |
276 TransmissionType transmission_type, | |
277 QuicTime sent_time, | |
278 QuicPacketLength bytes_sent, | |
279 bool has_crypto_handshake, | |
280 int num_padding_bytes) | |
281 : encryption_level(level), | |
282 packet_number_length(packet_number_length), | |
283 bytes_sent(bytes_sent), | |
284 sent_time(sent_time), | |
285 transmission_type(transmission_type), | |
286 in_flight(false), | |
287 is_unackable(false), | |
288 has_crypto_handshake(has_crypto_handshake), | |
289 num_padding_bytes(num_padding_bytes), | |
290 retransmission(0) {} | |
291 | |
292 TransmissionInfo::TransmissionInfo(const TransmissionInfo& other) = default; | |
293 | |
294 TransmissionInfo::~TransmissionInfo() {} | |
295 | |
296 } // namespace net | 251 } // namespace net |
OLD | NEW |