diff options
author | Angelo Mantellini <manangel@cisco.com> | 2019-01-30 12:11:34 +0100 |
---|---|---|
committer | Angelo Mantellini <manangel@cisco.com> | 2019-01-30 15:23:44 +0100 |
commit | e5145b878f9de35676085409878a66899d2ee4f2 (patch) | |
tree | 177f77810901921ee03d1d3b850600c5f2cd1ef9 /libtransport/src/hicn/transport/core | |
parent | 30061551cd39c9f30280bfa0cf3cc909f4fac015 (diff) |
[HICN-18] first commit of libtransport for windows
Change-Id: I3a43b22194aa13ae5de1746e3d4bd9a275070261
Signed-off-by: Angelo Mantellini <manangel@cisco.com>
Diffstat (limited to 'libtransport/src/hicn/transport/core')
-rw-r--r--[-rwxr-xr-x] | libtransport/src/hicn/transport/core/CMakeLists.txt | 0 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/content_object.cc | 2 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/hicn_forwarder_interface.cc | 1 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/interest.cc | 2 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/name.h | 2 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/packet.cc | 2 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/pending_interest.cc | 14 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/pending_interest.h | 8 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/portal.h | 35 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/prefix.cc | 4 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/socket_connector.cc | 12 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/socket_connector.h | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | libtransport/src/hicn/transport/core/test/CMakeLists.txt | 0 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc | 15 |
14 files changed, 59 insertions, 40 deletions
diff --git a/libtransport/src/hicn/transport/core/CMakeLists.txt b/libtransport/src/hicn/transport/core/CMakeLists.txt index a97e74b2a..a97e74b2a 100755..100644 --- a/libtransport/src/hicn/transport/core/CMakeLists.txt +++ b/libtransport/src/hicn/transport/core/CMakeLists.txt diff --git a/libtransport/src/hicn/transport/core/content_object.cc b/libtransport/src/hicn/transport/core/content_object.cc index dc2056582..4cd5623c4 100644 --- a/libtransport/src/hicn/transport/core/content_object.cc +++ b/libtransport/src/hicn/transport/core/content_object.cc @@ -18,7 +18,9 @@ #include <hicn/transport/utils/branch_prediction.h> extern "C" { +#ifndef _WIN32 TRANSPORT_CLANG_DISABLE_WARNING("-Wextern-c-compat") +#endif #include <hicn/hicn.h> } diff --git a/libtransport/src/hicn/transport/core/hicn_forwarder_interface.cc b/libtransport/src/hicn/transport/core/hicn_forwarder_interface.cc index 1d82ff0b0..e8b38cd7b 100644 --- a/libtransport/src/hicn/transport/core/hicn_forwarder_interface.cc +++ b/libtransport/src/hicn/transport/core/hicn_forwarder_interface.cc @@ -15,7 +15,6 @@ #include <hicn/transport/core/hicn_forwarder_interface.h> - #define ADDR_INET 1 #define ADDR_INET6 2 #define ADD_ROUTE 3 diff --git a/libtransport/src/hicn/transport/core/interest.cc b/libtransport/src/hicn/transport/core/interest.cc index ff4a5bb34..4ea0c4419 100644 --- a/libtransport/src/hicn/transport/core/interest.cc +++ b/libtransport/src/hicn/transport/core/interest.cc @@ -18,7 +18,9 @@ #include <hicn/transport/utils/hash.h> extern "C" { +#ifndef _WIN32 TRANSPORT_CLANG_DISABLE_WARNING("-Wextern-c-compat") +#endif #include <hicn/hicn.h> } diff --git a/libtransport/src/hicn/transport/core/name.h b/libtransport/src/hicn/transport/core/name.h index b0da15026..b2f913986 100644 --- a/libtransport/src/hicn/transport/core/name.h +++ b/libtransport/src/hicn/transport/core/name.h @@ -24,7 +24,9 @@ #include <unordered_map> extern "C" { +#ifndef _WIN32 TRANSPORT_CLANG_DISABLE_WARNING("-Wextern-c-compat") +#endif #include <hicn/hicn.h> }; diff --git a/libtransport/src/hicn/transport/core/packet.cc b/libtransport/src/hicn/transport/core/packet.cc index 69cbb3cb3..dd150d723 100644 --- a/libtransport/src/hicn/transport/core/packet.cc +++ b/libtransport/src/hicn/transport/core/packet.cc @@ -19,7 +19,9 @@ #include <hicn/transport/utils/log.h> extern "C" { +#ifndef _WIN32 TRANSPORT_CLANG_DISABLE_WARNING("-Wextern-c-compat") +#endif #include <hicn/error.h> } diff --git a/libtransport/src/hicn/transport/core/pending_interest.cc b/libtransport/src/hicn/transport/core/pending_interest.cc index a2df9ba44..73bc41e87 100644 --- a/libtransport/src/hicn/transport/core/pending_interest.cc +++ b/libtransport/src/hicn/transport/core/pending_interest.cc @@ -34,10 +34,10 @@ PendingInterest::PendingInterest(Interest::Ptr &&interest, on_interest_timeout_callback_(), received_(false) {} -PendingInterest::PendingInterest(Interest::Ptr &&interest, - const OnContentObjectCallback &&on_content_object, - const OnInterestTimeoutCallback &&on_interest_timeout, - std::unique_ptr<asio::steady_timer> &&timer) +PendingInterest::PendingInterest( + Interest::Ptr &&interest, const OnContentObjectCallback &&on_content_object, + const OnInterestTimeoutCallback &&on_interest_timeout, + std::unique_ptr<asio::steady_timer> &&timer) : interest_(std::move(interest)), timer_(std::move(timer)), on_content_object_callback_(std::move(on_content_object)), @@ -60,7 +60,8 @@ const OnContentObjectCallback &PendingInterest::getOnDataCallback() const { return on_content_object_callback_; } -void PendingInterest::setOnDataCallback(const OnContentObjectCallback &on_content_object) { +void PendingInterest::setOnDataCallback( + const OnContentObjectCallback &on_content_object) { PendingInterest::on_content_object_callback_ = on_content_object; } @@ -68,7 +69,8 @@ const OnInterestTimeoutCallback &PendingInterest::getOnTimeoutCallback() const { return on_interest_timeout_callback_; } -void PendingInterest::setOnTimeoutCallback(const OnInterestTimeoutCallback &on_interest_timeout) { +void PendingInterest::setOnTimeoutCallback( + const OnInterestTimeoutCallback &on_interest_timeout) { PendingInterest::on_interest_timeout_callback_ = on_interest_timeout; } diff --git a/libtransport/src/hicn/transport/core/pending_interest.h b/libtransport/src/hicn/transport/core/pending_interest.h index 58b51db79..9a26c7b2b 100644 --- a/libtransport/src/hicn/transport/core/pending_interest.h +++ b/libtransport/src/hicn/transport/core/pending_interest.h @@ -34,8 +34,9 @@ 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(Interest::Ptr &&, ContentObject::Ptr &&)> + OnContentObjectCallback; +typedef std::function<void(Interest::Ptr &&)> OnInterestTimeoutCallback; typedef std::function<void(const std::error_code &)> TimerCallback; class PendingInterest { @@ -77,7 +78,8 @@ class PendingInterest { const OnInterestTimeoutCallback &getOnTimeoutCallback() const; - void setOnTimeoutCallback(const OnInterestTimeoutCallback &on_interest_timeout); + void setOnTimeoutCallback( + const OnInterestTimeoutCallback &on_interest_timeout); private: Interest::Ptr interest_; diff --git a/libtransport/src/hicn/transport/core/portal.h b/libtransport/src/hicn/transport/core/portal.h index 58406bbde..0932b56c6 100644 --- a/libtransport/src/hicn/transport/core/portal.h +++ b/libtransport/src/hicn/transport/core/portal.h @@ -127,9 +127,7 @@ class Portal { forwarder_interface_.connect(is_consumer); } - ~Portal() { - stopEventsLoop(true); - } + ~Portal() { stopEventsLoop(true); } TRANSPORT_ALWAYS_INLINE bool interestIsPending(const Name &name) { auto it = pending_interest_hash_table_.find(name); @@ -153,10 +151,10 @@ class Portal { std::placeholders::_1, name)); } - TRANSPORT_ALWAYS_INLINE void sendInterest(Interest::Ptr &&interest, - const OnContentObjectCallback &&on_content_object_callback, - const OnInterestTimeoutCallback &&on_interest_timeout_callback) { - + TRANSPORT_ALWAYS_INLINE void sendInterest( + Interest::Ptr &&interest, + const OnContentObjectCallback &&on_content_object_callback, + const OnInterestTimeoutCallback &&on_interest_timeout_callback) { const Name name(interest->getName(), true); // Send it @@ -168,9 +166,8 @@ class Portal { std::make_unique<asio::steady_timer>(io_service_)); pending_interest_hash_table_[name]->startCountdown( - std::bind(&Portal<ForwarderInt>::timerHandler, - this, std::placeholders::_1, name)); - + std::bind(&Portal<ForwarderInt>::timerHandler, this, + std::placeholders::_1, name)); } TRANSPORT_ALWAYS_INLINE void timerHandler(const std::error_code &ec, @@ -187,9 +184,9 @@ class Portal { std::unique_ptr<PendingInterest> ptr = std::move(it->second); pending_interest_hash_table_.erase(it); - if(ptr->getOnTimeoutCallback() != UNSET_CALLBACK){ - ptr->on_interest_timeout_callback_(std::move(ptr->getInterest())); - }else if (consumer_callback_) { + if (ptr->getOnTimeoutCallback() != UNSET_CALLBACK) { + ptr->on_interest_timeout_callback_(std::move(ptr->getInterest())); + } else if (consumer_callback_) { consumer_callback_->onTimeout(std::move(ptr->getInterest())); } } @@ -231,7 +228,7 @@ class Portal { clear(); - if(kill_connection) { + if (kill_connection) { connector_.close(); } @@ -310,11 +307,11 @@ class Portal { interest_ptr->setReceived(); pending_interest_hash_table_.erase(content_object->getName()); - if(interest_ptr->getOnDataCallback() != UNSET_CALLBACK){ - interest_ptr->on_content_object_callback_( - std::move(interest_ptr->getInterest()), - std::move(content_object)); - }else if (consumer_callback_) { + if (interest_ptr->getOnDataCallback() != UNSET_CALLBACK) { + interest_ptr->on_content_object_callback_( + std::move(interest_ptr->getInterest()), + std::move(content_object)); + } else if (consumer_callback_) { consumer_callback_->onContentObject( std::move(interest_ptr->getInterest()), std::move(content_object)); diff --git a/libtransport/src/hicn/transport/core/prefix.cc b/libtransport/src/hicn/transport/core/prefix.cc index 69c2b845a..575bcc2ed 100644 --- a/libtransport/src/hicn/transport/core/prefix.cc +++ b/libtransport/src/hicn/transport/core/prefix.cc @@ -17,9 +17,13 @@ #include <hicn/transport/errors/errors.h> #include <hicn/transport/utils/string_tokenizer.h> +#ifndef _WIN32 extern "C" { #include <arpa/inet.h> } +#else +#include <hicn/transport/portability/win_portability.h> +#endif #include <cstring> #include <memory> diff --git a/libtransport/src/hicn/transport/core/socket_connector.cc b/libtransport/src/hicn/transport/core/socket_connector.cc index 704d3badb..84a843f14 100644 --- a/libtransport/src/hicn/transport/core/socket_connector.cc +++ b/libtransport/src/hicn/transport/core/socket_connector.cc @@ -13,6 +13,9 @@ * limitations under the License. */ +#ifdef _WIN32 +#include <hicn/transport/portability/win_portability.h> +#endif #include <hicn/transport/core/socket_connector.h> #include <hicn/transport/errors/errors.h> #include <hicn/transport/utils/log.h> @@ -130,7 +133,8 @@ void SocketConnector::doWrite() { if (!output_buffer_.empty()) { doWrite(); } - } else if (ec.value() == static_cast<int>(std::errc::operation_canceled)) { + } else if (ec.value() == + static_cast<int>(std::errc::operation_canceled)) { // The connection has been closed by the application. return; } else { @@ -149,7 +153,8 @@ void SocketConnector::doReadBody(std::size_t body_length) { if (TRANSPORT_EXPECT_TRUE(!ec)) { receive_callback_(std::move(read_msg_)); doReadHeader(); - } else if (ec.value() == static_cast<int>(std::errc::operation_canceled)) { + } else if (ec.value() == + static_cast<int>(std::errc::operation_canceled)) { // The connection has been closed by the application. return; } else { @@ -176,7 +181,8 @@ void SocketConnector::doReadHeader() { } else { TRANSPORT_LOGE("Decoding error. Ignoring packet."); } - } else if (ec.value() == static_cast<int>(std::errc::operation_canceled)) { + } else if (ec.value() == + static_cast<int>(std::errc::operation_canceled)) { // The connection has been closed by the application. return; } else { diff --git a/libtransport/src/hicn/transport/core/socket_connector.h b/libtransport/src/hicn/transport/core/socket_connector.h index e014111e2..6eff1aff5 100644 --- a/libtransport/src/hicn/transport/core/socket_connector.h +++ b/libtransport/src/hicn/transport/core/socket_connector.h @@ -19,8 +19,8 @@ #include <hicn/transport/core/name.h> #include <hicn/transport/utils/branch_prediction.h> -#include <asio/steady_timer.hpp> #include <asio.hpp> +#include <asio/steady_timer.hpp> #include <deque> namespace transport { diff --git a/libtransport/src/hicn/transport/core/test/CMakeLists.txt b/libtransport/src/hicn/transport/core/test/CMakeLists.txt index 48c50e9b0..48c50e9b0 100755..100644 --- a/libtransport/src/hicn/transport/core/test/CMakeLists.txt +++ b/libtransport/src/hicn/transport/core/test/CMakeLists.txt diff --git a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc index 0335c3829..828e31a0a 100644 --- a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc +++ b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc @@ -45,7 +45,8 @@ VPPForwarderInterface::VPPForwarderInterface(MemifConnector &connector) VPPForwarderInterface::~VPPForwarderInterface() { if (sw_if_index_ != uint32_t(~0) && VPPForwarderInterface::memif_api_) { - int ret = memif_binary_api_delete_memif(VPPForwarderInterface::memif_api_, sw_if_index_); + int ret = memif_binary_api_delete_memif(VPPForwarderInterface::memif_api_, + sw_if_index_); if (ret < 0) { TRANSPORT_LOGE("Error deleting memif with sw idx %u.", sw_if_index_); @@ -82,7 +83,7 @@ uint32_t VPPForwarderInterface::getMemifConfiguration() { memif_output_params_t output_params = {0}; ret = memif_binary_api_create_memif(VPPForwarderInterface::memif_api_, - &input_params, &output_params); + &input_params, &output_params); if (ret < 0) { throw errors::RuntimeException( @@ -105,8 +106,8 @@ void VPPForwarderInterface::consumerConnection() { input.swif = sw_if_index_; - int ret = hicn_binary_api_register_cons_app( - VPPForwarderInterface::hicn_api_, &input, &output); + int ret = hicn_binary_api_register_cons_app(VPPForwarderInterface::hicn_api_, + &input, &output); if (ret < 0) { throw errors::RuntimeException(hicn_binary_api_get_error_string(ret)); @@ -178,7 +179,7 @@ void VPPForwarderInterface::registerRoute(Prefix &prefix) { input.cs_reserved = content_store_reserved_; int ret = hicn_binary_api_register_prod_app( - VPPForwarderInterface::hicn_api_, &input, &output); + VPPForwarderInterface::hicn_api_, &input, &output); if (ret < 0) { throw errors::RuntimeException(hicn_binary_api_get_error_string(ret)); @@ -206,8 +207,8 @@ void VPPForwarderInterface::registerRoute(Prefix &prefix) { params.prefix->prefix_len = addr.prefix_len; params.face_id = face_id_; - int ret = hicn_binary_api_register_route( - VPPForwarderInterface::hicn_api_, ¶ms); + int ret = hicn_binary_api_register_route(VPPForwarderInterface::hicn_api_, + ¶ms); if (ret < 0) { throw errors::RuntimeException(hicn_binary_api_get_error_string(ret)); |