aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/src/core')
-rw-r--r--libtransport/src/core/manifest.h6
-rw-r--r--libtransport/src/core/manifest_format.h10
-rw-r--r--libtransport/src/core/manifest_format_fixed.cc6
-rw-r--r--libtransport/src/core/manifest_format_fixed.h4
-rw-r--r--libtransport/src/core/manifest_inline.h2
-rw-r--r--libtransport/src/core/packet.cc2
-rw-r--r--libtransport/src/core/pending_interest.h7
-rw-r--r--libtransport/src/core/portal.h54
8 files changed, 19 insertions, 72 deletions
diff --git a/libtransport/src/core/manifest.h b/libtransport/src/core/manifest.h
index b4875bf22..eadfed752 100644
--- a/libtransport/src/core/manifest.h
+++ b/libtransport/src/core/manifest.h
@@ -96,13 +96,13 @@ class Manifest : public Base {
return *this;
}
- Manifest &setHashAlgorithm(HashAlgorithm hash_algorithm) {
+ Manifest &setHashAlgorithm(utils::CryptoHashType hash_algorithm) {
hash_algorithm_ = hash_algorithm;
encoder_.setHashAlgorithm(hash_algorithm_);
return *this;
}
- HashAlgorithm getHashAlgorithm() { return hash_algorithm_; }
+ utils::CryptoHashType getHashAlgorithm() { return hash_algorithm_; }
ManifestType getManifestType() const { return manifest_type_; }
@@ -138,7 +138,7 @@ class Manifest : public Base {
protected:
ManifestType manifest_type_;
- HashAlgorithm hash_algorithm_;
+ utils::CryptoHashType hash_algorithm_;
bool is_last_;
Encoder encoder_;
diff --git a/libtransport/src/core/manifest_format.h b/libtransport/src/core/manifest_format.h
index f95d19aa8..36d23f99b 100644
--- a/libtransport/src/core/manifest_format.h
+++ b/libtransport/src/core/manifest_format.h
@@ -45,12 +45,6 @@ enum class ManifestType : uint8_t {
FLIC_MANIFEST = 3,
};
-enum class HashAlgorithm : uint8_t {
- SHA_256 = static_cast<uint8_t>(utils::CryptoHashType::SHA_256),
- SHA_512 = static_cast<uint8_t>(utils::CryptoHashType::SHA_512),
- CRC32C = static_cast<uint8_t>(utils::CryptoHashType::CRC32C),
-};
-
/**
* INCREMENTAL: Manifests will be received inline with the data with no specific
* assumption regarding the manifest capacity. Consumers can send interests
@@ -92,7 +86,7 @@ class ManifestEncoder {
return static_cast<Implementation &>(*this).setManifestTypeImpl(type);
}
- ManifestEncoder &setHashAlgorithm(HashAlgorithm hash) {
+ ManifestEncoder &setHashAlgorithm(utils::CryptoHashType hash) {
return static_cast<Implementation &>(*this).setHashAlgorithmImpl(hash);
}
@@ -166,7 +160,7 @@ class ManifestDecoder {
return static_cast<const Implementation &>(*this).getManifestTypeImpl();
}
- HashAlgorithm getHashAlgorithm() const {
+ utils::CryptoHashType getHashAlgorithm() const {
return static_cast<const Implementation &>(*this).getHashAlgorithmImpl();
}
diff --git a/libtransport/src/core/manifest_format_fixed.cc b/libtransport/src/core/manifest_format_fixed.cc
index 4073a5d26..ca80c38b1 100644
--- a/libtransport/src/core/manifest_format_fixed.cc
+++ b/libtransport/src/core/manifest_format_fixed.cc
@@ -55,7 +55,7 @@ FixedManifestEncoder &FixedManifestEncoder::clearImpl() {
}
FixedManifestEncoder &FixedManifestEncoder::setHashAlgorithmImpl(
- HashAlgorithm algorithm) {
+ utils::CryptoHashType algorithm) {
manifest_header_->hash_algorithm = static_cast<uint8_t>(algorithm);
return *this;
}
@@ -170,8 +170,8 @@ ManifestType FixedManifestDecoder::getManifestTypeImpl() const {
return static_cast<ManifestType>(manifest_header_->manifest_type);
}
-HashAlgorithm FixedManifestDecoder::getHashAlgorithmImpl() const {
- return static_cast<HashAlgorithm>(manifest_header_->hash_algorithm);
+utils::CryptoHashType FixedManifestDecoder::getHashAlgorithmImpl() const {
+ return static_cast<utils::CryptoHashType>(manifest_header_->hash_algorithm);
}
NextSegmentCalculationStrategy
diff --git a/libtransport/src/core/manifest_format_fixed.h b/libtransport/src/core/manifest_format_fixed.h
index 9cacb3bc2..1d7cd7d32 100644
--- a/libtransport/src/core/manifest_format_fixed.h
+++ b/libtransport/src/core/manifest_format_fixed.h
@@ -94,7 +94,7 @@ class FixedManifestEncoder : public ManifestEncoder<FixedManifestEncoder> {
FixedManifestEncoder &setManifestTypeImpl(ManifestType manifest_type);
- FixedManifestEncoder &setHashAlgorithmImpl(HashAlgorithm algorithm);
+ FixedManifestEncoder &setHashAlgorithmImpl(utils::CryptoHashType algorithm);
FixedManifestEncoder &setNextSegmentCalculationStrategyImpl(
NextSegmentCalculationStrategy strategy);
@@ -144,7 +144,7 @@ class FixedManifestDecoder : public ManifestDecoder<FixedManifestDecoder> {
ManifestType getManifestTypeImpl() const;
- HashAlgorithm getHashAlgorithmImpl() const;
+ utils::CryptoHashType getHashAlgorithmImpl() const;
NextSegmentCalculationStrategy getNextSegmentCalculationStrategyImpl() const;
diff --git a/libtransport/src/core/manifest_inline.h b/libtransport/src/core/manifest_inline.h
index 235c6f3a0..0227fa93a 100644
--- a/libtransport/src/core/manifest_inline.h
+++ b/libtransport/src/core/manifest_inline.h
@@ -44,7 +44,7 @@ class ManifestInline
static TRANSPORT_ALWAYS_INLINE ManifestInline *createManifest(
const core::Name &manifest_name, ManifestVersion version,
- ManifestType type, HashAlgorithm algorithm, bool is_last,
+ ManifestType type, utils::CryptoHashType algorithm, bool is_last,
const Name &base_name, NextSegmentCalculationStrategy strategy,
std::size_t signature_size) {
auto manifest = new ManifestInline(manifest_name, signature_size);
diff --git a/libtransport/src/core/packet.cc b/libtransport/src/core/packet.cc
index 817f8de66..67e647fca 100644
--- a/libtransport/src/core/packet.cc
+++ b/libtransport/src/core/packet.cc
@@ -344,7 +344,7 @@ utils::KeyId Packet::getKeyId() const {
return return_value;
}
-utils::CryptoHash Packet::computeDigest(HashAlgorithm algorithm) const {
+utils::CryptoHash Packet::computeDigest(utils::CryptoHashType algorithm) const {
utils::CryptoHasher hasher(static_cast<utils::CryptoHashType>(algorithm));
hasher.init();
diff --git a/libtransport/src/core/pending_interest.h b/libtransport/src/core/pending_interest.h
index 87fed5073..d9ec2ed40 100644
--- a/libtransport/src/core/pending_interest.h
+++ b/libtransport/src/core/pending_interest.h
@@ -19,6 +19,7 @@
#include <hicn/transport/core/content_object.h>
#include <hicn/transport/core/interest.h>
#include <hicn/transport/core/name.h>
+#include <hicn/transport/interfaces/portal.h>
#include <hicn/transport/portability/portability.h>
#include <utils/deadline_timer.h>
@@ -36,10 +37,8 @@ class RawSocketInterface;
template <typename ForwarderInt>
class Portal;
-typedef std::function<void(Interest::Ptr &&, ContentObject::Ptr &&)>
- OnContentObjectCallback;
-typedef std::function<void(Interest::Ptr &&)> OnInterestTimeoutCallback;
-typedef std::function<void(const std::error_code &)> TimerCallback;
+using OnContentObjectCallback = interface::Portal::OnContentObjectCallback;
+using OnInterestTimeoutCallback = interface::Portal::OnInterestTimeoutCallback;
class PendingInterest {
friend class Portal<HicnForwarderInterface>;
diff --git a/libtransport/src/core/portal.h b/libtransport/src/core/portal.h
index d7c463dfd..cf1010068 100644
--- a/libtransport/src/core/portal.h
+++ b/libtransport/src/core/portal.h
@@ -21,6 +21,7 @@
#include <hicn/transport/core/name.h>
#include <hicn/transport/core/prefix.h>
#include <hicn/transport/errors/errors.h>
+#include <hicn/transport/interfaces/portal.h>
#include <hicn/transport/portability/portability.h>
#include <hicn/transport/utils/log.h>
@@ -39,8 +40,6 @@
#include <queue>
#include <unordered_map>
-#define UNSET_CALLBACK 0
-
namespace transport {
namespace core {
@@ -230,36 +229,7 @@ class Pool {
using PendingInterestHashTable =
std::unordered_map<uint32_t, PendingInterest::Ptr>;
-template <typename PrefixType>
-class BasicBindConfig {
- static_assert(std::is_same<Prefix, PrefixType>::value,
- "Prefix must be a Prefix type.");
-
- const uint32_t standard_cs_reserved = 5000;
-
- public:
- template <typename T>
- BasicBindConfig(T &&prefix)
- : prefix_(std::forward<T &&>(prefix)),
- content_store_reserved_(standard_cs_reserved) {}
-
- template <typename T>
- BasicBindConfig(T &&prefix, uint32_t cs_reserved)
- : prefix_(std::forward<T &&>(prefix)),
- content_store_reserved_(cs_reserved) {}
-
- TRANSPORT_ALWAYS_INLINE const PrefixType &prefix() const { return prefix_; }
-
- TRANSPORT_ALWAYS_INLINE uint32_t csReserved() const {
- return content_store_reserved_;
- }
-
- private:
- PrefixType prefix_;
- uint32_t content_store_reserved_;
-};
-
-using BindConfig = BasicBindConfig<Prefix>;
+using interface::BindConfig;
/**
* Portal is a opaque class which is used for sending/receiving interest/data
@@ -290,24 +260,8 @@ class Portal {
"ForwarderInt must inherit from ForwarderInterface!");
public:
- /**
- * Consumer callback is an abstract class containing two methods to be
- * implemented by a consumer application.
- */
- class ConsumerCallback {
- public:
- virtual void onContentObject(Interest::Ptr &&i, ContentObject::Ptr &&c) = 0;
- virtual void onTimeout(Interest::Ptr &&i) = 0;
- };
-
- /**
- * Producer callback is an abstract class containing two methods to be
- * implemented by a producer application.
- */
- class ProducerCallback {
- public:
- virtual void onInterest(Interest::Ptr &&i) = 0;
- };
+ using ConsumerCallback = interface::Portal::ConsumerCallback;
+ using ProducerCallback = interface::Portal::ProducerCallback;
Portal() : Portal(internal_io_service_) {}