aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormichele papalini <micpapal@cisco.com>2019-08-27 10:45:50 +0200
committermichele papalini <micpapal@cisco.com>2019-08-27 10:45:50 +0200
commit91b8ed64a63865802df7914c43eb0fae03544cc9 (patch)
treebfd743104c3a4eecc710eb93175728cbeb9011ac /lib
parent3f709888ef31c008021f2e929a937a3d6b312c87 (diff)
HICN-270 correcly create hicn name from ip address in lib
Change-Id: Ie2ebe1db4ad5bddb7a9b1a67e38bf7e16b873ac0 Signed-off-by: michele papalini <micpapal@cisco.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/src/name.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/src/name.c b/lib/src/name.c
index ba5ff85b5..0a0da63cf 100644
--- a/lib/src/name.c
+++ b/lib/src/name.c
@@ -82,28 +82,22 @@ hicn_name_create_from_ip_address (const ip_address_t * ip_address, u32 id,
switch (ip_address->family)
{
case AF_INET:
- if (name->type == HNT_UNSPEC)
- {
- name->type = HNT_CONTIGUOUS_V4;
- }
+ name->type = HNT_CONTIGUOUS_V4;
break;
case AF_INET6:
- if (name->type == HNT_UNSPEC)
- {
- name->type = HNT_CONTIGUOUS_V6;
- }
+ name->type = HNT_CONTIGUOUS_V6;
break;
default:
return HICN_LIB_ERROR_INVALID_IP_ADDRESS;
}
- name->len = (u8) (ip_address->prefix_len);
+ name->len = (u8) ip_address_len (ip_address);
if ((name->type != HNT_CONTIGUOUS_V4) && (name->type != HNT_CONTIGUOUS_V6))
{
return HICN_LIB_ERROR_NOT_IMPLEMENTED;
}
- memcpy (name->buffer, ip_address->buffer, ip_address_len (ip_address));
+ memcpy (name->buffer, ip_address->buffer, name->len);
*(u32 *) (name->buffer + name->len) = id;
return HICN_LIB_ERROR_NONE;