| 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 #ifndef NET_QUIC_QUIC_PROTOCOL_H_ | 5 #ifndef NET_QUIC_QUIC_PROTOCOL_H_ |
| 6 #define NET_QUIC_QUIC_PROTOCOL_H_ | 6 #define NET_QUIC_QUIC_PROTOCOL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 NEGOTIATION_IN_PROGRESS, | 759 NEGOTIATION_IN_PROGRESS, |
| 760 // This indicates this endpoint has received a packet from the peer with a | 760 // This indicates this endpoint has received a packet from the peer with a |
| 761 // version this endpoint supports. Version negotiation is complete, and the | 761 // version this endpoint supports. Version negotiation is complete, and the |
| 762 // version number will no longer be sent with future packets. | 762 // version number will no longer be sent with future packets. |
| 763 NEGOTIATED_VERSION | 763 NEGOTIATED_VERSION |
| 764 }; | 764 }; |
| 765 | 765 |
| 766 typedef QuicPacketPublicHeader QuicVersionNegotiationPacket; | 766 typedef QuicPacketPublicHeader QuicVersionNegotiationPacket; |
| 767 | 767 |
| 768 // A padding frame contains no payload. | 768 // A padding frame contains no payload. |
| 769 struct NET_EXPORT_PRIVATE QuicPaddingFrame {}; | 769 struct NET_EXPORT_PRIVATE QuicPaddingFrame { |
| 770 QuicPaddingFrame() : num_padding_bytes(-1) {} |
| 771 explicit QuicPaddingFrame(int num_padding_bytes) |
| 772 : num_padding_bytes(num_padding_bytes) {} |
| 773 |
| 774 // -1: full padding to the end of a max-sized packet |
| 775 // otherwise: only pad up to num_padding_bytes bytes |
| 776 int num_padding_bytes; |
| 777 }; |
| 770 | 778 |
| 771 // A ping frame contains no payload, though it is retransmittable, | 779 // A ping frame contains no payload, though it is retransmittable, |
| 772 // and ACK'd just like other normal frames. | 780 // and ACK'd just like other normal frames. |
| 773 struct NET_EXPORT_PRIVATE QuicPingFrame {}; | 781 struct NET_EXPORT_PRIVATE QuicPingFrame {}; |
| 774 | 782 |
| 775 // A path MTU discovery frame contains no payload and is serialized as a ping | 783 // A path MTU discovery frame contains no payload and is serialized as a ping |
| 776 // frame. | 784 // frame. |
| 777 struct NET_EXPORT_PRIVATE QuicMtuDiscoveryFrame {}; | 785 struct NET_EXPORT_PRIVATE QuicMtuDiscoveryFrame {}; |
| 778 | 786 |
| 779 class NET_EXPORT_PRIVATE QuicBufferAllocator { | 787 class NET_EXPORT_PRIVATE QuicBufferAllocator { |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 bool has_ack, | 1358 bool has_ack, |
| 1351 bool has_stop_waiting); | 1359 bool has_stop_waiting); |
| 1352 SerializedPacket(const SerializedPacket& other); | 1360 SerializedPacket(const SerializedPacket& other); |
| 1353 ~SerializedPacket(); | 1361 ~SerializedPacket(); |
| 1354 | 1362 |
| 1355 // Not owned. | 1363 // Not owned. |
| 1356 const char* encrypted_buffer; | 1364 const char* encrypted_buffer; |
| 1357 QuicPacketLength encrypted_length; | 1365 QuicPacketLength encrypted_length; |
| 1358 QuicFrames retransmittable_frames; | 1366 QuicFrames retransmittable_frames; |
| 1359 IsHandshake has_crypto_handshake; | 1367 IsHandshake has_crypto_handshake; |
| 1360 bool needs_padding; | 1368 // -1: full padding to the end of a max-sized packet |
| 1369 // 0: no padding |
| 1370 // otherwise: only pad up to num_padding_bytes bytes |
| 1371 int num_padding_bytes; |
| 1361 QuicPathId path_id; | 1372 QuicPathId path_id; |
| 1362 QuicPacketNumber packet_number; | 1373 QuicPacketNumber packet_number; |
| 1363 QuicPacketNumberLength packet_number_length; | 1374 QuicPacketNumberLength packet_number_length; |
| 1364 EncryptionLevel encryption_level; | 1375 EncryptionLevel encryption_level; |
| 1365 QuicPacketEntropyHash entropy_hash; | 1376 QuicPacketEntropyHash entropy_hash; |
| 1366 bool has_ack; | 1377 bool has_ack; |
| 1367 bool has_stop_waiting; | 1378 bool has_stop_waiting; |
| 1368 QuicPacketNumber original_packet_number; | 1379 QuicPacketNumber original_packet_number; |
| 1369 TransmissionType transmission_type; | 1380 TransmissionType transmission_type; |
| 1370 | 1381 |
| 1371 // Optional notifiers which will be informed when this packet has been ACKed. | 1382 // Optional notifiers which will be informed when this packet has been ACKed. |
| 1372 std::list<AckListenerWrapper> listeners; | 1383 std::list<AckListenerWrapper> listeners; |
| 1373 }; | 1384 }; |
| 1374 | 1385 |
| 1375 struct NET_EXPORT_PRIVATE TransmissionInfo { | 1386 struct NET_EXPORT_PRIVATE TransmissionInfo { |
| 1376 // Used by STL when assigning into a map. | 1387 // Used by STL when assigning into a map. |
| 1377 TransmissionInfo(); | 1388 TransmissionInfo(); |
| 1378 | 1389 |
| 1379 // Constructs a Transmission with a new all_transmissions set | 1390 // Constructs a Transmission with a new all_transmissions set |
| 1380 // containing |packet_number|. | 1391 // containing |packet_number|. |
| 1381 TransmissionInfo(EncryptionLevel level, | 1392 TransmissionInfo(EncryptionLevel level, |
| 1382 QuicPacketNumberLength packet_number_length, | 1393 QuicPacketNumberLength packet_number_length, |
| 1383 TransmissionType transmission_type, | 1394 TransmissionType transmission_type, |
| 1384 QuicTime sent_time, | 1395 QuicTime sent_time, |
| 1385 QuicPacketLength bytes_sent, | 1396 QuicPacketLength bytes_sent, |
| 1386 bool has_crypto_handshake, | 1397 bool has_crypto_handshake, |
| 1387 bool needs_padding); | 1398 int num_padding_bytes); |
| 1388 | 1399 |
| 1389 TransmissionInfo(const TransmissionInfo& other); | 1400 TransmissionInfo(const TransmissionInfo& other); |
| 1390 | 1401 |
| 1391 ~TransmissionInfo(); | 1402 ~TransmissionInfo(); |
| 1392 | 1403 |
| 1393 QuicFrames retransmittable_frames; | 1404 QuicFrames retransmittable_frames; |
| 1394 EncryptionLevel encryption_level; | 1405 EncryptionLevel encryption_level; |
| 1395 QuicPacketNumberLength packet_number_length; | 1406 QuicPacketNumberLength packet_number_length; |
| 1396 QuicPacketLength bytes_sent; | 1407 QuicPacketLength bytes_sent; |
| 1397 uint16_t nack_count; | 1408 uint16_t nack_count; |
| 1398 QuicTime sent_time; | 1409 QuicTime sent_time; |
| 1399 // Reason why this packet was transmitted. | 1410 // Reason why this packet was transmitted. |
| 1400 TransmissionType transmission_type; | 1411 TransmissionType transmission_type; |
| 1401 // In flight packets have not been abandoned or lost. | 1412 // In flight packets have not been abandoned or lost. |
| 1402 bool in_flight; | 1413 bool in_flight; |
| 1403 // True if the packet can never be acked, so it can be removed. | 1414 // True if the packet can never be acked, so it can be removed. |
| 1404 bool is_unackable; | 1415 bool is_unackable; |
| 1405 // True if the packet contains stream data from the crypto stream. | 1416 // True if the packet contains stream data from the crypto stream. |
| 1406 bool has_crypto_handshake; | 1417 bool has_crypto_handshake; |
| 1407 // True if the packet needs padding if it's retransmitted. | 1418 // Non-zero if the packet needs padding if it's retransmitted. |
| 1408 bool needs_padding; | 1419 int num_padding_bytes; |
| 1409 // Stores the packet number of the next retransmission of this packet. | 1420 // Stores the packet number of the next retransmission of this packet. |
| 1410 // Zero if the packet has not been retransmitted. | 1421 // Zero if the packet has not been retransmitted. |
| 1411 QuicPacketNumber retransmission; | 1422 QuicPacketNumber retransmission; |
| 1412 // Non-empty if there is a listener for this packet. | 1423 // Non-empty if there is a listener for this packet. |
| 1413 std::list<AckListenerWrapper> ack_listeners; | 1424 std::list<AckListenerWrapper> ack_listeners; |
| 1414 }; | 1425 }; |
| 1415 | 1426 |
| 1416 // Struct to store the pending retransmission information. | 1427 // Struct to store the pending retransmission information. |
| 1417 struct PendingRetransmission { | 1428 struct PendingRetransmission { |
| 1418 PendingRetransmission(QuicPathId path_id, | 1429 PendingRetransmission(QuicPathId path_id, |
| 1419 QuicPacketNumber packet_number, | 1430 QuicPacketNumber packet_number, |
| 1420 TransmissionType transmission_type, | 1431 TransmissionType transmission_type, |
| 1421 const QuicFrames& retransmittable_frames, | 1432 const QuicFrames& retransmittable_frames, |
| 1422 bool has_crypto_handshake, | 1433 bool has_crypto_handshake, |
| 1423 bool needs_padding, | 1434 int num_padding_bytes, |
| 1424 EncryptionLevel encryption_level, | 1435 EncryptionLevel encryption_level, |
| 1425 QuicPacketNumberLength packet_number_length) | 1436 QuicPacketNumberLength packet_number_length) |
| 1426 : packet_number(packet_number), | 1437 : packet_number(packet_number), |
| 1427 retransmittable_frames(retransmittable_frames), | 1438 retransmittable_frames(retransmittable_frames), |
| 1428 transmission_type(transmission_type), | 1439 transmission_type(transmission_type), |
| 1429 path_id(path_id), | 1440 path_id(path_id), |
| 1430 has_crypto_handshake(has_crypto_handshake), | 1441 has_crypto_handshake(has_crypto_handshake), |
| 1431 needs_padding(needs_padding), | 1442 num_padding_bytes(num_padding_bytes), |
| 1432 encryption_level(encryption_level), | 1443 encryption_level(encryption_level), |
| 1433 packet_number_length(packet_number_length) {} | 1444 packet_number_length(packet_number_length) {} |
| 1434 | 1445 |
| 1435 QuicPacketNumber packet_number; | 1446 QuicPacketNumber packet_number; |
| 1436 const QuicFrames& retransmittable_frames; | 1447 const QuicFrames& retransmittable_frames; |
| 1437 TransmissionType transmission_type; | 1448 TransmissionType transmission_type; |
| 1438 QuicPathId path_id; | 1449 QuicPathId path_id; |
| 1439 bool has_crypto_handshake; | 1450 bool has_crypto_handshake; |
| 1440 bool needs_padding; | 1451 int num_padding_bytes; |
| 1441 EncryptionLevel encryption_level; | 1452 EncryptionLevel encryption_level; |
| 1442 QuicPacketNumberLength packet_number_length; | 1453 QuicPacketNumberLength packet_number_length; |
| 1443 }; | 1454 }; |
| 1444 | 1455 |
| 1445 // Convenience wrapper to wrap an iovec array and the total length, which must | 1456 // Convenience wrapper to wrap an iovec array and the total length, which must |
| 1446 // be less than or equal to the actual total length of the iovecs. | 1457 // be less than or equal to the actual total length of the iovecs. |
| 1447 struct NET_EXPORT_PRIVATE QuicIOVector { | 1458 struct NET_EXPORT_PRIVATE QuicIOVector { |
| 1448 QuicIOVector(const struct iovec* iov, int iov_count, size_t total_length) | 1459 QuicIOVector(const struct iovec* iov, int iov_count, size_t total_length) |
| 1449 : iov(iov), iov_count(iov_count), total_length(total_length) {} | 1460 : iov(iov), iov_count(iov_count), total_length(total_length) {} |
| 1450 | 1461 |
| 1451 const struct iovec* iov; | 1462 const struct iovec* iov; |
| 1452 const int iov_count; | 1463 const int iov_count; |
| 1453 const size_t total_length; | 1464 const size_t total_length; |
| 1454 }; | 1465 }; |
| 1455 | 1466 |
| 1456 } // namespace net | 1467 } // namespace net |
| 1457 | 1468 |
| 1458 #endif // NET_QUIC_QUIC_PROTOCOL_H_ | 1469 #endif // NET_QUIC_QUIC_PROTOCOL_H_ |
| OLD | NEW |