diff options
author | Mauro <you@example.com> | 2021-06-30 07:57:22 +0000 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2021-07-06 16:16:04 +0000 |
commit | 08233d44a6cfde878d7e10bca38ae935ed1c8fd5 (patch) | |
tree | 7ecc534d55bdc7e8dd15ecab084720910bcdf4d9 /libtransport/includes/hicn/transport/core | |
parent | 147ba39bed26887f5eba84757e2463ab8e370a9a (diff) |
[HICN-713] Transport Library Major Refactoring 2
Co-authored-by: Luca Muscariello <muscariello@ieee.org>
Co-authored-by: Michele Papalini <micpapal@cisco.com>
Co-authored-by: Olivier Roques <oroques+fdio@cisco.com>
Co-authored-by: Giulio Grassi <gigrassi@cisco.com>
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Change-Id: I5b2c667bad66feb45abdb5effe22ed0f6c85d1c2
Diffstat (limited to 'libtransport/includes/hicn/transport/core')
9 files changed, 87 insertions, 30 deletions
diff --git a/libtransport/includes/hicn/transport/core/CMakeLists.txt b/libtransport/includes/hicn/transport/core/CMakeLists.txt index 2553b7dcd..14c795a7a 100644 --- a/libtransport/includes/hicn/transport/core/CMakeLists.txt +++ b/libtransport/includes/hicn/transport/core/CMakeLists.txt @@ -11,9 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 3.5 FATAL_ERROR) - list(APPEND HEADER_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/asio_wrapper.h ${CMAKE_CURRENT_SOURCE_DIR}/content_object.h ${CMAKE_CURRENT_SOURCE_DIR}/interest.h ${CMAKE_CURRENT_SOURCE_DIR}/name.h diff --git a/libtransport/includes/hicn/transport/core/asio_wrapper.h b/libtransport/includes/hicn/transport/core/asio_wrapper.h new file mode 100644 index 000000000..78cad35dc --- /dev/null +++ b/libtransport/includes/hicn/transport/core/asio_wrapper.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include <hicn/transport/portability/portability.h> + +TRANSPORT_PUSH_WARNING +TRANSPORT_CLANG_DISABLE_WARNING("-Wdeprecated-declarations") + +#ifndef ASIO_STANDALONE +#define ASIO_STANDALONE +#endif +#include <asio.hpp> + +TRANSPORT_POP_WARNING diff --git a/libtransport/includes/hicn/transport/core/connector_stats.h b/libtransport/includes/hicn/transport/core/connector_stats.h index 1985331e9..fff370d02 100644 --- a/libtransport/includes/hicn/transport/core/connector_stats.h +++ b/libtransport/includes/hicn/transport/core/connector_stats.h @@ -1,5 +1,16 @@ /* - * Copyright (c) 2019 Cisco and/or its affiliates. + * Copyright (c) 2021 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #pragma once diff --git a/libtransport/includes/hicn/transport/core/content_object.h b/libtransport/includes/hicn/transport/core/content_object.h index 805bc814c..38baafc69 100644 --- a/libtransport/includes/hicn/transport/core/content_object.h +++ b/libtransport/includes/hicn/transport/core/content_object.h @@ -42,7 +42,7 @@ class ContentObject : public Packet { std::size_t payload_size); template <typename... Args> - ContentObject(CopyBufferOp op, Args &&...args) + ContentObject(CopyBufferOp op, Args &&... args) : Packet(op, std::forward<Args>(args)...) { if (hicn_data_get_name(format_, packet_start_, name_.getStructReference()) < 0) { @@ -51,7 +51,7 @@ class ContentObject : public Packet { } template <typename... Args> - ContentObject(WrapBufferOp op, Args &&...args) + ContentObject(WrapBufferOp op, Args &&... args) : Packet(op, std::forward<Args>(args)...) { if (hicn_data_get_name(format_, packet_start_, name_.getStructReference()) < 0) { @@ -60,7 +60,7 @@ class ContentObject : public Packet { } template <typename... Args> - ContentObject(CreateOp op, Args &&...args) + ContentObject(CreateOp op, Args &&... args) : Packet(op, std::forward<Args>(args)...) { if (hicn_data_get_name(format_, packet_start_, name_.getStructReference()) < 0) { @@ -82,8 +82,6 @@ class ContentObject : public Packet { void setName(const Name &name) override; - void setName(Name &&name) override; - uint32_t getPathLabel() const; ContentObject &setPathLabel(uint32_t path_label); diff --git a/libtransport/includes/hicn/transport/core/endpoint.h b/libtransport/includes/hicn/transport/core/endpoint.h index 4a19744a7..cb6b0f562 100644 --- a/libtransport/includes/hicn/transport/core/endpoint.h +++ b/libtransport/includes/hicn/transport/core/endpoint.h @@ -15,10 +15,7 @@ #pragma once -#ifndef ASIO_STANDALONE -#define ASIO_STANDALONE -#endif -#include <asio.hpp> +#include <hicn/transport/core/asio_wrapper.h> namespace transport { diff --git a/libtransport/includes/hicn/transport/core/global_object_pool.h b/libtransport/includes/hicn/transport/core/global_object_pool.h index e0b6e373f..d7f3a9e41 100644 --- a/libtransport/includes/hicn/transport/core/global_object_pool.h +++ b/libtransport/includes/hicn/transport/core/global_object_pool.h @@ -71,7 +71,7 @@ class PacketManager template < typename PacketType, typename... Args, typename = std::enable_if_t<std::is_base_of<Packet, PacketType>::value>> - typename PacketType::Ptr getPacket(Args &&...args) { + typename PacketType::Ptr getPacket(Args &&... args) { PacketType *memory = nullptr; memory = reinterpret_cast<PacketType *>(memory_pool_.allocateBlock()); @@ -98,7 +98,7 @@ class PacketManager template <typename PacketType, typename... Args> typename PacketType::Ptr getPacketFromExistingBuffer(uint8_t *buffer, std::size_t length, - Args &&...args) { + Args &&... args) { auto offset = offsetof(PacketStorage, align); auto memory = reinterpret_cast<PacketType *>(buffer - offset); utils::STLAllocator<PacketType, MemoryPool> allocator(memory, diff --git a/libtransport/includes/hicn/transport/core/interest.h b/libtransport/includes/hicn/transport/core/interest.h index b41b0c94a..a5b9cf375 100644 --- a/libtransport/includes/hicn/transport/core/interest.h +++ b/libtransport/includes/hicn/transport/core/interest.h @@ -25,6 +25,8 @@ namespace transport { namespace core { +const uint32_t MAX_AGGREGATED_INTEREST = 128; + class Interest : public Packet /*, public std::enable_shared_from_this<Interest>*/ { private: @@ -47,7 +49,7 @@ class Interest Interest(MemBuf &&buffer); template <typename... Args> - Interest(CopyBufferOp op, Args &&...args) + Interest(CopyBufferOp op, Args &&... args) : Packet(op, std::forward<Args>(args)...) { if (hicn_interest_get_name(format_, packet_start_, name_.getStructReference()) < 0) { @@ -56,7 +58,7 @@ class Interest } template <typename... Args> - Interest(WrapBufferOp op, Args &&...args) + Interest(WrapBufferOp op, Args &&... args) : Packet(op, std::forward<Args>(args)...) { if (hicn_interest_get_name(format_, packet_start_, name_.getStructReference()) < 0) { @@ -65,7 +67,7 @@ class Interest } template <typename... Args> - Interest(CreateOp op, Args &&...args) + Interest(CreateOp op, Args &&... args) : Packet(op, std::forward<Args>(args)...) {} /* Move constructor */ @@ -85,8 +87,6 @@ class Interest void setName(const Name &name) override; - void setName(Name &&name) override; - void setLocator(const ip_address_t &ip_address) override; ip_address_t getLocator() const override; diff --git a/libtransport/includes/hicn/transport/core/io_module.h b/libtransport/includes/hicn/transport/core/io_module.h index d4c3bb03a..ea3cf4e16 100644 --- a/libtransport/includes/hicn/transport/core/io_module.h +++ b/libtransport/includes/hicn/transport/core/io_module.h @@ -15,6 +15,7 @@ #pragma once +#include <hicn/transport/core/asio_wrapper.h> #include <hicn/transport/core/connector.h> #include <hicn/transport/core/packet.h> #include <hicn/transport/core/prefix.h> @@ -24,11 +25,6 @@ #include <deque> -#ifndef ASIO_STANDALONE -#define ASIO_STANDALONE -#endif -#include <asio/io_service.hpp> - namespace transport { namespace core { diff --git a/libtransport/includes/hicn/transport/core/packet.h b/libtransport/includes/hicn/transport/core/packet.h index 68daea841..269a1571a 100644 --- a/libtransport/includes/hicn/transport/core/packet.h +++ b/libtransport/includes/hicn/transport/core/packet.h @@ -15,19 +15,28 @@ #pragma once +#include <hicn/transport/auth/crypto_hash.h> +#include <hicn/transport/auth/crypto_suite.h> +#include <hicn/transport/auth/key_id.h> #include <hicn/transport/core/name.h> #include <hicn/transport/core/payload_type.h> #include <hicn/transport/errors/malformed_packet_exception.h> #include <hicn/transport/portability/portability.h> -#include <hicn/transport/auth/crypto_hasher.h> -#include <hicn/transport/auth/crypto_suite.h> -#include <hicn/transport/auth/key_id.h> #include <hicn/transport/utils/branch_prediction.h> -#include <hicn/transport/utils/log.h> #include <hicn/transport/utils/membuf.h> #include <hicn/transport/utils/object_pool.h> namespace transport { + +namespace auth { +class Signer; +class AsymmetricSigner; +class SymmetricSigner; +class Verifier; +class AsymmetricVerifier; +class SymmetricVerifier; +} // namespace auth + namespace core { /* @@ -42,7 +51,11 @@ namespace core { class Packet : public utils::MemBuf, public std::enable_shared_from_this<Packet> { friend class auth::Signer; + friend class auth::SymmetricSigner; + friend class auth::AsymmetricSigner; friend class auth::Verifier; + friend class auth::AsymmetricVerifier; + friend class auth::SymmetricVerifier; public: using Ptr = std::shared_ptr<Packet>; @@ -135,8 +148,6 @@ class Packet : public utils::MemBuf, virtual void setName(const Name &name) = 0; - virtual void setName(Name &&name) = 0; - virtual void setLifetime(uint32_t lifetime) = 0; virtual uint32_t getLifetime() const = 0; @@ -223,6 +234,7 @@ class Packet : public utils::MemBuf, private: virtual void resetForHash() = 0; void setSignatureSize(std::size_t size_bytes); + void setSignatureSizeGap(std::size_t size_bytes); void prependPayload(const uint8_t **buffer, std::size_t *size); bool authenticationHeader() const { return _is_ah(format_); } @@ -239,6 +251,22 @@ class Packet : public utils::MemBuf, return size_bytes; } + std::size_t getSignatureSizeGap() const { + uint8_t size_bytes; + int ret = + hicn_packet_get_signature_gap(format_, packet_start_, &size_bytes); + + if (ret < 0) { + throw errors::RuntimeException("Packet without Authentication Header."); + } + + return (size_t)size_bytes; + } + + std::size_t getSignatureSizeReal() const { + return getSignatureSize() - getSignatureSizeGap(); + } + uint8_t *getSignature() const; protected: |