diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/includes/hicn/common.h | 1 | ||||
-rw-r--r-- | lib/includes/hicn/name.h | 82 | ||||
-rw-r--r-- | lib/src/compat.c | 5 | ||||
-rw-r--r-- | lib/src/name.c | 435 | ||||
-rw-r--r-- | lib/src/protocol/ipv4.c | 24 | ||||
-rw-r--r-- | lib/src/protocol/ipv6.c | 24 |
6 files changed, 87 insertions, 484 deletions
diff --git a/lib/includes/hicn/common.h b/lib/includes/hicn/common.h index 30f370241..3385b4d19 100644 --- a/lib/includes/hicn/common.h +++ b/lib/includes/hicn/common.h @@ -154,6 +154,7 @@ struct iovec typedef union { + u8 as_u8[4]; u32 as_u32; struct in_addr as_inaddr; } ip4_address_t; diff --git a/lib/includes/hicn/name.h b/lib/includes/hicn/name.h index d5202068b..9cee0bc1d 100644 --- a/lib/includes/hicn/name.h +++ b/lib/includes/hicn/name.h @@ -62,81 +62,18 @@ typedef union { struct { - union - { - u32 prefix; - u8 prefix_as_u8[4]; - ip4_address_t prefix_as_ip4; - }; - hicn_name_suffix_t suffix; - }; - u8 buffer[HICN_V4_NAME_LEN]; -} hicn_v4_name_t; - -typedef union -{ - struct - { - union - { - u64 prefix[2]; - u8 prefix_as_u8[16]; - ip6_address_t prefix_as_ip6; - }; + ip46_address_t prefix; hicn_name_suffix_t suffix; }; u8 buffer[HICN_V6_NAME_LEN]; -} hicn_v6_name_t; - -#ifndef HICN_VPP_PLUGIN -#define HICN_NAME_COMPONENT_SIZE 2 - -typedef struct -{ - struct iovec buffers[HICN_NAME_COMPONENT_SIZE]; -} hicn_iov_name_t; - -#define UNSPEC 1 << 0 -#define HNT_CONTIGUOUS 1 << 1 -#define HNT_IOV 1 << 2 -#define HNT_INET 1 << 3 -#define HNT_INET6 1 << 4 - -typedef enum -{ - HNT_UNSPEC = UNSPEC, - HNT_CONTIGUOUS_V4 = HNT_CONTIGUOUS | HNT_INET, - HNT_CONTIGUOUS_V6 = HNT_CONTIGUOUS | HNT_INET6, - HNT_IOV_V4 = HNT_IOV | HNT_INET, - HNT_IOV_V6 = HNT_IOV | HNT_INET6, -} hicn_name_type_t; -#endif /* HICN_VPP_PLUGIN */ - -typedef struct -{ -#ifndef HICN_VPP_PLUGIN - hicn_name_type_t type; - u8 len; -#endif /* HICN_VPP_PLUGIN */ - union - { - hicn_v4_name_t ip4; - hicn_v6_name_t ip6; - ip46_address_t ip46; -#ifndef HICN_VPP_PLUGIN - hicn_iov_name_t iov; - u8 buffer[HICN_V6_NAME_LEN]; -#endif /* HICN_VPP_PLUGIN */ - }; } hicn_name_t; -#ifndef HICN_VPP_PLUGIN -#define _is_unspec(name) ((name->type & UNSPEC)) -#define _is_contiguous(name) ((name->type & HNT_CONTIGUOUS) >> 1) -#define _is_iov(name) ((name->type & HNT_IOV) >> 2) -#define _is_inet4(name) ((name->type & HNT_INET) >> 3) -#define _is_inet6(name) ((name->type & HNT_INET6) >> 4) -#endif /* HICN_VPP_PLUGIN */ +always_inline +int hicn_name_is_ip4 (const hicn_name_t * name) +{ + const ip46_address_t *ip46 = &name->prefix; + return (((ip46)->pad[0] | (ip46)->pad[1] | (ip46)->pad[2]) == 0); +} /** * @brief Create an hICN name from IP address in presentation format @@ -192,7 +129,10 @@ int hicn_name_hash (const hicn_name_t * name, u32 * hash, bool consider_suffix); * @return 0 if the name is empty, any other value otherwise (implementation * returns 1) */ -int hicn_name_empty (hicn_name_t * name); +always_inline int hicn_name_empty (hicn_name_t * name) +{ + return ((name->prefix.ip6.as_u64[0] | name->prefix.ip6.as_u64[1] | (u64)name->suffix) == 0); +} /** * @brief Copy an hICN name diff --git a/lib/src/compat.c b/lib/src/compat.c index 615175e3b..db2f40e37 100644 --- a/lib/src/compat.c +++ b/lib/src/compat.c @@ -255,11 +255,6 @@ hicn_packet_set_name (hicn_format_t format, hicn_header_t * h, { hicn_type_t type = hicn_format_to_type (format); -#ifndef HICN_VPP_PLUGIN - if (name->type & HNT_IOV) - return HICN_LIB_ERROR_NOT_IMPLEMENTED; -#endif /* HICN_VPP_PLUGIN */ - if (is_interest) return hicn_ops_vft[type.l1]->set_interest_name (type, &h->protocol, name); diff --git a/lib/src/name.c b/lib/src/name.c index 9388c35e7..1aa54ad40 100644 --- a/lib/src/name.c +++ b/lib/src/name.c @@ -30,72 +30,32 @@ #include <hicn/error.h> #include <hicn/name.h> -#if ! HICN_VPP_PLUGIN int hicn_name_create (const char *ip_address, u32 id, hicn_name_t * name) { int af, rc; + u8 *dst; af = get_addr_family (ip_address); switch (af) { case AF_INET: - if (name->type == HNT_UNSPEC) - { - name->type = HNT_CONTIGUOUS_V4; - } - name->len = IPV4_ADDR_LEN; + dst = (u8*)(&name->prefix.ip4); break; case AF_INET6: - if (name->type == HNT_UNSPEC) - { - name->type = HNT_CONTIGUOUS_V6; - } - name->len = IPV6_ADDR_LEN; + dst = (u8*)(&name->prefix.ip6.as_u8); break; default: return HICN_LIB_ERROR_INVALID_IP_ADDRESS; } - if ((name->type != HNT_CONTIGUOUS_V4) && (name->type != HNT_CONTIGUOUS_V6)) - { - return HICN_LIB_ERROR_NOT_IMPLEMENTED; - } - - rc = inet_pton (af, ip_address, name->buffer); + rc = inet_pton (af, ip_address, dst); if (rc <= 0) { return HICN_LIB_ERROR_UNKNOWN_ADDRESS; } - *(u32 *) (name->buffer + name->len) = id; - - return HICN_LIB_ERROR_NONE; -} - -int -hicn_name_create_from_ip_prefix (const ip_prefix_t * prefix, u32 id, - hicn_name_t * name) -{ - switch (prefix->family) - { - case AF_INET: - name->type = HNT_CONTIGUOUS_V4; - memcpy (name->buffer, prefix->address.v4.buffer, - ip_address_len(prefix->family)); - name->len = IPV4_ADDR_LEN; - break; - case AF_INET6: - name->type = HNT_CONTIGUOUS_V6; - memcpy (name->buffer, prefix->address.v6.buffer, - ip_address_len(prefix->family)); - name->len = IPV6_ADDR_LEN; - break; - default: - return HICN_LIB_ERROR_INVALID_IP_ADDRESS; - } - - *(u32 *) (name->buffer + name->len) = id; + name->suffix = id; return HICN_LIB_ERROR_NONE; } @@ -103,170 +63,25 @@ hicn_name_create_from_ip_prefix (const ip_prefix_t * prefix, u32 id, u8 hicn_name_get_length (const hicn_name_t * name) { - return name->len; + return hicn_name_is_ip4(name) ? HICN_V4_NAME_LEN : HICN_V4_NAME_LEN; } -int -hicn_name_compare (const hicn_name_t * name_1, const hicn_name_t * name_2, - bool consider_segment) -{ - hicn_name_t *name1 = (hicn_name_t *) name_1; - hicn_name_t *name2 = (hicn_name_t *) name_2; - - if ((name1->type == HNT_CONTIGUOUS_V4 && name2->type == HNT_CONTIGUOUS_V6) - || (name1->type == HNT_CONTIGUOUS_V6 - && name2->type == HNT_CONTIGUOUS_V4)) - { - return -1; - } - - if ((name1->type == HNT_IOV_V4 && name2->type == HNT_IOV_V6) || - (name1->type == HNT_IOV_V6 && name2->type == HNT_IOV_V4)) - { - return -1; - } - - if ((name1->type == HNT_IOV_V4 && name2->type == HNT_CONTIGUOUS_V6) || - (name1->type == HNT_IOV_V6 && name2->type == HNT_CONTIGUOUS_V4)) - { - return -1; - } - - if (name1->type == HNT_UNSPEC || name2->type == HNT_UNSPEC) - { - return -1; - } - - size_t len1 = 0, len2 = 0; - - u8 *buffer11, *buffer12, *buffer21, *buffer22; - - switch (name1->type) - { - case HNT_CONTIGUOUS_V4: - buffer11 = name1->buffer; - buffer12 = name1->buffer + IPV4_ADDR_LEN; - len1 = IPV4_ADDR_LEN; - break; - case HNT_CONTIGUOUS_V6: - buffer11 = name1->buffer; - buffer12 = name1->buffer + IPV6_ADDR_LEN; - len1 = IPV6_ADDR_LEN; - break; - case HNT_IOV_V4: - buffer11 = name1->iov.buffers[0].iov_base; - buffer12 = name1->iov.buffers[1].iov_base; - len1 = IPV4_ADDR_LEN; - break; - case HNT_IOV_V6: - buffer11 = name1->iov.buffers[0].iov_base; - buffer12 = name1->iov.buffers[1].iov_base; - len1 = IPV6_ADDR_LEN; - break; - default: - return HICN_LIB_ERROR_NOT_IMPLEMENTED; - } - - switch (name2->type) - { - case HNT_CONTIGUOUS_V4: - buffer21 = name2->buffer; - buffer22 = name2->buffer + IPV4_ADDR_LEN; - len2 = IPV4_ADDR_LEN; - break; - case HNT_CONTIGUOUS_V6: - buffer21 = name2->buffer; - buffer22 = name2->buffer + IPV6_ADDR_LEN; - len2 = IPV6_ADDR_LEN; - break; - case HNT_IOV_V4: - buffer21 = name2->iov.buffers[0].iov_base; - buffer22 = name2->iov.buffers[1].iov_base; - len2 = IPV4_ADDR_LEN; - break; - case HNT_IOV_V6: - buffer21 = name2->iov.buffers[0].iov_base; - buffer22 = name2->iov.buffers[1].iov_base; - len2 = IPV6_ADDR_LEN; - break; - default: - return HICN_LIB_ERROR_NOT_IMPLEMENTED; - } - - // Sanity check - if (len1 != len2) - { - return HICN_LIB_ERROR_UNEXPECTED; - } - - int ret1 = memcmp ((u8 *) buffer11, (u8 *) buffer21, len1); - - if (!consider_segment) - { - return ret1; - } - - int ret2 = memcmp ((u8 *) buffer12, (u8 *) buffer22, HICN_SEGMENT_LEN); - - return ret1 || ret2; -} +#if ! HICN_VPP_PLUGIN int hicn_name_hash (const hicn_name_t * name, u32 * hash, bool consider_suffix) { - switch (name->type) - { - case HNT_CONTIGUOUS_V4: - *hash = hash32 (name->buffer, consider_suffix ? HICN_V4_NAME_LEN : HICN_V4_PREFIX_LEN); - break; - case HNT_CONTIGUOUS_V6: - *hash = hash32 (name->buffer, consider_suffix ? HICN_V6_NAME_LEN : HICN_V6_PREFIX_LEN); - break; - case HNT_IOV_V4: - case HNT_IOV_V6: - *hash = - hash32 (name->iov.buffers[0].iov_base, name->iov.buffers[0].iov_len); - if (consider_suffix) - { - *hash = cumulative_hash32 (name->iov.buffers[1].iov_base, - name->iov.buffers[1].iov_len, *hash); - } - break; - default: - return HICN_LIB_ERROR_NOT_IMPLEMENTED; - } - + size_t size = (u8)consider_suffix * sizeof(hicn_name_suffix_t) + IPV6_ADDR_LEN; + *hash = hash32 (name->buffer, size); return HICN_LIB_ERROR_NONE; } -int -hicn_name_empty (hicn_name_t * name) -{ - return name->type == HNT_UNSPEC ? HICN_LIB_ERROR_NONE : 1; -} +#endif /* ! HICN_VPP_PLUGIN */ int hicn_name_copy (hicn_name_t * dst, const hicn_name_t * src) { - switch (src->type) - { - case HNT_CONTIGUOUS_V4: - case HNT_CONTIGUOUS_V6: - *dst = *src; - break; - case HNT_IOV_V4: - case HNT_IOV_V6: - dst->type = - src->type == HNT_IOV_V4 ? HNT_CONTIGUOUS_V4 : HNT_CONTIGUOUS_V6; - memcpy (dst->buffer, src->iov.buffers[0].iov_base, - src->iov.buffers[0].iov_len); - memcpy (dst->buffer + src->iov.buffers[0].iov_len, - src->iov.buffers[1].iov_base, src->iov.buffers[1].iov_len); - break; - default: - return HICN_LIB_ERROR_NOT_IMPLEMENTED; - } - + memcpy (dst, src, sizeof(*dst)); return HICN_LIB_ERROR_NONE; } @@ -274,78 +89,18 @@ int hicn_name_copy_to_destination (u8 * dst, const hicn_name_t * src, bool copy_suffix) { - size_t length; - - switch (src->type) - { - case HNT_CONTIGUOUS_V4: - if (copy_suffix) - { - length = HICN_V4_NAME_LEN; - } - else - { - length = IPV4_ADDR_LEN; - } - memcpy (dst, src->buffer, length); - break; - case HNT_CONTIGUOUS_V6: - if (copy_suffix) - { - length = HICN_V6_NAME_LEN; - } - else - { - length = IPV6_ADDR_LEN; - } - memcpy (dst, src->buffer, length); - break; - case HNT_IOV_V4: - case HNT_IOV_V6: - memcpy (dst, src->iov.buffers[0].iov_base, src->iov.buffers[0].iov_len); - if (copy_suffix) - { - memcpy (dst + src->iov.buffers[0].iov_len, - src->iov.buffers[1].iov_base, src->iov.buffers[1].iov_len); - } - break; - default: - return HICN_LIB_ERROR_NOT_IMPLEMENTED; - } - + u8 is_ip4 = hicn_name_is_ip4(src); + size_t size = is_ip4 * IPV4_ADDR_LEN + (1 - is_ip4) * IPV6_ADDR_LEN; + size += (u8)copy_suffix * sizeof (hicn_name_suffix_t); + void *_src = (void *)(is_ip4 * (u64)(&src->prefix.ip4) + (1 - is_ip4) * (u64)(&src->prefix.ip6)); + memcpy (dst, _src, size); return HICN_LIB_ERROR_NONE; } int hicn_name_set_seq_number (hicn_name_t * name, u32 seq_number) { - u8 *sequence_number = NULL; - - switch (name->type) - { - case HNT_CONTIGUOUS_V6: - sequence_number = name->buffer + IPV6_ADDR_LEN; - break; - case HNT_CONTIGUOUS_V4: - sequence_number = name->buffer + IPV4_ADDR_LEN; - break; - case HNT_IOV_V6: - case HNT_IOV_V4: - sequence_number = name->iov.buffers[1].iov_base; - break; - case HNT_UNSPEC: - return HICN_LIB_ERROR_UNEXPECTED; - } - - if (sequence_number) - { - *(u32 *) sequence_number = seq_number; - } - else - { - return HICN_LIB_ERROR_UNEXPECTED; - } - + name->suffix = seq_number; return HICN_LIB_ERROR_NONE; } @@ -356,34 +111,20 @@ hicn_name_to_sockaddr_address (const hicn_name_t * name, struct sockaddr_in6 *tmp6 = (struct sockaddr_in6 *) ip_address; struct sockaddr_in *tmp4 = (struct sockaddr_in *) ip_address; - switch (name->type) + u8 is_ip4 = hicn_name_is_ip4 (name); + ip_address->sa_family = AF_INET * is_ip4 + AF_INET6 * (1 - is_ip4); + + if (is_ip4) { - case HNT_CONTIGUOUS_V6: - tmp6->sin6_family = AF_INET6; - tmp6->sin6_scope_id = 0; - tmp6->sin6_port = DUMMY_PORT; - memcpy (&tmp6->sin6_addr, name->buffer, IPV6_ADDR_LEN); - break; - case HNT_IOV_V6: - tmp6->sin6_family = AF_INET6; - tmp6->sin6_scope_id = 0; - tmp6->sin6_port = DUMMY_PORT; - memcpy (&tmp6->sin6_addr, name->iov.buffers[0].iov_base, - name->iov.buffers[0].iov_len); - break; - case HNT_CONTIGUOUS_V4: tmp4->sin_family = AF_INET; tmp4->sin_port = DUMMY_PORT; - memcpy (&tmp4->sin_addr, name->buffer, IPV4_ADDR_LEN); - break; - case HNT_IOV_V4: - tmp4->sin_family = AF_INET; - tmp4->sin_port = DUMMY_PORT; - memcpy (&tmp4->sin_addr, name->iov.buffers[0].iov_base, - name->iov.buffers[0].iov_len); - break; - default: - return HICN_LIB_ERROR_UNEXPECTED; + memcpy (&tmp4->sin_addr, name->prefix.ip4.as_u8, IPV4_ADDR_LEN); + } + else + { + tmp6->sin6_family = AF_INET6; + tmp6->sin6_port = DUMMY_PORT; + memcpy (&tmp6->sin6_addr, name->prefix.ip6.as_u8, IPV6_ADDR_LEN); } return HICN_LIB_ERROR_NONE; @@ -392,63 +133,14 @@ hicn_name_to_sockaddr_address (const hicn_name_t * name, int hicn_name_to_ip_prefix (const hicn_name_t * name, ip_prefix_t * prefix) { - switch (name->type) - { - case HNT_CONTIGUOUS_V6: - memcpy (&prefix->address.v6.buffer, name->buffer, IPV6_ADDR_LEN); - prefix->family = AF_INET6; - break; - case HNT_IOV_V6: - memcpy (&prefix->address.v6.buffer, name->iov.buffers[0].iov_base, - name->iov.buffers[0].iov_len); - prefix->family = AF_INET6; - break; - case HNT_CONTIGUOUS_V4: - memcpy (&prefix->address.v4.buffer, name->buffer, IPV4_ADDR_LEN); - prefix->family = AF_INET; - break; - case HNT_IOV_V4: - memcpy (&prefix->address.v4.buffer, name->iov.buffers[0].iov_base, - name->iov.buffers[0].iov_len); - prefix->family = AF_INET; - break; - default: - return HICN_LIB_ERROR_UNEXPECTED; - } - + memcpy (prefix, &name->prefix, sizeof(*prefix)); return HICN_LIB_ERROR_NONE; } int hicn_name_get_seq_number (const hicn_name_t * name, u32 * seq_number) { - const u8 *sequence_number = NULL; - - switch (name->type) - { - case HNT_CONTIGUOUS_V6: - sequence_number = name->buffer + IPV6_ADDR_LEN; - break; - case HNT_CONTIGUOUS_V4: - sequence_number = name->buffer + IPV4_ADDR_LEN; - break; - case HNT_IOV_V6: - case HNT_IOV_V4: - sequence_number = name->iov.buffers[1].iov_base; - break; - default: - return HICN_LIB_ERROR_UNEXPECTED; - } - - if (sequence_number) - { - *seq_number = *(u32 *) sequence_number; - } - else - { - return HICN_LIB_ERROR_UNEXPECTED; - } - + *seq_number = name->suffix; return HICN_LIB_ERROR_NONE; } @@ -457,29 +149,12 @@ hicn_name_ntop (const hicn_name_t * src, char *dst, size_t len) { int offset; const char *rc; - void *seg_number = NULL; + u8 is_ip4 = hicn_name_is_ip4 (src); - switch (src->type) - { - case HNT_CONTIGUOUS_V6: - rc = inet_ntop (AF_INET6, src->buffer, dst, (socklen_t)len); - seg_number = (u8 *) src->buffer + IPV6_ADDR_LEN; - break; - case HNT_CONTIGUOUS_V4: - rc = inet_ntop (AF_INET, src->buffer, dst, (socklen_t)len); - seg_number = (u8 *) src->buffer + IPV4_ADDR_LEN; - break; - case HNT_IOV_V6: - rc = inet_ntop (AF_INET6, src->iov.buffers[0].iov_base, dst, (socklen_t)len); - seg_number = src->iov.buffers[1].iov_base; - break; - case HNT_IOV_V4: - rc = inet_ntop (AF_INET, src->iov.buffers[0].iov_base, dst, (socklen_t)len); - seg_number = src->iov.buffers[1].iov_base; - break; - default: - return HICN_LIB_ERROR_NOT_IMPLEMENTED; - } + if (is_ip4) + rc = inet_ntop (AF_INET, (struct in_addr*)(src->prefix.ip4.as_u8), dst, (socklen_t)len); + else + rc = inet_ntop (AF_INET6, (struct in6_addr*)(src->prefix.ip6.as_u8), dst, (socklen_t)len); if (!rc) { @@ -489,8 +164,7 @@ hicn_name_ntop (const hicn_name_t * src, char *dst, size_t len) offset = (int) strlen (dst); dst[offset] = '|'; - sprintf (dst + offset + 1, "%lu", (unsigned long) (*(u32 *) seg_number)); - + sprintf (dst + offset + 1, "%lu", (unsigned long) src->suffix); return HICN_LIB_ERROR_NONE; ERR: @@ -506,19 +180,8 @@ hicn_name_pton (const char *src, hicn_name_t * dst) int hicn_name_get_family (const hicn_name_t * name, int *family) { - switch (name->type) - { - case HNT_CONTIGUOUS_V6: - case HNT_IOV_V6: - *family = AF_INET6; - break; - case HNT_CONTIGUOUS_V4: - case HNT_IOV_V4: - *family = AF_INET; - break; - default: - return HICN_LIB_ERROR_UNEXPECTED; - } + u8 is_ip4 = hicn_name_is_ip4 (name); + *family = AF_INET * is_ip4 + (1 - is_ip4) * AF_INET6; return HICN_LIB_ERROR_NONE; } @@ -539,12 +202,32 @@ hicn_prefix_create_from_ip_prefix (const ip_prefix_t * ip_prefix, default: return HICN_LIB_ERROR_INVALID_IP_ADDRESS; } + prefix->len = (u8) (ip_prefix->len); return HICN_LIB_ERROR_NONE; } -#endif /* ! HICN_VPP_PLUGIN */ +int +hicn_name_create_from_ip_prefix (const ip_prefix_t * prefix, u32 id, + hicn_name_t * name) +{ + int i; + + for (i = 0; i < 2; i++) + name->prefix.ip6.as_u64[i] = prefix->address.v6.as_u64[i]; + name->suffix = id; + + return HICN_LIB_ERROR_NONE; +} + +int +hicn_name_compare (const hicn_name_t * name_1, const hicn_name_t * name_2, + bool consider_segment) +{ + size_t size = (u8)consider_segment * sizeof(hicn_name_suffix_t) + IPV6_ADDR_LEN; + return memcmp (name_1, name_2, size); +} /* diff --git a/lib/src/protocol/ipv4.c b/lib/src/protocol/ipv4.c index 781907231..5ad4ddbfa 100644 --- a/lib/src/protocol/ipv4.c +++ b/lib/src/protocol/ipv4.c @@ -78,20 +78,16 @@ int ipv4_get_interest_name (hicn_type_t type, const hicn_protocol_t * h, hicn_name_t * name) { - name->ip4.prefix_as_ip4 = h->ipv4.daddr; -#ifndef HICN_VPP_PLUGIN - name->type = HNT_CONTIGUOUS_V4; - name->len = HICN_V4_NAME_LEN; -#endif /* HICN_VPP_PLUGIN */ - return CHILD_OPS (get_interest_name_suffix, type, h, &(name->ip4.suffix)); + name->prefix.ip4.as_u32 = h->ipv4.daddr.as_u32; + return CHILD_OPS (get_interest_name_suffix, type, h, &(name->suffix)); } int ipv4_set_interest_name (hicn_type_t type, hicn_protocol_t * h, const hicn_name_t * name) { - h->ipv4.daddr = name->ip4.prefix_as_ip4; - return CHILD_OPS (set_interest_name_suffix, type, h, &(name->ip4.suffix)); + h->ipv4.daddr.as_u32 = name->prefix.ip4.as_u32; + return CHILD_OPS (set_interest_name_suffix, type, h, &(name->suffix)); } int @@ -149,20 +145,16 @@ int ipv4_get_data_name (hicn_type_t type, const hicn_protocol_t * h, hicn_name_t * name) { - name->ip4.prefix_as_ip4 = h->ipv4.saddr; -#ifndef HICN_VPP_PLUGIN - name->type = HNT_CONTIGUOUS_V4; - name->len = HICN_V4_NAME_LEN; -#endif /* HICN_VPP_PLUGIN */ - return CHILD_OPS (get_data_name_suffix, type, h, &(name->ip4.suffix)); + name->prefix.ip4.as_u32 = h->ipv4.saddr.as_u32; + return CHILD_OPS (get_data_name_suffix, type, h, &(name->suffix)); } int ipv4_set_data_name (hicn_type_t type, hicn_protocol_t * h, const hicn_name_t * name) { - h->ipv4.saddr = name->ip4.prefix_as_ip4; - return CHILD_OPS (set_data_name_suffix, type, h, &(name->ip4.suffix)); + h->ipv4.saddr.as_u32 = name->prefix.ip4.as_u32; + return CHILD_OPS (set_data_name_suffix, type, h, &(name->suffix)); } int diff --git a/lib/src/protocol/ipv6.c b/lib/src/protocol/ipv6.c index f23b01cd8..9db3e3a17 100644 --- a/lib/src/protocol/ipv6.c +++ b/lib/src/protocol/ipv6.c @@ -68,20 +68,16 @@ int ipv6_get_interest_name (hicn_type_t type, const hicn_protocol_t * h, hicn_name_t * name) { - name->ip6.prefix_as_ip6 = h->ipv6.daddr; -#ifndef HICN_VPP_PLUGIN - name->type = HNT_CONTIGUOUS_V6; - name->len = HICN_V6_NAME_LEN; -#endif /* HICN_VPP_PLUGIN */ - return CHILD_OPS (get_interest_name_suffix, type, h, &(name->ip6.suffix)); + name->prefix.ip6 = h->ipv6.daddr; + return CHILD_OPS (get_interest_name_suffix, type, h, &(name->suffix)); } int ipv6_set_interest_name (hicn_type_t type, hicn_protocol_t * h, const hicn_name_t * name) { - h->ipv6.daddr = name->ip6.prefix_as_ip6; - return CHILD_OPS (set_interest_name_suffix, type, h, &(name->ip6.suffix)); + h->ipv6.daddr = name->prefix.ip6; + return CHILD_OPS (set_interest_name_suffix, type, h, &(name->suffix)); } int @@ -139,20 +135,16 @@ int ipv6_get_data_name (hicn_type_t type, const hicn_protocol_t * h, hicn_name_t * name) { - name->ip6.prefix_as_ip6 = h->ipv6.saddr; -#ifndef HICN_VPP_PLUGIN - name->type = HNT_CONTIGUOUS_V6; - name->len = HICN_V6_NAME_LEN; -#endif /* HICN_VPP_PLUGIN */ - return CHILD_OPS (get_data_name_suffix, type, h, &(name->ip6.suffix)); + name->prefix.ip6 = h->ipv6.saddr; + return CHILD_OPS (get_data_name_suffix, type, h, &(name->suffix)); } int ipv6_set_data_name (hicn_type_t type, hicn_protocol_t * h, const hicn_name_t * name) { - h->ipv6.saddr = name->ip6.prefix_as_ip6; - return CHILD_OPS (set_data_name_suffix, type, h, &(name->ip6.suffix)); + h->ipv6.saddr = name->prefix.ip6; + return CHILD_OPS (set_data_name_suffix, type, h, &(name->suffix)); } int |