You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2017/11/28 05:22:48 UTC

[trafficserver] 02/02: Rename QUICPacketHeader::length() to size()

This is an automated email from the ASF dual-hosted git repository.

maskit pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 668757f0ac9f291323fd05d086dc9e54abcbe34a
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Tue Nov 28 14:22:14 2017 +0900

    Rename QUICPacketHeader::length() to size()
---
 iocore/net/quic/QUICPacket.cc           | 28 ++++++++++++++--------------
 iocore/net/quic/QUICPacket.h            |  6 +++---
 iocore/net/quic/test/test_QUICPacket.cc |  4 ++--
 3 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/iocore/net/quic/QUICPacket.cc b/iocore/net/quic/QUICPacket.cc
index b2a0792..651e563 100644
--- a/iocore/net/quic/QUICPacket.cc
+++ b/iocore/net/quic/QUICPacket.cc
@@ -197,7 +197,7 @@ uint16_t
 QUICPacketHeader::payload_size() const
 {
   if (this->_buf) {
-    return this->_buf_len - this->length();
+    return this->_buf_len - this->size();
   } else {
     return this->_payload_len;
   }
@@ -217,7 +217,7 @@ QUICPacketLongHeader::key_phase() const
 }
 
 uint16_t
-QUICPacketLongHeader::length() const
+QUICPacketLongHeader::size() const
 {
   return LONGHEADER_LENGTH;
 }
