aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src/hicn/transport/utils
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2019-02-04 11:06:18 +0100
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-03-05 09:56:19 +0000
commit6d7704c1b497341fd6dd3c27e3f64d0db062ccc2 (patch)
tree668c6820653cd84da8474d330d2807a8765f96b5 /libtransport/src/hicn/transport/utils
parentca66305af16e2f8d8f271218ea71f132e6c21916 (diff)
[HICN-11] Rework on transport protocols improving components modularity
Change-Id: I6683ec5b494238dc93591c103d25275e89b9f267 Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'libtransport/src/hicn/transport/utils')
-rw-r--r--libtransport/src/hicn/transport/utils/CMakeLists.txt2
-rw-r--r--libtransport/src/hicn/transport/utils/array.h2
-rw-r--r--libtransport/src/hicn/transport/utils/chrono_typedefs.h (renamed from libtransport/src/hicn/transport/utils/sharable_vector.h)13
-rw-r--r--libtransport/src/hicn/transport/utils/content_store.cc28
-rw-r--r--libtransport/src/hicn/transport/utils/content_store.h4
-rw-r--r--libtransport/src/hicn/transport/utils/crypto_hash.h4
-rw-r--r--libtransport/src/hicn/transport/utils/endianess.h141
-rw-r--r--libtransport/src/hicn/transport/utils/event_thread.h2
-rw-r--r--libtransport/src/hicn/transport/utils/identity.h1
-rw-r--r--libtransport/src/hicn/transport/utils/signer.cc22
-rw-r--r--libtransport/src/hicn/transport/utils/socket.h267
-rw-r--r--libtransport/src/hicn/transport/utils/verifier.cc19
12 files changed, 36 insertions, 469 deletions
diff --git a/libtransport/src/hicn/transport/utils/CMakeLists.txt b/libtransport/src/hicn/transport/utils/CMakeLists.txt
index a5daf785e..c6b09fc5f 100644
--- a/libtransport/src/hicn/transport/utils/CMakeLists.txt
+++ b/libtransport/src/hicn/transport/utils/CMakeLists.txt
@@ -30,7 +30,6 @@ list(APPEND HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/string_tokenizer.h
${CMAKE_CURRENT_SOURCE_DIR}/hash.h
${CMAKE_CURRENT_SOURCE_DIR}/uri.h
- ${CMAKE_CURRENT_SOURCE_DIR}/sharable_vector.h
${CMAKE_CURRENT_SOURCE_DIR}/branch_prediction.h
${CMAKE_CURRENT_SOURCE_DIR}/event_reactor.h
${CMAKE_CURRENT_SOURCE_DIR}/deadline_timer.h
@@ -38,7 +37,6 @@ list(APPEND HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/event_reactor.h
${CMAKE_CURRENT_SOURCE_DIR}/min_filter.h
${CMAKE_CURRENT_SOURCE_DIR}/stream_buffer.h
- ${CMAKE_CURRENT_SOURCE_DIR}/endianess.h
${CMAKE_CURRENT_SOURCE_DIR}/literals.h
${CMAKE_CURRENT_SOURCE_DIR}/signer.h
${CMAKE_CURRENT_SOURCE_DIR}/verifier.h
diff --git a/libtransport/src/hicn/transport/utils/array.h b/libtransport/src/hicn/transport/utils/array.h
index a3a66e498..7c0ed65d8 100644
--- a/libtransport/src/hicn/transport/utils/array.h
+++ b/libtransport/src/hicn/transport/utils/array.h
@@ -21,7 +21,7 @@
namespace utils {
-template <typename T>
+template <typename T = uint8_t>
class Array {
public:
explicit Array(const T *array, size_t size) : array_(array), size_(size) {
diff --git a/libtransport/src/hicn/transport/utils/sharable_vector.h b/libtransport/src/hicn/transport/utils/chrono_typedefs.h
index 31adff1ad..8f28e763c 100644
--- a/libtransport/src/hicn/transport/utils/sharable_vector.h
+++ b/libtransport/src/hicn/transport/utils/chrono_typedefs.h
@@ -15,16 +15,13 @@
#pragma once
-#include <memory>
-#include <vector>
+#include <chrono>
namespace utils {
-template <class T>
-class SharableVector : public std::vector<T>,
- public std::enable_shared_from_this<SharableVector<T>> {
- public:
- virtual ~SharableVector(){};
-};
+using SteadyClock = std::chrono::steady_clock;
+using TimePoint = SteadyClock::time_point;
+using Milliseconds = std::chrono::milliseconds;
+using Microseconds = std::chrono::microseconds;
} // namespace utils
diff --git a/libtransport/src/hicn/transport/utils/content_store.cc b/libtransport/src/hicn/transport/utils/content_store.cc
index 4c7637dad..d48e16daf 100644
--- a/libtransport/src/hicn/transport/utils/content_store.cc
+++ b/libtransport/src/hicn/transport/utils/content_store.cc
@@ -34,29 +34,29 @@ void ContentStore::insert(
std::unique_lock<std::mutex> lock(cs_mutex_);
if (TRANSPORT_EXPECT_FALSE(content_store_hash_table_.size() !=
- lru_list_.size())) {
+ fifo_list_.size())) {
TRANSPORT_LOGW("Inconsistent size!!!!");
TRANSPORT_LOGW("Hash Table: %zu |||| FIFO List: %zu",
- content_store_hash_table_.size(), lru_list_.size());
+ content_store_hash_table_.size(), fifo_list_.size());
}
// Check if the content can be cached
if (content_object->getLifetime() > 0) {
if (content_store_hash_table_.size() >= max_content_store_size_) {
- content_store_hash_table_.erase(lru_list_.back());
- lru_list_.pop_back();
+ content_store_hash_table_.erase(fifo_list_.back());
+ fifo_list_.pop_back();
}
// Insert new item
auto it = content_store_hash_table_.find(content_object->getName());
if (it != content_store_hash_table_.end()) {
- lru_list_.erase(it->second.second);
+ fifo_list_.erase(it->second.second);
content_store_hash_table_.erase(content_object->getName());
}
- lru_list_.push_front(std::cref(content_object->getName()));
- auto pos = lru_list_.begin();
+ fifo_list_.push_front(std::cref(content_object->getName()));
+ auto pos = fifo_list_.begin();
content_store_hash_table_[content_object->getName()] = ContentStoreEntry(
ObjectTimeEntry(content_object, std::chrono::steady_clock::now()), pos);
}
@@ -67,13 +67,11 @@ const std::shared_ptr<ContentObject> &ContentStore::find(
std::unique_lock<std::mutex> lock(cs_mutex_);
auto it = content_store_hash_table_.find(interest.getName());
if (it != content_store_hash_table_.end()) {
- // if (std::chrono::duration_cast<std::chrono::milliseconds>(
- // std::chrono::steady_clock::now() - it->second.first.second).count()
- // < it->second.first.first->getLifetime() ||
- // it->second.first.first->getLifetime() ==
- // default_values::never_expire_time) {
- return it->second.first.first;
- // }
+ if (std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::steady_clock::now() - it->second.first.second)
+ .count() < it->second.first.first->getLifetime()) {
+ return it->second.first.first;
+ }
}
return empty_reference_;
@@ -82,7 +80,7 @@ const std::shared_ptr<ContentObject> &ContentStore::find(
void ContentStore::erase(const Name &exact_name) {
std::unique_lock<std::mutex> lock(cs_mutex_);
auto it = content_store_hash_table_.find(exact_name);
- lru_list_.erase(it->second.second);
+ fifo_list_.erase(it->second.second);
content_store_hash_table_.erase(exact_name);
}
diff --git a/libtransport/src/hicn/transport/utils/content_store.h b/libtransport/src/hicn/transport/utils/content_store.h
index ab4963fff..39e87fb7d 100644
--- a/libtransport/src/hicn/transport/utils/content_store.h
+++ b/libtransport/src/hicn/transport/utils/content_store.h
@@ -41,7 +41,7 @@ typedef std::pair<std::shared_ptr<ContentObject>,
typedef std::pair<ObjectTimeEntry,
std::list<std::reference_wrapper<const Name>>::iterator>
ContentStoreEntry;
-typedef std::list<std::reference_wrapper<const Name>> LRUList;
+typedef std::list<std::reference_wrapper<const Name>> FIFOList;
typedef std::unordered_map<Name, ContentStoreEntry> ContentStoreHashTable;
class ContentStore {
@@ -66,7 +66,7 @@ class ContentStore {
private:
ContentStoreHashTable content_store_hash_table_;
- LRUList lru_list_;
+ FIFOList fifo_list_;
std::shared_ptr<ContentObject> empty_reference_;
std::size_t max_content_store_size_;
std::mutex cs_mutex_;
diff --git a/libtransport/src/hicn/transport/utils/crypto_hash.h b/libtransport/src/hicn/transport/utils/crypto_hash.h
index 0c15c8bda..945909d14 100644
--- a/libtransport/src/hicn/transport/utils/crypto_hash.h
+++ b/libtransport/src/hicn/transport/utils/crypto_hash.h
@@ -108,6 +108,10 @@ class CryptoHash {
std::memcmp(digest1, digest2, hash_size_map[hash_type]));
}
+ TRANSPORT_ALWAYS_INLINE void display() {
+ parcBuffer_Display(parcCryptoHash_GetDigest(hash_), 2);
+ }
+
private:
PARCCryptoHash* hash_;
};
diff --git a/libtransport/src/hicn/transport/utils/endianess.h b/libtransport/src/hicn/transport/utils/endianess.h
deleted file mode 100644
index d86e764ab..000000000
--- a/libtransport/src/hicn/transport/utils/endianess.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2017-2019 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>
-
-#ifndef _WIN32
-#include <arpa/inet.h>
-#else
-#include <hicn/transport/portability/win_portability.h>
-#endif
-
-#include <cstring>
-
-namespace utils {
-
-namespace {
-
-template <size_t Size>
-struct uint_types_by_size;
-
-#define GENERATOR(sz, fn) \
- static TRANSPORT_ALWAYS_INLINE uint##sz##_t byteswap_gen(uint##sz##_t v) { \
- return fn(v); \
- } \
- template <> \
- struct uint_types_by_size<sz / 8> { \
- using type = uint##sz##_t; \
- };
-
-GENERATOR(8, uint8_t)
-#ifdef _MSC_VER
-GENERATOR(64, _byteswap_uint64)
-GENERATOR(32, _byteswap_ulong)
-GENERATOR(16, _byteswap_ushort)
-#else
-GENERATOR(64, __builtin_bswap64)
-GENERATOR(32, __builtin_bswap32)
-GENERATOR(16, __builtin_bswap16)
-#endif
-
-template <typename T>
-struct EndianInt {
- static_assert(
- (std::is_integral<T>::value && !std::is_same<T, bool>::value) ||
- std::is_floating_point<T>::value,
- "template type parameter must be non-bool integral or floating point");
-
- static T swap(T x) {
- // we implement this with memcpy because that is defined behavior in C++
- // we rely on compilers to optimize away the memcpy calls
- constexpr auto s = sizeof(T);
- using B = typename uint_types_by_size<s>::type;
- B b;
- std::memcpy(&b, &x, s);
- b = byteswap_gen(b);
- std::memcpy(&x, &b, s);
- return x;
- }
- static T big(T x) {
- return portability::little_endian_arch ? EndianInt::swap(x) : x;
- }
- static T little(T x) {
- return portability::big_endian_arch ? EndianInt::swap(x) : x;
- }
-};
-
-} // namespace
-
-// big* convert between native and big-endian representations
-// little* convert between native and little-endian representations
-// swap* convert between big-endian and little-endian representations
-//
-// ntohs, htons == big16
-// ntohl, htonl == big32
-#define GENERATOR1(fn, t, sz) \
- static t fn##sz(t x) { return fn<t>(x); }
-
-#define GENERATOR2(t, sz) \
- GENERATOR1(swap, t, sz) \
- GENERATOR1(big, t, sz) \
- GENERATOR1(little, t, sz)
-
-#define GENERATOR3(sz) \
- GENERATOR2(uint##sz##_t, sz) \
- GENERATOR2(int##sz##_t, sz)
-
-class Endian {
- public:
- enum class Order : uint8_t { LITTLE, BIG };
-
- static constexpr Order order =
- portability::little_endian_arch ? Order::LITTLE : Order::BIG;
-
- template <typename T>
- static T swap(T x) {
- return EndianInt<T>::swap(x);
- }
-
- template <typename T>
- static T big(T x) {
- return EndianInt<T>::big(x);
- }
-
- template <typename T>
- static T little(T x) {
- return EndianInt<T>::little(x);
- }
-
-#if !defined(__ANDROID__)
- GENERATOR3(64)
- GENERATOR3(32)
- GENERATOR3(16)
- GENERATOR3(8)
-#endif
-};
-
-template <typename T>
-static TRANSPORT_ALWAYS_INLINE T ntoh(T x) {
- return Endian::order == Endian::Order::LITTLE ? Endian::little(x) : x;
-}
-
-template <typename T>
-static TRANSPORT_ALWAYS_INLINE T hton(T x) {
- return Endian::order == Endian::Order::LITTLE ? Endian::big(x) : x;
-}
-
-} // namespace utils \ No newline at end of file
diff --git a/libtransport/src/hicn/transport/utils/event_thread.h b/libtransport/src/hicn/transport/utils/event_thread.h
index 3bf08c94b..e50ae9648 100644
--- a/libtransport/src/hicn/transport/utils/event_thread.h
+++ b/libtransport/src/hicn/transport/utils/event_thread.h
@@ -76,8 +76,6 @@ class EventThread {
}
void stop() {
- TRANSPORT_LOGI("Stopping event thread!");
-
io_service_.stop();
if (thread_ && thread_->joinable()) {
diff --git a/libtransport/src/hicn/transport/utils/identity.h b/libtransport/src/hicn/transport/utils/identity.h
index 018842ee3..349b38914 100644
--- a/libtransport/src/hicn/transport/utils/identity.h
+++ b/libtransport/src/hicn/transport/utils/identity.h
@@ -36,7 +36,6 @@ class Identity {
unsigned int signature_length, unsigned int validity_days,
const std::string &subject_name);
- // No copies
Identity(const Identity &other);
Identity(std::string &file_name, std::string &password,
diff --git a/libtransport/src/hicn/transport/utils/signer.cc b/libtransport/src/hicn/transport/utils/signer.cc
index e1262ec94..981e5f02b 100644
--- a/libtransport/src/hicn/transport/utils/signer.cc
+++ b/libtransport/src/hicn/transport/utils/signer.cc
@@ -16,7 +16,6 @@
*/
#include <hicn/transport/errors/malformed_ahpacket_exception.h>
-#include <hicn/transport/utils/endianess.h>
#include <hicn/transport/utils/key_id.h>
#include <hicn/transport/utils/membuf.h>
#include <hicn/transport/utils/signer.h>
@@ -91,14 +90,8 @@ void Signer::sign(Packet &packet) {
// Copy IP+TCP/ICMP header before zeroing them
hicn_header_t header_copy;
- if (format == HF_INET_TCP_AH) {
- memcpy(&header_copy, hicn_packet, HICN_V4_TCP_HDRLEN);
- } else if (format == HF_INET6_TCP_AH) {
- memcpy(&header_copy, hicn_packet, HICN_V6_TCP_HDRLEN);
- } else {
- throw errors::RuntimeException(
- "Signer::sign -- Packet format not expected.");
- }
+ hicn_packet_copy_header(format, (const hicn_header_t *)packet.packet_start_,
+ &header_copy, false);
std::size_t header_len = Packet::getHeaderSizeFromFormat(format);
@@ -130,7 +123,8 @@ void Signer::sign(Packet &packet) {
utils::CryptoHash hash = hasher.finalize();
PARCSignature *signature = parcSigner_SignDigestNoAlloc(
- this->signer_, hash.hash_, packet.getSignature(), (uint32_t)sign_len_bytes);
+ this->signer_, hash.hash_, packet.getSignature(),
+ (uint32_t)sign_len_bytes);
PARCBuffer *buffer = parcSignature_GetSignature(signature);
size_t bytes_len = parcBuffer_Remaining(buffer);
@@ -139,12 +133,8 @@ void Signer::sign(Packet &packet) {
throw errors::MalformedAHPacketException();
}
- /* Restore the resetted fields */
- if (format & HFO_INET) {
- memcpy(hicn_packet, &header_copy, HICN_V4_TCP_HDRLEN);
- } else if (format & HFO_INET6) {
- memcpy(hicn_packet, &header_copy, HICN_V6_TCP_HDRLEN);
- }
+ hicn_packet_copy_header(format, &header_copy,
+ (hicn_header_t *)packet.packet_start_, false);
}
PARCKeyStore *Signer::getKeyStore() {
diff --git a/libtransport/src/hicn/transport/utils/socket.h b/libtransport/src/hicn/transport/utils/socket.h
deleted file mode 100644
index ab8578f91..000000000
--- a/libtransport/src/hicn/transport/utils/socket.h
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (c) 2017-2019 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/config.h>
-#include <hicn/transport/core/content_object.h>
-#include <hicn/transport/core/facade.h>
-#include <hicn/transport/core/interest.h>
-#include <hicn/transport/core/manifest_format_fixed.h>
-#include <hicn/transport/core/manifest_inline.h>
-#include <hicn/transport/core/name.h>
-#include <hicn/transport/transport/download_observer.h>
-#include <hicn/transport/transport/socket_options_default_values.h>
-#include <hicn/transport/transport/socket_options_keys.h>
-#include <hicn/transport/utils/crypto_suite.h>
-#include <hicn/transport/utils/identity.h>
-#include <hicn/transport/utils/verifier.h>
-
-#define SOCKET_OPTION_GET 0
-#define SOCKET_OPTION_NOT_GET 1
-#define SOCKET_OPTION_SET 2
-#define SOCKET_OPTION_NOT_SET 3
-#define SOCKET_OPTION_DEFAULT 12345
-
-#define VOID_HANDLER 0
-
-namespace transport {
-
-namespace transport {
-
-template <typename PortalType>
-class Socket;
-class ConsumerSocket;
-class ProducerSocket;
-
-using Interest = core::Interest;
-using ContentObject = core::ContentObject;
-using Name = core::Name;
-using ContentObjectManifest = core::ManifestInline<ContentObject, core::Fixed>;
-using InterestManifest = core::ManifestInline<Interest, core::Fixed>;
-using HashAlgorithm = core::HashAlgorithm;
-using CryptoSuite = utils::CryptoSuite;
-using Identity = utils::Identity;
-using Verifier = utils::Verifier;
-
-using HicnForwarderPortal = core::HicnForwarderPortal;
-
-#ifdef __linux__
-#ifndef __ANDROID__
-using RawSocketPortal = core::RawSocketPortal;
-#endif
-#endif
-
-#ifdef __vpp__
-using VPPForwarderPortal = core::VPPForwarderPortal;
-using BaseSocket = Socket<VPPForwarderPortal>;
-using BasePortal = VPPForwarderPortal;
-#else
-using BaseSocket = Socket<HicnForwarderPortal>;
-using BasePortal = HicnForwarderPortal;
-#endif
-
-using PayloadType = core::PayloadType;
-using Prefix = core::Prefix;
-using Array = utils::Array<uint8_t>;
-
-using ConsumerInterestCallback =
- std::function<void(ConsumerSocket &, const Interest &)>;
-
-using ConsumerContentCallback =
- std::function<void(ConsumerSocket &, std::size_t, const std::error_code &)>;
-
-using ConsumerTimerCallback =
- std::function<void(ConsumerSocket &, std::size_t,
- std::chrono::milliseconds &, float, uint32_t, uint32_t)>;
-
-using ProducerContentCallback = std::function<void(
- ProducerSocket &, const std::error_code &, uint64_t bytes_written)>;
-
-using ConsumerContentObjectCallback =
- std::function<void(ConsumerSocket &, const ContentObject &)>;
-
-using ConsumerContentObjectVerificationCallback =
- std::function<bool(ConsumerSocket &, const ContentObject &)>;
-
-using ConsumerManifestCallback =
- std::function<void(ConsumerSocket &, const ContentObjectManifest &)>;
-
-using ProducerContentObjectCallback =
- std::function<void(ProducerSocket &, ContentObject &)>;
-
-using ProducerInterestCallback =
- std::function<void(ProducerSocket &, const Interest &)>;
-
-using ProducerInterestCallback =
- std::function<void(ProducerSocket &, const Interest &)>;
-
-template <typename PortalType>
-class Socket {
- static_assert(std::is_same<PortalType, HicnForwarderPortal>::value
-#ifdef __linux__
-#ifndef __ANDROID__
- || std::is_same<PortalType, RawSocketPortal>::value
-#ifdef __vpp__
- || std::is_same<PortalType, VPPForwarderPortal>::value
-#endif
-#endif
- ,
-#else
- ,
-
-#endif
- "This class is not allowed as Portal");
-
- public:
- typedef PortalType Portal;
-
- virtual asio::io_service &getIoService() = 0;
-
- virtual void connect() = 0;
-
- virtual int setSocketOption(int socket_option_key,
- uint32_t socket_option_value) = 0;
-
- virtual int setSocketOption(int socket_option_key,
- double socket_option_value) = 0;
-
- virtual int setSocketOption(int socket_option_key,
- bool socket_option_value) = 0;
-
- virtual int setSocketOption(int socket_option_key,
- Name socket_option_value) = 0;
-
- virtual int setSocketOption(int socket_option_key,
- std::list<Prefix> socket_option_value) = 0;
-
- virtual int setSocketOption(
- int socket_option_key,
- ProducerContentObjectCallback socket_option_value) = 0;
-
- virtual int setSocketOption(int socket_option_key,
- ProducerInterestCallback socket_option_value) = 0;
-
- virtual int setSocketOption(int socket_option_key,
- ProducerContentCallback socket_option_value) = 0;
-
- virtual int setSocketOption(
- int socket_option_key,
- ConsumerContentObjectVerificationCallback socket_option_value) = 0;
-
- virtual int setSocketOption(
- int socket_option_key,
- ConsumerContentObjectCallback socket_option_value) = 0;
-
- virtual int setSocketOption(int socket_option_key,
- ConsumerInterestCallback socket_option_value) = 0;
-
- virtual int setSocketOption(int socket_option_key,
- ConsumerContentCallback socket_option_value) = 0;
-
- virtual int setSocketOption(int socket_option_key,
- ConsumerManifestCallback socket_option_value) = 0;
-
- virtual int setSocketOption(int socket_option_key,
- IcnObserver *socket_option_value) = 0;
-
- virtual int setSocketOption(int socket_option_key,
- HashAlgorithm socket_option_value) = 0;
-
- virtual int setSocketOption(int socket_option_key,
- CryptoSuite socket_option_value) = 0;
-
- virtual int setSocketOption(int socket_option_key,
- const Identity &socket_option_value) = 0;
-
- virtual int setSocketOption(int socket_option_key,
- ConsumerTimerCallback socket_option_value) = 0;
-
- virtual int setSocketOption(int socket_option_key,
- const std::string &socket_option_value) = 0;
-
- virtual int getSocketOption(int socket_option_key,
- uint32_t &socket_option_value) = 0;
-
- virtual int getSocketOption(int socket_option_key,
- double &socket_option_value) = 0;
-
- virtual int getSocketOption(int socket_option_key,
- bool &socket_option_value) = 0;
-
- virtual int getSocketOption(int socket_option_key,
- Name &socket_option_value) = 0;
-
- virtual int getSocketOption(int socket_option_key,
- std::list<Prefix> &socket_option_value) = 0;
-
- virtual int getSocketOption(
- int socket_option_key,
- ProducerContentObjectCallback &socket_option_value) = 0;
-
- virtual int getSocketOption(
- int socket_option_key, ProducerInterestCallback &socket_option_value) = 0;
-
- virtual int getSocketOption(
- int socket_option_key,
- ConsumerContentObjectVerificationCallback &socket_option_value) = 0;
-
- virtual int getSocketOption(
- int socket_option_key,
- ConsumerContentObjectCallback &socket_option_value) = 0;
-
- virtual int getSocketOption(
- int socket_option_key, ConsumerInterestCallback &socket_option_value) = 0;
-
- virtual int getSocketOption(int socket_option_key,
- ConsumerContentCallback &socket_option_value) = 0;
-
- virtual int getSocketOption(
- int socket_option_key, ConsumerManifestCallback &socket_option_value) = 0;
-
- virtual int getSocketOption(int socket_option_key,
- ProducerContentCallback &socket_option_value) = 0;
-
- virtual int getSocketOption(int socket_option_key,
- std::shared_ptr<Portal> &socket_option_value) = 0;
-
- virtual int getSocketOption(int socket_option_key,
- IcnObserver **socket_option_value) = 0;
-
- virtual int getSocketOption(int socket_option_key,
- HashAlgorithm &socket_option_value) = 0;
-
- virtual int getSocketOption(int socket_option_key,
- CryptoSuite &socket_option_value) = 0;
-
- virtual int getSocketOption(int socket_option_key,
- Identity &socket_option_value) = 0;
-
- virtual int getSocketOption(int socket_option_key,
- std::string &socket_option_value) = 0;
-
- virtual int getSocketOption(int socket_option_key,
- ConsumerTimerCallback &socket_option_value) = 0;
-
- protected:
- virtual ~Socket(){};
-
- protected:
- std::string output_interface_;
-};
-
-} // namespace transport
-
-} // namespace transport
diff --git a/libtransport/src/hicn/transport/utils/verifier.cc b/libtransport/src/hicn/transport/utils/verifier.cc
index 4295aaab7..af19d8b5e 100644
--- a/libtransport/src/hicn/transport/utils/verifier.cc
+++ b/libtransport/src/hicn/transport/utils/verifier.cc
@@ -109,14 +109,8 @@ int Verifier::verify(const Packet &packet) {
// Copy IP+TCP/ICMP header before zeroing them
hicn_header_t header_copy;
- if (format == HF_INET_TCP_AH) {
- memcpy(&header_copy, hicn_packet, HICN_V4_TCP_HDRLEN);
- } else if (format == HF_INET6_TCP_AH) {
- memcpy(&header_copy, hicn_packet, HICN_V6_TCP_HDRLEN);
- } else {
- throw errors::RuntimeException(
- "Verifier::verify -- Packet format not expected.");
- }
+ hicn_packet_copy_header(format, (const hicn_header_t *)packet.packet_start_,
+ &header_copy, false);
std::size_t header_len = Packet::getHeaderSizeFromFormat(format);
@@ -130,7 +124,7 @@ int Verifier::verify(const Packet &packet) {
int ah_payload_len = (int)packet.getSignatureSize();
uint8_t *_signature = packet.getSignature();
- uint8_t * signature = new uint8_t[ah_payload_len];
+ uint8_t *signature = new uint8_t[ah_payload_len];
// TODO Remove signature copy at this point, by not setting to zero
// the validation payload.
@@ -185,11 +179,8 @@ int Verifier::verify(const Packet &packet) {
verifier_, key_id, hash_computed_locally, suite, signatureToVerify);
/* Restore the resetted fields */
- if (format & HFO_INET) {
- memcpy(hicn_packet, &header_copy, HICN_V4_TCP_HDRLEN);
- } else if (format & HFO_INET6) {
- memcpy(hicn_packet, &header_copy, HICN_V6_TCP_HDRLEN);
- }
+ hicn_packet_copy_header(format, &header_copy,
+ (hicn_header_t *)packet.packet_start_, false);
delete[] signature;