aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src
diff options
context:
space:
mode:
authorAngelo Mantellini <manangel@cisco.com>2019-02-08 15:11:57 +0100
committerAngelo Mantellini <manangel@cisco.com>2019-02-12 10:53:54 +0100
commitf126f86da5acf088f24e97ecb32f9ba5a1789aa4 (patch)
treeb81704d6048117cbe15a398a3f6f5d974d143d14 /lib/src
parent3447d02974947d10440e4aa5627318c29be95c01 (diff)
[HICN-44] Remove warnings libhicn (lib) on windows
Change-Id: I637e9c1e05de8a9e6743ea729b62d3eedd6ca54b Signed-off-by: Angelo Mantellini <manangel@cisco.com>
Diffstat (limited to 'lib/src')
-rw-r--r--lib/src/common.h29
-rw-r--r--lib/src/compat.c12
-rw-r--r--lib/src/name.c6
-rw-r--r--lib/src/name.h5
-rw-r--r--lib/src/protocol/ah.c2
-rw-r--r--lib/src/protocol/ipv4.c2
-rw-r--r--lib/src/protocol/ipv6.c2
-rw-r--r--lib/src/protocol/tcp.c16
8 files changed, 40 insertions, 34 deletions
diff --git a/lib/src/common.h b/lib/src/common.h
index 57b9078ff..e67762301 100644
--- a/lib/src/common.h
+++ b/lib/src/common.h
@@ -80,24 +80,25 @@ typedef uint8_t u8;
#define __ORDER_BIG_ENDIAN__ 0x44434241UL
#define __BYTE_ORDER__ ('ABCD')
- /* Windows compatibility headers*/
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <winsock2.h>
-#include <ws2ipdef.h>
-#include <Ws2tcpip.h>
+ /* Windows compatibility headers*/
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <winsock2.h>
+#include <ws2ipdef.h>
+#include <Ws2tcpip.h>
#include <In6addr.h>
+#define strdup _strdup
#define __attribute__(A)
-#ifndef IOVEC
-#define IOVEC
-#define UIO_MAXIOV 16
-#define IOV_MAX UIO_MAXIOV
-struct iovec {
- void* iov_base;
- size_t iov_len;
-};
+#ifndef IOVEC
+#define IOVEC
+#define UIO_MAXIOV 16
+#define IOV_MAX UIO_MAXIOV
+struct iovec {
+ void* iov_base;
+ size_t iov_len;
+};
#endif
#endif
diff --git a/lib/src/compat.c b/lib/src/compat.c
index fba826ab0..23683ff8e 100644
--- a/lib/src/compat.c
+++ b/lib/src/compat.c
@@ -199,7 +199,7 @@ hicn_packet_get_payload_length (hicn_format_t format, const hicn_header_t * h,
int
hicn_packet_set_payload_length (hicn_format_t format, hicn_header_t * h,
- size_t payload_length)
+ const size_t payload_length)
{
hicn_type_t type = hicn_format_to_type (format);
return hicn_ops_vft[type.l1]->set_payload_length (type, &h->protocol,
@@ -504,10 +504,10 @@ hicn_packet_get_reserved_bits (const hicn_header_t * h, u8 * reserved_bits)
switch (HICN_IP_VERSION (h))
{
case 6:
- *reserved_bits = h->v6.tcp.reserved;
+ *reserved_bits = (u8)(h->v6.tcp.reserved);
break;
case 4:
- *reserved_bits = h->v4.tcp.reserved;
+ *reserved_bits = (u8)(h->v4.tcp.reserved);
break;
default:
return HICN_LIB_ERROR_UNEXPECTED;
@@ -517,7 +517,7 @@ hicn_packet_get_reserved_bits (const hicn_header_t * h, u8 * reserved_bits)
}
int
-hicn_packet_set_reserved_bits (hicn_header_t * h, u8 reserved_bits)
+hicn_packet_set_reserved_bits (hicn_header_t * h, const u8 reserved_bits)
{
switch (HICN_IP_VERSION (h))
{
@@ -1011,7 +1011,7 @@ int
hicn_interest_set_payload (hicn_format_t format, hicn_header_t * interest,
const u8 * payload, size_t payload_length)
{
- return hicn_packet_set_payload (format, interest, payload, payload_length);
+ return hicn_packet_set_payload (format, interest, payload, (u16)payload_length);
}
int
@@ -1122,7 +1122,7 @@ int
hicn_data_set_payload (hicn_format_t format, hicn_header_t * data,
const u8 * payload, size_t payload_length)
{
- return hicn_packet_set_payload (format, data, payload, payload_length);
+ return hicn_packet_set_payload (format, data, payload, (u16)payload_length);
}
int
diff --git a/lib/src/name.c b/lib/src/name.c
index 9e409bd3b..ba5ff85b5 100644
--- a/lib/src/name.c
+++ b/lib/src/name.c
@@ -97,7 +97,7 @@ hicn_name_create_from_ip_address (const ip_address_t * ip_address, u32 id,
return HICN_LIB_ERROR_INVALID_IP_ADDRESS;
}
- name->len = ip_address->prefix_len;
+ name->len = (u8) (ip_address->prefix_len);
if ((name->type != HNT_CONTIGUOUS_V4) && (name->type != HNT_CONTIGUOUS_V6))
{
return HICN_LIB_ERROR_NOT_IMPLEMENTED;
@@ -493,7 +493,7 @@ hicn_name_ntop (const hicn_name_t * src, char *dst, size_t len)
goto ERR;
}
- offset = strlen (dst);
+ offset = (int) strlen (dst);
dst[offset] = '|';
sprintf (dst + offset + 1, "%lu", (unsigned long) (*(u32 *) seg_number));
@@ -546,7 +546,7 @@ hicn_prefix_create_from_ip_address (const ip_address_t * ip_address,
default:
return HICN_LIB_ERROR_INVALID_IP_ADDRESS;
}
- prefix->len = ip_address->prefix_len;
+ prefix->len = (u8) (ip_address->prefix_len);
return HICN_LIB_ERROR_NONE;
}
diff --git a/lib/src/name.h b/lib/src/name.h
index 0fe8f7446..434b563b8 100644
--- a/lib/src/name.h
+++ b/lib/src/name.h
@@ -35,8 +35,13 @@
******************************************************************************/
/* Presentation format */
+#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
+#endif
+
+#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN 46
+#endif
//#define INET_MAX_ADDRSTRLEN INET6_ADDRSTRLEN
/* Address size */
diff --git a/lib/src/protocol/ah.c b/lib/src/protocol/ah.c
index c1395dee8..8bd9bca83 100644
--- a/lib/src/protocol/ah.c
+++ b/lib/src/protocol/ah.c
@@ -163,7 +163,7 @@ int
ah_set_signature_size (hicn_type_t type, hicn_protocol_t * h,
const size_t signature_size)
{
- h->ah.payloadlen = signature_size >> 2;
+ h->ah.payloadlen = (u8)(signature_size >> 2);
return HICN_LIB_ERROR_NONE;
}
diff --git a/lib/src/protocol/ipv4.c b/lib/src/protocol/ipv4.c
index 4e4c47f5b..97aafaeaf 100644
--- a/lib/src/protocol/ipv4.c
+++ b/lib/src/protocol/ipv4.c
@@ -383,7 +383,7 @@ ipv4_set_payload_length (hicn_type_t type, hicn_protocol_t * h,
int rc = CHILD_OPS (get_header_length, type, h, &child_header_length);
if (rc < 0)
return rc;
- h->ipv4.len = htons (payload_length + IPV4_HDRLEN + child_header_length);
+ h->ipv4.len = htons ((u_short) (payload_length + IPV4_HDRLEN + child_header_length));
return HICN_LIB_ERROR_NONE;
}
diff --git a/lib/src/protocol/ipv6.c b/lib/src/protocol/ipv6.c
index 1cdcc75c0..7554eadf2 100644
--- a/lib/src/protocol/ipv6.c
+++ b/lib/src/protocol/ipv6.c
@@ -341,7 +341,7 @@ ipv6_set_payload_length (hicn_type_t type, hicn_protocol_t * h,
int rc = CHILD_OPS (get_header_length, type, h, &child_header_length);
if (rc < 0)
return rc;
- h->ipv6.len = htons (payload_length + child_header_length);
+ h->ipv6.len = htons ( (u_short) (payload_length + child_header_length));
return HICN_LIB_ERROR_NONE;
}
diff --git a/lib/src/protocol/tcp.c b/lib/src/protocol/tcp.c
index bbe25fc6d..08b7bde8a 100644
--- a/lib/src/protocol/tcp.c
+++ b/lib/src/protocol/tcp.c
@@ -247,10 +247,10 @@ tcp_rewrite_interest (hicn_type_t type, hicn_protocol_t * h,
* csum = ip_csum_sub_even (*tcp_checksum, h->ipv4.saddr.as_u32);
* csum = ip_csum_add_even (csum, h->ipv4.saddr.as_u32);
*/
- u16 csum = ip_csum_sub_even (*tcp_checksum, h->ipv6.saddr.as_u64[0]);
- csum = ip_csum_sub_even (csum, h->ipv6.saddr.as_u64[1]);
- csum = ip_csum_add_even (csum, h->ipv6.saddr.as_u64[0]);
- csum = ip_csum_add_even (csum, h->ipv6.saddr.as_u64[1]);
+ u16 csum = ip_csum_sub_even (*tcp_checksum, (ip_csum_t) (h->ipv6.saddr.as_u64[0]));
+ csum = ip_csum_sub_even (csum, (ip_csum_t) (h->ipv6.saddr.as_u64[1]));
+ csum = ip_csum_add_even (csum, (ip_csum_t) (h->ipv6.saddr.as_u64[0]));
+ csum = ip_csum_add_even (csum, (ip_csum_t) (h->ipv6.saddr.as_u64[1]));
*tcp_checksum = ip_csum_fold (csum);
@@ -272,10 +272,10 @@ tcp_rewrite_data (hicn_type_t type, hicn_protocol_t * h,
* csum = ip_csum_sub_even (*tcp_checksum, h->ipv4.saddr.as_u32);
* csum = ip_csum_add_even (csum, h->ipv4.saddr.as_u32);
*/
- u16 csum = ip_csum_sub_even (*tcp_checksum, addr_old->ip6.as_u64[0]);
- csum = ip_csum_sub_even (*tcp_checksum, addr_old->ip6.as_u64[1]);
- csum = ip_csum_add_even (csum, addr_new->ip6.as_u64[0]);
- csum = ip_csum_add_even (csum, addr_new->ip6.as_u64[1]);
+ u16 csum = ip_csum_sub_even (*tcp_checksum, (ip_csum_t) (addr_old->ip6.as_u64[0]));
+ csum = ip_csum_sub_even (*tcp_checksum, (ip_csum_t) (addr_old->ip6.as_u64[1]));
+ csum = ip_csum_add_even (csum, (ip_csum_t) (addr_new->ip6.as_u64[0]));
+ csum = ip_csum_add_even (csum, (ip_csum_t) (addr_new->ip6.as_u64[1]));
csum = ip_csum_sub_even (csum, h->tcp.pathlabel);
tcp_update_data_pathlabel (type, h, face_id);