From afe807c61372fe2481e73af63c8382af1e1d3011 Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Wed, 4 Mar 2020 16:21:54 +0100 Subject: [HICN-540] Optimizations for libhicntransport Change-Id: I8b46b4eb2ef5488c09041887cc8296a216440f33 Signed-off-by: Mauro Sardara --- libtransport/src/core/packet.cc | 54 ----------------------------------------- 1 file changed, 54 deletions(-) (limited to 'libtransport/src/core/packet.cc') diff --git a/libtransport/src/core/packet.cc b/libtransport/src/core/packet.cc index 67e647fca..6815868f0 100644 --- a/libtransport/src/core/packet.cc +++ b/libtransport/src/core/packet.cc @@ -69,14 +69,6 @@ Packet::Packet(Packet &&other) Packet::~Packet() {} -std::size_t Packet::getHeaderSizeFromFormat(Format format, - size_t signature_size) { - std::size_t header_length; - hicn_packet_get_header_length_from_format(format, &header_length); - int is_ah = _is_ah(format); - return is_ah * (header_length + signature_size) + (!is_ah) * header_length; -} - std::size_t Packet::getHeaderSizeFromBuffer(Format format, const uint8_t *buffer) { size_t header_length; @@ -99,17 +91,6 @@ bool Packet::isInterest(const uint8_t *buffer) { return !is_interest; } -Packet::Format Packet::getFormatFromBuffer(const uint8_t *buffer) { - Format format = HF_UNSPEC; - - if (TRANSPORT_EXPECT_FALSE( - hicn_packet_get_format((const hicn_header_t *)buffer, &format) < 0)) { - throw errors::MalformedPacketException(); - } - - return format; -} - std::size_t Packet::getPayloadSizeFromBuffer(Format format, const uint8_t *buffer) { std::size_t payload_length; @@ -122,14 +103,6 @@ std::size_t Packet::getPayloadSizeFromBuffer(Format format, return payload_length; } -void Packet::replace(MemBufPtr &&buffer) { - packet_ = std::move(buffer); - packet_start_ = reinterpret_cast(packet_->writableData()); - header_head_ = packet_.get(); - payload_head_ = nullptr; - format_ = getFormatFromBuffer(reinterpret_cast(packet_start_)); -} - std::size_t Packet::payloadSize() const { return getPayloadSizeFromBuffer(format_, reinterpret_cast(packet_start_)); @@ -270,17 +243,6 @@ uint8_t *Packet::getSignature() const { return signature; } -std::size_t Packet::getSignatureSize() const { - size_t size_bytes; - int ret = hicn_packet_get_signature_size(format_, packet_start_, &size_bytes); - - if (ret < 0) { - throw errors::RuntimeException("Packet without Authentication Header."); - } - - return size_bytes; -} - void Packet::setSignatureTimestamp(const uint64_t ×tamp) { int ret = hicn_packet_set_signature_timestamp(format_, packet_start_, timestamp); @@ -366,22 +328,6 @@ utils::CryptoHash Packet::computeDigest(utils::CryptoHashType algorithm) const { return hasher.finalize(); } -void Packet::setChecksum() { - uint16_t partial_csum = 0; - - for (utils::MemBuf *current = header_head_->next(); - current && current != header_head_; current = current->next()) { - if (partial_csum != 0) { - partial_csum = ~partial_csum; - } - partial_csum = csum(current->data(), current->length(), partial_csum); - } - if (hicn_packet_compute_header_checksum(format_, packet_start_, - partial_csum) < 0) { - throw errors::MalformedPacketException(); - } -} - bool Packet::checkIntegrity() const { if (hicn_packet_check_integrity(format_, packet_start_) < 0) { return false; -- cgit 1.2.3-korg