summaryrefslogtreecommitdiffstats
path: root/lib/includes
diff options
context:
space:
mode:
Diffstat (limited to 'lib/includes')
-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
8 files changed, 230 insertions, 28 deletions
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