aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src/name.c
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2020-02-21 17:30:49 +0000
committerGerrit Code Review <gerrit@fd.io>2020-02-21 17:30:49 +0000
commite1135db42f05a94c6790c8650a3ac20396e0d78c (patch)
tree65b48490ced07f11597aedc2b752381b0d9e4b30 /lib/src/name.c
parent1b9512282a5324b2bd2b28b8e5555e15676cb54c (diff)
parent35058cdfe0134c88f1aa8d23342d1d7b9d39e296 (diff)
Merge "[HICN-2] Added P2P confidential communication on hICN"
Diffstat (limited to 'lib/src/name.c')
-rw-r--r--lib/src/name.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/src/name.c b/lib/src/name.c
index 7c1f7582a..9388c35e7 100644
--- a/lib/src/name.c
+++ b/lib/src/name.c
@@ -212,23 +212,25 @@ hicn_name_compare (const hicn_name_t * name_1, const hicn_name_t * name_2,
}
int
-hicn_name_hash (const hicn_name_t * name, u32 * hash)
+hicn_name_hash (const hicn_name_t * name, u32 * hash, bool consider_suffix)
{
switch (name->type)
{
case HNT_CONTIGUOUS_V4:
- *hash = hash32 (name->buffer, HICN_V4_NAME_LEN);
+ *hash = hash32 (name->buffer, consider_suffix ? HICN_V4_NAME_LEN : HICN_V4_PREFIX_LEN);
break;
case HNT_CONTIGUOUS_V6:
- *hash = hash32 (name->buffer, HICN_V6_NAME_LEN);
+ *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);
- *hash =
- cumulative_hash32 (name->iov.buffers[1].iov_base,
- name->iov.buffers[1].iov_len, *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;