From 3718e549ee31ac764b327bbf3d6e51dd7e224b46 Mon Sep 17 00:00:00 2001 From: Angelo Mantellini Date: Thu, 26 Mar 2020 12:02:23 +0100 Subject: [HICN-581] update hicn stack to support windows, again Signed-off-by: Angelo Mantellini Change-Id: Ic5cfeae600fde8140a076807fa1e411da1933a02 --- hicn-light/CMakeLists.txt | 9 +++++++-- .../src/hicn/command_line/controller/hicnLightControl_main.c | 3 ++- hicn-light/src/hicn/config/configuration.c | 6 +++--- hicn-light/src/hicn/config/controlListPolicies.c | 3 +-- hicn-light/src/hicn/core/messageHandler.h | 8 +++++--- hicn-light/src/hicn/io/udpConnection.c | 9 +++++---- 6 files changed, 23 insertions(+), 15 deletions(-) (limited to 'hicn-light') diff --git a/hicn-light/CMakeLists.txt b/hicn-light/CMakeLists.txt index 1923e7aee..db56feff7 100644 --- a/hicn-light/CMakeLists.txt +++ b/hicn-light/CMakeLists.txt @@ -60,7 +60,11 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) find_package_wrapper(Libhicn REQUIRED) else() if (DISABLE_SHARED_LIBRARIES) - set(HICN_LIBRARIES ${LIBHICN_STATIC} log) + if (WIN32) + set(HICN_LIBRARIES ${LIBHICN_STATIC}) + else () + set(HICN_LIBRARIES ${LIBHICN_STATIC} log) + endif () list(APPEND DEPENDENCIES ${LIBHICN_STATIC} ) @@ -87,11 +91,12 @@ set(HICN_LIGHT_LINK_LIBRARIES ${WINDOWS_LIBRARIES} ) + # Include dirs -- Order does matter! list(APPEND HICN_LIGHT_INCLUDE_DIRS ${HICN_INCLUDE_DIRS} ${LIBPARC_INCLUDE_DIRS} - ${PTHREAD_INCLUDE_DIRS} + ${WINDOWS_INCLUDE_DIRS} ) if (UNIX) 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 0a8e01f65..8f56dc60a 100644 --- a/hicn-light/src/hicn/command_line/controller/hicnLightControl_main.c +++ b/hicn-light/src/hicn/command_line/controller/hicnLightControl_main.c @@ -23,6 +23,7 @@ #include #include #include +#include #endif #include #include @@ -49,7 +50,7 @@ #include -#include + size_t commandOutputLen = 0; // preserve the number of structs composing // payload in case on not interactive call. diff --git a/hicn-light/src/hicn/config/configuration.c b/hicn-light/src/hicn/config/configuration.c index a5be84f32..39d327165 100644 --- a/hicn-light/src/hicn/config/configuration.c +++ b/hicn-light/src/hicn/config/configuration.c @@ -87,7 +87,7 @@ getConnectionBySymbolicOrId(Configuration * config, const char * symbolicOrConni /* Try to resolve an eventual symbolic name as input */ if (utils_IsNumber(symbolicOrConnid)) { - connid = strtold(symbolicOrConnid, NULL); + connid = (unsigned int)strtold(symbolicOrConnid, NULL); } else { connid = symbolicNameTable_Get(config->symbolicNameTable, symbolicOrConnid); @@ -661,7 +661,7 @@ struct iovec *configuration_ProcessRemoveTunnel(Configuration *config, return response; } -void _strlwr(char *string) { +void _parc_strlwr(char *string) { char *p = string; while ((*p = tolower(*p))) { p++; @@ -697,7 +697,7 @@ struct iovec *configuration_ProcessConnectionList(Configuration *config, const char *connectionName = symbolicNameTable_GetNameByIndex(config->symbolicNameTable, connection_GetConnectionId(original)); snprintf(listConnectionsCommand->connectionName, SYMBOLIC_NAME_LEN, "%s", connectionName); - _strlwr(listConnectionsCommand->connectionName); + _parc_strlwr(listConnectionsCommand->connectionName); snprintf(listConnectionsCommand->interfaceName, SYMBOLIC_NAME_LEN, "%s", ioOperations_GetInterfaceName(connection_GetIoOperations(original))); diff --git a/hicn-light/src/hicn/config/controlListPolicies.c b/hicn-light/src/hicn/config/controlListPolicies.c index 9aff68c69..81be6ddfc 100644 --- a/hicn-light/src/hicn/config/controlListPolicies.c +++ b/hicn-light/src/hicn/config/controlListPolicies.c @@ -14,7 +14,6 @@ */ #ifdef WITH_POLICY - #include #include @@ -120,7 +119,7 @@ static CommandReturn _controlListPolicies_Execute(CommandParser *parser, foreach_policy_tag #undef _ "%s", - MAXSZ_PREFIX, "prefix", MAXSZ_APP_NAME /*APP_NAME_LEN*/, "app_name", + MAXSZ_PREFIX, "prefix", MAXSZ_APP_NAME /*APP_NAME_LEN*/, "app_name", #define _(x, y) MAXSZ_COLUMN, policy_tag_str[POLICY_TAG_ ## x], foreach_policy_tag #undef _ diff --git a/hicn-light/src/hicn/core/messageHandler.h b/hicn-light/src/hicn/core/messageHandler.h index 0bf6bebbe..a8b2a3e54 100644 --- a/hicn-light/src/hicn/core/messageHandler.h +++ b/hicn-light/src/hicn/core/messageHandler.h @@ -17,7 +17,9 @@ #define messageHandler #include +#ifndef _WIN32 #include // close +#endif #include #include @@ -195,7 +197,7 @@ _createRecvAddressPairFromPacket(const uint8_t *msgBuffer) { packetSrcAddr = addressCreateFromInet6(&addr_in6); /* We now determine the local address used to reach the packet src address */ - int sock = socket (AF_INET6, SOCK_DGRAM, 0); + int sock = (int)socket (AF_INET6, SOCK_DGRAM, 0); if (sock < 0) goto ERR; @@ -226,7 +228,7 @@ _createRecvAddressPairFromPacket(const uint8_t *msgBuffer) { /* We now determine the local address used to reach the packet src address */ - int sock = socket (AF_INET, SOCK_DGRAM, 0); + int sock = (int)socket (AF_INET, SOCK_DGRAM, 0); if (sock < 0) { perror("Socket error"); goto ERR; @@ -693,7 +695,7 @@ static inline void messageHandler_SetWldrNotification(uint8_t *notification, } static inline uint8_t * messageHandler_CreateProbePacket(hicn_format_t format, - uint32_t probe_lifetime){ + uint32_t probe_lifetime){ size_t header_length; hicn_packet_get_header_length_from_format(format, &header_length); diff --git a/hicn-light/src/hicn/io/udpConnection.c b/hicn-light/src/hicn/io/udpConnection.c index 14ffe1e5b..cd3ccc84a 100644 --- a/hicn-light/src/hicn/io/udpConnection.c +++ b/hicn-light/src/hicn/io/udpConnection.c @@ -326,18 +326,19 @@ static bool _sendIOVBuffer(IoOperations *ops, struct iovec *message, return false; } #else - WSABUF dataBuf[ARRAY_SIZE(message)]; + + WSABUF *dataBuf = (WSABUF *) malloc(size * sizeof (dataBuf)); DWORD BytesSent = 0; - for (int i = 0; i < ARRAY_SIZE(message); i++) { + for (int i = 0; i < size; i++) { dataBuf[i].buf = message[i].iov_base; dataBuf[i].len = (ULONG)message[i].iov_len; } - int rc = WSASendTo(udpConnState->udpListenerSocket, dataBuf, ARRAY_SIZE(message), + int rc = WSASendTo(udpConnState->udpListenerSocket, dataBuf, size, &BytesSent, 0, (SOCKADDR *)udpConnState->peerAddress, udpConnState->peerAddressLength, NULL, NULL); - + free(dataBuf); if (rc == SOCKET_ERROR) { return false; } -- cgit 1.2.3-korg