aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngelo Mantellini <angelo.mantellini@cisco.com>2020-03-31 11:10:00 +0000
committerGerrit Code Review <gerrit@fd.io>2020-03-31 11:10:00 +0000
commit23c3bb7400839b664096ad5e16a2346386109bda (patch)
treed1999acef9f91cd25db9b7c63fd2963cd7ba0e57
parentd46e59824bd3fc67abe7bd725965aa454942d640 (diff)
parent3718e549ee31ac764b327bbf3d6e51dd7e224b46 (diff)
Merge "[HICN-581] update hicn stack to support windows, again"
-rw-r--r--CMakeLists.txt9
-rw-r--r--cmake/Modules/FindConfig.cmake37
-rw-r--r--ctrl/facemgr/CMakeLists.txt6
-rw-r--r--ctrl/libhicnctrl/CMakeLists.txt6
-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
-rw-r--r--lib/includes/CMakeLists.txt3
-rw-r--r--lib/includes/hicn/name.h31
-rw-r--r--lib/includes/hicn/policy.h4
-rw-r--r--lib/includes/hicn/util/ip_address.h15
-rw-r--r--lib/includes/hicn/util/log.h3
-rw-r--r--lib/includes/hicn/util/types.h3
-rw-r--r--lib/includes/hicn/util/win_portability.h45
-rwxr-xr-xlib/includes/hicn/util/windows/windows_utils.h154
-rw-r--r--lib/src/util/ip_address.c20
-rw-r--r--libtransport/CMakeLists.txt8
-rw-r--r--libtransport/includes/hicn/transport/core/packet.h1
-rw-r--r--libtransport/src/core/prefix.cc3
-rw-r--r--libtransport/src/core/tcp_socket_connector.cc2
-rw-r--r--libtransport/src/core/udp_socket_connector.cc2
-rw-r--r--libtransport/src/http/response.cc14
-rw-r--r--utils/CMakeLists.txt2
-rw-r--r--utils/src/ping_server.cc3
27 files changed, 333 insertions, 76 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 77dcbb6d8..afbd45f21 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,13 +25,18 @@ option(BUILD_HICNLIGHT "Build the hicn light forwarder" ON)
option(BUILD_LIBTRANSPORT "Build the hicn transport library" ON)
option(BUILD_UTILS "Build the hicn utils" ON)
option(BUILD_APPS "Build the hicn apps" OFF)
-option(BUILD_CTRL "Build the hicn control tools" ON)
+if (NOT WIN32)
+ option(BUILD_CTRL "Build the hicn control tools" ON)
+ option(DISABLE_SHARED_LIBRARIES "Disable shared libraries" OFF)
+else ()
+ option(BUILD_CTRL "Build the hicn control tools" OFF)
+ option(DISABLE_SHARED_LIBRARIES "Disable shared libraries" ON)
+endif ()
option(BUILD_HICNPLUGIN "Build the hicn vpp plugin" OFF)
option(BUILD_SYSREPOPLUGIN "Build the sysrepo plugin" OFF)
option(BUILD_EXTRAS "Build external projects" OFF)
option(BUILD_TELEMETRY "Build telemetry projects" OFF)
option(DISABLE_EXECUTABLES "Disable executables" OFF)
-option(DISABLE_SHARED_LIBRARIES "Disable shared libraries" OFF)
if ((BUILD_APPS OR BUILD_UTILS) AND NOT BUILD_LIBTRANSPORT)
message(STATUS "Libhicntransport required. Enabled by default.")
diff --git a/cmake/Modules/FindConfig.cmake b/cmake/Modules/FindConfig.cmake
index 5361d9611..11e764d21 100644
--- a/cmake/Modules/FindConfig.cmake
+++ b/cmake/Modules/FindConfig.cmake
@@ -1,6 +1,39 @@
-FIND_PATH(CONFIG_INCLUDE_DIR libconfig.h /usr/include /usr/local/include)
+set(LIBCONFIG_SEARCH_PATH_LIST
+ ${LIBCONFIG_HOME}
+ $ENV{LIBCONFIG_HOME}
+ /usr/local
+ /opt
+ /usr
+)
+
+find_path(CONFIG_INCLUDE_DIR libconfig.h
+ HINTS ${LIBCONFIG_SEARCH_PATH_LIST}
+ PATH_SUFFIXES include
+ DOC "Find the libconfig include"
+)
+
+if (WIN32)
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ find_library(CONFIG_LIBRARY 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(CONFIG_LIBRARY NAMES libconfig.lib
+ HINTS ${LIBCONFIG_SEARCH_PATH_LIST}
+ PATH_SUFFIXES lib/x32
+ DOC "Find the libconfig libraries"
+ )
+ endif()
+else()
+ find_library(CONFIG_LIBRARY NAMES config
+ HINTS ${LIBCONFIG_SEARCH_PATH_LIST}
+ PATH_SUFFIXES lib
+ DOC "Find the libconfig libraries"
+ )
+endif()
-FIND_LIBRARY(CONFIG_LIBRARY NAMES config PATH /usr/lib /usr/local/lib)
IF (CONFIG_INCLUDE_DIR AND CONFIG_LIBRARY)
SET(CONFIG_FOUND TRUE)
diff --git a/ctrl/facemgr/CMakeLists.txt b/ctrl/facemgr/CMakeLists.txt
index a1cd48bbd..4290d9cd6 100644
--- a/ctrl/facemgr/CMakeLists.txt
+++ b/ctrl/facemgr/CMakeLists.txt
@@ -70,7 +70,11 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
find_package_wrapper(Libhicnctrl 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 ()
set(LIBHICNCTRL_LIBRARIES ${LIBHICNCTRL_STATIC})
list(APPEND DEPENDENCIES
${LIBHICN_STATIC}
diff --git a/ctrl/libhicnctrl/CMakeLists.txt b/ctrl/libhicnctrl/CMakeLists.txt
index 15425b513..b2c5975be 100644
--- a/ctrl/libhicnctrl/CMakeLists.txt
+++ b/ctrl/libhicnctrl/CMakeLists.txt
@@ -64,7 +64,11 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
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}
)
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;
}
diff --git a/lib/includes/CMakeLists.txt b/lib/includes/CMakeLists.txt
index 60247909c..12529bd57 100644
--- a/lib/includes/CMakeLists.txt
+++ b/lib/includes/CMakeLists.txt
@@ -11,15 +11,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# XXX
-
set(HICN_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR} ""
CACHE INTERNAL
"" FORCE
)
-
set(LIBHICN_HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/hicn/hicn.h
${CMAKE_CURRENT_SOURCE_DIR}/hicn/base.h
diff --git a/lib/includes/hicn/name.h b/lib/includes/hicn/name.h
index 7234a5159..d5202068b 100644
--- a/lib/includes/hicn/name.h
+++ b/lib/includes/hicn/name.h
@@ -26,7 +26,7 @@
#include <stdbool.h>
#ifndef _WIN32
-#include <netinet/in.h> // struct sockadd
+#include <netinet/in.h> // struct sockadd
#endif
#include <hicn/util/ip_address.h>
#include "common.h"
@@ -35,12 +35,12 @@
* hICN names
******************************************************************************/
-#define TCP_SEQNO_LEN 4 /* bytes */
+#define TCP_SEQNO_LEN 4 /* bytes */
#define HICN_V4_PREFIX_LEN IPV4_ADDR_LEN
#define HICN_V6_PREFIX_LEN IPV6_ADDR_LEN
#define HICN_SEGMENT_LEN TCP_SEQNO_LEN
-#define HICN_V6_NAME_LEN (HICN_V6_PREFIX_LEN + HICN_SEGMENT_LEN) /* 20 bytes */
-#define HICN_V4_NAME_LEN (HICN_V4_PREFIX_LEN + HICN_SEGMENT_LEN) /* 8 bytes */
+#define HICN_V6_NAME_LEN (HICN_V6_PREFIX_LEN + HICN_SEGMENT_LEN) /* 20 bytes */
+#define HICN_V4_NAME_LEN (HICN_V4_PREFIX_LEN + HICN_SEGMENT_LEN) /* 8 bytes */
/* Prefix */
@@ -88,11 +88,6 @@ typedef union
u8 buffer[HICN_V6_NAME_LEN];
} hicn_v6_name_t;
-typedef struct
-{
- u8 buffer[0];
-} hicn_v46_name_t;
-
#ifndef HICN_VPP_PLUGIN
#define HICN_NAME_COMPONENT_SIZE 2
@@ -122,7 +117,7 @@ typedef struct
#ifndef HICN_VPP_PLUGIN
hicn_name_type_t type;
u8 len;
-#endif /* HICN_VPP_PLUGIN */
+#endif /* HICN_VPP_PLUGIN */
union
{
hicn_v4_name_t ip4;
@@ -130,8 +125,8 @@ typedef struct
ip46_address_t ip46;
#ifndef HICN_VPP_PLUGIN
hicn_iov_name_t iov;
- u8 buffer[0];
-#endif /* HICN_VPP_PLUGIN */
+ u8 buffer[HICN_V6_NAME_LEN];
+#endif /* HICN_VPP_PLUGIN */
};
} hicn_name_t;
@@ -160,7 +155,7 @@ int hicn_name_create (const char *ip_address, u32 id, hicn_name_t * name);
* @return hICN error code
*/
int hicn_name_create_from_ip_prefix (const ip_prefix_t * prefix, u32 id,
- hicn_name_t * name);
+ hicn_name_t * name);
/**
* @brief Returns the length of an hICN name
@@ -180,7 +175,7 @@ u8 hicn_name_get_length (const hicn_name_t * name);
* based on numeric order.
*/
int hicn_name_compare (const hicn_name_t * name_1, const hicn_name_t * name_2,
- bool consider_segment);
+ bool consider_segment);
/**
* @brief Provides a 32-bit hash of an hICN name
@@ -215,7 +210,7 @@ int hicn_name_copy (hicn_name_t * dst, const hicn_name_t * src);
* considered
*/
int hicn_name_copy_to_destination (u8 * dst, const hicn_name_t * src,
- bool copy_suffix);
+ bool copy_suffix);
/**
* @brief Sets the segment part of an hICN name
@@ -240,7 +235,7 @@ int hicn_name_get_seq_number (const hicn_name_t * name, u32 * seq_number);
* @return hICN error code
*/
int hicn_name_to_sockaddr_address (const hicn_name_t * name,
- struct sockaddr *ip_address);
+ struct sockaddr *ip_address);
/**
* @brief Convert an hICN name to an IP address
@@ -249,7 +244,7 @@ int hicn_name_to_sockaddr_address (const hicn_name_t * name,
* @return hICN error code
*/
int hicn_name_to_ip_prefix (const hicn_name_t * name,
- ip_prefix_t * ip_prefix);
+ ip_prefix_t * ip_prefix);
/**
* @brief Convert an hICN name to presentation format
@@ -283,7 +278,7 @@ int hicn_name_get_family (const hicn_name_t * name, int *family);
* @return hICN error code
*/
int hicn_prefix_create_from_ip_prefix (const ip_prefix_t * ip_prefix,
- hicn_prefix_t * prefix);
+ hicn_prefix_t * prefix);
#endif /* HICN_NAME_H */
diff --git a/lib/includes/hicn/policy.h b/lib/includes/hicn/policy.h
index 73d281cd6..51bab4241 100644
--- a/lib/includes/hicn/policy.h
+++ b/lib/includes/hicn/policy.h
@@ -20,7 +20,11 @@
#ifndef HICN_POLICY_H
#define HICN_POLICY_H
+#ifndef _WIN32
#include <netinet/in.h> // INET*_ADDRSTRLEN
+#else
+#include <hicn/util/win_portability.h>
+#endif
#include <string.h> // strcasecmp
#include <hicn/util/token.h>
diff --git a/lib/includes/hicn/util/ip_address.h b/lib/includes/hicn/util/ip_address.h
index d9dea8faa..4facd9ad0 100644
--- a/lib/includes/hicn/util/ip_address.h
+++ b/lib/includes/hicn/util/ip_address.h
@@ -20,22 +20,23 @@
#ifndef UTIL_IP_ADDRESS_H
#define UTIL_IP_ADDRESS_H
-#include <arpa/inet.h> // inet_ntop
+
#ifdef __APPLE__
#include <libkern/OSByteOrder.h>
#define __bswap_constant_32(x) OSSwapInt32(x)
#include <machine/endian.h>
#else
-#include <endian.h>
#ifdef __ANDROID__
#include <byteswap.h>
#endif
-#include <endian.h>
+
#endif
#include <errno.h>
-#include <netdb.h> // struct addrinfo
+
#ifndef _WIN32
-#include <netinet/in.h> // struct sockadd
+#include <netinet/in.h> // struct sockadd
+#include <arpa/inet.h> // inet_ntop
+#include <netdb.h> // struct addrinfo
#endif
#include <stdbool.h>
#include <stdlib.h>
@@ -45,8 +46,8 @@
#include "types.h"
#define bytes_to_bits(x) (x * 8)
-#define IPV6_ADDR_LEN 16 /* bytes */
-#define IPV4_ADDR_LEN 4 /* bytes */
+#define IPV6_ADDR_LEN 16 /* bytes */
+#define IPV4_ADDR_LEN 4 /* bytes */
#define IPV6_ADDR_LEN_BITS bytes_to_bits(IPV6_ADDR_LEN)
#define IPV4_ADDR_LEN_BITS bytes_to_bits(IPV4_ADDR_LEN)
diff --git a/lib/includes/hicn/util/log.h b/lib/includes/hicn/util/log.h
index 26d7d9418..6763d464f 100644
--- a/lib/includes/hicn/util/log.h
+++ b/lib/includes/hicn/util/log.h
@@ -46,6 +46,9 @@ extern log_conf_t log_conf;
BLOCK
#define FATAL(fmt, ...) (_log(LOG_FATAL, fmt, ##__VA_ARGS__ ))
+#ifdef ERROR
+#undef ERROR
+#endif
#define ERROR(fmt, ...) (_log(LOG_ERROR, fmt, ##__VA_ARGS__ ))
#define WARN(fmt, ...) (_log(LOG_WARN, fmt, ##__VA_ARGS__ ))
#define INFO(fmt, ...) (_log(LOG_INFO, fmt, ##__VA_ARGS__ ))
diff --git a/lib/includes/hicn/util/types.h b/lib/includes/hicn/util/types.h
index 50b368b8d..017e85b72 100644
--- a/lib/includes/hicn/util/types.h
+++ b/lib/includes/hicn/util/types.h
@@ -15,6 +15,9 @@
#ifndef UTIL_TYPES
#define UTIL_TYPES
+#ifdef _WIN32
+#include <hicn/util/windows/windows_Utils.h>
+#endif
typedef uint8_t u8;
typedef uint16_t u16;
diff --git a/lib/includes/hicn/util/win_portability.h b/lib/includes/hicn/util/win_portability.h
new file mode 100644
index 000000000..5f30cfbb2
--- /dev/null
+++ b/lib/includes/hicn/util/win_portability.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * 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
+#include <hicn/util/windows/windows_Utils.h>
+#include <afunix.h>
+#include <io.h>
+#include <iphlpapi.h>
+#include <process.h>
+#include <stdio.h>
+#pragma comment(lib, "IPHLPAPI.lib")
+
+#ifndef in_port_t
+#define in_port_t uint16_t
+#endif
+
+#ifndef in_addr_t
+#define in_addr_t uint32_t
+#endif
+
+#ifndef strncasecmp
+#define strncasecmp _strnicmp
+#endif
+
+#ifndef strcasecmp
+#define strcasecmp _stricmp
+#endif
+
+#define HAVE_STRUCT_TIMESPEC
+
+#ifndef getline
+int getline(char **lineptr, size_t *n, FILE *stream);
+#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
new file mode 100755
index 000000000..c4662af5e
--- /dev/null
+++ b/lib/includes/hicn/util/windows/windows_utils.h
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * 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.
+ */
+
+#ifndef WINDOWS_UTILS_H
+#define WINDOWS_UTILS_H
+#define WIN32_LEAN_AND_MEAN
+#define HAVE_STRUCT_TIMESPEC
+#include <Windows.h>
+#include <stdint.h>
+#include <io.h>
+#include <stdlib.h>
+#include <winsock2.h>
+#include <WS2tcpip.h>
+
+#ifndef IOVEC
+#define IOVEC
+struct iovec {
+ void* iov_base;
+ size_t iov_len;
+};
+#endif
+
+typedef uint16_t in_port_t;
+
+#ifndef SLEEP
+#define SLEEP
+#define sleep Sleep
+#endif
+
+#ifndef USLEEP
+#define USLEEP
+void usleep(__int64 usec);
+#endif
+
+#ifndef S_ISDIR
+#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
+#endif
+
+#define PARCLibrary_DISABLE_ATOMICS
+#include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+
+#ifndef __ATTRIBUTE__
+#define __ATTRIBUTE__
+#define __attribute__(A)
+#endif
+
+#ifndef RESTRICT
+#define RESTRICT
+#define restrict __restrict
+#endif
+
+#ifndef GETTIMEOFDAY
+#define GETTIMEOFDAY
+int gettimeofday(struct timeval * tp, struct timezone * tzp);
+#endif
+
+#ifndef timersub
+#define timersub(a, b, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
+ if ((result)->tv_usec < 0) { \
+ --(result)->tv_sec; \
+ (result)->tv_usec += 1000000; \
+ } \
+ } while (0)
+#endif // timersub
+
+#ifndef dup
+#define dup _dup
+#endif
+
+#ifndef access
+#define access _access
+#endif
+
+#ifndef __cplusplus
+
+#ifndef read
+#define read _read
+#endif
+
+#ifndef close
+#define close _close
+#endif
+
+#ifndef write
+#define write _write
+#endif
+
+#ifndef open
+#define open _open
+#endif
+
+#endif
+
+#ifndef unlink
+#define unlink _unlink
+#endif
+
+#ifndef strcasecmp
+#define strncasecmp _strnicmp
+#endif
+
+#ifndef strcasecmp
+
+#define strcasecmp _stricmp
+#endif
+
+#ifndef S_ISREG
+#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
+#endif
+#ifndef R_OK
+#define R_OK 4 /* Test for read permission. */
+#endif
+#ifndef W_OK
+#define W_OK 2 /* Test for write permission. */
+#endif
+#ifndef F_OK
+#define F_OK 0
+#endif
+
+#ifndef STDIN_FILENO
+#define STDIN_FILENO _fileno(stdin)
+#endif
+
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO _fileno(stdout)
+#endif
+
+#ifndef STDERR_FILENO
+#define STDERR_FILENO _fileno(stderr)
+#endif
+
+#endif
+
+#ifndef __bswap_constant_32
+#define __bswap_constant_32(x) \
+ ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) \
+ | (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
+#endif
diff --git a/lib/src/util/ip_address.c b/lib/src/util/ip_address.c
index 805b0b261..49916547d 100644
--- a/lib/src/util/ip_address.c
+++ b/lib/src/util/ip_address.c
@@ -33,19 +33,19 @@
/* No htonl() with const */
-const ip_address_t IPV4_LOOPBACK = (ip_address_t) {
+const ip_address_t IPV4_LOOPBACK = {
.v4.as_inaddr.s_addr = SWAP(INADDR_LOOPBACK),
};
-const ip_address_t IPV6_LOOPBACK = (ip_address_t) {
+const ip_address_t IPV6_LOOPBACK ={
.v6.as_in6addr = IN6ADDR_LOOPBACK_INIT,
};
-const ip_address_t IPV4_ANY = (ip_address_t) {
+const ip_address_t IPV4_ANY = {
.v4.as_inaddr.s_addr = INADDR_ANY,
};
-const ip_address_t IPV6_ANY = (ip_address_t) {
+const ip_address_t IPV6_ANY = {
.v6.as_in6addr = IN6ADDR_ANY_INIT,
};
@@ -86,7 +86,7 @@ ip_address_len (int family)
int
ip_address_ntop (const ip_address_t * ip_address, char *dst, const size_t len,
- int family)
+ int family)
{
const char * s;
switch(family) {
@@ -161,7 +161,7 @@ ip_address_snprintf(char * s, size_t size, const ip_address_t * ip_address, int
int
ip_address_to_sockaddr(const ip_address_t * ip_address,
- struct sockaddr *sa, int family)
+ struct sockaddr *sa, int family)
{
struct sockaddr_in6 *tmp6 = (struct sockaddr_in6 *) sa;
struct sockaddr_in *tmp4 = (struct sockaddr_in *) sa;
@@ -222,9 +222,9 @@ ip_prefix_pton (const char *ip_address_str, ip_prefix_t * ip_prefix)
p = strchr (addr, '/');
if (!p) {
- ip_prefix->len = ~0; // until we get the ip address family
+ ip_prefix->len = ~0; // until we get the ip address family
} else {
- ip_prefix->len = strtoul (p + 1, &eptr, 10);
+ ip_prefix->len = (u8)strtoul (p + 1, &eptr, 10);
*p = 0;
}
@@ -236,14 +236,14 @@ ip_prefix_pton (const char *ip_address_str, ip_prefix_t * ip_prefix)
if (ip_prefix->len == (u8)~0)
ip_prefix->len = IPV6_ADDR_LEN_BITS;
if (ip_prefix->len > IPV6_ADDR_LEN_BITS)
- goto ERR;
+ goto ERR;
pton_fd = inet_pton (AF_INET6, addr, &ip_prefix->address.v6.buffer);
break;
case AF_INET:
if (ip_prefix->len == (u8)~0)
ip_prefix->len = IPV4_ADDR_LEN_BITS;
if (ip_prefix->len > IPV4_ADDR_LEN_BITS)
- goto ERR;
+ goto ERR;
pton_fd = inet_pton (AF_INET, addr, &ip_prefix->address.v4.buffer);
break;
default:
diff --git a/libtransport/CMakeLists.txt b/libtransport/CMakeLists.txt
index 973dbaf35..c431ace04 100644
--- a/libtransport/CMakeLists.txt
+++ b/libtransport/CMakeLists.txt
@@ -99,7 +99,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}
)
@@ -144,8 +148,6 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
find_package(OpenSSL REQUIRED)
endif ()
-message ("---------------------------> ${OPENSSL_LIBRARIES}")
-
list(APPEND LIBRARIES
${LIBPARC_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
diff --git a/libtransport/includes/hicn/transport/core/packet.h b/libtransport/includes/hicn/transport/core/packet.h
index 3ddc4a595..e58e7962d 100644
--- a/libtransport/includes/hicn/transport/core/packet.h
+++ b/libtransport/includes/hicn/transport/core/packet.h
@@ -257,7 +257,6 @@ class Packet : public std::enable_shared_from_this<Packet> {
utils::MemBuf *header_head_;
utils::MemBuf *payload_head_;
mutable Format format_;
-
static const core::Name base_name;
};
diff --git a/libtransport/src/core/prefix.cc b/libtransport/src/core/prefix.cc
index 59898ab70..30f780461 100644
--- a/libtransport/src/core/prefix.cc
+++ b/libtransport/src/core/prefix.cc
@@ -226,7 +226,7 @@ Name Prefix::getRandomName() const {
ip_prefix_.len;
size_t size = (size_t)ceil((float)addr_len / 8.0);
- uint8_t buffer[size];
+ uint8_t *buffer = (uint8_t *) malloc(sizeof(uint8_t) * size);
RAND_bytes(buffer, size);
@@ -237,6 +237,7 @@ Name Prefix::getRandomName() const {
name_ip_buffer[i] = buffer[j];
j++;
}
+ free(buffer);
return Name(ip_prefix_.family, (uint8_t *)&name_ip);
}
diff --git a/libtransport/src/core/tcp_socket_connector.cc b/libtransport/src/core/tcp_socket_connector.cc
index 58df8fb08..20b3d6ce6 100644
--- a/libtransport/src/core/tcp_socket_connector.cc
+++ b/libtransport/src/core/tcp_socket_connector.cc
@@ -15,7 +15,7 @@
#include <core/tcp_socket_connector.h>
#ifdef _WIN32
-#include <portability/win_portability.h>
+#include <hicn/transport/portability/win_portability.h>
#endif
#include <hicn/transport/errors/errors.h>
diff --git a/libtransport/src/core/udp_socket_connector.cc b/libtransport/src/core/udp_socket_connector.cc
index ec59c2e64..f5ddd6270 100644
--- a/libtransport/src/core/udp_socket_connector.cc
+++ b/libtransport/src/core/udp_socket_connector.cc
@@ -14,7 +14,7 @@
*/
#ifdef _WIN32
-#include <portability/win_portability.h>
+#include <hicn/transport/portability/win_portability.h>
#endif
#include <hicn/transport/errors/errors.h>
diff --git a/libtransport/src/http/response.cc b/libtransport/src/http/response.cc
index ba0acd1ac..409992835 100644
--- a/libtransport/src/http/response.cc
+++ b/libtransport/src/http/response.cc
@@ -16,8 +16,8 @@
#include <hicn/transport/errors/errors.h>
#include <hicn/transport/http/response.h>
-#include <experimental/algorithm>
-#include <experimental/functional>
+#include <algorithm>
+#include <functional>
#include <cstring>
@@ -62,11 +62,9 @@ std::size_t HTTPResponse::parseHeaders(const uint8_t *buffer, std::size_t size,
const char *crlf2 = "\r\n\r\n";
const char *begin = (const char *)buffer;
const char *end = begin + size;
- auto it =
- std::experimental::search(begin, end,
- std::experimental::make_boyer_moore_searcher(
- crlf2, crlf2 + strlen(crlf2)));
-
+ const char *begincrlf2 = (const char *)crlf2;
+ const char *endcrlf2 = begincrlf2 + strlen(crlf2);
+ auto it = std::search(begin, end, begincrlf2, endcrlf2);
if (it != end) {
std::stringstream ss;
ss.str(std::string(begin, it));
@@ -135,4 +133,4 @@ const std::string &HTTPResponse::getStatusString() const {
} // namespace http
-} // namespace transport \ No newline at end of file
+} // namespace transport
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
index 3e99fbae2..d82425236 100644
--- a/utils/CMakeLists.txt
+++ b/utils/CMakeLists.txt
@@ -35,7 +35,7 @@ set(HICN_UTILS hicn-utils CACHE INTERNAL "" FORCE)
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
find_package(Libtransport REQUIRED)
else()
- if (${CMAKE_SYSTEM_NAME} STREQUAL "Android")
+ if (DISABLE_SHARED_LIBRARIES)
set(LIBTRANSPORT_LIBRARIES ${LIBTRANSPORT_STATIC})
set(DEPENDENCIES ${LIBTRANSPORT_STATIC})
else ()
diff --git a/utils/src/ping_server.cc b/utils/src/ping_server.cc
index de02a2072..b1a6e1509 100644
--- a/utils/src/ping_server.cc
+++ b/utils/src/ping_server.cc
@@ -16,6 +16,7 @@
#include <hicn/transport/interfaces/socket_producer.h>
#ifndef _WIN32
#include <hicn/transport/utils/daemonizator.h>
+#include <unistd.h>
#else
#include <openssl/applink.c>
#endif
@@ -26,7 +27,7 @@
#include <hicn/transport/security/signer.h>
#include <hicn/transport/utils/string_tokenizer.h>
-#include <unistd.h>
+
#include <asio.hpp>
namespace transport {