diff options
52 files changed, 340 insertions, 148 deletions
diff --git a/apps/higet/CMakeLists.txt b/apps/higet/CMakeLists.txt index 1cf14c287..b929a24e4 100644 --- a/apps/higet/CMakeLists.txt +++ b/apps/higet/CMakeLists.txt @@ -31,6 +31,10 @@ list(APPEND APPS_SRC higet.cc ) +if (WIN32) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:\"LIBCMT\"" ) +endif() + if (NOT DISABLE_EXECUTABLES) build_executable(${HIGET} SOURCES ${APPS_SRC} diff --git a/apps/higet/higet.cc b/apps/higet/higet.cc index 194e616ed..9ae869731 100644 --- a/apps/higet/higet.cc +++ b/apps/higet/higet.cc @@ -119,7 +119,7 @@ class ReadBytesCallbackImplementation auto it = std::search(begin, end, begincrlf2, endcrlf2); if (it != end) { chunk_size_ = std::stoul(begin, 0, 16); - content_size_ += chunk_size_; + content_size_ += (long)chunk_size_; payload->trimStart(it + chunk_separator.size() - begin); std::size_t to_write; @@ -131,7 +131,7 @@ class ReadBytesCallbackImplementation } out_->write((char *)payload->data(), to_write); - byte_downloaded_ += to_write; + byte_downloaded_ += (long)to_write; payload->trimStart(to_write); if (payload->length() >= chunk_separator.size()) { @@ -141,7 +141,7 @@ class ReadBytesCallbackImplementation } } else { out_->write((char *)payload->data(), payload->length()); - byte_downloaded_ += payload->length(); + byte_downloaded_ += (long)payload->length(); } if (file_name_ != "-") { @@ -208,7 +208,7 @@ class ReadBytesCallbackImplementation #endif std::cout << "["; - int pos = barWidth * progress; + int pos = barWidth * (int)progress; for (int i = 0; i < barWidth; ++i) { if (i < pos) { std::cout << "="; diff --git a/apps/http-proxy/src/http_proxy.cc b/apps/http-proxy/src/http_proxy.cc index c252afe88..262fcb8e1 100644 --- a/apps/http-proxy/src/http_proxy.cc +++ b/apps/http-proxy/src/http_proxy.cc @@ -225,7 +225,6 @@ class HTTPClientConnectionCallback : interface::ConsumerSocket::ReadCallback { const char* reply = nullptr; if (result) { reply = HTTPMessageFastParser::http_ok; - prefix_hash_ = configured_prefix; } else { reply = HTTPMessageFastParser::http_failed; } diff --git a/cmake/Modules/BuildMacros.cmake b/cmake/Modules/BuildMacros.cmake index 4c55f32fe..c57aaa73c 100644 --- a/cmake/Modules/BuildMacros.cmake +++ b/cmake/Modules/BuildMacros.cmake @@ -262,8 +262,12 @@ macro (build_module module) if (${CMAKE_SYSTEM_NAME} MATCHES Darwin) set(LINK_FLAGS "-Wl,-undefined,dynamic_lookup") + elseif(${CMAKE_SYSTEM_NAME} MATCHES iOS) + set(LINK_FLAGS "-Wl,-undefined,dynamic_lookup") elseif(${CMAKE_SYSTEM_NAME} MATCHES Linux) set(LINK_FLAGS "-Wl,-unresolved-symbols=ignore-all") + elseif(${CMAKE_SYSTEM_NAME} MATCHES Windows) + set(LINK_FLAGS "/wd4275") else() message(FATAL_ERROR "Trying to build module on a not supportd platform. Aborting.") endif() diff --git a/cmake/Modules/FindLibconfig++.cmake b/cmake/Modules/FindLibconfig++.cmake index 865f75078..8dfc5fbe8 100644 --- a/cmake/Modules/FindLibconfig++.cmake +++ b/cmake/Modules/FindLibconfig++.cmake @@ -14,13 +14,13 @@ find_path(LIBCONFIG_INCLUDE_DIR libconfig.h++ if (WIN32) if(CMAKE_SIZEOF_VOID_P EQUAL 8) - find_library(LIBCONFIG_LIBRARY NAMES libconfig.lib + find_library(LIBCONFIG_CPP_LIBRARIES NAMES libconfig++.lib HINTS ${LIBCONFIG_SEARCH_PATH_LIST} PATH_SUFFIXES lib/x64 DOC "Find the libconfig libraries" ) elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) - find_library(LIBCONFIG_LIBRARY NAMES libconfig.lib + find_library(LIBCONFIG_CPP_LIBRARIES NAMES libconfig++.lib HINTS ${LIBCONFIG_SEARCH_PATH_LIST} PATH_SUFFIXES lib/x32 DOC "Find the libconfig libraries" @@ -40,4 +40,5 @@ set(LIBCONFIG_INCLUDE_DIRS ${LIBCONFIG_INCLUDE_DIR}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Libconfig++ LIBCONFIG_CPP_LIBRARIES LIBCONFIG_INCLUDE_DIRS) + mark_as_advanced(LIBCONFIG_CPP_LIBRARIES LIBCONFIG_INCLUDE_DIRS) diff --git a/hicn-light/src/hicn/command_line/controller/CMakeLists.txt b/hicn-light/src/hicn/command_line/controller/CMakeLists.txt index 949cace28..68caa7dc8 100644 --- a/hicn-light/src/hicn/command_line/controller/CMakeLists.txt +++ b/hicn-light/src/hicn/command_line/controller/CMakeLists.txt @@ -14,6 +14,11 @@ list(APPEND CONTROLLER_SRC hicnLightControl_main.c ) + +if (WIN32) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:\"LIBCMT\"" ) +endif() + if (NOT DISABLE_EXECUTABLES) build_executable(${HICN_LIGHT_CONTROL} SOURCES ${CONTROLLER_SRC} diff --git a/hicn-light/src/hicn/command_line/controller/hicnLightControl_main.c b/hicn-light/src/hicn/command_line/controller/hicnLightControl_main.c index 31b9674ca..e6a97c4e2 100644 --- a/hicn-light/src/hicn/command_line/controller/hicnLightControl_main.c +++ b/hicn-light/src/hicn/command_line/controller/hicnLightControl_main.c @@ -16,6 +16,7 @@ #include <hicn/hicn-light/config.h> #include <hicn/utils/utils.h> + #ifndef _WIN32 #include <arpa/inet.h> #include <getopt.h> diff --git a/hicn-light/src/hicn/command_line/daemon/CMakeLists.txt b/hicn-light/src/hicn/command_line/daemon/CMakeLists.txt index 1ab8a4e6f..ce62b51e2 100644 --- a/hicn-light/src/hicn/command_line/daemon/CMakeLists.txt +++ b/hicn-light/src/hicn/command_line/daemon/CMakeLists.txt @@ -14,6 +14,10 @@ list(APPEND DAEMON_SRC hicnLightDaemon_main.c ) +if (WIN32) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:\"LIBCMT\"" ) +endif() + if (NOT DISABLE_EXECUTABLES) build_executable(${HICN_LIGHT_DAEMON} SOURCES ${DAEMON_SRC} diff --git a/hicn-light/src/hicn/config/commandOps.c b/hicn-light/src/hicn/config/commandOps.c index dd8e148d0..b00e48e2a 100644 --- a/hicn-light/src/hicn/config/commandOps.c +++ b/hicn-light/src/hicn/config/commandOps.c @@ -13,6 +13,7 @@ * limitations under the License. */ + #include <hicn/hicn-light/config.h> #include <stdbool.h> #include <stdint.h> diff --git a/hicn-light/src/hicn/config/configurationListeners.c b/hicn-light/src/hicn/config/configurationListeners.c index b862b98f4..31a0c4776 100644 --- a/hicn-light/src/hicn/config/configurationListeners.c +++ b/hicn-light/src/hicn/config/configurationListeners.c @@ -598,7 +598,7 @@ void configurationListeners_SetupAll(const Configuration *config, uint16_t port, // Do not start on link address char listenerName[SYMBOLIC_NAME_LEN]; -#ifdef __ANDROID__ +#if defined(__ANDROID__) || defined(_WIN32) snprintf(listenerName, SYMBOLIC_NAME_LEN, "local_%zu", i); #else snprintf(listenerName, SYMBOLIC_NAME_LEN, "local_%ld", i); diff --git a/hicn-light/src/hicn/config/controlSetStrategy.c b/hicn-light/src/hicn/config/controlSetStrategy.c index 3229c1864..fe0ba84a0 100644 --- a/hicn-light/src/hicn/config/controlSetStrategy.c +++ b/hicn-light/src/hicn/config/controlSetStrategy.c @@ -228,7 +228,7 @@ static CommandReturn _controlSetStrategy_Execute(CommandParser *parser, if(parcList_Size(args) > 4){ uint32_t index = 4; //first realted prefix uint32_t addr_index = 0; - setStrategyCommand->related_prefixes = parcList_Size(args) - 4; + setStrategyCommand->related_prefixes = (uint8_t)parcList_Size(args) - 4; while(index < parcList_Size(args)){ const char *str = parcList_GetAtIndex(args, index); char *rel_addr = (char *)malloc(sizeof(char) * (strlen(str) + 1)); diff --git a/hicn-light/src/hicn/core/mapme.c b/hicn-light/src/hicn/core/mapme.c index 2a64833a8..3a1c9777b 100644 --- a/hicn-light/src/hicn/core/mapme.c +++ b/hicn-light/src/hicn/core/mapme.c @@ -536,13 +536,31 @@ mapme_send_updates(const MapMe * mapme, FibEntry * fibEntry, const NumberSet * n const Name *name = fibEntry_GetPrefix(fibEntry); char *name_str = name_ToString(name); bool clear_tfib = true; + + INFO(mapme, "[MAP-Me] Candidate next hops changed"); for (size_t j = 0; j < numberSet_Length(nexthops); j++) { unsigned nexthop_id = numberSet_GetItem(nexthops, j); - INFO(mapme, "[MAP-Me] sending IU/IN for name %s on connection %d", name_str, - nexthop_id); + + /* We extract the nexthop type based on tags */ + const char * nexthop_type; + ConnectionTable * table = forwarder_GetConnectionTable(mapme->forwarder); + const Connection * conn = connectionTable_FindById(table, nexthop_id); + if (connection_HasTag(conn, POLICY_TAG_WIRED)) { + nexthop_type = "WIRED"; + } else if (connection_HasTag(conn, POLICY_TAG_WIFI)) { + nexthop_type = "WIFI"; + } else if (connection_HasTag(conn, POLICY_TAG_CELLULAR)) { + nexthop_type = "CELLULAR"; + } else { + nexthop_type = "UNKNOWN"; + } + + INFO(mapme, "[MAP-Me] sending IU/IN for name %s on connection %d - %s (%s)", name_str, + nexthop_id, connection_GetInterfaceName(conn), nexthop_type); mapme_setFacePending(mapme, name, fibEntry, nexthop_id, true, true, clear_tfib, 0); clear_tfib = false; } + INFO(mapme, "[MAP-Me] Done sending MAP-Me update"); free(name_str); } diff --git a/hicn-light/src/hicn/core/nameBitvector.c b/hicn-light/src/hicn/core/nameBitvector.c index cc13bf610..653560750 100644 --- a/hicn-light/src/hicn/core/nameBitvector.c +++ b/hicn-light/src/hicn/core/nameBitvector.c @@ -243,13 +243,13 @@ uint32_t nameBitvector_lpm(const NameBitvector *a, prefix_len = (uint32_t)(BV_SIZE - (_diff_bit_log2(diff) + 1)); //printf("if 1 diff = %lu plen = %d\n", diff, prefix_len); }else{ - prefix_len = BV_SIZE; + prefix_len = (uint32_t)BV_SIZE; diff = a->bits[1] ^ b->bits[1]; if(diff){ - prefix_len += (BV_SIZE - (_diff_bit_log2(diff) + 1)); + prefix_len += (uint32_t)(BV_SIZE - (_diff_bit_log2(diff) + 1)); //printf("if 2 diff = %lu plen = %d\n", diff, prefix_len); }else{ - prefix_len += BV_SIZE; + prefix_len += (uint32_t)BV_SIZE; } } diff --git a/hicn-light/src/hicn/io/udpConnection.c b/hicn-light/src/hicn/io/udpConnection.c index cd3ccc84a..2747b7ef4 100644 --- a/hicn-light/src/hicn/io/udpConnection.c +++ b/hicn-light/src/hicn/io/udpConnection.c @@ -335,7 +335,7 @@ static bool _sendIOVBuffer(IoOperations *ops, struct iovec *message, dataBuf[i].len = (ULONG)message[i].iov_len; } - int rc = WSASendTo(udpConnState->udpListenerSocket, dataBuf, size, + int rc = WSASendTo(udpConnState->udpListenerSocket, dataBuf, (DWORD)size, &BytesSent, 0, (SOCKADDR *)udpConnState->peerAddress, udpConnState->peerAddressLength, NULL, NULL); free(dataBuf); diff --git a/hicn-light/src/hicn/processor/fibEntry.c b/hicn-light/src/hicn/processor/fibEntry.c index 30bcc1f9a..00e8dfa11 100644 --- a/hicn-light/src/hicn/processor/fibEntry.c +++ b/hicn-light/src/hicn/processor/fibEntry.c @@ -631,38 +631,38 @@ void fibEntry_ReceiveObjectMessage(const FibEntry *fibEntry, continue; if (connection_HasTag(conn, POLICY_TAG_WIRED)) { fibEntry->policy_counters.wired.num_packets++; - fibEntry->policy_counters.wired.num_bytes += msg_size; - fibEntry->policy.stats.wired.latency = \ + fibEntry->policy_counters.wired.num_bytes += (uint32_t)msg_size; + fibEntry->policy.stats.wired.latency = (float) (\ ALPHA * fibEntry->policy.stats.wired.latency + \ - (1 - ALPHA) * (double)rtt; + (1 - ALPHA) * (double)rtt); fibEntry->policy_counters.wired.latency_idle = 0; } if (connection_HasTag(conn, POLICY_TAG_WIFI)) { fibEntry->policy_counters.wifi.num_packets++; - fibEntry->policy_counters.wifi.num_bytes += msg_size; - fibEntry->policy.stats.wifi.latency = \ + fibEntry->policy_counters.wifi.num_bytes += (uint32_t)msg_size; + fibEntry->policy.stats.wifi.latency = (float)(\ ALPHA * fibEntry->policy.stats.wifi.latency + \ - (1 - ALPHA) * (double)rtt; + (1 - ALPHA) * (double)rtt); fibEntry->policy_counters.wifi.latency_idle = 0; } if (connection_HasTag(conn, POLICY_TAG_CELLULAR)) { fibEntry->policy_counters.cellular.num_packets++; - fibEntry->policy_counters.cellular.num_bytes += msg_size; - fibEntry->policy.stats.cellular.latency = \ + fibEntry->policy_counters.cellular.num_bytes += (uint32_t)msg_size; + fibEntry->policy.stats.cellular.latency = (float)(\ ALPHA * fibEntry->policy.stats.cellular.latency + \ - (1 - ALPHA) * (double)rtt; + (1 - ALPHA) * (double)rtt); fibEntry->policy_counters.cellular.latency_idle = 0; } } - fibEntry->policy.stats.all.latency = \ + fibEntry->policy.stats.all.latency = (float)(\ ALPHA * fibEntry->policy.stats.all.latency + \ - (1 - ALPHA) * (double)rtt; + (1 - ALPHA) * (double)rtt); fibEntry->policy_counters.all.latency_idle = 0; fibEntry->policy_counters.all.num_packets++; - fibEntry->policy_counters.all.num_bytes += msg_size; + fibEntry->policy_counters.all.num_bytes += (uint32_t)msg_size; #endif /* WITH_POLICY */ @@ -716,17 +716,17 @@ void fibEntry_UpdateStats(FibEntry *fibEntry, uint64_t now) { /* a) throughput */ if (fibEntry->policy_counters.wired.num_bytes > 0) { - throughput = fibEntry->policy_counters.wired.num_bytes / \ - (now - fibEntry->policy_counters.last_update) ; + throughput = (float)(fibEntry->policy_counters.wired.num_bytes / \ + (now - fibEntry->policy_counters.last_update)) ; throughput = throughput * 8 / 1024; if (throughput < 0) throughput = 0; } else { throughput = 0; } - fibEntry->policy.stats.wired.throughput = \ + fibEntry->policy.stats.wired.throughput = (float)(\ ALPHA * fibEntry->policy.stats.wired.throughput + \ - (1-ALPHA) * throughput; + (1-ALPHA) * throughput); /* b) loss rate */ if ((fibEntry->policy_counters.wired.num_losses > 0) && \ @@ -737,9 +737,9 @@ void fibEntry_UpdateStats(FibEntry *fibEntry, uint64_t now) { } else { loss_rate = 0; } - fibEntry->policy.stats.wired.loss_rate = \ + fibEntry->policy.stats.wired.loss_rate = (float)(\ ALPHA * fibEntry->policy.stats.wired.loss_rate + \ - (1-ALPHA) * loss_rate; + (1-ALPHA) * loss_rate); /* Latency */ fibEntry->policy_counters.wired.latency_idle++; @@ -763,17 +763,17 @@ void fibEntry_UpdateStats(FibEntry *fibEntry, uint64_t now) { /* a) throughput */ if (fibEntry->policy_counters.wifi.num_bytes > 0) { - throughput = fibEntry->policy_counters.wifi.num_bytes / \ - (now - fibEntry->policy_counters.last_update); + throughput = (float)(fibEntry->policy_counters.wifi.num_bytes / \ + (now - fibEntry->policy_counters.last_update)); throughput = throughput * 8 / 1024; if (throughput < 0) throughput = 0; } else { throughput = 0; } - fibEntry->policy.stats.wifi.throughput = \ + fibEntry->policy.stats.wifi.throughput = (float)( \ ALPHA * fibEntry->policy.stats.wifi.throughput + \ - (1-ALPHA) * throughput; + (1-ALPHA) * throughput); /* b) loss rate */ if ((fibEntry->policy_counters.wifi.num_losses > 0) && \ @@ -784,9 +784,9 @@ void fibEntry_UpdateStats(FibEntry *fibEntry, uint64_t now) { } else { loss_rate = 0; } - fibEntry->policy.stats.wifi.loss_rate = \ + fibEntry->policy.stats.wifi.loss_rate = (float)(\ ALPHA * fibEntry->policy.stats.wifi.loss_rate + \ - (1-ALPHA) * loss_rate; + (1-ALPHA) * loss_rate); fibEntry->policy_counters.wifi.num_bytes = 0; fibEntry->policy_counters.wifi.num_losses = 0; @@ -796,17 +796,17 @@ void fibEntry_UpdateStats(FibEntry *fibEntry, uint64_t now) { /* a) throughput */ if (fibEntry->policy_counters.cellular.num_bytes > 0) { - throughput = fibEntry->policy_counters.cellular.num_bytes / \ - (now - fibEntry->policy_counters.last_update) ; + throughput = (float)(fibEntry->policy_counters.cellular.num_bytes / \ + (now - fibEntry->policy_counters.last_update)) ; throughput = throughput * 8 / 1024; if (throughput < 0) throughput = 0; } else { throughput = 0; } - fibEntry->policy.stats.cellular.throughput = \ + fibEntry->policy.stats.cellular.throughput = (float)( \ ALPHA * fibEntry->policy.stats.cellular.throughput + \ - (1-ALPHA) * throughput; + (1-ALPHA) * throughput); /* b) loss rate */ if ((fibEntry->policy_counters.cellular.num_losses > 0) && \ @@ -817,9 +817,9 @@ void fibEntry_UpdateStats(FibEntry *fibEntry, uint64_t now) { } else { loss_rate = 0; } - fibEntry->policy.stats.cellular.loss_rate = \ + fibEntry->policy.stats.cellular.loss_rate = (float)( \ ALPHA * fibEntry->policy.stats.cellular.loss_rate + \ - (1-ALPHA) * loss_rate; + (1-ALPHA) * loss_rate); fibEntry->policy_counters.cellular.num_bytes = 0; fibEntry->policy_counters.cellular.num_losses = 0; @@ -829,17 +829,17 @@ void fibEntry_UpdateStats(FibEntry *fibEntry, uint64_t now) { /* a) throughput */ if (fibEntry->policy_counters.all.num_bytes > 0) { - throughput = fibEntry->policy_counters.all.num_bytes / \ - (now - fibEntry->policy_counters.last_update); + throughput = (float)( fibEntry->policy_counters.all.num_bytes / \ + (now - fibEntry->policy_counters.last_update)); throughput = throughput * 8 / 1024; if (throughput < 0) throughput = 0; } else { throughput = 0; } - fibEntry->policy.stats.all.throughput = \ + fibEntry->policy.stats.all.throughput = (float)(\ ALPHA * fibEntry->policy.stats.all.throughput + \ - (1-ALPHA) * throughput; + (1-ALPHA) * throughput); /* b) loss rate */ if ((fibEntry->policy_counters.all.num_losses > 0) && \ @@ -850,9 +850,9 @@ void fibEntry_UpdateStats(FibEntry *fibEntry, uint64_t now) { } else { loss_rate = 0; } - fibEntry->policy.stats.all.loss_rate = \ + fibEntry->policy.stats.all.loss_rate = (float)(\ ALPHA * fibEntry->policy.stats.all.loss_rate + \ - (1-ALPHA) * loss_rate; + (1-ALPHA) * loss_rate); fibEntry->policy_counters.all.num_bytes = 0; fibEntry->policy_counters.all.num_losses = 0; diff --git a/lib/includes/hicn/base.h b/lib/includes/hicn/base.h index 797912f91..1061724ce 100644 --- a/lib/includes/hicn/base.h +++ b/lib/includes/hicn/base.h @@ -22,8 +22,11 @@ #define HICN_BASE_H #include "common.h" +#ifdef _WIN32 +#include <Winsock2.h> +#else #include <netinet/in.h> - +#endif /* Default header fields */ #define HICN_DEFAULT_TTL 254 diff --git a/lib/includes/hicn/common.h b/lib/includes/hicn/common.h index a5ca2878b..05f8ad95f 100644 --- a/lib/includes/hicn/common.h +++ b/lib/includes/hicn/common.h @@ -104,6 +104,9 @@ typedef uword ip_csum_t; /* Windows compatibility headers */ #define WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX +#define NOMINMAX +#endif #include <windows.h> #include <winsock2.h> #include <ws2ipdef.h> diff --git a/lib/includes/hicn/util/windows/dlfcn.h b/lib/includes/hicn/util/windows/dlfcn.h new file mode 100644 index 000000000..7775226cd --- /dev/null +++ b/lib/includes/hicn/util/windows/dlfcn.h @@ -0,0 +1,33 @@ +/* dlfcn.h */ + +#ifndef DLFCN_H +#define DLFCN_H +#define RTLD_GLOBAL 0x100 /* do not hide entries in this module */ +#define RTLD_LOCAL 0x000 /* hide entries in this module */ + +#define RTLD_LAZY 0x000 /* accept unresolved externs */ +#define RTLD_NOW 0x001 /* abort if module has unresolved externs */ + +/* + How to call in Windows: + + void *h = dlopen ("path\\library.dll", flags) + void (*fun)() = dlsym (h, "entry") +*/ + +#ifdef __cplusplus +extern "C" { +#endif + + void *dlopen (const char *filename, int flag); + int dlclose (void *handle); + + void *dlsym (void *handle, const char *name); + +const char *dlerror (void); + +#ifdef __cplusplus +} +#endif + +#endif
\ No newline at end of file diff --git a/lib/includes/hicn/util/windows/windows_utils.h b/lib/includes/hicn/util/windows/windows_utils.h index c4662af5e..d24aaadbf 100755 --- a/lib/includes/hicn/util/windows/windows_utils.h +++ b/lib/includes/hicn/util/windows/windows_utils.h @@ -17,12 +17,16 @@ #define WINDOWS_UTILS_H
#define WIN32_LEAN_AND_MEAN
#define HAVE_STRUCT_TIMESPEC
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
#include <Windows.h>
#include <stdint.h>
#include <io.h>
#include <stdlib.h>
#include <winsock2.h>
#include <WS2tcpip.h>
+#include "dlfcn.h"
#ifndef IOVEC
#define IOVEC
@@ -152,3 +156,7 @@ int gettimeofday(struct timeval * tp, struct timezone * tzp); ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) \
| (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
#endif
+
+#ifndef bzero
+#define bzero(b,len) (memset((b), '\0', (len)), (void) 0)
+#endif
\ No newline at end of file diff --git a/lib/src/CMakeLists.txt b/lib/src/CMakeLists.txt index 49b735f51..f410e3d83 100644 --- a/lib/src/CMakeLists.txt +++ b/lib/src/CMakeLists.txt @@ -30,6 +30,11 @@ list(APPEND LIBHICN_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/util/log.c ) +if (WIN32) + list(APPEND LIBHICN_SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/util/windows/dlfcn.c + ) +endif () set (COMPILER_DEFINITIONS "-DWITH_MAPME") include(BuildMacros) diff --git a/lib/src/util/windows/dlfcn.c b/lib/src/util/windows/dlfcn.c new file mode 100644 index 000000000..c8173cdb0 --- /dev/null +++ b/lib/src/util/windows/dlfcn.c @@ -0,0 +1,65 @@ +/* dlfcn.c */ + +#include <inttypes.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <windows.h> + +static struct { + long lasterror; + const char *err_rutin; +} var = { + 0, + NULL +}; + +void *dlopen (const char *filename, int flags) +{ + HINSTANCE hInst; + + hInst= LoadLibrary (filename); + if (hInst==NULL) { + var.lasterror = GetLastError (); + var.err_rutin = "dlopen"; + } + return hInst; +} + +int dlclose (void *handle) +{ + BOOL ok; + int rc= 0; + + ok= FreeLibrary ((HINSTANCE)handle); + if (! ok) { + var.lasterror = GetLastError (); + var.err_rutin = "dlclose"; + rc= -1; + } + return rc; +} + +void *dlsym (void *handle, const char *name) +{ + FARPROC fp; + + fp= GetProcAddress ((HINSTANCE)handle, name); + if (!fp) { + var.lasterror = GetLastError (); + var.err_rutin = "dlsym"; + } + return (void *)(intptr_t)fp; +} + +const char *dlerror (void) +{ +static char errstr [88]; + + if (var.lasterror) { + sprintf (errstr, "%s error #%ld", var.err_rutin, var.lasterror); + return errstr; + } else { + return NULL; + } +}
\ No newline at end of file diff --git a/libtransport/CMakeLists.txt b/libtransport/CMakeLists.txt index 3f828c4d6..9d2b9069f 100644 --- a/libtransport/CMakeLists.txt +++ b/libtransport/CMakeLists.txt @@ -50,7 +50,9 @@ if ((BUILD_HICNPLUGIN OR BUILD_MEMIF_CONNECTOR) AND "${CMAKE_SYSTEM_NAME}" STREQ endif () set(LIBTRANSPORT ${LIBTRANSPORT} CACHE INTERNAL "" FORCE) +if (NOT WIN32) set(LIBTRANSPORT_SHARED ${LIBTRANSPORT}.shared CACHE INTERNAL "" FORCE) +endif () set(LIBTRANSPORT_STATIC ${LIBTRANSPORT}.static CACHE INTERNAL "" FORCE) set(LIBTRANSPORT_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src CACHE INTERNAL "" FORCE) @@ -79,11 +81,17 @@ else() else() set(HICN_LIBRARIES ${LIBHICN_SHARED}) list(APPEND DEPENDENCIES + ${LIBHICN_SHARED} ) endif() endif() - +if (WIN32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4275 /wd4996 /wd4311 /wd4302") + if (CMAKE_BUILD_TYPE EQUAL "RELEASE") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:\"MSVCRTD\"" ) + endif () +endif () include(Packaging) list(APPEND LIBRARIES @@ -97,6 +105,7 @@ list(APPEND LIBRARIES ${LIBCONFIG_CPP_LIBRARIES} ) + # Include dirs -- Order does matter! list(APPEND LIBTRANSPORT_INTERNAL_INCLUDE_DIRS ${HICN_INCLUDE_DIRS} diff --git a/libtransport/includes/hicn/transport/portability/win_portability.h b/libtransport/includes/hicn/transport/portability/win_portability.h index bfbe431d1..246b734ad 100644 --- a/libtransport/includes/hicn/transport/portability/win_portability.h +++ b/libtransport/includes/hicn/transport/portability/win_portability.h @@ -17,7 +17,9 @@ #pragma once
#define WIN32_LEAN_AND_MEAN
+#ifndef NOMINMAX
#define NOMINMAX
+#endif
#include <fcntl.h>
#include <io.h>
#include <parc/windows/parc_Utils.h>
diff --git a/libtransport/src/CMakeLists.txt b/libtransport/src/CMakeLists.txt index 0fa9bbe3c..079427fea 100644 --- a/libtransport/src/CMakeLists.txt +++ b/libtransport/src/CMakeLists.txt @@ -59,9 +59,9 @@ set(LIBTRANSPORT_INCLUDE_DIRS if (NOT WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") else () - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4200") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4200 -D_WIN32_WINDOWS=0x0400") if (CMAKE_BUILD_TYPE EQUAL "RELEASE") - set(CMAKE_SHARED_LINKER_FLAGS "/NODEFAULTLIB:\"MSVCRTD\"" ) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:\"MSVCRTD\"" ) endif () endif () diff --git a/libtransport/src/auth/signer.cc b/libtransport/src/auth/signer.cc index 281b9c59a..99c3d099d 100644 --- a/libtransport/src/auth/signer.cc +++ b/libtransport/src/auth/signer.cc @@ -88,7 +88,7 @@ void Signer::signPacket(PacketPtr packet) { // Compute signature PARCSignature *signature = parcSigner_SignDigestNoAlloc( - signer_, hash.hash_, packet->getSignature(), signature_len); + signer_, hash.hash_, packet->getSignature(), (uint32_t)signature_len); PARCBuffer *buffer = parcSignature_GetSignature(signature); size_t bytes_len = parcBuffer_Remaining(buffer); diff --git a/libtransport/src/core/fec.cc b/libtransport/src/core/fec.cc index 134198b9e..0ce9625a2 100644 --- a/libtransport/src/core/fec.cc +++ b/libtransport/src/core/fec.cc @@ -55,13 +55,15 @@ * https://gcc.gnu.org/bugzilla//show_bug.cgi?id=88059 */ #ifndef __clang__ +#ifndef _WIN32 #pragma GCC diagnostic ignored "-Wstringop-overflow" #endif +#endif /* * compatibility stuff */ -#ifdef MSDOS /* but also for others, e.g. sun... */ +#if defined (MSDOS) || defined (_WIN32) /* but also for others, e.g. sun... */ #define NEED_BCOPY #define bcmp(a,b,n) memcmp(a,b,n) #endif diff --git a/libtransport/src/core/global_configuration.cc b/libtransport/src/core/global_configuration.cc index e0b6c040a..3e37a30a4 100644 --- a/libtransport/src/core/global_configuration.cc +++ b/libtransport/src/core/global_configuration.cc @@ -32,7 +32,7 @@ bool GlobalConfiguration::parseTransportConfig(const std::string& path) { try { cfg.readFile(path.c_str()); } catch (const FileIOException& fioex) { - TRANSPORT_LOGE("I/O error while reading file."); + TRANSPORT_LOGE("I/O error while reading file: %s", fioex.what()); return false; } catch (const ParseException& pex) { TRANSPORT_LOGE("Parse error at %s:%d - %s", pex.getFile(), pex.getLine(), @@ -67,6 +67,7 @@ void GlobalConfiguration::parseConfiguration(const std::string& path) { // Check if an environment variable with the configuration path exists. COnf // variable comes first. std::unique_lock<std::mutex> lck(cp_mtx_); + if (const char* env_c = std::getenv(GlobalConfiguration::conf_file)) { parseTransportConfig(env_c); } else if (!path.empty()) { diff --git a/libtransport/src/core/interest.cc b/libtransport/src/core/interest.cc index 06cbe9f81..b4a74762d 100644 --- a/libtransport/src/core/interest.cc +++ b/libtransport/src/core/interest.cc @@ -175,7 +175,7 @@ void Interest::encodeSuffixes() { // We assume interest does not hold signature for the moment. auto int_manifest_header = (InterestManifestHeader *)(writableData() + headerSize()); - int_manifest_header->n_suffixes = suffix_set_.size(); + int_manifest_header->n_suffixes = (uint32_t)suffix_set_.size(); std::size_t additional_length = int_manifest_header->n_suffixes * sizeof(uint32_t); diff --git a/libtransport/src/core/io_module.cc b/libtransport/src/core/io_module.cc index fef0c1504..7c2ec2cab 100644 --- a/libtransport/src/core/io_module.cc +++ b/libtransport/src/core/io_module.cc @@ -13,12 +13,16 @@ * limitations under the License. */ +#ifndef _WIN32 #include <dlfcn.h> +#endif #include <hicn/transport/core/io_module.h> #include <hicn/transport/utils/log.h> #ifdef ANDROID #include <io_modules/udp/hicn_forwarder_module.h> +#elif _WIN32 +#include <hicn/util/windows/windows_utils.h> #endif #include <deque> diff --git a/libtransport/src/core/manifest_format_fixed.cc b/libtransport/src/core/manifest_format_fixed.cc index 55280b460..7076a4c90 100644 --- a/libtransport/src/core/manifest_format_fixed.cc +++ b/libtransport/src/core/manifest_format_fixed.cc @@ -34,7 +34,7 @@ FixedManifestEncoder::FixedManifestEncoder(Packet &packet, current_entry_(0), signature_size_(signature_size) { if (clear) { - *manifest_header_ = {0}; + memset(manifest_header_, 0, sizeof(*manifest_header_)); } } @@ -51,7 +51,7 @@ FixedManifestEncoder &FixedManifestEncoder::clearImpl() { packet_.trimEnd(sizeof(ManifestHeader) + manifest_header_->number_of_entries * sizeof(ManifestEntry)); current_entry_ = 0; - *manifest_header_ = {0}; + memset(manifest_header_, 0, sizeof(*manifest_header_)); return *this; } diff --git a/libtransport/src/core/portal.cc b/libtransport/src/core/portal.cc index d1d26c5b7..33335e542 100644 --- a/libtransport/src/core/portal.cc +++ b/libtransport/src/core/portal.cc @@ -33,6 +33,8 @@ static const constexpr char default_module[] = ""; static const constexpr char default_module[] = "hicnlight_module.dylib"; #elif defined(LINUX) static const constexpr char default_module[] = "hicnlight_module.so"; +#elif defined(WINDOWS) +static const constexpr char default_module[] = "hicnlight_module.lib"; #endif IoModuleConfiguration Portal::conf_; @@ -69,6 +71,8 @@ std::string getIoModulePath(const std::string& name, std::string extension = ".so"; #elif defined(MACINTOSH) std::string extension = ".dylib"; +#elif defined(WINDOWS) + std::string extension = ".lib"; #else #error "Platform not supported."; #endif diff --git a/libtransport/src/core/prefix.cc b/libtransport/src/core/prefix.cc index 1e2b2ed9d..d598cff75 100644 --- a/libtransport/src/core/prefix.cc +++ b/libtransport/src/core/prefix.cc @@ -69,7 +69,7 @@ Prefix::Prefix(const core::Name &content_name, uint16_t prefix_length) { } ip_prefix_ = content_name.toIpAddress(); - ip_prefix_.len = prefix_length; + ip_prefix_.len = (u8)prefix_length; ip_prefix_.family = family; } @@ -95,7 +95,7 @@ void Prefix::buildPrefix(std::string &prefix, uint16_t prefix_length, throw errors::InvalidIpAddressException(); } - ip_prefix_.len = prefix_length; + ip_prefix_.len = (u8)prefix_length; ip_prefix_.family = family; } @@ -123,7 +123,7 @@ std::unique_ptr<Sockaddr> Prefix::toSockaddr() const { uint16_t Prefix::getPrefixLength() const { return ip_prefix_.len; } Prefix &Prefix::setPrefixLength(uint16_t prefix_length) { - ip_prefix_.len = prefix_length; + ip_prefix_.len = (u8)prefix_length; return *this; } @@ -228,7 +228,7 @@ Name Prefix::getRandomName() const { size_t size = (size_t)ceil((float)addr_len / 8.0); uint8_t *buffer = (uint8_t *)malloc(sizeof(uint8_t) * size); - RAND_bytes(buffer, size); + RAND_bytes(buffer, (int)size); int j = 0; for (uint8_t i = (uint8_t)ceil((float)ip_prefix_.len / 8.0); diff --git a/libtransport/src/core/rs.cc b/libtransport/src/core/rs.cc index 44b5852e5..33270736d 100644 --- a/libtransport/src/core/rs.cc +++ b/libtransport/src/core/rs.cc @@ -70,8 +70,8 @@ bool BlockCode::addSymbol(const fec::buffer &packet, uint32_t i, } void BlockCode::encode() { - gf *data[n_]; - std::uint16_t old_values[k_]; + gf **data = new gf*[k_]; + uint32_t *old_values = new uint32_t[k_]; uint32_t base = operator[](0).first; // Set packet length in first 2 bytes @@ -93,9 +93,10 @@ void BlockCode::encode() { uint16_t *length = reinterpret_cast<uint16_t *>(packet->writableData()); old_values[i] = *length; - *length = htons(packet->length() - LEN_SIZE_BYTES); + *length = htons(u_short(packet->length() - LEN_SIZE_BYTES)); data[i] = packet->writableData(); + } // Finish to fill source block with the buffers to hold the repair symbols @@ -121,7 +122,7 @@ void BlockCode::encode() { TRANSPORT_LOGD("Calling encode with max_buffer_size_ = %zu", max_buffer_size_); for (uint32_t i = k_; i < n_; i++) { - fec_encode(code_, data, data[i], i, max_buffer_size_ + LEN_SIZE_BYTES); + fec_encode(code_, data, data[i], i, (int)(max_buffer_size_ + LEN_SIZE_BYTES)); } // Restore original content of buffer space used to store the length @@ -138,11 +139,13 @@ void BlockCode::encode() { TRANSPORT_LOGD("Produced repair symbol of size = %zu", packet->length()); packet->prepend(sizeof(fec_header)); } + delete [] data; + delete [] old_values; } void BlockCode::decode() { - gf *data[k_]; - uint32_t index[k_]; + gf **data = new gf*[k_]; + uint32_t *index = new uint32_t[k_]; for (uint32_t i = 0; i < k_; i++) { auto &packet = operator[](i).second; @@ -161,7 +164,7 @@ void BlockCode::decode() { packet->ensureCapacityAndFillUnused(max_buffer_size_, 0); uint16_t *length = reinterpret_cast<uint16_t *>(packet->writableData()); - *length = htons(packet->length() - LEN_SIZE_BYTES); + *length = htons(u_short(packet->length() - LEN_SIZE_BYTES)); } else { TRANSPORT_LOGD("DECODE SYMBOL - index %u - Current buffer size: %zu", index[i], packet->length()); @@ -169,12 +172,14 @@ void BlockCode::decode() { } data[i] = packet->writableData(); + delete [] data; + delete [] index; } // We decode the source block TRANSPORT_LOGD("Calling decode with max_buffer_size_ = %zu", max_buffer_size_); - fec_decode(code_, data, reinterpret_cast<int *>(index), max_buffer_size_); + fec_decode(code_, data, reinterpret_cast<int *>(index), (int)max_buffer_size_); // Find the index in the block for recovered packets for (uint32_t i = 0; i < k_; i++) { diff --git a/libtransport/src/core/rs.h b/libtransport/src/core/rs.h index d630bd233..9a8c43e4d 100644 --- a/libtransport/src/core/rs.h +++ b/libtransport/src/core/rs.h @@ -14,7 +14,9 @@ * limitations under the License. */ +#ifndef _WIN32 #include <arpa/inet.h> +#endif #include <hicn/transport/utils/membuf.h> #include <protocols/fec_base.h> diff --git a/libtransport/src/implementation/p2psecure_socket_consumer.cc b/libtransport/src/implementation/p2psecure_socket_consumer.cc index 8c7c175b2..0b5966e71 100644 --- a/libtransport/src/implementation/p2psecure_socket_consumer.cc +++ b/libtransport/src/implementation/p2psecure_socket_consumer.cc @@ -76,7 +76,7 @@ int readOld(BIO *b, char *buf, int size) { } } - return read; + return (int)read; } /* Return the number of read bytes in readbytes */ diff --git a/libtransport/src/implementation/p2psecure_socket_producer.cc b/libtransport/src/implementation/p2psecure_socket_producer.cc index 6dff2ba08..aa14f9e37 100644 --- a/libtransport/src/implementation/p2psecure_socket_producer.cc +++ b/libtransport/src/implementation/p2psecure_socket_producer.cc @@ -55,8 +55,8 @@ P2PSecureProducerSocket::P2PSecureProducerSocket( der_prk_ = parcKeyStore_GetDEREncodedPrivateKey( (identity->getSigner()->getParcKeyStore())); - int cert_size = parcBuffer_Limit(der_cert_); - int prk_size = parcBuffer_Limit(der_prk_); + int cert_size = (int)parcBuffer_Limit(der_cert_); + int prk_size = (int)parcBuffer_Limit(der_prk_); const uint8_t *cert = reinterpret_cast<uint8_t *>(parcBuffer_Overlay(der_cert_, cert_size)); const uint8_t *prk = diff --git a/libtransport/src/implementation/socket_producer.h b/libtransport/src/implementation/socket_producer.h index af69cd818..f511f7743 100644 --- a/libtransport/src/implementation/socket_producer.h +++ b/libtransport/src/implementation/socket_producer.h @@ -417,7 +417,7 @@ class ProducerSocket : public Socket { uint32_t &socket_option_value) { switch (socket_option_key) { case GeneralTransportOptions::OUTPUT_BUFFER_SIZE: - socket_option_value = production_protocol_->getOutputBufferSize(); + socket_option_value = (uint32_t)production_protocol_->getOutputBufferSize(); break; case GeneralTransportOptions::DATA_PACKET_SIZE: diff --git a/libtransport/src/implementation/tls_socket_consumer.cc b/libtransport/src/implementation/tls_socket_consumer.cc index 99bcd4360..65472b41d 100644 --- a/libtransport/src/implementation/tls_socket_consumer.cc +++ b/libtransport/src/implementation/tls_socket_consumer.cc @@ -75,7 +75,7 @@ int readOldTLS(BIO *b, char *buf, int size) { } } - return read; + return (int)read; } /* Return the number of read bytes in readbytes */ diff --git a/libtransport/src/implementation/tls_socket_producer.cc b/libtransport/src/implementation/tls_socket_producer.cc index e54d38d56..dd92e58cf 100644 --- a/libtransport/src/implementation/tls_socket_producer.cc +++ b/libtransport/src/implementation/tls_socket_producer.cc @@ -64,7 +64,7 @@ int TLSProducerSocket::readOld(BIO *b, char *buf, int size) { if ((int)membuf->length() > size) { size_to_read = size; } else { - size_to_read = membuf->length(); + size_to_read = (int)membuf->length(); socket->something_to_read_ = false; } @@ -289,7 +289,7 @@ void TLSProducerSocket::onInterest(ProducerSocket &p, Interest &interest) { SSL_read( ssl_, const_cast<unsigned char *>(interest.getPayload()->writableData()), - interest.getPayload()->length()); + (int)interest.getPayload()->length()); } ProducerInterestCallback *on_interest_input_decrypted; @@ -325,7 +325,7 @@ void TLSProducerSocket::cacheMiss(interface::ProducerSocket &p, SSL_read( ssl_, const_cast<unsigned char *>(interest.getPayload()->writableData()), - interest.getPayload()->length()); + (int)interest.getPayload()->length()); } if (on_interest_process_decrypted_ != VOID_HANDLER) @@ -360,7 +360,7 @@ uint32_t TLSProducerSocket::produceStream( size_t buf_size = buffer->length(); name_ = production_protocol_->getNamespaces().front().mapName(content_name); tls_chunks_ = to_call_oncontentproduced_ = - ceil((float)buf_size / (float)SSL3_RT_MAX_PLAIN_LENGTH); + (int)ceil((float)buf_size / (float)SSL3_RT_MAX_PLAIN_LENGTH); if (!is_last) { tls_chunks_++; @@ -368,7 +368,7 @@ uint32_t TLSProducerSocket::produceStream( last_segment_ = start_offset; - SSL_write(ssl_, buffer->data(), buf_size); + SSL_write(ssl_, buffer->data(), (int)buf_size); BIO *wbio = SSL_get_wbio(ssl_); int i = BIO_flush(wbio); (void)i; // To shut up gcc 5 diff --git a/libtransport/src/io_modules/CMakeLists.txt b/libtransport/src/io_modules/CMakeLists.txt index 6553b9a2b..cf466721f 100644 --- a/libtransport/src/io_modules/CMakeLists.txt +++ b/libtransport/src/io_modules/CMakeLists.txt @@ -13,7 +13,8 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR) -if (${CMAKE_SYSTEM_NAME} MATCHES Android) +if (${CMAKE_SYSTEM_NAME} MATCHES "^(iOS|Android|Windows)$") + list(APPEND SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/udp/hicn_forwarder_module.cc ${CMAKE_CURRENT_SOURCE_DIR}/udp/udp_socket_connector.cc @@ -26,7 +27,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES Android) set(SOURCE_FILES ${SOURCE_FILES} PARENT_SCOPE) set(HEADER_FILES ${HEADER_FILES} PARENT_SCOPE) -else() +else () add_subdirectory(udp) add_subdirectory(loopback) add_subdirectory(forwarder) diff --git a/libtransport/src/io_modules/udp/CMakeLists.txt b/libtransport/src/io_modules/udp/CMakeLists.txt index 1a43492dc..93518d0a2 100644 --- a/libtransport/src/io_modules/udp/CMakeLists.txt +++ b/libtransport/src/io_modules/udp/CMakeLists.txt @@ -34,14 +34,13 @@ list(APPEND MODULE_SOURCE_FILES # MACOSX_BUNDLE_SHORT_VERSION_STRING "0.1" # # MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/customtemplate.plist.in # ) - build_module(hicnlight_module - SHARED - SOURCES ${MODULE_SOURCE_FILES} - DEPENDS ${DEPENDENCIES} - COMPONENT lib${LIBTRANSPORT} - INCLUDE_DIRS ${LIBTRANSPORT_INCLUDE_DIRS} ${LIBTRANSPORT_INTERNAL_INCLUDE_DIRS} - # LIBRARY_ROOT_DIR "vpp_plugins" - DEFINITIONS ${COMPILER_DEFINITIONS} - COMPILE_OPTIONS ${COMPILE_FLAGS} + SHARED + SOURCES ${MODULE_SOURCE_FILES} + DEPENDS ${DEPENDENCIES} + COMPONENT lib${LIBTRANSPORT} + INCLUDE_DIRS ${LIBTRANSPORT_INCLUDE_DIRS} ${LIBTRANSPORT_INTERNAL_INCLUDE_DIRS} + # LIBRARY_ROOT_DIR "vpp_plugins" + DEFINITIONS ${COMPILER_DEFINITIONS} + COMPILE_OPTIONS ${COMPILE_FLAGS} ) diff --git a/libtransport/src/protocols/prod_protocol_rtc.cc b/libtransport/src/protocols/prod_protocol_rtc.cc index 8081923e3..049752876 100644 --- a/libtransport/src/protocols/prod_protocol_rtc.cc +++ b/libtransport/src/protocols/prod_protocol_rtc.cc @@ -90,8 +90,8 @@ void RTCProductionProtocol::updateStats() { uint32_t prev_packets_production_rate = packets_production_rate_; - bytes_production_rate_ = ceil((double)produced_bytes_ * per_second); - packets_production_rate_ = ceil((double)produced_packets_ * per_second); + bytes_production_rate_ = (uint32_t)ceil((double)produced_bytes_ * per_second); + packets_production_rate_ = (uint32_t)ceil((double)produced_packets_ * per_second); TRANSPORT_LOGD("Updating production rate: produced_bytes_ = %u bps = %u", produced_bytes_, bytes_production_rate_); @@ -99,7 +99,7 @@ void RTCProductionProtocol::updateStats() { // update the production rate as soon as it increases by 10% with respect to // the last round max_packet_production_ = - produced_packets_ + ceil((double)produced_packets_ * 0.1); + produced_packets_ + (uint32_t)ceil((double)produced_packets_ * 0.1); if (max_packet_production_ < rtc::WIN_MIN) max_packet_production_ = rtc::WIN_MIN; @@ -189,8 +189,8 @@ void RTCProductionProtocol::produceInternal( content_object->setPathLabel(prod_label_); // update stats - produced_bytes_ += - content_object->headerSize() + content_object->payloadSize(); + produced_bytes_ += (uint32_t)( + content_object->headerSize() + content_object->payloadSize()); produced_packets_++; if (produced_packets_ >= max_packet_production_) { @@ -318,14 +318,14 @@ void RTCProductionProtocol::onInterest(Interest &interest) { if (!consumer_in_sync_ && on_consumer_in_sync_) { // we consider the remote consumer to be in sync as soon as it covers 70% // of the production window with interests - uint32_t perc = ceil((double)max_gap * 0.7); + uint32_t perc = (uint32_t)ceil((double)max_gap * 0.7); if (interest_seg > (perc + current_seg_)) { consumer_in_sync_ = true; on_consumer_in_sync_(*socket_->getInterface(), interest); } } - uint64_t expiration = - now + floor((double)lifetime * rtc::INTEREST_LIFETIME_REDUCTION_FACTOR); + uint64_t expiration =(uint32_t)( + now + floor((double)lifetime * rtc::INTEREST_LIFETIME_REDUCTION_FACTOR)); addToInterestQueue(interest_seg, expiration); } } @@ -377,7 +377,7 @@ void RTCProductionProtocol::sendNacksForPendingInterests() { uint32_t packet_gap = 100000; // set it to a high value (100sec) if (packets_production_rate_ != 0) - packet_gap = ceil(rtc::MILLI_IN_A_SEC / (double)packets_production_rate_); + packet_gap = (uint32_t)ceil(rtc::MILLI_IN_A_SEC / (double)packets_production_rate_); uint64_t now = std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::steady_clock::now().time_since_epoch()) diff --git a/libtransport/src/protocols/rtc/rtc.cc b/libtransport/src/protocols/rtc/rtc.cc index bb95ab686..46659ac74 100644 --- a/libtransport/src/protocols/rtc/rtc.cc +++ b/libtransport/src/protocols/rtc/rtc.cc @@ -220,11 +220,11 @@ void RTCTransportProtocol::updateSyncWindow() { // if some of the info are not available do not update the current win if (prod_rate != 0.0 && rtt != 0.0 && packet_size != 0.0) { current_sync_win_ = (uint32_t)ceil(prod_rate * rtt / packet_size); - current_sync_win_ += + current_sync_win_ += (uint32_t) ceil(prod_rate * (PRODUCER_BUFFER_MS / MILLI_IN_A_SEC) / packet_size); if(current_state_ == SyncState::catch_up) { - current_sync_win_ = current_sync_win_ * CATCH_UP_WIN_INCREMENT; + current_sync_win_ = (uint32_t) (current_sync_win_ * CATCH_UP_WIN_INCREMENT); } current_sync_win_ = std::min(current_sync_win_, max_sync_win_); @@ -515,7 +515,7 @@ void RTCTransportProtocol::onContentObject(Interest &interest, ContentObject &content_object) { TRANSPORT_LOGD("Received content object of size: %zu", content_object.payloadSize()); - uint32_t payload_size = content_object.payloadSize(); + uint32_t payload_size = (uint32_t) content_object.payloadSize(); uint32_t segment_number = content_object.getName().getSuffix(); if (segment_number >= MIN_PROBE_SEQ) { diff --git a/libtransport/src/protocols/rtc/rtc_consts.h b/libtransport/src/protocols/rtc/rtc_consts.h index 0cf9516ab..e172fc7a1 100644 --- a/libtransport/src/protocols/rtc/rtc_consts.h +++ b/libtransport/src/protocols/rtc/rtc_consts.h @@ -97,7 +97,7 @@ const double MAX_CACHED_PACKETS = 262144; // 2^18 // about 50 sec of traffic at 50Mbps // with 1200 bytes packets -const uint32_t MAX_ROUND_WHIOUT_PACKETS = +const uint32_t MAX_ROUND_WHIOUT_PACKETS = (const uint32_t) (20 * MILLI_IN_A_SEC) / ROUND_LEN; // 20 sec in rounds; // used in ldr diff --git a/libtransport/src/protocols/rtc/rtc_data_path.cc b/libtransport/src/protocols/rtc/rtc_data_path.cc index c098088a3..a545225cb 100644 --- a/libtransport/src/protocols/rtc/rtc_data_path.cc +++ b/libtransport/src/protocols/rtc/rtc_data_path.cc @@ -69,7 +69,7 @@ void RTCDataPath::insertOwdSample(int64_t owd) { if (avg_owd != DBL_MAX) avg_owd = (avg_owd * (1 - ALPHA_RTC)) + (owd * ALPHA_RTC); else { - avg_owd = owd; + avg_owd = (double)owd; } int64_t queueVal = owd - std::min(getMinOwd(), min_owd); @@ -77,7 +77,7 @@ void RTCDataPath::insertOwdSample(int64_t owd) { if (queuing_delay != DBL_MAX) queuing_delay = (queuing_delay * (1 - ALPHA_RTC)) + (queueVal * ALPHA_RTC); else { - queuing_delay = queueVal; + queuing_delay = (double)queueVal; } // keep track of the jitter computed as for RTP (RFC 3550) @@ -100,7 +100,7 @@ void RTCDataPath::computeInterArrivalGap(uint32_t segment_number) { largest_recv_seq_ = segment_number; largest_recv_seq_time_ = now; if (avg_inter_arrival_ == DBL_MAX) - avg_inter_arrival_ = delta; + avg_inter_arrival_ = (double)delta; else avg_inter_arrival_ = (avg_inter_arrival_ * (1 - ALPHA_RTC)) + (delta * ALPHA_RTC); diff --git a/libtransport/src/protocols/rtc/rtc_ldr.cc b/libtransport/src/protocols/rtc/rtc_ldr.cc index e91b29c04..0ef381fe1 100644 --- a/libtransport/src/protocols/rtc/rtc_ldr.cc +++ b/libtransport/src/protocols/rtc/rtc_ldr.cc @@ -40,7 +40,7 @@ RTCLossDetectionAndRecovery::~RTCLossDetectionAndRecovery() {} void RTCLossDetectionAndRecovery::turnOnRTX() { rtx_on_ = true; - scheduleSentinelTimer(state_->getRTT() * CATCH_UP_RTT_INCREMENT); + scheduleSentinelTimer((uint32_t)(state_->getRTT() * CATCH_UP_RTT_INCREMENT)); } void RTCLossDetectionAndRecovery::turnOffRTX() { @@ -182,8 +182,8 @@ uint64_t RTCLossDetectionAndRecovery::computeNextSend(uint32_t seq, if (prod_rate != 0) { double packet_size = state_->getAveragePacketSize(); - estimated_iat = ceil(1000.0 / (prod_rate / packet_size)); - jitter = ceil(state_->getJitter()); + estimated_iat = (uint32_t)ceil(1000.0 / (prod_rate / packet_size)); + jitter = (uint32_t)ceil(state_->getJitter()); } uint32_t wait = estimated_iat + jitter; @@ -202,20 +202,20 @@ uint64_t RTCLossDetectionAndRecovery::computeNextSend(uint32_t seq, } double packet_size = state_->getAveragePacketSize(); - uint32_t estimated_iat = ceil(1000.0 / (prod_rate / packet_size)); + uint32_t estimated_iat = (uint32_t)ceil(1000.0 / (prod_rate / packet_size)); uint64_t rtt = state_->getRTT(); if (rtt == 0) rtt = SENTINEL_TIMER_INTERVAL; - wait = rtt; + wait = (uint32_t)rtt; if (estimated_iat > rtt) wait = estimated_iat; - uint32_t jitter = ceil(state_->getJitter()); + uint32_t jitter = (uint32_t)ceil(state_->getJitter()); wait += jitter; // it may happen that the channel is congested and we have some additional // queuing delay to take into account - uint32_t queue = ceil(state_->getQueuing()); + uint32_t queue = (uint32_t)ceil(state_->getQueuing()); wait += queue; TRANSPORT_LOGD( @@ -389,8 +389,8 @@ void RTCLossDetectionAndRecovery::sentinelTimer() { } else { double prod_rate = state_->getProducerRate(); double packet_size = state_->getAveragePacketSize(); - uint32_t estimated_iat = ceil(1000.0 / (prod_rate / packet_size)); - uint32_t jitter = ceil(state_->getJitter()); + uint32_t estimated_iat = (uint32_t)ceil(1000.0 / (prod_rate / packet_size)); + uint32_t jitter = (uint32_t)ceil(state_->getJitter()); // try to reduce the number of timers if the estimated IAT is too small next_timer = std::max((estimated_iat + jitter) * 20, (uint32_t)1); @@ -400,7 +400,7 @@ void RTCLossDetectionAndRecovery::sentinelTimer() { if (!expired) { // discount the amout of time that is already passed - uint32_t discount = now - last_event_; + uint32_t discount = (uint32_t)(now - last_event_); if (next_timer > discount) { next_timer = next_timer - discount; } else { @@ -411,7 +411,7 @@ void RTCLossDetectionAndRecovery::sentinelTimer() { } else if (sent) { // wait at least one producer stats interval + owd to check if the // production rate is reducing. - uint32_t min_wait = PRODUCER_STATS_INTERVAL + ceil(state_->getQueuing()); + uint32_t min_wait = PRODUCER_STATS_INTERVAL + (uint32_t)ceil(state_->getQueuing()); next_timer = std::max(next_timer, min_wait); TRANSPORT_LOGD("wait for updates from prod, next timer: %u", next_timer); } diff --git a/libtransport/src/protocols/rtc/rtc_packet.h b/libtransport/src/protocols/rtc/rtc_packet.h index abb1323a3..2f2b19fb9 100644 --- a/libtransport/src/protocols/rtc/rtc_packet.h +++ b/libtransport/src/protocols/rtc/rtc_packet.h @@ -25,7 +25,11 @@ */ #pragma once +#ifndef _WIN32 #include <arpa/inet.h> +#else +#include <hicn/transport/portability/win_portability.h> +#endif namespace transport { @@ -37,14 +41,14 @@ inline uint64_t _ntohll(const uint64_t *input) { uint64_t return_val; uint8_t *tmp = (uint8_t *)&return_val; - tmp[0] = *input >> 56; - tmp[1] = *input >> 48; - tmp[2] = *input >> 40; - tmp[3] = *input >> 32; - tmp[4] = *input >> 24; - tmp[5] = *input >> 16; - tmp[6] = *input >> 8; - tmp[7] = *input >> 0; + tmp[0] = (uint8_t)(*input >> 56); + tmp[1] = (uint8_t)(*input >> 48); + tmp[2] = (uint8_t)(*input >> 40); + tmp[3] = (uint8_t)(*input >> 32); + tmp[4] = (uint8_t)(*input >> 24); + tmp[5] = (uint8_t)(*input >> 16); + tmp[6] = (uint8_t)(*input >> 8); + tmp[7] = (uint8_t)(*input >> 0); return return_val; } @@ -86,4 +90,4 @@ struct nack_packet_t { } // end namespace protocol -} // end namespace transport +} // end namespace transport
\ No newline at end of file diff --git a/libtransport/src/protocols/rtc/rtc_rc_queue.cc b/libtransport/src/protocols/rtc/rtc_rc_queue.cc index a1c89e329..3c7318dae 100644 --- a/libtransport/src/protocols/rtc/rtc_rc_queue.cc +++ b/libtransport/src/protocols/rtc/rtc_rc_queue.cc @@ -67,11 +67,11 @@ void RTCRateControlQueue::onNewRound(double round_len) { if (prev_congestion_state == CongestionState::Normal) { // init the congetion window using the received rate congestion_win_ = (uint32_t)ceil(received_rate * rtt / packet_size); - rounds_since_last_drop_ = ROUNDS_BEFORE_TAKE_ACTION + 1; + rounds_since_last_drop_ = (uint32_t)ROUNDS_BEFORE_TAKE_ACTION + 1; } if (rounds_since_last_drop_ >= ROUNDS_BEFORE_TAKE_ACTION) { - uint32_t win = congestion_win_ * WIN_DECREASE_FACTOR; + uint32_t win = congestion_win_ * (uint32_t)WIN_DECREASE_FACTOR; congestion_win_ = std::max(win, WIN_MIN); rounds_since_last_drop_ = 0; return; @@ -88,7 +88,7 @@ void RTCRateControlQueue::onNewRound(double round_len) { rounds_without_congestion_++; if (rounds_without_congestion_ < ROUNDS_BEFORE_TAKE_ACTION) return; - congestion_win_ = congestion_win_ * WIN_INCREASE_FACTOR; + congestion_win_ = congestion_win_ * (uint32_t)WIN_INCREASE_FACTOR; congestion_win_ = std::min(congestion_win_, INITIAL_WIN_MAX); } } diff --git a/libtransport/src/protocols/rtc/rtc_state.cc b/libtransport/src/protocols/rtc/rtc_state.cc index eabf8942c..9c965bfed 100644 --- a/libtransport/src/protocols/rtc/rtc_state.cc +++ b/libtransport/src/protocols/rtc/rtc_state.cc @@ -547,7 +547,7 @@ void RTCState::checkInitRttTimer() { double prod_rate = getProducerRate(); double rtt = (double)getRTT() / MILLI_IN_A_SEC; double packet_size = getAveragePacketSize(); - uint32_t pkt_in_rtt_ = std::floor(((prod_rate / packet_size) * rtt) * 0.8); + uint32_t pkt_in_rtt_ = (uint32_t)std::floor(((prod_rate / packet_size) * rtt) * 0.8); last_seq_nacked_ = last_production_seq_ + pkt_in_rtt_; discovered_rtt_callback_(); diff --git a/libtransport/src/protocols/rtc/rtc_state.h b/libtransport/src/protocols/rtc/rtc_state.h index 943a0a113..e4fefaffe 100644 --- a/libtransport/src/protocols/rtc/rtc_state.h +++ b/libtransport/src/protocols/rtc/rtc_state.h @@ -102,7 +102,7 @@ class RTCState : std::enable_shared_from_this<RTCState> { return false; } uint32_t getPendingInterestNumber() const { - return pending_interests_.size(); + return (uint32_t)pending_interests_.size(); } PacketState isReceivedOrLost(uint32_t seq) { auto it = received_or_lost_packets_.find(seq); diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index d82425236..953b46339 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -16,6 +16,10 @@ set(CMAKE_CXX_STANDARD 14) project(utils) +if (WIN32) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:\"LIBCMT\"" ) +endif() + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/Modules" diff --git a/utils/src/hiperf.cc b/utils/src/hiperf.cc index 203c2acb9..9a1cf6236 100644 --- a/utils/src/hiperf.cc +++ b/utils/src/hiperf.cc @@ -65,14 +65,14 @@ inline uint64_t _ntohll(const uint64_t *input) { uint64_t return_val; uint8_t *tmp = (uint8_t *)&return_val; - tmp[0] = *input >> 56; - tmp[1] = *input >> 48; - tmp[2] = *input >> 40; - tmp[3] = *input >> 32; - tmp[4] = *input >> 24; - tmp[5] = *input >> 16; - tmp[6] = *input >> 8; - tmp[7] = *input >> 0; + tmp[0] = (uint8_t)(*input >> 56); + tmp[1] = (uint8_t)(*input >> 48); + tmp[2] = (uint8_t)(*input >> 40); + tmp[3] = (uint8_t)(*input >> 32); + tmp[4] = (uint8_t)(*input >> 24); + tmp[5] = (uint8_t)(*input >> 16); + tmp[6] = (uint8_t)(*input >> 8); + tmp[7] = (uint8_t)(*input >> 0); return return_val; } @@ -302,7 +302,7 @@ class HIperfClient { return; } - received_bytes_ += (payload->length() - 12); + received_bytes_ += (uint32_t)(payload->length() - 12); received_data_pkt_++; // collecting delay stats. Just for performance testing @@ -479,8 +479,8 @@ class HIperfClient { old_bytes_recovered_value_ = stats.getBytesRecoveredData(); old_fec_interest_tx_value_ = stats.getInterestFecTxCount(); old_fec_data_rx_value_ = stats.getBytesFecRecv(); - old_retx_value_ = stats.getRetxCount(); - old_sent_int_value_ = stats.getInterestTx(); + old_retx_value_ = (uint32_t)stats.getRetxCount(); + old_sent_int_value_ = (uint32_t)stats.getInterestTx(); old_received_nacks_value_ = stats.getReceivedNacks(); delay_sample_ = 0; avg_data_delay_ = 0; @@ -1127,7 +1127,7 @@ class HIperfServer { std::memcpy(payload->writableData(), &now, sizeof(uint64_t)); - if (packet_len > payload->length()) packet_len = payload->length(); + if (packet_len > payload->length()) packet_len = (uint32_t)payload->length(); if (packet_len > 1400) packet_len = 1400; producer_socket_->produceDatagram(flow_name_, payload->data(), packet_len); @@ -1268,8 +1268,9 @@ class HIperfServer { asio::posix::stream_descriptor input_; asio::streambuf input_buffer_; bool rtc_running_; - core::Name flow_name_; + #endif + core::Name flow_name_; }; // namespace interface void usage() { |