summaryrefslogtreecommitdiffstats
path: root/hicn-light
diff options
context:
space:
mode:
authorAngelo Mantellini <angelo.mantellini@cisco.com>2020-03-26 12:02:23 +0100
committerAngelo Mantellini <angelo.mantellini@cisco.com>2020-03-31 11:35:33 +0200
commit3718e549ee31ac764b327bbf3d6e51dd7e224b46 (patch)
tree5bfc2147e348a5fd4b0291ad458dacf3feececc0 /hicn-light
parent4b36dc3d5dd3ec206aa24d49557c61ae5886be2b (diff)
[HICN-581] update hicn stack to support windows, again
Signed-off-by: Angelo Mantellini <angelo.mantellini@cisco.com> Change-Id: Ic5cfeae600fde8140a076807fa1e411da1933a02
Diffstat (limited to 'hicn-light')
-rw-r--r--hicn-light/CMakeLists.txt9
-rw-r--r--hicn-light/src/hicn/command_line/controller/hicnLightControl_main.c3
-rw-r--r--hicn-light/src/hicn/config/configuration.c6
-rw-r--r--hicn-light/src/hicn/config/controlListPolicies.c3
-rw-r--r--hicn-light/src/hicn/core/messageHandler.h8
-rw-r--r--hicn-light/src/hicn/io/udpConnection.c9
6 files changed, 23 insertions, 15 deletions
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 <sys/socket.h>
#include <sys/uio.h>
#include <unistd.h>
+#include <arpa/inet.h>
#endif
#include <stdbool.h>
#include <stdint.h>
@@ -49,7 +50,7 @@
#include <hicn/utils/commands.h>
-#include <arpa/inet.h>
+
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 <hicn/hicn-light/config.h>
#include <stdbool.h>
@@ -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 <stdlib.h>
+#ifndef _WIN32
#include <unistd.h> // close
+#endif
#include <hicn/hicn.h>
#include <hicn/core/messagePacketType.h>
@@ -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;
}