diff options
author | Mauro Sardara <msardara@cisco.com> | 2019-03-11 19:19:15 +0100 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2019-03-12 11:04:38 +0100 |
commit | e1dbbf7e8e0b2d5101aa4e06d90f82cfab5087d2 (patch) | |
tree | eb7ecbc11044255e7f0a6508d746024f956fc273 /lib | |
parent | f14470a4e352b15aea76a8c6176c409c595cf534 (diff) |
[HICN-106]
Added generation of .lib for dll shared libraries
fixed warning for shift in csum_fold function in libhicn
added declaration of external symbol in libtransport log.
Change-Id: I9377eb6016a74f14eb8f05df2ced36ee41a27bfd
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/src/common.h | 28 | ||||
-rw-r--r-- | lib/src/protocol/tcp.c | 4 |
2 files changed, 26 insertions, 6 deletions
diff --git a/lib/src/common.h b/lib/src/common.h index 1d4b1e6bf..33323da1b 100644 --- a/lib/src/common.h +++ b/lib/src/common.h @@ -60,6 +60,28 @@ typedef uint8_t u8; #define STATIC_ASSERT(x) +/* Architecture-dependent uword size */ +#if INTPTR_MAX == INT64_MAX +#define log2_uword_bits 6 +#elif INTPTR_MAX == INT32_MAX +#define log2_uword_bits 5 +#else +#error "Impossible to detect architecture" +#endif + +#define uword_bits (1 << log2_uword_bits) + +/* Word types. */ +#if uword_bits == 64 +/* 64 bit word machines. */ +typedef u64 uword; +#else +/* 32 bit word machines. */ +typedef u32 uword; +#endif + +typedef uword ip_csum_t; + #endif /* ! HICN_VPP_PLUGIN */ /* @@ -173,8 +195,6 @@ int get_addr_family (const char *ip_address); #ifndef HICN_VPP_PLUGIN -typedef u16 ip_csum_t; - /* * Checksum update (incremental and non-incremental) * @@ -186,7 +206,7 @@ static_always_inline u16 ip_csum_fold (ip_csum_t c) { /* Reduce to 16 bits. */ -#if 0 // uword_bits == 64 +#if uword_bits == 64 c = (c & (ip_csum_t) 0xffffffff) + (c >> (ip_csum_t) 32); c = (c & 0xffff) + (c >> 16); #endif @@ -194,7 +214,7 @@ ip_csum_fold (ip_csum_t c) c = (c & 0xffff) + (c >> 16); c = (c & 0xffff) + (c >> 16); - return c; + return (u16)c; } static_always_inline ip_csum_t diff --git a/lib/src/protocol/tcp.c b/lib/src/protocol/tcp.c index 08b7bde8a..b9f1d2775 100644 --- a/lib/src/protocol/tcp.c +++ b/lib/src/protocol/tcp.c @@ -247,7 +247,7 @@ 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, (ip_csum_t) (h->ipv6.saddr.as_u64[0])); + ip_csum_t 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])); @@ -272,7 +272,7 @@ 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, (ip_csum_t) (addr_old->ip6.as_u64[0])); + ip_csum_t 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])); |