public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Mihail <mihail.costea2005@gmail.com>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [RFC 2/4] batman-adv: added IPv6 to DAT and generic functions in distributed-arp-table.c
Date: Fri, 17 May 2013 15:27:50 +0300	[thread overview]
Message-ID: <1368793673-27539-2-git-send-email-mihail.costea2005@gmail.com> (raw)
In-Reply-To: <1368793673-27539-1-git-send-email-mihail.costea2005@gmail.com>

From: "mihail.costea90@gmail.com" <mihail.costea90@gmail.com>

Added IPv6 functionality to generic functions implemented in the first
patch.

Signed-off-by: Mihail Costea <mihail.costea90@gmail.com>
Signed-off-by: Stefan Popa <Stefan.A.Popa@intel.com>
Reviewed-by: Stefan Popa <Stefan.A.Popa@intel.com>

---
 distributed-arp-table.c |   30 ++++++++++++++++++++++++++----
 types.h                 |    6 +++++-
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/distributed-arp-table.c b/distributed-arp-table.c
index b2ca7e0..42118be 100644
--- a/distributed-arp-table.c
+++ b/distributed-arp-table.c
@@ -32,7 +32,7 @@
 #include "unicast.h"
 
 static char *batadv_dat_types_str_fmt[] = {
-	"%pI4",
+	"%pI4", "%pI6c",
 };
 
 static void batadv_dat_purge(struct work_struct *work);
@@ -173,6 +173,10 @@ static size_t batadv_sizeof_dat_data(uint8_t data_type)
 	switch (data_type) {
 	case BATADV_DAT_IPV4:
 		return sizeof(__be32);
+#if IS_ENABLED(CONFIG_IPV6)
+	case BATADV_DAT_IPV6:
+		return sizeof(struct in6_addr);
+#endif
 	default:
 		return 0;
 	}
@@ -295,6 +299,12 @@ static uint32_t batadv_hash_dat_ipv4(const void *data, uint32_t size)
 	return batadv_hash_dat(data, BATADV_DAT_IPV4, size);
 }
 
+#if IS_ENABLED(CONFIG_IPV6)
+static uint32_t batadv_hash_dat_ipv6(const void *data, uint32_t size)
+{
+	return batadv_hash_dat(data, BATADV_DAT_IPV6, size);
+}
+#endif
 
 /**
  * batadv_dat_entry_hash_find - look for a given dat_entry in the local hash
@@ -393,6 +403,11 @@ static void batadv_dat_entry_add(struct batadv_priv *bat_priv, void *data,
 	case BATADV_DAT_IPV4:
 		choose = batadv_hash_dat_ipv4;
 		break;
+#if IS_ENABLED(CONFIG_IPV6)
+	case BATADV_DAT_IPV6:
+		choose = batadv_hash_dat_ipv6;
+		break;
+#endif
 	default:
 		goto out;
 	}
@@ -872,8 +887,8 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset)
 		goto out;
 
 	seq_printf(seq, "Distributed ARP Table (%s):\n", net_dev->name);
-	seq_printf(seq, "          %-7s          %-13s %5s\n", "IPv4", "MAC",
-		   "last-seen");
+	seq_printf(seq, "                       %-26s %-15s %5s\n",
+		   "IPv4/IPv6", "MAC", "last-seen");
 
 	for (i = 0; i < hash->size; i++) {
 		head = &hash->table[i];
@@ -888,10 +903,17 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset)
 
 			switch (dat_entry->type) {
 			case BATADV_DAT_IPV4:
-				seq_printf(seq, " * %15pI4 %14pM %6i:%02i\n",
+				seq_printf(seq, " * %-40pI4 %15pM %6i:%02i\n",
 					   dat_entry->data, dat_entry->mac_addr,
 					   last_seen_mins, last_seen_secs);
 				break;
+#if IS_ENABLED(CONFIG_IPV6)
+			case BATADV_DAT_IPV6:
+				seq_printf(seq, " * %-40pI6c %15pM %6i:%02i\n",
+					   dat_entry->data, dat_entry->mac_addr,
+					   last_seen_mins, last_seen_secs);
+				break;
+#endif
 			}
 		}
 		rcu_read_unlock();
diff --git a/types.h b/types.h
index 284e3d2..74c7091 100644
--- a/types.h
+++ b/types.h
@@ -931,10 +931,14 @@ struct batadv_dat_entry {
 
 /**
  * batadv_dat_types - types used in batadv_dat_entry for IP
- * @BATADV_DAT_IPv4: IPv4 address type
+ * @BATADV_DAT_IPV4: IPv4 address type
+ * @BATADV_DAT_IPV4: IPv6 address type
  */
 enum batadv_dat_types {
 	BATADV_DAT_IPV4 = 0,
+#if IS_ENABLED(CONFIG_IPV6)
+	BATADV_DAT_IPV6 = 1,
+#endif
 };
 
 /**
-- 
1.7.10.4


  reply	other threads:[~2013-05-17 12:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-17 12:27 [B.A.T.M.A.N.] [RFC 1/4] batman-adv: renamed batadv_dat_snoop_*_arp_* functions to batadv_dat_snoop_*_msg_* Mihail
2013-05-17 12:27 ` Mihail [this message]
2013-05-26 13:57   ` [B.A.T.M.A.N.] [RFC 2/4] batman-adv: added IPv6 to DAT and generic functions in distributed-arp-table.c Antonio Quartulli
2013-05-29 15:16     ` Mihail Costea
2013-05-29 15:32       ` Antonio Quartulli
2013-05-29 15:21     ` Mihail Costea
2013-05-29 15:33       ` Antonio Quartulli
2013-05-29 16:12         ` Mihail Costea
2013-05-29 16:13           ` Antonio Quartulli
2013-05-17 12:27 ` [B.A.T.M.A.N.] [RFC 3/4] batman-adv: added necessary functions for NDP, like checking if a packet is valid or creating a Neighbor Advertisement Mihail
2013-05-26 14:02   ` Antonio Quartulli
2013-05-29 15:36     ` Mihail Costea
2013-05-29 15:43       ` Antonio Quartulli
2013-05-30  2:19         ` Mihail Costea
2013-05-17 12:27 ` [B.A.T.M.A.N.] [RFC 4/4] batman-adv: generalize snooping mechanism in order to suport NDP too Mihail
2013-05-17 12:33 ` [B.A.T.M.A.N.] [RFC 1/4] batman-adv: renamed batadv_dat_snoop_*_arp_* functions to batadv_dat_snoop_*_msg_* Mihail Costea
2013-05-26 13:59 ` Antonio Quartulli
2013-05-29 14:54   ` Mihail Costea
2013-06-24  7:57     ` Antonio Quartulli
2013-06-25  3:42       ` Mihail Costea

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1368793673-27539-2-git-send-email-mihail.costea2005@gmail.com \
    --to=mihail.costea2005@gmail.com \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox