summaryrefslogtreecommitdiffstats
path: root/lib/src/compat.c
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-11-07 16:42:01 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-11-08 01:36:45 +0100
commit1bf749aa3e4b0ccc40057b2587af5211926a1431 (patch)
tree1e59105d64e7dc13f4f1cd4ae8437bb8bb932292 /lib/src/compat.c
parenta30d495f6e91f3bed0420bf76c19315fe0de8801 (diff)
[HICN-385] fix route removal in hicnctrl, code uniformization in hicn-light control api
Change-Id: Id097368dcde993775f206623195cc5aa57b4fe12 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'lib/src/compat.c')
-rw-r--r--lib/src/compat.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/src/compat.c b/lib/src/compat.c
index 8ec4c83e8..615175e3b 100644
--- a/lib/src/compat.c
+++ b/lib/src/compat.c
@@ -323,25 +323,26 @@ int
hicn_packet_get_locator (hicn_format_t format, const hicn_header_t * h,
ip_address_t * address, bool is_interest)
{
- const void *locator;
int is_ipv4 = (format & HFO_INET);
int is_ipv6 = (format & HFO_INET6) >> 1;
if (is_ipv4)
{
- locator = is_interest ? &h->v4.ip.saddr : &h->v4.ip.daddr;
+ address->v4.as_inaddr = is_interest
+ ? h->v4.ip.saddr.as_inaddr
+ : h->v4.ip.daddr.as_inaddr;
}
else if (is_ipv6)
{
- locator = is_interest ? &h->v6.ip.saddr : &h->v6.ip.daddr;
+ address->v6.as_in6addr = is_interest
+ ? h->v6.ip.saddr.as_in6addr
+ : h->v6.ip.daddr.as_in6addr;
}
else
{
return HICN_LIB_ERROR_NOT_IMPLEMENTED;
}
- memcpy (address->as_u8, locator, is_ipv4 ? IPV4_ADDR_LEN : IPV6_ADDR_LEN);
-
return HICN_LIB_ERROR_NONE;
}
@@ -349,25 +350,28 @@ int
hicn_packet_set_locator (hicn_format_t format, hicn_header_t * h,
const ip_address_t * address, bool is_interest)
{
- void *locator;
int is_ipv4 = (format & HFO_INET);
int is_ipv6 = (format & HFO_INET6) >> 1;
if (is_ipv6)
{
- locator = is_interest ? &h->v6.ip.saddr : &h->v6.ip.daddr;
+ if (is_interest)
+ h->v6.ip.saddr.as_in6addr = address->v6.as_in6addr;
+ else
+ h->v6.ip.daddr.as_in6addr = address->v6.as_in6addr;
}
else if (is_ipv4)
{
- locator = is_interest ? &h->v4.ip.saddr : &h->v4.ip.daddr;
+ if (is_interest)
+ h->v4.ip.saddr.as_inaddr = address->v4.as_inaddr;
+ else
+ h->v4.ip.daddr.as_inaddr = address->v4.as_inaddr;
}
else
{
return HICN_LIB_ERROR_INVALID_PARAMETER;
}
- memcpy (locator, address->as_u8, is_ipv4 ? IPV4_ADDR_LEN : IPV6_ADDR_LEN);
-
return HICN_LIB_ERROR_NONE;
}