public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH 1/8] batman-adv: Move hash_ipv4 to distributed-arp-table.c
@ 2012-05-12 11:48 Sven Eckelmann
  2012-05-12 11:48 ` [B.A.T.M.A.N.] [PATCH 2/8] batman-adv: Prefix bitarray static inline functions with batadv_ Sven Eckelmann
                   ` (8 more replies)
  0 siblings, 9 replies; 19+ messages in thread
From: Sven Eckelmann @ 2012-05-12 11:48 UTC (permalink / raw)
  To: b.a.t.m.a.n

hash_ipv4 is only used in distributed-arp-table.c and therefore can be placed
inside this file instead of the header.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 distributed-arp-table.c |   24 +++++++++++++++++++++++-
 distributed-arp-table.h |   22 ----------------------
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/distributed-arp-table.c b/distributed-arp-table.c
index e678ec4..4894a85 100644
--- a/distributed-arp-table.c
+++ b/distributed-arp-table.c
@@ -32,6 +32,28 @@
 #include "translation-table.h"
 #include "unicast.h"
 
+/* hash function to choose an entry in a hash table of given size.
+ * hash algorithm from http://en.wikipedia.org/wiki/Hash_table
+ */
+static uint32_t batadv_hash_ipv4(const void *data, uint32_t size)
+{
+	const unsigned char *key = data;
+	uint32_t hash = 0;
+	size_t i;
+
+	for (i = 0; i < 4; i++) {
+		hash += key[i];
+		hash += (hash << 10);
+		hash ^= (hash >> 6);
+	}
+
+	hash += (hash << 3);
+	hash ^= (hash >> 11);
+	hash += (hash << 15);
+
+	return hash % size;
+}
+
 #ifdef CONFIG_BATMAN_ADV_DEBUG
 
 static void bat_dbg_arp(struct bat_priv *bat_priv, struct sk_buff *skb,
@@ -214,7 +236,7 @@ static struct dht_candidate *dht_select_candidates(struct bat_priv *bat_priv,
 	if (!res)
 		return NULL;
 
-	ip_key = (dat_addr_t)hash_ipv4(&ip_dst, DAT_ADDR_MAX);
+	ip_key = (dat_addr_t)batadv_hash_ipv4(&ip_dst, DAT_ADDR_MAX);
 
 	bat_dbg(DBG_DAT, bat_priv,
 		"dht_select_candidates(): IP=%pI4 hash(IP)=%u\n", &ip_dst,
diff --git a/distributed-arp-table.h b/distributed-arp-table.h
index 1ba7f01..ee5200a 100644
--- a/distributed-arp-table.h
+++ b/distributed-arp-table.h
@@ -49,28 +49,6 @@ bool batadv_dat_drop_broadcast_packet(struct bat_priv *bat_priv,
 				      struct forw_packet *forw_packet);
 void batadv_arp_change_timeout(struct net_device *soft_iface, const char *name);
 
-/* hash function to choose an entry in a hash table of given size.
- * hash algorithm from http://en.wikipedia.org/wiki/Hash_table
- */
-static inline uint32_t hash_ipv4(const void *data, uint32_t size)
-{
-	const unsigned char *key = data;
-	uint32_t hash = 0;
-	size_t i;
-
-	for (i = 0; i < 4; i++) {
-		hash += key[i];
-		hash += (hash << 10);
-		hash ^= (hash >> 6);
-	}
-
-	hash += (hash << 3);
-	hash ^= (hash >> 11);
-	hash += (hash << 15);
-
-	return hash % size;
-}
-
 static inline void
 batadv_dat_init_orig_node_dht_addr(struct orig_node *orig_node)
 {
-- 
1.7.10


^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2012-05-15  8:44 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-12 11:48 [B.A.T.M.A.N.] [PATCH 1/8] batman-adv: Move hash_ipv4 to distributed-arp-table.c Sven Eckelmann
2012-05-12 11:48 ` [B.A.T.M.A.N.] [PATCH 2/8] batman-adv: Prefix bitarray static inline functions with batadv_ Sven Eckelmann
2012-05-15  8:16   ` Marek Lindner
2012-05-12 11:48 ` [B.A.T.M.A.N.] [PATCH 3/8] batman-adv: Prefix hard-interface " Sven Eckelmann
2012-05-15  8:19   ` Marek Lindner
2012-05-12 11:48 ` [B.A.T.M.A.N.] [PATCH 4/8] batman-adv: Prefix hash " Sven Eckelmann
2012-05-15  8:23   ` Marek Lindner
2012-05-12 11:48 ` [B.A.T.M.A.N.] [PATCH 5/8] batman-adv: Prefix originator " Sven Eckelmann
2012-05-15  8:31   ` Marek Lindner
2012-05-12 11:48 ` [B.A.T.M.A.N.] [PATCH 6/8] batman-adv: Prefix unicast " Sven Eckelmann
2012-05-15  8:34   ` Marek Lindner
2012-05-12 11:48 ` [B.A.T.M.A.N.] [PATCH 7/8] batman-adv: Prefix main " Sven Eckelmann
2012-05-15  8:43   ` Marek Lindner
2012-05-12 11:48 ` [B.A.T.M.A.N.] [PATCH 8/8] batman-adv: Prefix compat " Sven Eckelmann
2012-05-15  8:44   ` Marek Lindner
2012-05-12 11:56 ` [B.A.T.M.A.N.] [PATCH 1/8] batman-adv: Move hash_ipv4 to distributed-arp-table.c Antonio Quartulli
2012-05-12 12:01   ` Sven Eckelmann
2012-05-12 12:07     ` Antonio Quartulli
2012-05-15  8:14 ` Marek Lindner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox