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 | |
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')
122 files changed, 216 insertions, 123 deletions
diff --git a/libtransport/src/hicn/transport/CMakeLists.txt b/libtransport/src/hicn/transport/CMakeLists.txt index fd5721273..fd5721273 100755..100644 --- a/libtransport/src/hicn/transport/CMakeLists.txt +++ b/libtransport/src/hicn/transport/CMakeLists.txt diff --git a/libtransport/src/hicn/transport/config.h.in b/libtransport/src/hicn/transport/config.h.in index a140f4b78..a140f4b78 100755..100644 --- a/libtransport/src/hicn/transport/config.h.in +++ b/libtransport/src/hicn/transport/config.h.in 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)); diff --git a/libtransport/src/hicn/transport/errors/CMakeLists.txt b/libtransport/src/hicn/transport/errors/CMakeLists.txt index 1c19a9070..1c19a9070 100755..100644 --- a/libtransport/src/hicn/transport/errors/CMakeLists.txt +++ b/libtransport/src/hicn/transport/errors/CMakeLists.txt diff --git a/libtransport/src/hicn/transport/errors/errors.h b/libtransport/src/hicn/transport/errors/errors.h index 512e35736..512e35736 100755..100644 --- a/libtransport/src/hicn/transport/errors/errors.h +++ b/libtransport/src/hicn/transport/errors/errors.h diff --git a/libtransport/src/hicn/transport/errors/invalid_ip_address_exception.h b/libtransport/src/hicn/transport/errors/invalid_ip_address_exception.h index 60226f576..60226f576 100755..100644 --- a/libtransport/src/hicn/transport/errors/invalid_ip_address_exception.h +++ b/libtransport/src/hicn/transport/errors/invalid_ip_address_exception.h diff --git a/libtransport/src/hicn/transport/errors/malformed_ahpacket_exception.h b/libtransport/src/hicn/transport/errors/malformed_ahpacket_exception.h index f0cfe0b82..f0cfe0b82 100755..100644 --- a/libtransport/src/hicn/transport/errors/malformed_ahpacket_exception.h +++ b/libtransport/src/hicn/transport/errors/malformed_ahpacket_exception.h diff --git a/libtransport/src/hicn/transport/errors/malformed_name_exception.h b/libtransport/src/hicn/transport/errors/malformed_name_exception.h index 4ef45d2e8..4ef45d2e8 100755..100644 --- a/libtransport/src/hicn/transport/errors/malformed_name_exception.h +++ b/libtransport/src/hicn/transport/errors/malformed_name_exception.h diff --git a/libtransport/src/hicn/transport/errors/malformed_packet_exception.h b/libtransport/src/hicn/transport/errors/malformed_packet_exception.h index ec5c97e6e..ec5c97e6e 100755..100644 --- a/libtransport/src/hicn/transport/errors/malformed_packet_exception.h +++ b/libtransport/src/hicn/transport/errors/malformed_packet_exception.h diff --git a/libtransport/src/hicn/transport/errors/not_implemented_exception.h b/libtransport/src/hicn/transport/errors/not_implemented_exception.h index e9869163d..e9869163d 100755..100644 --- a/libtransport/src/hicn/transport/errors/not_implemented_exception.h +++ b/libtransport/src/hicn/transport/errors/not_implemented_exception.h diff --git a/libtransport/src/hicn/transport/errors/null_pointer_exception.h b/libtransport/src/hicn/transport/errors/null_pointer_exception.h index bd06485ed..bd06485ed 100755..100644 --- a/libtransport/src/hicn/transport/errors/null_pointer_exception.h +++ b/libtransport/src/hicn/transport/errors/null_pointer_exception.h diff --git a/libtransport/src/hicn/transport/errors/runtime_exception.h b/libtransport/src/hicn/transport/errors/runtime_exception.h index ba5128a7e..ba5128a7e 100755..100644 --- a/libtransport/src/hicn/transport/errors/runtime_exception.h +++ b/libtransport/src/hicn/transport/errors/runtime_exception.h diff --git a/libtransport/src/hicn/transport/errors/tokenizer_exception.h b/libtransport/src/hicn/transport/errors/tokenizer_exception.h index 76eda838e..76eda838e 100755..100644 --- a/libtransport/src/hicn/transport/errors/tokenizer_exception.h +++ b/libtransport/src/hicn/transport/errors/tokenizer_exception.h diff --git a/libtransport/src/hicn/transport/http/CMakeLists.txt b/libtransport/src/hicn/transport/http/CMakeLists.txt index ddcf1fdc3..ddcf1fdc3 100755..100644 --- a/libtransport/src/hicn/transport/http/CMakeLists.txt +++ b/libtransport/src/hicn/transport/http/CMakeLists.txt diff --git a/libtransport/src/hicn/transport/http/callbacks.h b/libtransport/src/hicn/transport/http/callbacks.h index 5ca5fcbe2..5ca5fcbe2 100755..100644 --- a/libtransport/src/hicn/transport/http/callbacks.h +++ b/libtransport/src/hicn/transport/http/callbacks.h diff --git a/libtransport/src/hicn/transport/http/client_connection.cc b/libtransport/src/hicn/transport/http/client_connection.cc index d4207bb81..d4207bb81 100755..100644 --- a/libtransport/src/hicn/transport/http/client_connection.cc +++ b/libtransport/src/hicn/transport/http/client_connection.cc diff --git a/libtransport/src/hicn/transport/http/client_connection.h b/libtransport/src/hicn/transport/http/client_connection.h index f6e1fa03e..f6e1fa03e 100755..100644 --- a/libtransport/src/hicn/transport/http/client_connection.h +++ b/libtransport/src/hicn/transport/http/client_connection.h diff --git a/libtransport/src/hicn/transport/http/default_values.h b/libtransport/src/hicn/transport/http/default_values.h index 2d5a6b821..2d5a6b821 100755..100644 --- a/libtransport/src/hicn/transport/http/default_values.h +++ b/libtransport/src/hicn/transport/http/default_values.h diff --git a/libtransport/src/hicn/transport/http/facade.h b/libtransport/src/hicn/transport/http/facade.h index 31c2d1b8d..31c2d1b8d 100755..100644 --- a/libtransport/src/hicn/transport/http/facade.h +++ b/libtransport/src/hicn/transport/http/facade.h diff --git a/libtransport/src/hicn/transport/http/message.h b/libtransport/src/hicn/transport/http/message.h index 7d4485c90..b2f271bcb 100755..100644 --- a/libtransport/src/hicn/transport/http/message.h +++ b/libtransport/src/hicn/transport/http/message.h @@ -15,6 +15,10 @@ #pragma once +#ifdef _WIN32 +#include <hicn/transport/portability/win_portability.h> +#endif + #include <hicn/transport/utils/sharable_vector.h> #include <map> diff --git a/libtransport/src/hicn/transport/http/request.cc b/libtransport/src/hicn/transport/http/request.cc index 7a63b4f75..7a63b4f75 100755..100644 --- a/libtransport/src/hicn/transport/http/request.cc +++ b/libtransport/src/hicn/transport/http/request.cc diff --git a/libtransport/src/hicn/transport/http/request.h b/libtransport/src/hicn/transport/http/request.h index 88d67d4ad..88d67d4ad 100755..100644 --- a/libtransport/src/hicn/transport/http/request.h +++ b/libtransport/src/hicn/transport/http/request.h diff --git a/libtransport/src/hicn/transport/http/response.cc b/libtransport/src/hicn/transport/http/response.cc index 0aa9affe8..0aa9affe8 100755..100644 --- a/libtransport/src/hicn/transport/http/response.cc +++ b/libtransport/src/hicn/transport/http/response.cc diff --git a/libtransport/src/hicn/transport/http/response.h b/libtransport/src/hicn/transport/http/response.h index e7dec8c40..e7dec8c40 100755..100644 --- a/libtransport/src/hicn/transport/http/response.h +++ b/libtransport/src/hicn/transport/http/response.h diff --git a/libtransport/src/hicn/transport/http/server_acceptor.cc b/libtransport/src/hicn/transport/http/server_acceptor.cc index 717dfb642..717dfb642 100755..100644 --- a/libtransport/src/hicn/transport/http/server_acceptor.cc +++ b/libtransport/src/hicn/transport/http/server_acceptor.cc diff --git a/libtransport/src/hicn/transport/http/server_acceptor.h b/libtransport/src/hicn/transport/http/server_acceptor.h index 549962414..549962414 100755..100644 --- a/libtransport/src/hicn/transport/http/server_acceptor.h +++ b/libtransport/src/hicn/transport/http/server_acceptor.h diff --git a/libtransport/src/hicn/transport/http/server_publisher.cc b/libtransport/src/hicn/transport/http/server_publisher.cc index 012f36091..012f36091 100755..100644 --- a/libtransport/src/hicn/transport/http/server_publisher.cc +++ b/libtransport/src/hicn/transport/http/server_publisher.cc diff --git a/libtransport/src/hicn/transport/http/server_publisher.h b/libtransport/src/hicn/transport/http/server_publisher.h index 91f7e43e9..91f7e43e9 100755..100644 --- a/libtransport/src/hicn/transport/http/server_publisher.h +++ b/libtransport/src/hicn/transport/http/server_publisher.h diff --git a/libtransport/src/hicn/transport/interfaces/CMakeLists.txt b/libtransport/src/hicn/transport/interfaces/CMakeLists.txt index cbf371bac..cbf371bac 100755..100644 --- a/libtransport/src/hicn/transport/interfaces/CMakeLists.txt +++ b/libtransport/src/hicn/transport/interfaces/CMakeLists.txt diff --git a/libtransport/src/hicn/transport/interfaces/async_transport.h b/libtransport/src/hicn/transport/interfaces/async_transport.h index 492b4ec26..2911377a4 100755..100644 --- a/libtransport/src/hicn/transport/interfaces/async_transport.h +++ b/libtransport/src/hicn/transport/interfaces/async_transport.h @@ -20,7 +20,10 @@ #include <hicn/transport/portability/portability.h> #include <hicn/transport/utils/sharable_vector.h> +#ifndef _WIN32 #include <sys/uio.h> +#endif + #include <memory> namespace transport { diff --git a/libtransport/src/hicn/transport/interfaces/full_duplex_socket.cc b/libtransport/src/hicn/transport/interfaces/full_duplex_socket.cc index e06858cc3..0a091d94e 100644 --- a/libtransport/src/hicn/transport/interfaces/full_duplex_socket.cc +++ b/libtransport/src/hicn/transport/interfaces/full_duplex_socket.cc @@ -57,21 +57,23 @@ AsyncFullDuplexSocket::AsyncFullDuplexSocket(const Prefix &locator, producer_->setSocketOption(GeneralTransportOptions::OUTPUT_BUFFER_SIZE, uint32_t{150000}); - producer_->setSocketOption( - ProducerCallbacksOptions::CONTENT_PRODUCED, - std::bind(&AsyncFullDuplexSocket::onContentProduced, this, _1, _2, _3)); + ProducerContentCallback producer_callback = + std::bind(&AsyncFullDuplexSocket::onContentProduced, this, _1, _2, _3); + producer_->setSocketOption(ProducerCallbacksOptions::CONTENT_PRODUCED, + producer_callback); producer_->connect(); - consumer_->setSocketOption(ConsumerCallbacksOptions::CONTENT_OBJECT_TO_VERIFY, - (ConsumerContentObjectVerificationCallback)[]( - ConsumerSocket & s, const ContentObject &c) - ->bool { return true; }); + consumer_->setSocketOption( + ConsumerCallbacksOptions::CONTENT_OBJECT_TO_VERIFY, + (ConsumerContentObjectVerificationCallback)[](ConsumerSocket & s, + const ContentObject &c) + ->bool { return true; }); - ConsumerContentCallback callback = + ConsumerContentCallback consumer_callback = std::bind(&AsyncFullDuplexSocket::onContentRetrieved, this, _1, _2, _3); consumer_->setSocketOption(ConsumerCallbacksOptions::CONTENT_RETRIEVED, - callback); + consumer_callback); consumer_->setSocketOption(GeneralTransportOptions::MAX_INTEREST_RETX, uint32_t{4}); diff --git a/libtransport/src/hicn/transport/interfaces/full_duplex_socket.h b/libtransport/src/hicn/transport/interfaces/full_duplex_socket.h index f881bea54..f881bea54 100755..100644 --- a/libtransport/src/hicn/transport/interfaces/full_duplex_socket.h +++ b/libtransport/src/hicn/transport/interfaces/full_duplex_socket.h diff --git a/libtransport/src/hicn/transport/interfaces/publication_options.h b/libtransport/src/hicn/transport/interfaces/publication_options.h index ae5366ce7..ae5366ce7 100755..100644 --- a/libtransport/src/hicn/transport/interfaces/publication_options.h +++ b/libtransport/src/hicn/transport/interfaces/publication_options.h diff --git a/libtransport/src/hicn/transport/interfaces/rtc_socket_consumer.cc b/libtransport/src/hicn/transport/interfaces/rtc_socket_consumer.cc index cc4f478af..ef952a891 100755..100644 --- a/libtransport/src/hicn/transport/interfaces/rtc_socket_consumer.cc +++ b/libtransport/src/hicn/transport/interfaces/rtc_socket_consumer.cc @@ -22,8 +22,7 @@ namespace interface { RTCConsumerSocket::RTCConsumerSocket(int protocol, asio::io_service &io_service) : ConsumerSocket(protocol, io_service) {} -RTCConsumerSocket::RTCConsumerSocket(int protocol) - : ConsumerSocket(protocol) {} +RTCConsumerSocket::RTCConsumerSocket(int protocol) : ConsumerSocket(protocol) {} RTCConsumerSocket::~RTCConsumerSocket() {} diff --git a/libtransport/src/hicn/transport/interfaces/rtc_socket_consumer.h b/libtransport/src/hicn/transport/interfaces/rtc_socket_consumer.h index cfde3128d..cfde3128d 100755..100644 --- a/libtransport/src/hicn/transport/interfaces/rtc_socket_consumer.h +++ b/libtransport/src/hicn/transport/interfaces/rtc_socket_consumer.h diff --git a/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc b/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc index f19502dee..84c80dad7 100644 --- a/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc +++ b/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc @@ -72,7 +72,6 @@ RTCProducerSocket::RTCProducerSocket() prodLabel_ = ((rand() % 255) << 24UL); } - RTCProducerSocket::~RTCProducerSocket() {} void RTCProducerSocket::registerName(Prefix &producer_namespace) { diff --git a/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.h b/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.h index f1bcaa9e8..f1bcaa9e8 100755..100644 --- a/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.h +++ b/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.h diff --git a/libtransport/src/hicn/transport/interfaces/socket.h b/libtransport/src/hicn/transport/interfaces/socket.h index 22757810a..22757810a 100755..100644 --- a/libtransport/src/hicn/transport/interfaces/socket.h +++ b/libtransport/src/hicn/transport/interfaces/socket.h diff --git a/libtransport/src/hicn/transport/interfaces/socket_consumer.h b/libtransport/src/hicn/transport/interfaces/socket_consumer.h index 536d2fde3..536d2fde3 100755..100644 --- a/libtransport/src/hicn/transport/interfaces/socket_consumer.h +++ b/libtransport/src/hicn/transport/interfaces/socket_consumer.h diff --git a/libtransport/src/hicn/transport/interfaces/socket_options_default_values.h b/libtransport/src/hicn/transport/interfaces/socket_options_default_values.h index 5fae1c484..5fae1c484 100755..100644 --- a/libtransport/src/hicn/transport/interfaces/socket_options_default_values.h +++ b/libtransport/src/hicn/transport/interfaces/socket_options_default_values.h diff --git a/libtransport/src/hicn/transport/interfaces/socket_options_keys.h b/libtransport/src/hicn/transport/interfaces/socket_options_keys.h index 1afad2b48..1afad2b48 100755..100644 --- a/libtransport/src/hicn/transport/interfaces/socket_options_keys.h +++ b/libtransport/src/hicn/transport/interfaces/socket_options_keys.h diff --git a/libtransport/src/hicn/transport/interfaces/socket_producer.cc b/libtransport/src/hicn/transport/interfaces/socket_producer.cc index d9204f111..5bd522faf 100755..100644 --- a/libtransport/src/hicn/transport/interfaces/socket_producer.cc +++ b/libtransport/src/hicn/transport/interfaces/socket_producer.cc @@ -54,7 +54,6 @@ ProducerSocket::ProducerSocket(asio::io_service &io_service) } ProducerSocket::~ProducerSocket() { - processing_thread_stop_ = true; portal_->stopEventsLoop(true); @@ -78,9 +77,7 @@ void ProducerSocket::serveForever() { } } -void ProducerSocket::stop() { - portal_->stopEventsLoop(); -} +void ProducerSocket::stop() { portal_->stopEventsLoop(); } void ProducerSocket::registerPrefix(const Prefix &producer_namespace) { served_namespaces_.push_back(producer_namespace); diff --git a/libtransport/src/hicn/transport/interfaces/socket_producer.h b/libtransport/src/hicn/transport/interfaces/socket_producer.h index 06c47d973..06c47d973 100755..100644 --- a/libtransport/src/hicn/transport/interfaces/socket_producer.h +++ b/libtransport/src/hicn/transport/interfaces/socket_producer.h diff --git a/libtransport/src/hicn/transport/portability/CMakeLists.txt b/libtransport/src/hicn/transport/portability/CMakeLists.txt index eee973c2d..5ad3c8207 100755..100644 --- a/libtransport/src/hicn/transport/portability/CMakeLists.txt +++ b/libtransport/src/hicn/transport/portability/CMakeLists.txt @@ -22,5 +22,11 @@ list(APPEND SOURCE_FILES "" ) +if(WIN32) + list(APPEND HEADER_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/win_portability.h + ) +endif() + set(SOURCE_FILES ${SOURCE_FILES} PARENT_SCOPE) set(HEADER_FILES ${HEADER_FILES} PARENT_SCOPE)
\ No newline at end of file diff --git a/libtransport/src/hicn/transport/portability/c_portability.h b/libtransport/src/hicn/transport/portability/c_portability.h index 71e976a81..71e976a81 100755..100644 --- a/libtransport/src/hicn/transport/portability/c_portability.h +++ b/libtransport/src/hicn/transport/portability/c_portability.h diff --git a/libtransport/src/hicn/transport/portability/portability.h b/libtransport/src/hicn/transport/portability/portability.h index 7063e1822..1d97a346e 100755..100644 --- a/libtransport/src/hicn/transport/portability/portability.h +++ b/libtransport/src/hicn/transport/portability/portability.h @@ -17,6 +17,10 @@ #pragma once +#ifdef _WIN32 +#include <hicn/transport/portability/win_portability.h> +#endif + #include <hicn/transport/portability/c_portability.h> #include <string.h> diff --git a/libtransport/src/hicn/transport/portability/win_portability.h b/libtransport/src/hicn/transport/portability/win_portability.h new file mode 100644 index 000000000..f1d6e2b0e --- /dev/null +++ b/libtransport/src/hicn/transport/portability/win_portability.h @@ -0,0 +1,38 @@ +/*
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright 2017 Facebook, Inc.
+ *
+ * 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
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include <parc/windows/parc_Utils.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <windows.h>
+#include <winsock2.h>
+#include <ws2ipdef.h>
+#include <ws2tcpip.h>
+#include <algorithm>
+
+#define __ORDER_LITTLE_ENDIAN__ 0x41424344UL
+#define __ORDER_BIG_ENDIAN__ 0x44434241UL
+#define __BYTE_ORDER__ ('ABCD')
+#undef DELETE
+
+#define HAVE_STRUCT_TIMESPEC
+#include <pthread.h>
\ No newline at end of file diff --git a/libtransport/src/hicn/transport/protocols/CMakeLists.txt b/libtransport/src/hicn/transport/protocols/CMakeLists.txt index 1c3b76c24..1c3b76c24 100755..100644 --- a/libtransport/src/hicn/transport/protocols/CMakeLists.txt +++ b/libtransport/src/hicn/transport/protocols/CMakeLists.txt diff --git a/libtransport/src/hicn/transport/protocols/cbr.cc b/libtransport/src/hicn/transport/protocols/cbr.cc index 3da4819c3..3da4819c3 100755..100644 --- a/libtransport/src/hicn/transport/protocols/cbr.cc +++ b/libtransport/src/hicn/transport/protocols/cbr.cc diff --git a/libtransport/src/hicn/transport/protocols/cbr.h b/libtransport/src/hicn/transport/protocols/cbr.h index 0a572292a..0a572292a 100755..100644 --- a/libtransport/src/hicn/transport/protocols/cbr.h +++ b/libtransport/src/hicn/transport/protocols/cbr.h diff --git a/libtransport/src/hicn/transport/protocols/consumer.conf b/libtransport/src/hicn/transport/protocols/consumer.conf index 1a366f32f..1a366f32f 100755..100644 --- a/libtransport/src/hicn/transport/protocols/consumer.conf +++ b/libtransport/src/hicn/transport/protocols/consumer.conf diff --git a/libtransport/src/hicn/transport/protocols/download_observer.h b/libtransport/src/hicn/transport/protocols/download_observer.h index 6d24fe6fd..6d24fe6fd 100755..100644 --- a/libtransport/src/hicn/transport/protocols/download_observer.h +++ b/libtransport/src/hicn/transport/protocols/download_observer.h diff --git a/libtransport/src/hicn/transport/protocols/protocol.cc b/libtransport/src/hicn/transport/protocols/protocol.cc index ea4fd6dbf..ea4fd6dbf 100755..100644 --- a/libtransport/src/hicn/transport/protocols/protocol.cc +++ b/libtransport/src/hicn/transport/protocols/protocol.cc diff --git a/libtransport/src/hicn/transport/protocols/protocol.h b/libtransport/src/hicn/transport/protocols/protocol.h index 56c57e025..56c57e025 100755..100644 --- a/libtransport/src/hicn/transport/protocols/protocol.h +++ b/libtransport/src/hicn/transport/protocols/protocol.h diff --git a/libtransport/src/hicn/transport/protocols/raaqm.cc b/libtransport/src/hicn/transport/protocols/raaqm.cc index cd22ecfdc..cd22ecfdc 100755..100644 --- a/libtransport/src/hicn/transport/protocols/raaqm.cc +++ b/libtransport/src/hicn/transport/protocols/raaqm.cc diff --git a/libtransport/src/hicn/transport/protocols/raaqm.h b/libtransport/src/hicn/transport/protocols/raaqm.h index 6ca410251..6ca410251 100755..100644 --- a/libtransport/src/hicn/transport/protocols/raaqm.h +++ b/libtransport/src/hicn/transport/protocols/raaqm.h diff --git a/libtransport/src/hicn/transport/protocols/raaqm_data_path.cc b/libtransport/src/hicn/transport/protocols/raaqm_data_path.cc index f876cf4f8..2e7aa531a 100755..100644 --- a/libtransport/src/hicn/transport/protocols/raaqm_data_path.cc +++ b/libtransport/src/hicn/transport/protocols/raaqm_data_path.cc @@ -42,10 +42,9 @@ RaaqmDataPath::RaaqmDataPath(double drop_factor, raw_data_bytes_received_(0), last_raw_data_bytes_received_(0), rtt_samples_(samples_), + last_received_pkt_(std::chrono::steady_clock::now()), average_rtt_(0), - alpha_(ALPHA) { - gettimeofday(&m_last_received_pkt_, 0); -} + alpha_(ALPHA) {} RaaqmDataPath &RaaqmDataPath::insertNewRtt(uint64_t new_rtt) { rtt_ = new_rtt; @@ -59,7 +58,7 @@ RaaqmDataPath &RaaqmDataPath::insertNewRtt(uint64_t new_rtt) { prop_delay_ = rtt_min_; } - gettimeofday(&m_last_received_pkt_, 0); + last_received_pkt_ = std::chrono::steady_clock::now(); return *this; } @@ -144,9 +143,9 @@ bool RaaqmDataPath::newPropagationDelayAvailable() { unsigned int RaaqmDataPath::getPropagationDelay() { return prop_delay_; } bool RaaqmDataPath::isStale() { - struct timeval now; - gettimeofday(&now, 0); - double time = getMicroSeconds(now) - getMicroSeconds(m_last_received_pkt_); + TimePoint now = std::chrono::steady_clock::now(); + auto time = std::chrono::duration_cast<Microseconds>(now - last_received_pkt_) + .count(); if (time > 2000000) { return true; } diff --git a/libtransport/src/hicn/transport/protocols/raaqm_data_path.h b/libtransport/src/hicn/transport/protocols/raaqm_data_path.h index 6f63940c9..a0b9ec9ca 100755..100644 --- a/libtransport/src/hicn/transport/protocols/raaqm_data_path.h +++ b/libtransport/src/hicn/transport/protocols/raaqm_data_path.h @@ -17,7 +17,7 @@ #include <hicn/transport/utils/min_filter.h> -#include <sys/time.h> +#include <chrono> #include <climits> #include <iostream> @@ -30,6 +30,9 @@ namespace transport { namespace protocol { class RaaqmDataPath { + using TimePoint = std::chrono::steady_clock::time_point; + using Microseconds = std::chrono::microseconds; + public: RaaqmDataPath(double drop_factor, double minimum_drop_probability, unsigned new_timer, unsigned int samples, @@ -219,7 +222,7 @@ class RaaqmDataPath { /** * Time of the last call to the path reporter method */ - struct timeval m_last_received_pkt_; + TimePoint last_received_pkt_; double average_rtt_; double alpha_; diff --git a/libtransport/src/hicn/transport/protocols/rate_estimation.cc b/libtransport/src/hicn/transport/protocols/rate_estimation.cc index e313bf9f6..b603ec200 100755..100644 --- a/libtransport/src/hicn/transport/protocols/rate_estimation.cc +++ b/libtransport/src/hicn/transport/protocols/rate_estimation.cc @@ -16,6 +16,8 @@ #include <hicn/transport/protocols/rate_estimation.h> #include <hicn/transport/utils/log.h> +#include <thread> + namespace transport { namespace protocol { @@ -31,7 +33,8 @@ void *Timer(void *data) { pthread_mutex_unlock(&(estimator->mutex_)); while (estimator->is_running_) { - usleep(KV * dat_rtt); + std::this_thread::sleep_for( + std::chrono::microseconds((uint64_t)(KV * dat_rtt))); pthread_mutex_lock(&(estimator->mutex_)); @@ -88,8 +91,8 @@ InterRttEstimator::InterRttEstimator(double alpha_arg) { this->win_current_ = 1.0; pthread_mutex_init(&(this->mutex_), NULL); - gettimeofday(&(this->start_time_), 0); - gettimeofday(&(this->begin_batch_), 0); + this->start_time_ = std::chrono::steady_clock::now(); + this->begin_batch_ = std::chrono::steady_clock::now(); } InterRttEstimator::~InterRttEstimator() { @@ -124,10 +127,10 @@ void InterRttEstimator::onRttUpdate(double rtt) { } void InterRttEstimator::onWindowIncrease(double win_current) { - timeval end; - gettimeofday(&end, 0); - double delay = RaaqmDataPath::getMicroSeconds(end) - - RaaqmDataPath::getMicroSeconds(this->begin_batch_); + TimePoint end = std::chrono::steady_clock::now(); + auto delay = + std::chrono::duration_cast<Microseconds>(end - this->begin_batch_) + .count(); pthread_mutex_lock(&(this->mutex_)); this->avg_win_ += this->win_current_ * delay; @@ -135,14 +138,14 @@ void InterRttEstimator::onWindowIncrease(double win_current) { this->win_change_ += delay; pthread_mutex_unlock(&(this->mutex_)); - gettimeofday(&(this->begin_batch_), 0); + this->begin_batch_ = std::chrono::steady_clock::now(); } void InterRttEstimator::onWindowDecrease(double win_current) { - timeval end; - gettimeofday(&end, 0); - double delay = RaaqmDataPath::getMicroSeconds(end) - - RaaqmDataPath::getMicroSeconds(this->begin_batch_); + TimePoint end = std::chrono::steady_clock::now(); + auto delay = + std::chrono::duration_cast<Microseconds>(end - this->begin_batch_) + .count(); pthread_mutex_lock(&(this->mutex_)); this->avg_win_ += this->win_current_ * delay; @@ -150,26 +153,25 @@ void InterRttEstimator::onWindowDecrease(double win_current) { this->win_change_ += delay; pthread_mutex_unlock(&(this->mutex_)); - gettimeofday(&(this->begin_batch_), 0); + this->begin_batch_ = std::chrono::steady_clock::now(); } ALaTcpEstimator::ALaTcpEstimator() { this->estimation_ = 0.0; this->observer_ = NULL; - gettimeofday(&(this->start_time_), 0); + this->start_time_ = std::chrono::steady_clock::now(); this->totalSize_ = 0.0; } void ALaTcpEstimator::onStart() { this->totalSize_ = 0.0; - gettimeofday(&(this->start_time_), 0); + this->start_time_ = std::chrono::steady_clock::now(); } void ALaTcpEstimator::onDownloadFinished() { - timeval end; - gettimeofday(&end, 0); - double delay = RaaqmDataPath::getMicroSeconds(end) - - RaaqmDataPath::getMicroSeconds(this->start_time_); + TimePoint end = std::chrono::steady_clock::now(); + auto delay = + std::chrono::duration_cast<Microseconds>(end - this->start_time_).count(); this->estimation_ = this->totalSize_ * 8 * 1000000 / delay; if (observer_) { observer_->notifyStats(this->estimation_); @@ -189,23 +191,22 @@ SimpleEstimator::SimpleEstimator(double alphaArg, int batching_param) { this->number_of_packets_ = 0; this->base_alpha_ = alphaArg; this->alpha_ = alphaArg; - gettimeofday(&(this->start_time_), 0); - gettimeofday(&(this->begin_batch_), 0); + this->start_time_ = std::chrono::steady_clock::now(); + this->begin_batch_ = std::chrono::steady_clock::now(); } void SimpleEstimator::onStart() { this->estimated_ = false; this->number_of_packets_ = 0; this->total_size_ = 0.0; - gettimeofday(&(this->begin_batch_), 0); - gettimeofday(&(this->start_time_), 0); + this->start_time_ = std::chrono::steady_clock::now(); + this->begin_batch_ = std::chrono::steady_clock::now(); } void SimpleEstimator::onDownloadFinished() { - timeval end; - gettimeofday(&end, 0); - double delay = RaaqmDataPath::getMicroSeconds(end) - - RaaqmDataPath::getMicroSeconds(this->start_time_); + TimePoint end = std::chrono::steady_clock::now(); + auto delay = + std::chrono::duration_cast<Microseconds>(end - this->start_time_).count(); if (observer_) { observer_->notifyDownloadTime(delay); } @@ -227,8 +228,8 @@ void SimpleEstimator::onDownloadFinished() { } else { if (this->number_of_packets_ >= (int)(75.0 * (double)this->batching_param_ / 100.0)) { - delay = RaaqmDataPath::getMicroSeconds(end) - - RaaqmDataPath::getMicroSeconds(this->begin_batch_); + delay = std::chrono::duration_cast<Microseconds>(end - this->begin_batch_) + .count(); // Assuming all packets carry max_packet_size_ bytes of data // (8*max_packet_size_ bits); 1000000 factor to convert us to seconds if (this->estimation_) { @@ -247,8 +248,8 @@ void SimpleEstimator::onDownloadFinished() { } this->number_of_packets_ = 0; this->total_size_ = 0.0; - gettimeofday(&(this->begin_batch_), 0); - gettimeofday(&(this->start_time_), 0); + this->start_time_ = std::chrono::steady_clock::now(); + this->begin_batch_ = std::chrono::steady_clock::now(); } void SimpleEstimator::onDataReceived(int packet_size) { @@ -259,10 +260,10 @@ void SimpleEstimator::onRttUpdate(double rtt) { this->number_of_packets_++; if (number_of_packets_ == this->batching_param_) { - timeval end; - gettimeofday(&end, 0); - double delay = RaaqmDataPath::getMicroSeconds(end) - - RaaqmDataPath::getMicroSeconds(this->begin_batch_); + TimePoint end = std::chrono::steady_clock::now(); + auto delay = + std::chrono::duration_cast<Microseconds>(end - this->begin_batch_) + .count(); // Assuming all packets carry max_packet_size_ bytes of data // (8*max_packet_size_ bits); 1000000 factor to convert us to seconds if (this->estimation_) { @@ -278,7 +279,7 @@ void SimpleEstimator::onRttUpdate(double rtt) { this->alpha_ = this->base_alpha_; this->number_of_packets_ = 0; this->total_size_ = 0.0; - gettimeofday(&(this->begin_batch_), 0); + this->begin_batch_ = std::chrono::steady_clock::now(); } } @@ -295,8 +296,8 @@ BatchingPacketsEstimator::BatchingPacketsEstimator(double alpha_arg, this->max_packet_size_ = 0; this->estimation_ = 0.0; this->win_current_ = 1.0; - gettimeofday(&(this->begin_batch_), 0); - gettimeofday(&(this->start_time_), 0); + this->begin_batch_ = std::chrono::steady_clock::now(); + this->start_time_ = std::chrono::steady_clock::now(); } void BatchingPacketsEstimator::onRttUpdate(double rtt) { @@ -327,25 +328,25 @@ void BatchingPacketsEstimator::onRttUpdate(double rtt) { } void BatchingPacketsEstimator::onWindowIncrease(double win_current) { - timeval end; - gettimeofday(&end, 0); - double delay = RaaqmDataPath::getMicroSeconds(end) - - RaaqmDataPath::getMicroSeconds(this->begin_batch_); + TimePoint end = std::chrono::steady_clock::now(); + auto delay = + std::chrono::duration_cast<Microseconds>(end - this->begin_batch_) + .count(); this->avg_win_ += this->win_current_ * delay; this->win_current_ = win_current; this->win_change_ += delay; - gettimeofday(&(this->begin_batch_), 0); + this->begin_batch_ = std::chrono::steady_clock::now(); } void BatchingPacketsEstimator::onWindowDecrease(double win_current) { - timeval end; - gettimeofday(&end, 0); - double delay = RaaqmDataPath::getMicroSeconds(end) - - RaaqmDataPath::getMicroSeconds(this->begin_batch_); + TimePoint end = std::chrono::steady_clock::now(); + auto delay = + std::chrono::duration_cast<Microseconds>(end - this->begin_batch_) + .count(); this->avg_win_ += this->win_current_ * delay; this->win_current_ = win_current; this->win_change_ += delay; - gettimeofday(&(this->begin_batch_), 0); + this->begin_batch_ = std::chrono::steady_clock::now(); } } // end namespace protocol diff --git a/libtransport/src/hicn/transport/protocols/rate_estimation.h b/libtransport/src/hicn/transport/protocols/rate_estimation.h index b889efe12..91964ec1d 100755..100644 --- a/libtransport/src/hicn/transport/protocols/rate_estimation.h +++ b/libtransport/src/hicn/transport/protocols/rate_estimation.h @@ -15,11 +15,11 @@ #pragma once -#include <unistd.h> - #include <hicn/transport/protocols/download_observer.h> #include <hicn/transport/protocols/raaqm_data_path.h> +#include <chrono> + #define BATCH 50 #define KV 20 #define ALPHA 0.8 @@ -31,6 +31,9 @@ namespace protocol { class IcnRateEstimator { public: + using TimePoint = std::chrono::steady_clock::time_point; + using Microseconds = std::chrono::microseconds; + IcnRateEstimator(){}; virtual ~IcnRateEstimator(){}; @@ -51,8 +54,8 @@ class IcnRateEstimator { this->observer_ = observer; }; IcnObserver *observer_; - struct timeval start_time_; - struct timeval begin_batch_; + TimePoint start_time_; + TimePoint begin_batch_; double base_alpha_; double alpha_; double estimation_; diff --git a/libtransport/src/hicn/transport/protocols/rtc.h b/libtransport/src/hicn/transport/protocols/rtc.h index 249af6b99..249af6b99 100755..100644 --- a/libtransport/src/hicn/transport/protocols/rtc.h +++ b/libtransport/src/hicn/transport/protocols/rtc.h diff --git a/libtransport/src/hicn/transport/protocols/rtc_data_path.cc b/libtransport/src/hicn/transport/protocols/rtc_data_path.cc index 6c9605fb2..6c9605fb2 100755..100644 --- a/libtransport/src/hicn/transport/protocols/rtc_data_path.cc +++ b/libtransport/src/hicn/transport/protocols/rtc_data_path.cc diff --git a/libtransport/src/hicn/transport/protocols/test/CMakeLists.txt b/libtransport/src/hicn/transport/protocols/test/CMakeLists.txt index 6f9fdb9aa..6f9fdb9aa 100755..100644 --- a/libtransport/src/hicn/transport/protocols/test/CMakeLists.txt +++ b/libtransport/src/hicn/transport/protocols/test/CMakeLists.txt diff --git a/libtransport/src/hicn/transport/protocols/test/test_transport_producer.cc b/libtransport/src/hicn/transport/protocols/test/test_transport_producer.cc index 204f2cbe2..204f2cbe2 100755..100644 --- a/libtransport/src/hicn/transport/protocols/test/test_transport_producer.cc +++ b/libtransport/src/hicn/transport/protocols/test/test_transport_producer.cc diff --git a/libtransport/src/hicn/transport/protocols/vegas.h b/libtransport/src/hicn/transport/protocols/vegas.h index 7791ffc94..7791ffc94 100755..100644 --- a/libtransport/src/hicn/transport/protocols/vegas.h +++ b/libtransport/src/hicn/transport/protocols/vegas.h diff --git a/libtransport/src/hicn/transport/protocols/vegas_rto_estimator.cc b/libtransport/src/hicn/transport/protocols/vegas_rto_estimator.cc index f5f797bbe..f5f797bbe 100755..100644 --- a/libtransport/src/hicn/transport/protocols/vegas_rto_estimator.cc +++ b/libtransport/src/hicn/transport/protocols/vegas_rto_estimator.cc diff --git a/libtransport/src/hicn/transport/protocols/vegas_rto_estimator.h b/libtransport/src/hicn/transport/protocols/vegas_rto_estimator.h index e84afc49c..e84afc49c 100755..100644 --- a/libtransport/src/hicn/transport/protocols/vegas_rto_estimator.h +++ b/libtransport/src/hicn/transport/protocols/vegas_rto_estimator.h diff --git a/libtransport/src/hicn/transport/utils/CMakeLists.txt b/libtransport/src/hicn/transport/utils/CMakeLists.txt index 088fb5862..088fb5862 100755..100644 --- a/libtransport/src/hicn/transport/utils/CMakeLists.txt +++ b/libtransport/src/hicn/transport/utils/CMakeLists.txt diff --git a/libtransport/src/hicn/transport/utils/array.h b/libtransport/src/hicn/transport/utils/array.h index a3a66e498..a3a66e498 100755..100644 --- a/libtransport/src/hicn/transport/utils/array.h +++ b/libtransport/src/hicn/transport/utils/array.h diff --git a/libtransport/src/hicn/transport/utils/branch_prediction.h b/libtransport/src/hicn/transport/utils/branch_prediction.h index b12282fe8..8cbfaca76 100755..100644 --- a/libtransport/src/hicn/transport/utils/branch_prediction.h +++ b/libtransport/src/hicn/transport/utils/branch_prediction.h @@ -18,5 +18,10 @@ #undef TRANSPORT_EXPECT_TRUE #undef TRANSPORT_EXPECT_FALSE +#ifndef _WIN32 #define TRANSPORT_EXPECT_TRUE(x) __builtin_expect((x), 1) -#define TRANSPORT_EXPECT_FALSE(x) __builtin_expect((x), 0)
\ No newline at end of file +#define TRANSPORT_EXPECT_FALSE(x) __builtin_expect((x), 0) +#else +#define TRANSPORT_EXPECT_TRUE(x) (x) +#define TRANSPORT_EXPECT_FALSE(x) (x) +#endif
\ No newline at end of file diff --git a/libtransport/src/hicn/transport/utils/content_store.cc b/libtransport/src/hicn/transport/utils/content_store.cc index 4c7637dad..4c7637dad 100755..100644 --- a/libtransport/src/hicn/transport/utils/content_store.cc +++ b/libtransport/src/hicn/transport/utils/content_store.cc diff --git a/libtransport/src/hicn/transport/utils/content_store.h b/libtransport/src/hicn/transport/utils/content_store.h index ab4963fff..ab4963fff 100755..100644 --- a/libtransport/src/hicn/transport/utils/content_store.h +++ b/libtransport/src/hicn/transport/utils/content_store.h diff --git a/libtransport/src/hicn/transport/utils/conversions.h b/libtransport/src/hicn/transport/utils/conversions.h index 24b529206..24b529206 100755..100644 --- a/libtransport/src/hicn/transport/utils/conversions.h +++ b/libtransport/src/hicn/transport/utils/conversions.h diff --git a/libtransport/src/hicn/transport/utils/crypto_hash.h b/libtransport/src/hicn/transport/utils/crypto_hash.h index 0c15c8bda..0c15c8bda 100755..100644 --- a/libtransport/src/hicn/transport/utils/crypto_hash.h +++ b/libtransport/src/hicn/transport/utils/crypto_hash.h diff --git a/libtransport/src/hicn/transport/utils/crypto_hash_type.h b/libtransport/src/hicn/transport/utils/crypto_hash_type.h index b7597e208..b7597e208 100755..100644 --- a/libtransport/src/hicn/transport/utils/crypto_hash_type.h +++ b/libtransport/src/hicn/transport/utils/crypto_hash_type.h diff --git a/libtransport/src/hicn/transport/utils/crypto_hasher.h b/libtransport/src/hicn/transport/utils/crypto_hasher.h index c34a26fac..c34a26fac 100755..100644 --- a/libtransport/src/hicn/transport/utils/crypto_hasher.h +++ b/libtransport/src/hicn/transport/utils/crypto_hasher.h diff --git a/libtransport/src/hicn/transport/utils/crypto_suite.h b/libtransport/src/hicn/transport/utils/crypto_suite.h index 8ae32b846..8ae32b846 100755..100644 --- a/libtransport/src/hicn/transport/utils/crypto_suite.h +++ b/libtransport/src/hicn/transport/utils/crypto_suite.h diff --git a/libtransport/src/hicn/transport/utils/daemonizator.cc b/libtransport/src/hicn/transport/utils/daemonizator.cc index d9b3109af..d9b3109af 100755..100644 --- a/libtransport/src/hicn/transport/utils/daemonizator.cc +++ b/libtransport/src/hicn/transport/utils/daemonizator.cc diff --git a/libtransport/src/hicn/transport/utils/daemonizator.h b/libtransport/src/hicn/transport/utils/daemonizator.h index a21ce8a7b..a21ce8a7b 100755..100644 --- a/libtransport/src/hicn/transport/utils/daemonizator.h +++ b/libtransport/src/hicn/transport/utils/daemonizator.h diff --git a/libtransport/src/hicn/transport/utils/deadline_timer.h b/libtransport/src/hicn/transport/utils/deadline_timer.h index 61f906141..61f906141 100755..100644 --- a/libtransport/src/hicn/transport/utils/deadline_timer.h +++ b/libtransport/src/hicn/transport/utils/deadline_timer.h diff --git a/libtransport/src/hicn/transport/utils/endianess.h b/libtransport/src/hicn/transport/utils/endianess.h index a3ec21c90..d86e764ab 100755..100644 --- a/libtransport/src/hicn/transport/utils/endianess.h +++ b/libtransport/src/hicn/transport/utils/endianess.h @@ -17,7 +17,12 @@ #include <hicn/transport/portability/portability.h> +#ifndef _WIN32 #include <arpa/inet.h> +#else +#include <hicn/transport/portability/win_portability.h> +#endif + #include <cstring> namespace utils { diff --git a/libtransport/src/hicn/transport/utils/epoll_event_reactor.cc b/libtransport/src/hicn/transport/utils/epoll_event_reactor.cc index 81b471857..81b471857 100755..100644 --- a/libtransport/src/hicn/transport/utils/epoll_event_reactor.cc +++ b/libtransport/src/hicn/transport/utils/epoll_event_reactor.cc diff --git a/libtransport/src/hicn/transport/utils/epoll_event_reactor.h b/libtransport/src/hicn/transport/utils/epoll_event_reactor.h index bb4db3ee7..bb4db3ee7 100755..100644 --- a/libtransport/src/hicn/transport/utils/epoll_event_reactor.h +++ b/libtransport/src/hicn/transport/utils/epoll_event_reactor.h diff --git a/libtransport/src/hicn/transport/utils/event_reactor.h b/libtransport/src/hicn/transport/utils/event_reactor.h index 4f8b58296..4f8b58296 100755..100644 --- a/libtransport/src/hicn/transport/utils/event_reactor.h +++ b/libtransport/src/hicn/transport/utils/event_reactor.h diff --git a/libtransport/src/hicn/transport/utils/event_thread.h b/libtransport/src/hicn/transport/utils/event_thread.h index 3bf08c94b..3bf08c94b 100755..100644 --- a/libtransport/src/hicn/transport/utils/event_thread.h +++ b/libtransport/src/hicn/transport/utils/event_thread.h diff --git a/libtransport/src/hicn/transport/utils/fd_deadline_timer.h b/libtransport/src/hicn/transport/utils/fd_deadline_timer.h index 3ed4590bc..3ed4590bc 100755..100644 --- a/libtransport/src/hicn/transport/utils/fd_deadline_timer.h +++ b/libtransport/src/hicn/transport/utils/fd_deadline_timer.h diff --git a/libtransport/src/hicn/transport/utils/hash.h b/libtransport/src/hicn/transport/utils/hash.h index 6815ca4bf..6815ca4bf 100755..100644 --- a/libtransport/src/hicn/transport/utils/hash.h +++ b/libtransport/src/hicn/transport/utils/hash.h diff --git a/libtransport/src/hicn/transport/utils/identity.h b/libtransport/src/hicn/transport/utils/identity.h index 018842ee3..018842ee3 100755..100644 --- a/libtransport/src/hicn/transport/utils/identity.h +++ b/libtransport/src/hicn/transport/utils/identity.h diff --git a/libtransport/src/hicn/transport/utils/key_id.h b/libtransport/src/hicn/transport/utils/key_id.h index d67b73d7a..d67b73d7a 100755..100644 --- a/libtransport/src/hicn/transport/utils/key_id.h +++ b/libtransport/src/hicn/transport/utils/key_id.h diff --git a/libtransport/src/hicn/transport/utils/linux.h b/libtransport/src/hicn/transport/utils/linux.h index 5820528e1..5820528e1 100755..100644 --- a/libtransport/src/hicn/transport/utils/linux.h +++ b/libtransport/src/hicn/transport/utils/linux.h diff --git a/libtransport/src/hicn/transport/utils/literals.h b/libtransport/src/hicn/transport/utils/literals.h index bd00e0a58..bd00e0a58 100755..100644 --- a/libtransport/src/hicn/transport/utils/literals.h +++ b/libtransport/src/hicn/transport/utils/literals.h diff --git a/libtransport/src/hicn/transport/utils/membuf.cc b/libtransport/src/hicn/transport/utils/membuf.cc index 0ab1a6044..e75e85b35 100755..100644 --- a/libtransport/src/hicn/transport/utils/membuf.cc +++ b/libtransport/src/hicn/transport/utils/membuf.cc @@ -18,6 +18,9 @@ * The code in this file if adapated from the IOBuf of folly: * https://github.com/facebook/folly/blob/master/folly/io/IOBuf.h */ +#ifdef _WIN32 +#include <hicn/transport/portability/win_portability.h> +#endif #include <hicn/transport/utils/membuf.h> diff --git a/libtransport/src/hicn/transport/utils/membuf.h b/libtransport/src/hicn/transport/utils/membuf.h index 944237e2b..5a10d4182 100755..100644 --- a/libtransport/src/hicn/transport/utils/membuf.h +++ b/libtransport/src/hicn/transport/utils/membuf.h @@ -35,8 +35,9 @@ #include <type_traits> #include <vector> -// Ignore shadowing warnings within this file, so includers can use -Wshadow. +#ifndef _WIN32 TRANSPORT_GNU_DISABLE_WARNING("-Wshadow") +#endif namespace utils { diff --git a/libtransport/src/hicn/transport/utils/min_filter.h b/libtransport/src/hicn/transport/utils/min_filter.h index acb081edc..acb081edc 100755..100644 --- a/libtransport/src/hicn/transport/utils/min_filter.h +++ b/libtransport/src/hicn/transport/utils/min_filter.h diff --git a/libtransport/src/hicn/transport/utils/object_pool.h b/libtransport/src/hicn/transport/utils/object_pool.h index c369f7e12..9fda214cd 100755..100644 --- a/libtransport/src/hicn/transport/utils/object_pool.h +++ b/libtransport/src/hicn/transport/utils/object_pool.h @@ -47,9 +47,7 @@ class ObjectPool { ObjectPool() : destructor_(false) {} - ~ObjectPool() { - destructor_ = true; - } + ~ObjectPool() { destructor_ = true; } std::pair<bool, Ptr> get() { if (object_pool_.empty()) { diff --git a/libtransport/src/hicn/transport/utils/ring_buffer.h b/libtransport/src/hicn/transport/utils/ring_buffer.h index 52bcd81c4..52bcd81c4 100755..100644 --- a/libtransport/src/hicn/transport/utils/ring_buffer.h +++ b/libtransport/src/hicn/transport/utils/ring_buffer.h diff --git a/libtransport/src/hicn/transport/utils/sharable_vector.h b/libtransport/src/hicn/transport/utils/sharable_vector.h index 31adff1ad..31adff1ad 100755..100644 --- a/libtransport/src/hicn/transport/utils/sharable_vector.h +++ b/libtransport/src/hicn/transport/utils/sharable_vector.h diff --git a/libtransport/src/hicn/transport/utils/signer.cc b/libtransport/src/hicn/transport/utils/signer.cc index 579b08aff..005236c2e 100644 --- a/libtransport/src/hicn/transport/utils/signer.cc +++ b/libtransport/src/hicn/transport/utils/signer.cc @@ -22,7 +22,9 @@ #include <hicn/transport/utils/signer.h> extern "C" { +#ifndef _WIN32 TRANSPORT_CLANG_DISABLE_WARNING("-Wextern-c-compat") +#endif #include <hicn/hicn.h> #include <parc/security/parc_PublicKeySigner.h> #include <parc/security/parc_Security.h> diff --git a/libtransport/src/hicn/transport/utils/signer.h b/libtransport/src/hicn/transport/utils/signer.h index 7b54b63c8..7b54b63c8 100755..100644 --- a/libtransport/src/hicn/transport/utils/signer.h +++ b/libtransport/src/hicn/transport/utils/signer.h diff --git a/libtransport/src/hicn/transport/utils/socket.h b/libtransport/src/hicn/transport/utils/socket.h index ab8578f91..ab8578f91 100755..100644 --- a/libtransport/src/hicn/transport/utils/socket.h +++ b/libtransport/src/hicn/transport/utils/socket.h diff --git a/libtransport/src/hicn/transport/utils/spinlock.h b/libtransport/src/hicn/transport/utils/spinlock.h index 33e5cda85..009a94454 100755..100644 --- a/libtransport/src/hicn/transport/utils/spinlock.h +++ b/libtransport/src/hicn/transport/utils/spinlock.h @@ -35,7 +35,7 @@ class SpinLock : private std::atomic_flag { SpinLock& spin_lock_; }; - SpinLock() : std::atomic_flag(false) {} + SpinLock() { clear(); } void lock() { // busy-wait diff --git a/libtransport/src/hicn/transport/utils/stream_buffer.h b/libtransport/src/hicn/transport/utils/stream_buffer.h index adfb696f2..adfb696f2 100755..100644 --- a/libtransport/src/hicn/transport/utils/stream_buffer.h +++ b/libtransport/src/hicn/transport/utils/stream_buffer.h diff --git a/libtransport/src/hicn/transport/utils/string_tokenizer.cc b/libtransport/src/hicn/transport/utils/string_tokenizer.cc index 9d1911080..9d1911080 100755..100644 --- a/libtransport/src/hicn/transport/utils/string_tokenizer.cc +++ b/libtransport/src/hicn/transport/utils/string_tokenizer.cc diff --git a/libtransport/src/hicn/transport/utils/string_tokenizer.h b/libtransport/src/hicn/transport/utils/string_tokenizer.h index 36630eb58..36630eb58 100755..100644 --- a/libtransport/src/hicn/transport/utils/string_tokenizer.h +++ b/libtransport/src/hicn/transport/utils/string_tokenizer.h diff --git a/libtransport/src/hicn/transport/utils/test.h b/libtransport/src/hicn/transport/utils/test.h index e3dd619ac..e3dd619ac 100755..100644 --- a/libtransport/src/hicn/transport/utils/test.h +++ b/libtransport/src/hicn/transport/utils/test.h diff --git a/libtransport/src/hicn/transport/utils/uri.cc b/libtransport/src/hicn/transport/utils/uri.cc index 33eb8b45b..33eb8b45b 100755..100644 --- a/libtransport/src/hicn/transport/utils/uri.cc +++ b/libtransport/src/hicn/transport/utils/uri.cc diff --git a/libtransport/src/hicn/transport/utils/uri.h b/libtransport/src/hicn/transport/utils/uri.h index 7c28e8552..7c28e8552 100755..100644 --- a/libtransport/src/hicn/transport/utils/uri.h +++ b/libtransport/src/hicn/transport/utils/uri.h diff --git a/libtransport/src/hicn/transport/utils/verifier.cc b/libtransport/src/hicn/transport/utils/verifier.cc index 93efe063a..49cbe3b36 100644 --- a/libtransport/src/hicn/transport/utils/verifier.cc +++ b/libtransport/src/hicn/transport/utils/verifier.cc @@ -21,7 +21,9 @@ #include <hicn/transport/utils/verifier.h> extern "C" { +#ifndef _WIN32 TRANSPORT_CLANG_DISABLE_WARNING("-Wextern-c-compat") +#endif #include <hicn/hicn.h> #include <parc/security/parc_CertificateFactory.h> #include <parc/security/parc_InMemoryVerifier.h> diff --git a/libtransport/src/hicn/transport/utils/verifier.h b/libtransport/src/hicn/transport/utils/verifier.h index 6313a7240..6313a7240 100755..100644 --- a/libtransport/src/hicn/transport/utils/verifier.h +++ b/libtransport/src/hicn/transport/utils/verifier.h |