summaryrefslogtreecommitdiffstats
path: root/libtransport/src/interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/src/interfaces')
-rw-r--r--libtransport/src/interfaces/CMakeLists.txt6
-rw-r--r--libtransport/src/interfaces/global_configuration.cc50
-rw-r--r--libtransport/src/interfaces/p2psecure_socket_consumer.cc1
-rw-r--r--libtransport/src/interfaces/p2psecure_socket_producer.cc3
-rw-r--r--libtransport/src/interfaces/portal.cc37
-rw-r--r--libtransport/src/interfaces/socket_consumer.cc30
-rw-r--r--libtransport/src/interfaces/socket_producer.cc78
-rw-r--r--libtransport/src/interfaces/tls_rtc_socket_producer.cc3
-rw-r--r--libtransport/src/interfaces/tls_socket_consumer.cc3
-rw-r--r--libtransport/src/interfaces/tls_socket_producer.cc3
10 files changed, 109 insertions, 105 deletions
diff --git a/libtransport/src/interfaces/CMakeLists.txt b/libtransport/src/interfaces/CMakeLists.txt
index e1d144596..0284aa412 100644
--- a/libtransport/src/interfaces/CMakeLists.txt
+++ b/libtransport/src/interfaces/CMakeLists.txt
@@ -14,24 +14,24 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
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
+ ${CMAKE_CURRENT_SOURCE_DIR}/global_configuration.cc
)
if (${OPENSSL_VERSION} VERSION_EQUAL "1.1.1a" OR ${OPENSSL_VERSION} VERSION_GREATER "1.1.1a")
list(APPEND SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/p2psecure_socket_producer.cc
${CMAKE_CURRENT_SOURCE_DIR}/p2psecure_socket_consumer.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/tls_rtc_socket_producer.cc
+ # ${CMAKE_CURRENT_SOURCE_DIR}/tls_rtc_socket_producer.cc
${CMAKE_CURRENT_SOURCE_DIR}/tls_socket_producer.cc
${CMAKE_CURRENT_SOURCE_DIR}/tls_socket_consumer.cc
)
list(APPEND HEADER_FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/tls_rtc_socket_producer.h
+ # ${CMAKE_CURRENT_SOURCE_DIR}/tls_rtc_socket_producer.h
${CMAKE_CURRENT_SOURCE_DIR}/tls_socket_producer.h
${CMAKE_CURRENT_SOURCE_DIR}/tls_socket_consumer.h
)
diff --git a/libtransport/src/interfaces/global_configuration.cc b/libtransport/src/interfaces/global_configuration.cc
new file mode 100644
index 000000000..8fb6601f3
--- /dev/null
+++ b/libtransport/src/interfaces/global_configuration.cc
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+#include <core/global_configuration.h>
+#include <hicn/transport/interfaces/global_conf_interface.h>
+#include <hicn/transport/utils/log.h>
+
+#include <system_error>
+
+namespace transport {
+namespace interface {
+namespace global_config {
+
+void parseConfigurationFile(const std::string& path) {
+ core::GlobalConfiguration::getInstance().parseConfiguration(path);
+}
+
+void ConfigurationObject::get() {
+ std::error_code ec;
+ core::GlobalConfiguration::getInstance().getConfiguration(*this, ec);
+
+ if (ec) {
+ TRANSPORT_LOGE("Error setting global config: %s", ec.message().c_str());
+ }
+}
+
+void ConfigurationObject::set() {
+ std::error_code ec;
+ core::GlobalConfiguration::getInstance().setConfiguration(*this, ec);
+
+ if (ec) {
+ TRANSPORT_LOGE("Error setting global config: %s", ec.message().c_str());
+ }
+}
+
+} // namespace global_config
+} // namespace interface
+} // namespace transport \ No newline at end of file
diff --git a/libtransport/src/interfaces/p2psecure_socket_consumer.cc b/libtransport/src/interfaces/p2psecure_socket_consumer.cc
index 038441dfc..e473a1e2e 100644
--- a/libtransport/src/interfaces/p2psecure_socket_consumer.cc
+++ b/libtransport/src/interfaces/p2psecure_socket_consumer.cc
@@ -14,7 +14,6 @@
*/
#include <hicn/transport/interfaces/p2psecure_socket_consumer.h>
-
#include <implementation/p2psecure_socket_consumer.h>
namespace transport {
diff --git a/libtransport/src/interfaces/p2psecure_socket_producer.cc b/libtransport/src/interfaces/p2psecure_socket_producer.cc
index 37352259c..10d8a1367 100644
--- a/libtransport/src/interfaces/p2psecure_socket_producer.cc
+++ b/libtransport/src/interfaces/p2psecure_socket_producer.cc
@@ -14,7 +14,6 @@
*/
#include <hicn/transport/interfaces/p2psecure_socket_producer.h>
-
#include <implementation/p2psecure_socket_producer.h>
namespace transport {
@@ -25,7 +24,7 @@ P2PSecureProducerSocket::P2PSecureProducerSocket() {
}
P2PSecureProducerSocket::P2PSecureProducerSocket(
- bool rtc, const std::shared_ptr<utils::Identity> &identity) {
+ bool rtc, const std::shared_ptr<auth::Identity> &identity) {
socket_ = std::make_unique<implementation::P2PSecureProducerSocket>(this, rtc,
identity);
}
diff --git a/libtransport/src/interfaces/portal.cc b/libtransport/src/interfaces/portal.cc
index 36cbd0c3b..2ab51c4b9 100644
--- a/libtransport/src/interfaces/portal.cc
+++ b/libtransport/src/interfaces/portal.cc
@@ -14,38 +14,35 @@
*/
#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() { implementation_ = new core::Portal(); }
Portal::Portal(asio::io_service &io_service) {
- implementation_ = new BasePortal(io_service);
+ implementation_ = new core::Portal(io_service);
}
-Portal::~Portal() { delete reinterpret_cast<BasePortal *>(implementation_); }
+Portal::~Portal() { delete reinterpret_cast<core::Portal *>(implementation_); }
void Portal::setConsumerCallback(ConsumerCallback *consumer_callback) {
- reinterpret_cast<BasePortal *>(implementation_)
+ reinterpret_cast<core::Portal *>(implementation_)
->setConsumerCallback(consumer_callback);
}
void Portal::setProducerCallback(ProducerCallback *producer_callback) {
- reinterpret_cast<BasePortal *>(implementation_)
+ reinterpret_cast<core::Portal *>(implementation_)
->setProducerCallback(producer_callback);
}
void Portal::connect(bool is_consumer) {
- reinterpret_cast<BasePortal *>(implementation_)->connect(is_consumer);
+ reinterpret_cast<core::Portal *>(implementation_)->connect(is_consumer);
}
bool Portal::interestIsPending(const core::Name &name) {
- return reinterpret_cast<BasePortal *>(implementation_)
+ return reinterpret_cast<core::Portal *>(implementation_)
->interestIsPending(name);
}
@@ -53,46 +50,46 @@ void Portal::sendInterest(
core::Interest::Ptr &&interest,
OnContentObjectCallback &&on_content_object_callback,
OnInterestTimeoutCallback &&on_interest_timeout_callback) {
- reinterpret_cast<BasePortal *>(implementation_)
+ reinterpret_cast<core::Portal *>(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);
+ reinterpret_cast<core::Portal *>(implementation_)->bind(config);
}
void Portal::runEventsLoop() {
- reinterpret_cast<BasePortal *>(implementation_)->runEventsLoop();
+ reinterpret_cast<core::Portal *>(implementation_)->runEventsLoop();
}
void Portal::runOneEvent() {
- reinterpret_cast<BasePortal *>(implementation_)->runOneEvent();
+ reinterpret_cast<core::Portal *>(implementation_)->runOneEvent();
}
void Portal::sendContentObject(core::ContentObject &content_object) {
- reinterpret_cast<BasePortal *>(implementation_)
+ reinterpret_cast<core::Portal *>(implementation_)
->sendContentObject(content_object);
}
void Portal::stopEventsLoop() {
- reinterpret_cast<BasePortal *>(implementation_)->stopEventsLoop();
+ reinterpret_cast<core::Portal *>(implementation_)->stopEventsLoop();
}
void Portal::killConnection() {
- reinterpret_cast<BasePortal *>(implementation_)->killConnection();
+ reinterpret_cast<core::Portal *>(implementation_)->killConnection();
}
void Portal::clear() {
- reinterpret_cast<BasePortal *>(implementation_)->clear();
+ reinterpret_cast<core::Portal *>(implementation_)->clear();
}
asio::io_service &Portal::getIoService() {
- return reinterpret_cast<BasePortal *>(implementation_)->getIoService();
+ return reinterpret_cast<core::Portal *>(implementation_)->getIoService();
}
void Portal::registerRoute(core::Prefix &prefix) {
- reinterpret_cast<BasePortal *>(implementation_)->registerRoute(prefix);
+ reinterpret_cast<core::Portal *>(implementation_)->registerRoute(prefix);
}
} // namespace interface
diff --git a/libtransport/src/interfaces/socket_consumer.cc b/libtransport/src/interfaces/socket_consumer.cc
index ea0606347..4eee73cab 100644
--- a/libtransport/src/interfaces/socket_consumer.cc
+++ b/libtransport/src/interfaces/socket_consumer.cc
@@ -46,8 +46,6 @@ void ConsumerSocket::stop() { socket_->stop(); }
void ConsumerSocket::resume() { socket_->resume(); }
-bool ConsumerSocket::verifyKeyPackets() { return socket_->verifyKeyPackets(); }
-
asio::io_service &ConsumerSocket::getIoService() {
return socket_->getIoService();
}
@@ -88,22 +86,10 @@ int ConsumerSocket::setSocketOption(
}
int ConsumerSocket::setSocketOption(
- int socket_option_key,
- ConsumerContentObjectVerificationCallback socket_option_value) {
- return socket_->setSocketOption(socket_option_key, socket_option_value);
-}
-
-int ConsumerSocket::setSocketOption(
int socket_option_key, ConsumerInterestCallback socket_option_value) {
return socket_->setSocketOption(socket_option_key, socket_option_value);
}
-int ConsumerSocket::setSocketOption(
- int socket_option_key,
- ConsumerContentObjectVerificationFailedCallback socket_option_value) {
- return socket_->setSocketOption(socket_option_key, socket_option_value);
-}
-
int ConsumerSocket::setSocketOption(int socket_option_key,
IcnObserver *socket_option_value) {
return socket_->setSocketOption(socket_option_key, socket_option_value);
@@ -111,7 +97,7 @@ int ConsumerSocket::setSocketOption(int socket_option_key,
int ConsumerSocket::setSocketOption(
int socket_option_key,
- const std::shared_ptr<utils::Verifier> &socket_option_value) {
+ const std::shared_ptr<auth::Verifier> &socket_option_value) {
return socket_->setSocketOption(socket_option_key, socket_option_value);
}
@@ -152,22 +138,10 @@ int ConsumerSocket::getSocketOption(
}
int ConsumerSocket::getSocketOption(
- int socket_option_key,
- ConsumerContentObjectVerificationCallback **socket_option_value) {
- return socket_->setSocketOption(socket_option_key, socket_option_value);
-}
-
-int ConsumerSocket::getSocketOption(
int socket_option_key, ConsumerInterestCallback **socket_option_value) {
return socket_->setSocketOption(socket_option_key, socket_option_value);
}
-int ConsumerSocket::getSocketOption(
- int socket_option_key,
- ConsumerContentObjectVerificationFailedCallback **socket_option_value) {
- return socket_->setSocketOption(socket_option_key, socket_option_value);
-}
-
int ConsumerSocket::getSocketOption(int socket_option_key,
IcnObserver **socket_option_value) {
return socket_->getSocketOption(socket_option_key, socket_option_value);
@@ -175,7 +149,7 @@ int ConsumerSocket::getSocketOption(int socket_option_key,
int ConsumerSocket::getSocketOption(
int socket_option_key,
- std::shared_ptr<utils::Verifier> &socket_option_value) {
+ std::shared_ptr<auth::Verifier> &socket_option_value) {
return socket_->getSocketOption(socket_option_key, socket_option_value);
}
diff --git a/libtransport/src/interfaces/socket_producer.cc b/libtransport/src/interfaces/socket_producer.cc
index d030fe756..b04947dfd 100644
--- a/libtransport/src/interfaces/socket_producer.cc
+++ b/libtransport/src/interfaces/socket_producer.cc
@@ -14,7 +14,6 @@
*/
#include <hicn/transport/interfaces/socket_producer.h>
-
#include <implementation/socket_producer.h>
#include <atomic>
@@ -31,11 +30,12 @@ namespace interface {
using namespace core;
ProducerSocket::ProducerSocket(int protocol) {
- if (protocol != 0) {
- throw std::runtime_error("Production protocol must be 0.");
- }
+ socket_ = std::make_unique<implementation::ProducerSocket>(this, protocol);
+}
- socket_ = std::make_unique<implementation::ProducerSocket>(this);
+ProducerSocket::ProducerSocket(int protocol, asio::io_service &io_service) {
+ socket_ = std::make_unique<implementation::ProducerSocket>(this, protocol,
+ io_service);
}
ProducerSocket::ProducerSocket(bool) {}
@@ -46,19 +46,34 @@ void ProducerSocket::connect() { socket_->connect(); }
bool ProducerSocket::isRunning() { return socket_->isRunning(); }
-uint32_t ProducerSocket::produce(Name content_name,
- std::unique_ptr<utils::MemBuf> &&buffer,
- bool is_last, uint32_t start_offset) {
- return socket_->produce(content_name, std::move(buffer), is_last,
- start_offset);
+uint32_t ProducerSocket::produceStream(const Name &content_name,
+ std::unique_ptr<utils::MemBuf> &&buffer,
+ bool is_last, uint32_t start_offset) {
+ return socket_->produceStream(content_name, std::move(buffer), is_last,
+ start_offset);
}
-void ProducerSocket::produce(ContentObject &content_object) {
- return socket_->produce(content_object);
+uint32_t ProducerSocket::produceStream(const Name &content_name,
+ const uint8_t *buffer,
+ size_t buffer_size, bool is_last,
+ uint32_t start_offset) {
+ return socket_->produceStream(content_name, buffer, buffer_size, is_last,
+ start_offset);
}
-void ProducerSocket::produce(std::unique_ptr<utils::MemBuf> &&buffer) {
- socket_->produce(std::move(buffer));
+uint32_t ProducerSocket::produceDatagram(
+ const Name &content_name, std::unique_ptr<utils::MemBuf> &&buffer) {
+ return socket_->produceDatagram(content_name, std::move(buffer));
+}
+
+uint32_t ProducerSocket::produceDatagram(const Name &content_name,
+ const uint8_t *buffer,
+ size_t buffer_size) {
+ return socket_->produceDatagram(content_name, buffer, buffer_size);
+}
+
+void ProducerSocket::produce(ContentObject &content_object) {
+ return socket_->produce(content_object);
}
void ProducerSocket::asyncProduce(Name content_name,
@@ -69,16 +84,10 @@ void ProducerSocket::asyncProduce(Name content_name,
last_segment);
}
-void ProducerSocket::asyncProduce(ContentObject &content_object) {
- return socket_->asyncProduce(content_object);
-}
-
void ProducerSocket::registerPrefix(const Prefix &producer_namespace) {
return socket_->registerPrefix(producer_namespace);
}
-void ProducerSocket::serveForever() { return socket_->serveForever(); }
-
void ProducerSocket::stop() { return socket_->stop(); }
asio::io_service &ProducerSocket::getIoService() {
@@ -105,11 +114,6 @@ int ProducerSocket::setSocketOption(int socket_option_key,
return socket_->setSocketOption(socket_option_key, socket_option_value);
}
-int ProducerSocket::setSocketOption(int socket_option_key,
- std::list<Prefix> socket_option_value) {
- return socket_->setSocketOption(socket_option_key, socket_option_value);
-}
-
int ProducerSocket::setSocketOption(
int socket_option_key, ProducerContentObjectCallback socket_option_value) {
return socket_->setSocketOption(socket_option_key, socket_option_value);
@@ -126,18 +130,13 @@ int ProducerSocket::setSocketOption(
}
int ProducerSocket::setSocketOption(int socket_option_key,
- utils::CryptoHashType socket_option_value) {
- return socket_->setSocketOption(socket_option_key, socket_option_value);
-}
-
-int ProducerSocket::setSocketOption(int socket_option_key,
- utils::CryptoSuite socket_option_value) {
+ auth::CryptoHashType socket_option_value) {
return socket_->setSocketOption(socket_option_key, socket_option_value);
}
int ProducerSocket::setSocketOption(
int socket_option_key,
- const std::shared_ptr<utils::Signer> &socket_option_value) {
+ const std::shared_ptr<auth::Signer> &socket_option_value) {
return socket_->setSocketOption(socket_option_key, socket_option_value);
}
@@ -156,11 +155,6 @@ int ProducerSocket::getSocketOption(int socket_option_key,
return socket_->getSocketOption(socket_option_key, socket_option_value);
}
-int ProducerSocket::getSocketOption(int socket_option_key,
- std::list<Prefix> &socket_option_value) {
- return socket_->getSocketOption(socket_option_key, socket_option_value);
-}
-
int ProducerSocket::getSocketOption(
int socket_option_key,
ProducerContentObjectCallback **socket_option_value) {
@@ -177,19 +171,13 @@ int ProducerSocket::getSocketOption(
return socket_->getSocketOption(socket_option_key, socket_option_value);
}
-int ProducerSocket::getSocketOption(
- int socket_option_key, utils::CryptoHashType &socket_option_value) {
- return socket_->getSocketOption(socket_option_key, socket_option_value);
-}
-
int ProducerSocket::getSocketOption(int socket_option_key,
- utils::CryptoSuite &socket_option_value) {
+ auth::CryptoHashType &socket_option_value) {
return socket_->getSocketOption(socket_option_key, socket_option_value);
}
int ProducerSocket::getSocketOption(
- int socket_option_key,
- std::shared_ptr<utils::Signer> &socket_option_value) {
+ int socket_option_key, std::shared_ptr<auth::Signer> &socket_option_value) {
return socket_->getSocketOption(socket_option_key, socket_option_value);
}
diff --git a/libtransport/src/interfaces/tls_rtc_socket_producer.cc b/libtransport/src/interfaces/tls_rtc_socket_producer.cc
index 132f34721..7326fcbcb 100644
--- a/libtransport/src/interfaces/tls_rtc_socket_producer.cc
+++ b/libtransport/src/interfaces/tls_rtc_socket_producer.cc
@@ -13,9 +13,8 @@
* limitations under the License.
*/
-#include <interfaces/tls_rtc_socket_producer.h>
-
#include <implementation/tls_rtc_socket_producer.h>
+#include <interfaces/tls_rtc_socket_producer.h>
namespace transport {
namespace interface {
diff --git a/libtransport/src/interfaces/tls_socket_consumer.cc b/libtransport/src/interfaces/tls_socket_consumer.cc
index d87642f73..6c1c535b5 100644
--- a/libtransport/src/interfaces/tls_socket_consumer.cc
+++ b/libtransport/src/interfaces/tls_socket_consumer.cc
@@ -13,9 +13,8 @@
* limitations under the License.
*/
-#include <interfaces/tls_socket_consumer.h>
-
#include <implementation/tls_socket_consumer.h>
+#include <interfaces/tls_socket_consumer.h>
namespace transport {
namespace interface {
diff --git a/libtransport/src/interfaces/tls_socket_producer.cc b/libtransport/src/interfaces/tls_socket_producer.cc
index 44aa0cf8b..037702f72 100644
--- a/libtransport/src/interfaces/tls_socket_producer.cc
+++ b/libtransport/src/interfaces/tls_socket_producer.cc
@@ -13,9 +13,8 @@
* limitations under the License.
*/
-#include <interfaces/tls_socket_producer.h>
-
#include <implementation/tls_socket_producer.h>
+#include <interfaces/tls_socket_producer.h>
namespace transport {
namespace interface {