diff options
Diffstat (limited to 'lib/src')
-rw-r--r-- | lib/src/compat.c | 28 | ||||
-rw-r--r-- | lib/src/name.c | 2 | ||||
-rw-r--r-- | lib/src/util/ip_address.c | 4 |
3 files changed, 15 insertions, 19 deletions
diff --git a/lib/src/compat.c b/lib/src/compat.c index 68f761ac0..8ec4c83e8 100644 --- a/lib/src/compat.c +++ b/lib/src/compat.c @@ -321,7 +321,7 @@ hicn_packet_get_payload (hicn_format_t format, const hicn_header_t * h, int hicn_packet_get_locator (hicn_format_t format, const hicn_header_t * h, - ip_prefix_t * prefix, bool is_interest) + ip_address_t * address, bool is_interest) { const void *locator; int is_ipv4 = (format & HFO_INET); @@ -330,28 +330,24 @@ hicn_packet_get_locator (hicn_format_t format, const hicn_header_t * h, if (is_ipv4) { locator = is_interest ? &h->v4.ip.saddr : &h->v4.ip.daddr; - prefix->family = AF_INET; - prefix->len = IPV4_ADDR_LEN_BITS; } else if (is_ipv6) { locator = is_interest ? &h->v6.ip.saddr : &h->v6.ip.daddr; - prefix->family = AF_INET6; - prefix->len = IPV6_ADDR_LEN_BITS; } else { return HICN_LIB_ERROR_NOT_IMPLEMENTED; } - memcpy (prefix->address.buffer, locator, ip_address_len(&prefix->address, prefix->family)); + memcpy (address->as_u8, locator, is_ipv4 ? IPV4_ADDR_LEN : IPV6_ADDR_LEN); return HICN_LIB_ERROR_NONE; } int hicn_packet_set_locator (hicn_format_t format, hicn_header_t * h, - const ip_prefix_t * prefix, bool is_interest) + const ip_address_t * address, bool is_interest) { void *locator; int is_ipv4 = (format & HFO_INET); @@ -370,7 +366,7 @@ hicn_packet_set_locator (hicn_format_t format, hicn_header_t * h, return HICN_LIB_ERROR_INVALID_PARAMETER; } - memcpy (locator, prefix->address.buffer, ip_address_len(&prefix->address, prefix->family)); + memcpy (locator, address->as_u8, is_ipv4 ? IPV4_ADDR_LEN : IPV6_ADDR_LEN); return HICN_LIB_ERROR_NONE; } @@ -953,16 +949,16 @@ hicn_interest_set_name (hicn_format_t format, hicn_header_t * interest, int hicn_interest_get_locator (hicn_format_t format, const hicn_header_t * interest, - ip_prefix_t * prefix) + ip_address_t * address) { - return hicn_packet_get_locator (format, interest, prefix, _INTEREST); + return hicn_packet_get_locator (format, interest, address, _INTEREST); } int hicn_interest_set_locator (hicn_format_t format, hicn_header_t * interest, - const ip_prefix_t * prefix) + const ip_address_t * address) { - return hicn_packet_set_locator (format, interest, prefix, _INTEREST); + return hicn_packet_set_locator (format, interest, address, _INTEREST); } int @@ -1045,16 +1041,16 @@ hicn_data_set_name (hicn_format_t format, hicn_header_t * data, int hicn_data_get_locator (hicn_format_t format, const hicn_header_t * data, - ip_prefix_t * prefix) + ip_address_t * address) { - return hicn_packet_get_locator (format, data, prefix, _DATA); + return hicn_packet_get_locator (format, data, address, _DATA); } int hicn_data_set_locator (hicn_format_t format, hicn_header_t * data, - const ip_prefix_t * prefix) + const ip_address_t * address) { - return hicn_packet_set_locator (format, data, prefix, _DATA); + return hicn_packet_set_locator (format, data, address, _DATA); } int diff --git a/lib/src/name.c b/lib/src/name.c index d5ee1d520..2e98a3532 100644 --- a/lib/src/name.c +++ b/lib/src/name.c @@ -96,7 +96,7 @@ hicn_name_create_from_ip_prefix (const ip_prefix_t * prefix, u32 id, } memcpy (name->buffer, prefix->address.buffer, - ip_address_len(&prefix->address, prefix->family)); + ip_address_len(prefix->family)); *(u32 *) (name->buffer + name->len) = id; return HICN_LIB_ERROR_NONE; diff --git a/lib/src/util/ip_address.c b/lib/src/util/ip_address.c index c54b1fae6..d4fbcaae6 100644 --- a/lib/src/util/ip_address.c +++ b/lib/src/util/ip_address.c @@ -77,7 +77,7 @@ ip_address_get_family (const char * ip_address) } int -ip_address_len (const ip_address_t * ip_address, int family) +ip_address_len (int family) { return (family == AF_INET6) ? IPV6_ADDR_LEN : (family == AF_INET) ? IPV4_ADDR_LEN : 0; @@ -165,7 +165,7 @@ ip_address_to_sockaddr(const ip_address_t * ip_address, int ip_address_cmp(const ip_address_t * ip1, const ip_address_t * ip2, int family) { - return memcmp(ip1, ip2, ip_address_len(ip1, family)); + return memcmp(ip1, ip2, ip_address_len(family)); } int |