@@ -399,7 +399,7 @@ const uint8_t *
 QUICPacketShortHeader::payload() const
 {
   if (this->_buf) {
-    return this->_buf + length();
+    return this->_buf + this->size();
   } else {
     return this->_payload.get();
   }
@@ -429,7 +429,7 @@ QUICPacketShortHeader::key_phase() const
  * Header Length (doesn't include payload length)
  */
 uint16_t
-QUICPacketShortHeader::length() const
+QUICPacketShortHeader::size() const
 {
   uint16_t len = 1;
 
@@ -570,7 +570,7 @@ QUICPacket::size() const
 uint16_t
 QUICPacket::header_size() const
 {
-  return this->_header->length();
+  return this->_header->size();
 }
 
 uint16_t
@@ -588,9 +588,9 @@ QUICPacket::key_phase() const
 void
 QUICPacket::store(uint8_t *buf, size_t *len) const
 {
-  memcpy(buf, this->_header->buf(), this->_header->length());
-  memcpy(buf + this->_header->length(), this->payload(), this->payload_size());
-  *len = this->_header->length() + this->payload_size();
+  memcpy(buf, this->_header->buf(), this->_header->size());
+  memcpy(buf + this->_header->size(), this->payload(), this->payload_size());
+  *len = this->_header->size() + this->payload_size();
 }
 
 uint8_t
@@ -666,7 +666,7 @@ QUICPacketFactory::create(ats_unique_buf buf, size_t len, QUICPacketNumber base_
   case QUICPacketType::ONE_RTT_PROTECTED_KEY_PHASE_1:
     if (this->_crypto->is_handshake_finished()) {
       if (this->_crypto->decrypt(plain_txt.get(), plain_txt_len, max_plain_txt_len, header->payload(), header->payload_size(),
-                                 header->packet_number(), header->buf(), header->length(), header->key_phase())) {
+                                 header->packet_number(), header->buf(), header->size(), header->key_phase())) {
         result = QUICPacketCreationResult::SUCCESS;
       } else {
         result = QUICPacketCreationResult::FAILED;
@@ -679,7 +679,7 @@ QUICPacketFactory::create(ats_unique_buf buf, size_t len, QUICPacketNumber base_
   case QUICPacketType::CLIENT_CLEARTEXT:
   case QUICPacketType::SERVER_CLEARTEXT:
     if (this->_crypto->decrypt(plain_txt.get(), plain_txt_len, max_plain_txt_len, header->payload(), header->payload_size(),
-                               header->packet_number(), header->buf(), header->length(), QUICKeyPhase::CLEARTEXT)) {
+                               header->packet_number(), header->buf(), header->size(), QUICKeyPhase::CLEARTEXT)) {
       result = QUICPacketCreationResult::SUCCESS;
     } else {
       result = QUICPacketCreationResult::FAILED;
@@ -721,7 +721,7 @@ QUICPacketFactory::create_version_negotiation_packet(const QUICPacket *packet_se
                                                      packet_sent_by_client->packet_number(), base_packet_number,
                                                      packet_sent_by_client->version(), std::move(versions), len);
   if (this->_crypto->encrypt(cipher_txt.get(), cipher_txt_len, max_cipher_txt_len, header->payload(), header->payload_size(),
-                             header->packet_number(), header->buf(), header->length(), header->key_phase())) {
+                             header->packet_number(), header->buf(), header->size(), header->key_phase())) {
     packet = quicPacketAllocator.alloc();
     new (packet) QUICPacket(header, std::move(cipher_txt), cipher_txt_len, false);
   }
@@ -743,7 +743,7 @@ QUICPacketFactory::create_server_cleartext_packet(QUICConnectionId connection_id
                             base_packet_number, this->_version, std::move(payload), len);
 
   if (this->_crypto->encrypt(cipher_txt.get(), cipher_txt_len, max_cipher_txt_len, header->payload(), header->payload_size(),
-                             header->packet_number(), header->buf(), header->length(), header->key_phase())) {
+                             header->packet_number(), header->buf(), header->size(), header->key_phase())) {
     packet = quicPacketAllocator.alloc();
     new (packet) QUICPacket(header, std::move(cipher_txt), cipher_txt_len, retransmittable);
   }
@@ -767,7 +767,7 @@ QUICPacketFactory::create_server_protected_packet(QUICConnectionId connection_id
                             base_packet_number, std::move(payload), len);
 
   if (this->_crypto->encrypt(cipher_txt.get(), cipher_txt_len, max_cipher_txt_len, header->payload(), header->payload_size(),
-                             header->packet_number(), header->buf(), header->length(), header->key_phase())) {
+                             header->packet_number(), header->buf(), header->size(), header->key_phase())) {
     packet = quicPacketAllocator.alloc();
     new (packet) QUICPacket(header, std::move(cipher_txt), cipher_txt_len, retransmittable);
   }
@@ -788,7 +788,7 @@ QUICPacketFactory::create_client_initial_packet(QUICConnectionId connection_id,
     QUICPacketHeader::build(QUICPacketType::CLIENT_INITIAL, connection_id, this->_packet_number_generator.next(),
                             base_packet_number, version, std::move(payload), len);
   if (this->_crypto->encrypt(cipher_txt.get(), cipher_txt_len, max_cipher_txt_len, header->payload(), header->payload_size(),
-                             header->packet_number(), header->buf(), header->length(), header->key_phase())) {
+                             header->packet_number(), header->buf(), header->size(), header->key_phase())) {
     packet = quicPacketAllocator.alloc();
     new (packet) QUICPacket(header, std::move(cipher_txt), cipher_txt_len, false);
   }
diff --git a/iocore/net/quic/QUICPacket.h b/iocore/net/quic/QUICPacket.h
index 308beb0..3b1f799 100644
--- a/iocore/net/quic/QUICPacket.h
+++ b/iocore/net/quic/QUICPacket.h
@@ -59,7 +59,7 @@ public:
   /*
    * Returns its header size
    */
-  virtual uint16_t length() const = 0;
+  virtual uint16_t size() const = 0;
 
   /*
    * Returns its packet size
@@ -155,7 +155,7 @@ public:
   bool has_connection_id() const;
   QUICKeyPhase key_phase() const;
   bool has_key_phase() const;
-  uint16_t length() const;
+  uint16_t size() const;
   void store(uint8_t *buf, size_t *len) const;
 };
 
@@ -177,7 +177,7 @@ public:
   bool has_connection_id() const;
   QUICKeyPhase key_phase() const;
   bool has_key_phase() const;
-  uint16_t length() const;
+  uint16_t size() const;
   void store(uint8_t *buf, size_t *len) const;
 
 private:
diff --git a/iocore/net/quic/test/test_QUICPacket.cc b/iocore/net/quic/test/test_QUICPacket.cc
index 1bb582f..e2d7863 100644
--- a/iocore/net/quic/test/test_QUICPacket.cc
+++ b/iocore/net/quic/test/test_QUICPacket.cc
@@ -38,7 +38,7 @@ TEST_CASE("QUICPacketHeader", "[quic]")
     };
 
     QUICPacketHeader *header = QUICPacketHeader::load(input, sizeof(input), 0);
-    CHECK(header->length() == 17);
+    CHECK(header->size() == 17);
     CHECK(header->packet_size() == 19);
     CHECK(header->type() == QUICPacketType::VERSION_NEGOTIATION);
     CHECK(header->connection_id() == 0x0102030405060708);
@@ -56,7 +56,7 @@ TEST_CASE("QUICPacketHeader", "[quic]")
     };
 
     QUICPacketHeader *header = QUICPacketHeader::load(input, sizeof(input), 0);
-    CHECK(header->length() == 13);
+    CHECK(header->size() == 13);
     CHECK(header->packet_size() == 15);
     CHECK(header->connection_id() == 0x0102030405060708);
     CHECK(header->packet_number() == 0x12345678);

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.