]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: move prefix hash key to prefix.c to allow global use
authorChristian Franke <chris@opensourcerouting.org>
Thu, 3 Aug 2017 11:37:38 +0000 (13:37 +0200)
committerChristian Franke <chris@opensourcerouting.org>
Thu, 3 Aug 2017 11:37:58 +0000 (13:37 +0200)
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
lib/prefix.c
lib/prefix.h
lib/table.c

index 0ba0025c6826e728687e50e760ae3bbb3d30bf17..47e16dbf8b23470589d8a37d25b74fe89e1089c3 100644 (file)
@@ -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(&copy, 0, sizeof(copy));
+       prefix_copy(&copy, (struct prefix *)pp);
+       return jhash(&copy, sizeof(copy), 0x55aa5a5a);
+}
index ce13dcfa0a71a1f9c4f055502d47780eb526ac78..4f1f0b22d78dc8eef33eff37baa8b5e58e084de8 100644 (file)
@@ -323,6 +323,8 @@ extern const char *inet6_ntoa(struct in6_addr);
 extern int prefix_str2mac(const char *str, struct ethaddr *mac);
 extern char *prefix_mac2str(const struct ethaddr *mac, char *buf, int size);
 
+extern unsigned prefix_hash_key(void *pp);
+
 static inline int ipv6_martian(struct in6_addr *addr)
 {
        struct in6_addr localhost_addr;
index 2defa4fb62e9bc27d993c5fb1b6f7439566a1a17..e89d7d1c67e2ce038db7cd10631d2986579f34aa 100644 (file)
@@ -27,7 +27,6 @@
 #include "table.h"
 #include "memory.h"
 #include "sockunion.h"
-#include "jhash.h"
 
 DEFINE_MTYPE(LIB, ROUTE_TABLE, "Route table")
 DEFINE_MTYPE(LIB, ROUTE_NODE, "Route node")
@@ -35,18 +34,6 @@ DEFINE_MTYPE(LIB, ROUTE_NODE, "Route node")
 static void route_node_delete(struct route_node *);
 static void route_table_free(struct route_table *);
 
-static unsigned route_table_hash_key(void *pp)
-{
-       struct prefix copy;
-
-       /* make sure *all* unused bits are zero, particularly including
-        * alignment /
-        * padding and unused prefix bytes. */
-       memset(&copy, 0, sizeof(copy));
-       prefix_copy(&copy, (struct prefix *)pp);
-       return jhash(&copy, sizeof(copy), 0x55aa5a5a);
-}
-
 static int route_table_hash_cmp(const void *a, const void *b)
 {
        const struct prefix *pa = a, *pb = b;
@@ -63,7 +50,7 @@ route_table_init_with_delegate(route_table_delegate_t *delegate)
 
        rt = XCALLOC(MTYPE_ROUTE_TABLE, sizeof(struct route_table));
        rt->delegate = delegate;
-       rt->hash = hash_create(route_table_hash_key, route_table_hash_cmp,
+       rt->hash = hash_create(prefix_hash_key, route_table_hash_cmp,
                               "route table hash");
        return rt;
 }