From 6b94663b2455e212009a544ae23bb6a8c55407f8 Mon Sep 17 00:00:00 2001 From: Luca Muscariello Date: Thu, 9 Jun 2022 21:34:09 +0200 Subject: refactor(lib, hicn-light, vpp, hiperf): HICN-723 - move infra data structure into the shared lib - new packet cache using double hashing and lookup on prefix suffix - testing updates - authenticated requests using interest manifests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mauro Sardara Co-authored-by: Jordan Augé Co-authored-by: Michele Papalini Co-authored-by: Olivier Roques Co-authored-by: Enrico Loparco Change-Id: Iaddebfe6aa5279ea8553433b0f519578f6b9ccd9 Signed-off-by: Luca Muscariello --- libtransport/src/interfaces/CMakeLists.txt | 16 ---------- .../src/interfaces/global_configuration.cc | 22 ++++++++++++- .../src/interfaces/p2psecure_socket_consumer.cc | 37 ---------------------- .../src/interfaces/p2psecure_socket_producer.cc | 34 -------------------- libtransport/src/interfaces/portal.cc | 8 ++--- libtransport/src/interfaces/socket_consumer.cc | 11 +++++++ libtransport/src/interfaces/socket_producer.cc | 12 +++++++ .../src/interfaces/tls_rtc_socket_producer.cc | 31 ------------------ .../src/interfaces/tls_rtc_socket_producer.h | 36 --------------------- libtransport/src/interfaces/tls_socket_consumer.cc | 30 ------------------ libtransport/src/interfaces/tls_socket_consumer.h | 36 --------------------- libtransport/src/interfaces/tls_socket_producer.cc | 30 ------------------ libtransport/src/interfaces/tls_socket_producer.h | 36 --------------------- 13 files changed, 48 insertions(+), 291 deletions(-) delete mode 100644 libtransport/src/interfaces/p2psecure_socket_consumer.cc delete mode 100644 libtransport/src/interfaces/p2psecure_socket_producer.cc delete mode 100644 libtransport/src/interfaces/tls_rtc_socket_producer.cc delete mode 100644 libtransport/src/interfaces/tls_rtc_socket_producer.h delete mode 100644 libtransport/src/interfaces/tls_socket_consumer.cc delete mode 100644 libtransport/src/interfaces/tls_socket_consumer.h delete mode 100644 libtransport/src/interfaces/tls_socket_producer.cc delete mode 100644 libtransport/src/interfaces/tls_socket_producer.h (limited to 'libtransport/src/interfaces') diff --git a/libtransport/src/interfaces/CMakeLists.txt b/libtransport/src/interfaces/CMakeLists.txt index 0a0603ac8..bf8f8dcf8 100644 --- a/libtransport/src/interfaces/CMakeLists.txt +++ b/libtransport/src/interfaces/CMakeLists.txt @@ -19,20 +19,4 @@ list(APPEND SOURCE_FILES ${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_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_socket_producer.h - ${CMAKE_CURRENT_SOURCE_DIR}/tls_socket_consumer.h - ) -endif() - set(SOURCE_FILES ${SOURCE_FILES} PARENT_SCOPE) diff --git a/libtransport/src/interfaces/global_configuration.cc b/libtransport/src/interfaces/global_configuration.cc index cecdacc07..f8e7a90c3 100644 --- a/libtransport/src/interfaces/global_configuration.cc +++ b/libtransport/src/interfaces/global_configuration.cc @@ -14,6 +14,7 @@ */ #include +#include #include #include @@ -23,10 +24,29 @@ namespace transport { namespace interface { namespace global_config { -void parseConfigurationFile(const std::string& path) { +GlobalConfigInterface::GlobalConfigInterface() { libtransportConfigInit(); } + +GlobalConfigInterface::~GlobalConfigInterface() { + libtransportConfigTerminate(); +} + +void GlobalConfigInterface::parseConfigurationFile( + const std::string &path) const { core::GlobalConfiguration::getInstance().parseConfiguration(path); } +void GlobalConfigInterface::libtransportConfigInit() const { + // nothing to do +} + +void GlobalConfigInterface::libtransportConfigTerminate() const { + // cleanup workers + auto &workers = core::GlobalWorkers::getInstance().getWorkers(); + for (auto &worker : workers) { + worker.stop(); + } +} + void ConfigurationObject::get() { std::error_code ec; core::GlobalConfiguration::getInstance().getConfiguration(*this, ec); diff --git a/libtransport/src/interfaces/p2psecure_socket_consumer.cc b/libtransport/src/interfaces/p2psecure_socket_consumer.cc deleted file mode 100644 index e329a50f1..000000000 --- a/libtransport/src/interfaces/p2psecure_socket_consumer.cc +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 -#include - -namespace transport { -namespace interface { - -P2PSecureConsumerSocket::P2PSecureConsumerSocket(int handshake_protocol, - int transport_protocol) - : ConsumerSocket() { - socket_ = std::unique_ptr( - new implementation::P2PSecureConsumerSocket(this, handshake_protocol, - transport_protocol)); -} - -void P2PSecureConsumerSocket::registerPrefix(const Prefix &producer_namespace) { - implementation::P2PSecureConsumerSocket &secure_consumer_socket = - *(static_cast(socket_.get())); - secure_consumer_socket.registerPrefix(producer_namespace); -} - -} // namespace interface -} // namespace transport diff --git a/libtransport/src/interfaces/p2psecure_socket_producer.cc b/libtransport/src/interfaces/p2psecure_socket_producer.cc deleted file mode 100644 index 5f98302d0..000000000 --- a/libtransport/src/interfaces/p2psecure_socket_producer.cc +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 -#include - -namespace transport { -namespace interface { - -P2PSecureProducerSocket::P2PSecureProducerSocket() { - socket_ = std::make_unique(this); -} - -P2PSecureProducerSocket::P2PSecureProducerSocket(bool rtc, - std::string &keystore_path, - std::string &keystore_pwd) { - socket_ = std::make_unique( - this, rtc, keystore_path, keystore_pwd); -} - -} // namespace interface -} // namespace transport diff --git a/libtransport/src/interfaces/portal.cc b/libtransport/src/interfaces/portal.cc index 84634a282..898766c50 100644 --- a/libtransport/src/interfaces/portal.cc +++ b/libtransport/src/interfaces/portal.cc @@ -35,10 +35,10 @@ class Portal::Impl { return portal_->interestIsPending(name); } - void sendInterest(core::Interest::Ptr &&interest, + void sendInterest(core::Interest::Ptr &interest, uint32_t lifetime, OnContentObjectCallback &&on_content_object_callback, OnInterestTimeoutCallback &&on_interest_timeout_callback) { - portal_->sendInterest(std::move(interest), + portal_->sendInterest(interest, lifetime, std::move(on_content_object_callback), std::move(on_interest_timeout_callback)); } @@ -86,10 +86,10 @@ bool Portal::interestIsPending(const core::Name &name) { } void Portal::sendInterest( - core::Interest::Ptr &&interest, + core::Interest::Ptr &interest, uint32_t lifetime, OnContentObjectCallback &&on_content_object_callback, OnInterestTimeoutCallback &&on_interest_timeout_callback) { - implementation_->sendInterest(std::move(interest), + implementation_->sendInterest(interest, lifetime, std::move(on_content_object_callback), std::move(on_interest_timeout_callback)); } diff --git a/libtransport/src/interfaces/socket_consumer.cc b/libtransport/src/interfaces/socket_consumer.cc index 747dc0974..cc496c8a5 100644 --- a/libtransport/src/interfaces/socket_consumer.cc +++ b/libtransport/src/interfaces/socket_consumer.cc @@ -100,6 +100,12 @@ int ConsumerSocket::setSocketOption(int socket_option_key, return socket_->setSocketOption(socket_option_key, socket_option_value); } +int ConsumerSocket::setSocketOption( + int socket_option_key, + const std::shared_ptr &socket_option_value) { + return socket_->setSocketOption(socket_option_key, socket_option_value); +} + int ConsumerSocket::setSocketOption( int socket_option_key, const std::shared_ptr &socket_option_value) { @@ -162,6 +168,11 @@ int ConsumerSocket::getSocketOption(int socket_option_key, return socket_->getSocketOption(socket_option_key, socket_option_value); } +int ConsumerSocket::getSocketOption( + int socket_option_key, std::shared_ptr &socket_option_value) { + return socket_->getSocketOption(socket_option_key, socket_option_value); +} + int ConsumerSocket::getSocketOption( int socket_option_key, std::shared_ptr &socket_option_value) { diff --git a/libtransport/src/interfaces/socket_producer.cc b/libtransport/src/interfaces/socket_producer.cc index 10613c0e1..2155ebd78 100644 --- a/libtransport/src/interfaces/socket_producer.cc +++ b/libtransport/src/interfaces/socket_producer.cc @@ -148,6 +148,12 @@ int ProducerSocket::setSocketOption( return socket_->setSocketOption(socket_option_key, socket_option_value); } +int ProducerSocket::setSocketOption( + int socket_option_key, + const std::shared_ptr &socket_option_value) { + return socket_->setSocketOption(socket_option_key, socket_option_value); +} + int ProducerSocket::setSocketOption(int socket_option_key, Packet::Format socket_option_value) { return socket_->setSocketOption(socket_option_key, socket_option_value); @@ -194,6 +200,12 @@ int ProducerSocket::getSocketOption( return socket_->getSocketOption(socket_option_key, socket_option_value); } +int ProducerSocket::getSocketOption( + int socket_option_key, + std::shared_ptr &socket_option_value) { + return socket_->getSocketOption(socket_option_key, socket_option_value); +} + int ProducerSocket::getSocketOption(int socket_option_key, Packet::Format &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 deleted file mode 100644 index 6bf1b011c..000000000 --- a/libtransport/src/interfaces/tls_rtc_socket_producer.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 -#include - -namespace transport { -namespace interface { - -TLSRTCProducerSocket::TLSRTCProducerSocket( - implementation::TLSRTCProducerSocket *implementation) { - socket_ = - std::unique_ptr(implementation); -} - -TLSRTCProducerSocket::~TLSRTCProducerSocket() { socket_.release(); } - -} // namespace interface -} // namespace transport diff --git a/libtransport/src/interfaces/tls_rtc_socket_producer.h b/libtransport/src/interfaces/tls_rtc_socket_producer.h deleted file mode 100644 index b8b6ec298..000000000 --- a/libtransport/src/interfaces/tls_rtc_socket_producer.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 - -namespace transport { - -namespace implementation { -class TLSRTCProducerSocket; -} - -namespace interface { - -class TLSRTCProducerSocket : public ProducerSocket { - public: - TLSRTCProducerSocket(implementation::TLSRTCProducerSocket *implementation); - - ~TLSRTCProducerSocket(); -}; - -} // namespace interface -} // end namespace transport diff --git a/libtransport/src/interfaces/tls_socket_consumer.cc b/libtransport/src/interfaces/tls_socket_consumer.cc deleted file mode 100644 index 24060d1d8..000000000 --- a/libtransport/src/interfaces/tls_socket_consumer.cc +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 -#include - -namespace transport { -namespace interface { - -TLSConsumerSocket::TLSConsumerSocket( - implementation::TLSConsumerSocket *implementation) { - socket_ = std::unique_ptr(implementation); -} - -TLSConsumerSocket::~TLSConsumerSocket() { socket_.release(); } - -} // namespace interface -} // namespace transport diff --git a/libtransport/src/interfaces/tls_socket_consumer.h b/libtransport/src/interfaces/tls_socket_consumer.h deleted file mode 100644 index 242dc91a5..000000000 --- a/libtransport/src/interfaces/tls_socket_consumer.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 - -namespace transport { - -namespace implementation { -class TLSConsumerSocket; -} - -namespace interface { - -class TLSConsumerSocket : public ConsumerSocket { - public: - TLSConsumerSocket(implementation::TLSConsumerSocket *implementation); - ~TLSConsumerSocket(); -}; - -} // namespace interface - -} // end namespace transport diff --git a/libtransport/src/interfaces/tls_socket_producer.cc b/libtransport/src/interfaces/tls_socket_producer.cc deleted file mode 100644 index b2b9e723a..000000000 --- a/libtransport/src/interfaces/tls_socket_producer.cc +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 -#include - -namespace transport { -namespace interface { - -TLSProducerSocket::TLSProducerSocket( - implementation::TLSProducerSocket *implementation) { - socket_ = std::unique_ptr(implementation); -} - -TLSProducerSocket::~TLSProducerSocket() { socket_.release(); } - -} // namespace interface -} // namespace transport diff --git a/libtransport/src/interfaces/tls_socket_producer.h b/libtransport/src/interfaces/tls_socket_producer.h deleted file mode 100644 index 9b31cb483..000000000 --- a/libtransport/src/interfaces/tls_socket_producer.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 - -namespace transport { - -namespace implementation { -class TLSProducerSocket; -} - -namespace interface { - -class TLSProducerSocket : public ProducerSocket { - public: - TLSProducerSocket(implementation::TLSProducerSocket *implementation); - ~TLSProducerSocket(); -}; - -} // namespace interface - -} // end namespace transport -- cgit 1.2.3-korg