aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src/util/ip_address.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src/util/ip_address.c')
-rw-r--r--lib/src/util/ip_address.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/src/util/ip_address.c b/lib/src/util/ip_address.c
index ba7c6475b..3624a6fca 100644
--- a/lib/src/util/ip_address.c
+++ b/lib/src/util/ip_address.c
@@ -164,7 +164,7 @@ hicn_ip_address_pton (const char *hicn_ip_address_str,
if (pton_fd <= 0)
return -1;
- return 1;
+ return 0;
}
int
@@ -292,7 +292,7 @@ hicn_ip_prefix_pton (const char *hicn_ip_address_str,
goto ERR;
free (addr);
- return 1;
+ return 0;
ERR:
free (addr);
return -1;
@@ -409,11 +409,12 @@ hicn_ip_prefix_cmp (const hicn_ip_prefix_t *prefix1,
return hicn_ip_address_cmp (&prefix1->address, &prefix2->address);
}
+/* Network byte order + host bit order */
+
uint8_t
hicn_ip_address_get_bit (const hicn_ip_address_t *address, uint8_t pos)
{
- u64 quad = address->v6.as_u64[pos / 64];
- return quad & (0x1 << pos % 64);
+ return (address->v6.as_u8[pos / 8] >> (7 - pos % 8)) & 0x1;
}
bool