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 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 }; | 1257 }; |
1258 // QuicFrameType consumes 8 bytes with padding. | 1258 // QuicFrameType consumes 8 bytes with padding. |
1259 static_assert(sizeof(QuicFrame) <= 16, | 1259 static_assert(sizeof(QuicFrame) <= 16, |
1260 "Frames larger than 8 bytes should be referenced by pointer."); | 1260 "Frames larger than 8 bytes should be referenced by pointer."); |
1261 | 1261 |
1262 typedef std::vector<QuicFrame> QuicFrames; | 1262 typedef std::vector<QuicFrame> QuicFrames; |
1263 | 1263 |
1264 class NET_EXPORT_PRIVATE QuicData { | 1264 class NET_EXPORT_PRIVATE QuicData { |
1265 public: | 1265 public: |
1266 QuicData(const char* buffer, size_t length); | 1266 QuicData(const char* buffer, size_t length); |
1267 QuicData(char* buffer, size_t length, bool owns_buffer); | 1267 QuicData(const char* buffer, size_t length, bool owns_buffer); |
1268 virtual ~QuicData(); | 1268 virtual ~QuicData(); |
1269 | 1269 |
1270 base::StringPiece AsStringPiece() const { | 1270 base::StringPiece AsStringPiece() const { |
1271 return base::StringPiece(data(), length()); | 1271 return base::StringPiece(data(), length()); |
1272 } | 1272 } |
1273 | 1273 |
1274 const char* data() const { return buffer_; } | 1274 const char* data() const { return buffer_; } |
1275 size_t length() const { return length_; } | 1275 size_t length() const { return length_; } |
1276 bool owns_buffer() const { return owns_buffer_; } | 1276 bool owns_buffer() const { return owns_buffer_; } |
1277 | 1277 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 const bool includes_path_id_; | 1309 const bool includes_path_id_; |
1310 const bool includes_diversification_nonce_; | 1310 const bool includes_diversification_nonce_; |
1311 const QuicPacketNumberLength packet_number_length_; | 1311 const QuicPacketNumberLength packet_number_length_; |
1312 | 1312 |
1313 DISALLOW_COPY_AND_ASSIGN(QuicPacket); | 1313 DISALLOW_COPY_AND_ASSIGN(QuicPacket); |
1314 }; | 1314 }; |
1315 | 1315 |
1316 class NET_EXPORT_PRIVATE QuicEncryptedPacket : public QuicData { | 1316 class NET_EXPORT_PRIVATE QuicEncryptedPacket : public QuicData { |
1317 public: | 1317 public: |
1318 QuicEncryptedPacket(const char* buffer, size_t length); | 1318 QuicEncryptedPacket(const char* buffer, size_t length); |
1319 QuicEncryptedPacket(char* buffer, size_t length, bool owns_buffer); | 1319 QuicEncryptedPacket(const char* buffer, size_t length, bool owns_buffer); |
1320 | 1320 |
1321 // Clones the packet into a new packet which owns the buffer. | 1321 // Clones the packet into a new packet which owns the buffer. |
1322 QuicEncryptedPacket* Clone() const; | 1322 QuicEncryptedPacket* Clone() const; |
1323 | 1323 |
1324 // By default, gtest prints the raw bytes of an object. The bool data | 1324 // By default, gtest prints the raw bytes of an object. The bool data |
1325 // member (in the base class QuicData) causes this object to have padding | 1325 // member (in the base class QuicData) causes this object to have padding |
1326 // bytes, which causes the default gtest object printer to read | 1326 // bytes, which causes the default gtest object printer to read |
1327 // uninitialize memory. So we need to teach gtest how to print this object. | 1327 // uninitialize memory. So we need to teach gtest how to print this object. |
1328 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 1328 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
1329 std::ostream& os, | 1329 std::ostream& os, |
1330 const QuicEncryptedPacket& s); | 1330 const QuicEncryptedPacket& s); |
1331 | 1331 |
1332 private: | 1332 private: |
1333 DISALLOW_COPY_AND_ASSIGN(QuicEncryptedPacket); | 1333 DISALLOW_COPY_AND_ASSIGN(QuicEncryptedPacket); |
1334 }; | 1334 }; |
1335 | 1335 |
1336 // A received encrypted QUIC packet, with a recorded time of receipt. | 1336 // A received encrypted QUIC packet, with a recorded time of receipt. |
1337 class NET_EXPORT_PRIVATE QuicReceivedPacket : public QuicEncryptedPacket { | 1337 class NET_EXPORT_PRIVATE QuicReceivedPacket : public QuicEncryptedPacket { |
1338 public: | 1338 public: |
1339 QuicReceivedPacket(const char* buffer, size_t length, QuicTime receipt_time); | 1339 QuicReceivedPacket(const char* buffer, size_t length, QuicTime receipt_time); |
1340 QuicReceivedPacket(char* buffer, | 1340 QuicReceivedPacket(const char* buffer, |
1341 size_t length, | 1341 size_t length, |
1342 QuicTime receipt_time, | 1342 QuicTime receipt_time, |
1343 bool owns_buffer); | 1343 bool owns_buffer); |
| 1344 QuicReceivedPacket(const char* buffer, |
| 1345 size_t length, |
| 1346 QuicTime receipt_time, |
| 1347 bool owns_buffer, |
| 1348 int ttl, |
| 1349 bool ttl_valid); |
1344 | 1350 |
1345 // Clones the packet into a new packet which owns the buffer. | 1351 // Clones the packet into a new packet which owns the buffer. |
1346 QuicReceivedPacket* Clone() const; | 1352 QuicReceivedPacket* Clone() const; |
1347 | 1353 |
1348 // Returns the time at which the packet was received. | 1354 // Returns the time at which the packet was received. |
1349 QuicTime receipt_time() const { return receipt_time_; } | 1355 QuicTime receipt_time() const { return receipt_time_; } |
1350 | 1356 |
| 1357 // This is the TTL of the packet, assuming ttl_vaild_ is true. |
| 1358 int ttl() const { return ttl_; } |
| 1359 |
1351 // By default, gtest prints the raw bytes of an object. The bool data | 1360 // By default, gtest prints the raw bytes of an object. The bool data |
1352 // member (in the base class QuicData) causes this object to have padding | 1361 // member (in the base class QuicData) causes this object to have padding |
1353 // bytes, which causes the default gtest object printer to read | 1362 // bytes, which causes the default gtest object printer to read |
1354 // uninitialize memory. So we need to teach gtest how to print this object. | 1363 // uninitialize memory. So we need to teach gtest how to print this object. |
1355 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 1364 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
1356 std::ostream& os, | 1365 std::ostream& os, |
1357 const QuicReceivedPacket& s); | 1366 const QuicReceivedPacket& s); |
1358 | 1367 |
1359 private: | 1368 private: |
1360 const QuicTime receipt_time_; | 1369 const QuicTime receipt_time_; |
| 1370 int ttl_; |
1361 | 1371 |
1362 DISALLOW_COPY_AND_ASSIGN(QuicReceivedPacket); | 1372 DISALLOW_COPY_AND_ASSIGN(QuicReceivedPacket); |
1363 }; | 1373 }; |
1364 | 1374 |
1365 // Pure virtual class to listen for packet acknowledgements. | 1375 // Pure virtual class to listen for packet acknowledgements. |
1366 class NET_EXPORT_PRIVATE QuicAckListenerInterface | 1376 class NET_EXPORT_PRIVATE QuicAckListenerInterface |
1367 : public base::RefCounted<QuicAckListenerInterface> { | 1377 : public base::RefCounted<QuicAckListenerInterface> { |
1368 public: | 1378 public: |
1369 QuicAckListenerInterface() {} | 1379 QuicAckListenerInterface() {} |
1370 | 1380 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 : iov(iov), iov_count(iov_count), total_length(total_length) {} | 1550 : iov(iov), iov_count(iov_count), total_length(total_length) {} |
1541 | 1551 |
1542 const struct iovec* iov; | 1552 const struct iovec* iov; |
1543 const int iov_count; | 1553 const int iov_count; |
1544 const size_t total_length; | 1554 const size_t total_length; |
1545 }; | 1555 }; |
1546 | 1556 |
1547 } // namespace net | 1557 } // namespace net |
1548 | 1558 |
1549 #endif // NET_QUIC_QUIC_PROTOCOL_H_ | 1559 #endif // NET_QUIC_QUIC_PROTOCOL_H_ |
OLD | NEW |