aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport')
-rw-r--r--libtransport/includes/hicn/transport/core/packet.h3
-rw-r--r--libtransport/includes/hicn/transport/interfaces/CMakeLists.txt1
-rw-r--r--libtransport/includes/hicn/transport/interfaces/portal.h207
-rw-r--r--libtransport/includes/hicn/transport/interfaces/socket_consumer.h3
-rw-r--r--libtransport/includes/hicn/transport/interfaces/socket_producer.h9
-rw-r--r--libtransport/includes/hicn/transport/security/identity.h6
-rw-r--r--libtransport/src/CMakeLists.txt1
-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
-rw-r--r--libtransport/src/implementation/p2psecure_socket_producer.cc2
-rw-r--r--libtransport/src/implementation/p2psecure_socket_producer.h2
-rw-r--r--libtransport/src/implementation/socket_producer.h12
-rw-r--r--libtransport/src/interfaces/CMakeLists.txt1
-rw-r--r--libtransport/src/interfaces/portal.cc100
-rw-r--r--libtransport/src/interfaces/socket_producer.cc6
-rw-r--r--libtransport/src/protocols/manifest_incremental_indexer.h2
-rw-r--r--libtransport/src/protocols/protocol.h13
-rw-r--r--libtransport/src/security/identity.cc2
24 files changed, 362 insertions, 99 deletions
diff --git a/libtransport/includes/hicn/transport/core/packet.h b/libtransport/includes/hicn/transport/core/packet.h
index e80912cbe..e758aa13e 100644
--- a/libtransport/includes/hicn/transport/core/packet.h
+++ b/libtransport/includes/hicn/transport/core/packet.h
@@ -149,7 +149,8 @@ class Packet : public std::enable_shared_from_this<Packet> {
utils::KeyId getKeyId() const;
- virtual utils::CryptoHash computeDigest(HashAlgorithm algorithm) const;
+ virtual utils::CryptoHash computeDigest(
+ utils::CryptoHashType algorithm) const;
void setChecksum();
diff --git a/libtransport/includes/hicn/transport/interfaces/CMakeLists.txt b/libtransport/includes/hicn/transport/interfaces/CMakeLists.txt
index 38e6143f0..7370ad1b0 100644
--- a/libtransport/includes/hicn/transport/interfaces/CMakeLists.txt
+++ b/libtransport/includes/hicn/transport/interfaces/CMakeLists.txt
@@ -23,6 +23,7 @@ list(APPEND HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/callbacks.h
${CMAKE_CURRENT_SOURCE_DIR}/verification_policy.h
${CMAKE_CURRENT_SOURCE_DIR}/statistics.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/portal.h
)
if (${OPENSSL_VERSION} VERSION_EQUAL "1.1.1a" OR ${OPENSSL_VERSION} VERSION_GREATER "1.1.1a")
diff --git a/libtransport/includes/hicn/transport/interfaces/portal.h b/libtransport/includes/hicn/transport/interfaces/portal.h
new file mode 100644
index 000000000..724cd7592
--- /dev/null
+++ b/libtransport/includes/hicn/transport/interfaces/portal.h
@@ -0,0 +1,207 @@
+/*
+ * 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/core/content_object.h>
+#include <hicn/transport/core/interest.h>
+#include <hicn/transport/core/prefix.h>
+
+#ifndef ASIO_STANDALONE
+#define ASIO_STANDALONE
+#endif
+#include <asio/io_service.hpp>
+
+#include <functional>
+
+#define UNSET_CALLBACK 0
+
+namespace transport {
+
+namespace interface {
+
+template <typename PrefixType>
+class BasicBindConfig {
+ static_assert(std::is_same<core::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<core::Prefix>;
+
+class Portal {
+ public:
+ /**
+ * Consumer callback is an abstract class containing two methods to be
+ * implemented by a consumer application.
+ */
+ class ConsumerCallback {
+ public:
+ virtual void onContentObject(core::Interest::Ptr &&i,
+ core::ContentObject::Ptr &&c) = 0;
+ virtual void onTimeout(core::Interest::Ptr &&i) = 0;
+ virtual void onError(std::error_code ec) = 0;
+ };
+
+ /**
+ * Producer callback is an abstract class containing two methods to be
+ * implemented by a producer application.
+ */
+ class ProducerCallback {
+ public:
+ virtual void onInterest(core::Interest::Ptr &&i) = 0;
+ virtual void onError(std::error_code ec) = 0;
+ };
+
+ using OnContentObjectCallback =
+ std::function<void(core::Interest::Ptr &&, core::ContentObject::Ptr &&)>;
+ using OnInterestTimeoutCallback = std::function<void(core::Interest::Ptr &&)>;
+
+ Portal();
+
+ Portal(asio::io_service &io_service);
+
+ /**
+ * Set the consumer callback.
+ *
+ * @param consumer_callback - The pointer to the ConsumerCallback object.
+ */
+ void setConsumerCallback(ConsumerCallback *consumer_callback);
+
+ /**
+ * Set the producer callback.
+ *
+ * @param producer_callback - The pointer to the ProducerCallback object.
+ */
+ void setProducerCallback(ProducerCallback *producer_callback);
+
+ /**
+ * Connect the transport to the local hicn forwarder.
+ *
+ * @param is_consumer - Boolean specifying if the application on top of portal
+ * is a consumer or a producer.
+ */
+ void connect(bool is_consumer = true);
+
+ /**
+ * Destructor.
+ */
+ ~Portal();
+
+ /**
+ * Check if there is already a pending interest for a given name.
+ *
+ * @param name - The interest name.
+ */
+ bool interestIsPending(const core::Name &name);
+
+ /**
+ * Send an interest through to the local forwarder.
+ *
+ * @param interest - The pointer to the interest. The ownership of the
+ * interest is transferred by the caller to portal.
+ *
+ * @param on_content_object_callback - If the caller wishes to use a different
+ * callback to be called for this interest, it can set this parameter.
+ * Otherwise ConsumerCallback::onContentObject will be used.
+ *
+ * @param on_interest_timeout_callback - If the caller wishes to use a
+ * different callback to be called for this interest, it can set this
+ * parameter. Otherwise ConsumerCallback::onTimeout will be used.
+ */
+ void sendInterest(
+ core::Interest::Ptr &&interest,
+ OnContentObjectCallback &&on_content_object_callback = UNSET_CALLBACK,
+ OnInterestTimeoutCallback &&on_interest_timeout_callback =
+ UNSET_CALLBACK);
+
+ /**
+ * Register a producer name to the local forwarder and optionally set the
+ * content store size in a per-face manner.
+ *
+ * @param config - The configuration for the local forwarder binding.
+ */
+ void bind(const BindConfig &config);
+
+ void runEventsLoop();
+
+ /**
+ * Run one event and return.
+ */
+ void runOneEvent();
+
+ /**
+ * Send a data packet to the local forwarder. As opposite to sendInterest, the
+ * ownership of the content object is not transferred to the portal.
+ *
+ * @param content_object - The data packet.
+ */
+ void sendContentObject(core::ContentObject &content_object);
+ /**
+ * Stop the event loop, canceling all the pending events in the event queue.
+ *
+ * Beware that stopping the event loop DOES NOT disconnect the transport from
+ * the local forwarder, the connector underneath will stay connected.
+ */
+ void stopEventsLoop();
+
+ /**
+ * Disconnect the transport from the local forwarder.
+ */
+ void killConnection();
+
+ /**
+ * Clear the pending interest hash table.
+ */
+ void clear();
+
+ /**
+ * Get a reference to the io_service object.
+ */
+ asio::io_service &getIoService();
+
+ /**
+ * Register a route to the local forwarder.
+ */
+ void registerRoute(core::Prefix &prefix);
+
+ private:
+ void *implementation_;
+};
+
+} // namespace interface
+} // namespace transport \ No newline at end of file
diff --git a/libtransport/includes/hicn/transport/interfaces/socket_consumer.h b/libtransport/includes/hicn/transport/interfaces/socket_consumer.h
index ee60ecbff..0a6e9a43a 100644
--- a/libtransport/includes/hicn/transport/interfaces/socket_consumer.h
+++ b/libtransport/includes/hicn/transport/interfaces/socket_consumer.h
@@ -23,9 +23,10 @@
#include <hicn/transport/interfaces/socket_options_keys.h>
#include <hicn/transport/security/verifier.h>
+#ifndef ASIO_STANDALONE
#define ASIO_STANDALONE
+#endif
#include <asio/io_service.hpp>
-#undef ASIO_STANDALONE
#define CONSUMER_FINISHED 0
#define CONSUMER_BUSY 1
diff --git a/libtransport/includes/hicn/transport/interfaces/socket_producer.h b/libtransport/includes/hicn/transport/interfaces/socket_producer.h
index e4823cb5c..e269fb83d 100644
--- a/libtransport/includes/hicn/transport/interfaces/socket_producer.h
+++ b/libtransport/includes/hicn/transport/interfaces/socket_producer.h
@@ -23,9 +23,11 @@
#include <hicn/transport/interfaces/socket_options_keys.h>
#include <hicn/transport/security/signer.h>
+#ifndef ASIO_STANDALONE
#define ASIO_STANDALONE
+#endif
#include <asio/io_service.hpp>
-#undef ASIO_STANDALONE
+
namespace transport {
namespace implementation {
@@ -101,7 +103,8 @@ class ProducerSocket {
int setSocketOption(int socket_option_key,
ProducerContentCallback socket_option_value);
- int setSocketOption(int socket_option_key, HashAlgorithm socket_option_value);
+ int setSocketOption(int socket_option_key,
+ utils::CryptoHashType socket_option_value);
int setSocketOption(int socket_option_key,
utils::CryptoSuite socket_option_value);
@@ -130,7 +133,7 @@ class ProducerSocket {
ProducerInterestCallback **socket_option_value);
int getSocketOption(int socket_option_key,
- HashAlgorithm &socket_option_value);
+ utils::CryptoHashType &socket_option_value);
int getSocketOption(int socket_option_key,
utils::CryptoSuite &socket_option_value);
diff --git a/libtransport/includes/hicn/transport/security/identity.h b/libtransport/includes/hicn/transport/security/identity.h
index c5d4b975d..a575af134 100644
--- a/libtransport/includes/hicn/transport/security/identity.h
+++ b/libtransport/includes/hicn/transport/security/identity.h
@@ -18,8 +18,6 @@
#include <hicn/transport/security/crypto_suite.h>
#include <hicn/transport/security/signer.h>
-#include <core/manifest_format.h>
-
extern "C" {
#include <parc/security/parc_Identity.h>
#include <parc/security/parc_IdentityFile.h>
@@ -40,7 +38,7 @@ class Identity {
Identity(const Identity &other);
Identity(std::string &file_name, std::string &password,
- transport::core::HashAlgorithm hash_algorithm);
+ utils::CryptoHashType hash_algorithm);
~Identity();
@@ -57,7 +55,7 @@ class Identity {
private:
PARCIdentity *identity_;
std::shared_ptr<Signer> signer_;
- transport::core::HashAlgorithm hash_algorithm_;
+ utils::CryptoHashType hash_algorithm_;
};
} // namespace utils
diff --git a/libtransport/src/CMakeLists.txt b/libtransport/src/CMakeLists.txt
index a182998e3..c92393775 100644
--- a/libtransport/src/CMakeLists.txt
+++ b/libtransport/src/CMakeLists.txt
@@ -42,7 +42,6 @@ list(INSERT LIBTRANSPORT_INTERNAL_INCLUDE_DIRS 0
)
set(LIBTRANSPORT_INCLUDE_DIRS
- ${CMAKE_CURRENT_BINARY_DIR}
${LIBTRANSPORT_INCLUDE_DIRS}
"" CACHE INTERNAL
"" FORCE
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_) {}
diff --git a/libtransport/src/implementation/p2psecure_socket_producer.cc b/libtransport/src/implementation/p2psecure_socket_producer.cc
index d7161986b..d0852539a 100644
--- a/libtransport/src/implementation/p2psecure_socket_producer.cc
+++ b/libtransport/src/implementation/p2psecure_socket_producer.cc
@@ -367,7 +367,7 @@ int P2PSecureProducerSocket::setSocketOption(
}
int P2PSecureProducerSocket::setSocketOption(
- int socket_option_key, HashAlgorithm socket_option_value) {
+ int socket_option_key, utils::CryptoHashType socket_option_value) {
if (!list_secure_producers.empty())
for (auto it = list_secure_producers.cbegin();
it != list_secure_producers.cend(); it++)
diff --git a/libtransport/src/implementation/p2psecure_socket_producer.h b/libtransport/src/implementation/p2psecure_socket_producer.h
index c2cbf31ac..33339deba 100644
--- a/libtransport/src/implementation/p2psecure_socket_producer.h
+++ b/libtransport/src/implementation/p2psecure_socket_producer.h
@@ -84,7 +84,7 @@ class P2PSecureProducerSocket : public ProducerSocket {
ProducerContentCallback socket_option_value) override;
int setSocketOption(int socket_option_key,
- HashAlgorithm socket_option_value) override;
+ utils::CryptoHashType socket_option_value) override;
int setSocketOption(int socket_option_key,
utils::CryptoSuite socket_option_value) override;
diff --git a/libtransport/src/implementation/socket_producer.h b/libtransport/src/implementation/socket_producer.h
index 1f03fe53d..d4a239cf6 100644
--- a/libtransport/src/implementation/socket_producer.h
+++ b/libtransport/src/implementation/socket_producer.h
@@ -53,7 +53,7 @@ class ProducerSocket : public Socket<BasePortal>,
async_thread_(),
registration_status_(REGISTRATION_NOT_ATTEMPTED),
making_manifest_(false),
- hash_algorithm_(HashAlgorithm::SHA_256),
+ hash_algorithm_(utils::CryptoHashType::SHA_256),
suffix_strategy_(core::NextSegmentCalculationStrategy::INCREMENTAL),
on_interest_input_(VOID_HANDLER),
on_interest_dropped_input_buffer_(VOID_HANDLER),
@@ -108,7 +108,7 @@ class ProducerSocket : public Socket<BasePortal>,
// during the production
std::size_t data_packet_size = data_packet_size_;
uint32_t content_object_expiry_time = content_object_expiry_time_;
- HashAlgorithm hash_algo = hash_algorithm_;
+ utils::CryptoHashType hash_algo = hash_algorithm_;
bool making_manifest = making_manifest_;
auto suffix_strategy = utils::SuffixStrategyFactory::getSuffixStrategy(
suffix_strategy_, start_offset);
@@ -426,6 +426,8 @@ class ProducerSocket : public Socket<BasePortal>,
onInterest(*interest);
};
+ virtual void onError(std::error_code ec) override {}
+
virtual int setSocketOption(int socket_option_key,
uint32_t socket_option_value) {
switch (socket_option_key) {
@@ -648,7 +650,7 @@ class ProducerSocket : public Socket<BasePortal>,
}
virtual int setSocketOption(int socket_option_key,
- HashAlgorithm socket_option_value) {
+ utils::CryptoHashType socket_option_value) {
switch (socket_option_key) {
case GeneralTransportOptions::HASH_ALGORITHM:
hash_algorithm_ = socket_option_value;
@@ -848,7 +850,7 @@ class ProducerSocket : public Socket<BasePortal>,
}
virtual int getSocketOption(int socket_option_key,
- HashAlgorithm &socket_option_value) {
+ utils::CryptoHashType &socket_option_value) {
switch (socket_option_key) {
case GeneralTransportOptions::HASH_ALGORITHM:
socket_option_value = hash_algorithm_;
@@ -983,7 +985,7 @@ class ProducerSocket : public Socket<BasePortal>,
// function
std::unordered_map<Name, std::unordered_map<int, uint32_t>> seq_number_map_;
- std::atomic<HashAlgorithm> hash_algorithm_;
+ std::atomic<utils::CryptoHashType> hash_algorithm_;
std::atomic<utils::CryptoSuite> crypto_suite_;
utils::SpinLock signer_lock_;
std::shared_ptr<utils::Signer> signer_;
diff --git a/libtransport/src/interfaces/CMakeLists.txt b/libtransport/src/interfaces/CMakeLists.txt
index daf4b31e5..e1d144596 100644
--- a/libtransport/src/interfaces/CMakeLists.txt
+++ b/libtransport/src/interfaces/CMakeLists.txt
@@ -17,6 +17,7 @@ list(APPEND SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rtc_socket_producer.cc
${CMAKE_CURRENT_SOURCE_DIR}/socket_producer.cc
${CMAKE_CURRENT_SOURCE_DIR}/socket_consumer.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/portal.cc
${CMAKE_CURRENT_SOURCE_DIR}/callbacks.cc
)
diff --git a/libtransport/src/interfaces/portal.cc b/libtransport/src/interfaces/portal.cc
new file mode 100644
index 000000000..36cbd0c3b
--- /dev/null
+++ b/libtransport/src/interfaces/portal.cc
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2020 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.
+ */
+
+#include <hicn/transport/interfaces/portal.h>
+
+#include <implementation/socket.h>
+
+namespace transport {
+namespace interface {
+
+using implementation::BasePortal;
+
+Portal::Portal() { implementation_ = new implementation::BasePortal(); }
+
+Portal::Portal(asio::io_service &io_service) {
+ implementation_ = new BasePortal(io_service);
+}
+
+Portal::~Portal() { delete reinterpret_cast<BasePortal *>(implementation_); }
+
+void Portal::setConsumerCallback(ConsumerCallback *consumer_callback) {
+ reinterpret_cast<BasePortal *>(implementation_)
+ ->setConsumerCallback(consumer_callback);
+}
+
+void Portal::setProducerCallback(ProducerCallback *producer_callback) {
+ reinterpret_cast<BasePortal *>(implementation_)
+ ->setProducerCallback(producer_callback);
+}
+
+void Portal::connect(bool is_consumer) {
+ reinterpret_cast<BasePortal *>(implementation_)->connect(is_consumer);
+}
+
+bool Portal::interestIsPending(const core::Name &name) {
+ return reinterpret_cast<BasePortal *>(implementation_)
+ ->interestIsPending(name);
+}
+
+void Portal::sendInterest(
+ core::Interest::Ptr &&interest,
+ OnContentObjectCallback &&on_content_object_callback,
+ OnInterestTimeoutCallback &&on_interest_timeout_callback) {
+ reinterpret_cast<BasePortal *>(implementation_)
+ ->sendInterest(std::move(interest), std::move(on_content_object_callback),
+ std::move(on_interest_timeout_callback));
+}
+
+void Portal::bind(const BindConfig &config) {
+ reinterpret_cast<BasePortal *>(implementation_)->bind(config);
+}
+
+void Portal::runEventsLoop() {
+ reinterpret_cast<BasePortal *>(implementation_)->runEventsLoop();
+}
+
+void Portal::runOneEvent() {
+ reinterpret_cast<BasePortal *>(implementation_)->runOneEvent();
+}
+
+void Portal::sendContentObject(core::ContentObject &content_object) {
+ reinterpret_cast<BasePortal *>(implementation_)
+ ->sendContentObject(content_object);
+}
+
+void Portal::stopEventsLoop() {
+ reinterpret_cast<BasePortal *>(implementation_)->stopEventsLoop();
+}
+
+void Portal::killConnection() {
+ reinterpret_cast<BasePortal *>(implementation_)->killConnection();
+}
+
+void Portal::clear() {
+ reinterpret_cast<BasePortal *>(implementation_)->clear();
+}
+
+asio::io_service &Portal::getIoService() {
+ return reinterpret_cast<BasePortal *>(implementation_)->getIoService();
+}
+
+void Portal::registerRoute(core::Prefix &prefix) {
+ reinterpret_cast<BasePortal *>(implementation_)->registerRoute(prefix);
+}
+
+} // namespace interface
+
+} // namespace transport \ No newline at end of file
diff --git a/libtransport/src/interfaces/socket_producer.cc b/libtransport/src/interfaces/socket_producer.cc
index 679f7ccf4..d030fe756 100644
--- a/libtransport/src/interfaces/socket_producer.cc
+++ b/libtransport/src/interfaces/socket_producer.cc
@@ -126,7 +126,7 @@ int ProducerSocket::setSocketOption(
}
int ProducerSocket::setSocketOption(int socket_option_key,
- HashAlgorithm socket_option_value) {
+ utils::CryptoHashType socket_option_value) {
return socket_->setSocketOption(socket_option_key, socket_option_value);
}
@@ -177,8 +177,8 @@ int ProducerSocket::getSocketOption(
return socket_->getSocketOption(socket_option_key, socket_option_value);
}
-int ProducerSocket::getSocketOption(int socket_option_key,
- HashAlgorithm &socket_option_value) {
+int ProducerSocket::getSocketOption(
+ int socket_option_key, utils::CryptoHashType &socket_option_value) {
return socket_->getSocketOption(socket_option_key, socket_option_value);
}
diff --git a/libtransport/src/protocols/manifest_incremental_indexer.h b/libtransport/src/protocols/manifest_incremental_indexer.h
index 88ae1720b..38b01533e 100644
--- a/libtransport/src/protocols/manifest_incremental_indexer.h
+++ b/libtransport/src/protocols/manifest_incremental_indexer.h
@@ -30,7 +30,7 @@ class ManifestIncrementalIndexer : public IncrementalIndexer {
public:
using SuffixQueue = std::queue<uint32_t>;
- using HashEntry = std::pair<std::vector<uint8_t>, core::HashAlgorithm>;
+ using HashEntry = std::pair<std::vector<uint8_t>, utils::CryptoHashType>;
ManifestIncrementalIndexer(implementation::ConsumerSocket *icn_socket,
TransportProtocol *transport,
diff --git a/libtransport/src/protocols/protocol.h b/libtransport/src/protocols/protocol.h
index c094adaae..949380959 100644
--- a/libtransport/src/protocols/protocol.h
+++ b/libtransport/src/protocols/protocol.h
@@ -67,15 +67,18 @@ class TransportProtocol : public implementation::BasePortal::ConsumerCallback,
// Events generated by the indexing
virtual void onContentReassembled(std::error_code ec);
- virtual void onPacketDropped(Interest::Ptr &&interest,
- ContentObject::Ptr &&content_object) = 0;
- virtual void onReassemblyFailed(std::uint32_t missing_segment) = 0;
+ virtual void onPacketDropped(
+ Interest::Ptr &&interest,
+ ContentObject::Ptr &&content_object) override = 0;
+ virtual void onReassemblyFailed(std::uint32_t missing_segment) override = 0;
protected:
// Consumer Callback
virtual void reset() = 0;
- virtual void onContentObject(Interest::Ptr &&i, ContentObject::Ptr &&c) = 0;
- virtual void onTimeout(Interest::Ptr &&i) = 0;
+ virtual void onContentObject(Interest::Ptr &&i,
+ ContentObject::Ptr &&c) override = 0;
+ virtual void onTimeout(Interest::Ptr &&i) override = 0;
+ virtual void onError(std::error_code ec) override {}
protected:
implementation::ConsumerSocket *socket_;
diff --git a/libtransport/src/security/identity.cc b/libtransport/src/security/identity.cc
index 55713245e..d7a08f7b5 100644
--- a/libtransport/src/security/identity.cc
+++ b/libtransport/src/security/identity.cc
@@ -73,7 +73,7 @@ Identity Identity::generateIdentity(const std::string &subject_name) {
}
Identity::Identity(std::string &file_name, std::string &password,
- transport::core::HashAlgorithm hash_algorithm)
+ utils::CryptoHashType hash_algorithm)
: hash_algorithm_(hash_algorithm) {
parcSecurity_Init();