diff options
Diffstat (limited to 'lib/prefix.c')
| -rw-r--r-- | lib/prefix.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/prefix.c b/lib/prefix.c index 0ba0025c68..47e16dbf8b 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -26,6 +26,7 @@ #include "sockunion.h" #include "memory.h" #include "log.h" +#include "jhash.h" DEFINE_MTYPE_STATIC(LIB, PREFIX, "Prefix") @@ -1335,3 +1336,15 @@ char *prefix_mac2str(const struct ethaddr *mac, char *buf, int size) (uint8_t)mac->octet[4], (uint8_t)mac->octet[5]); return ptr; } + +unsigned prefix_hash_key(void *pp) +{ + struct prefix copy; + + /* make sure *all* unused bits are zero, particularly including + * alignment / + * padding and unused prefix bytes. */ + memset(©, 0, sizeof(copy)); + prefix_copy(©, (struct prefix *)pp); + return jhash(©, sizeof(copy), 0x55aa5a5a); +} |
