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] batman-adv: pass the WIFI flag from the local to global entry
@ 2012-07-29 23:15 Antonio Quartulli
  2012-07-30  7:59 ` Marek Lindner
  2012-07-31 12:14 ` [B.A.T.M.A.N.] [PATCHv2] " Antonio Quartulli
  0 siblings, 2 replies; 11+ messages in thread
From: Antonio Quartulli @ 2012-07-29 23:15 UTC (permalink / raw)
  To: b.a.t.m.a.n

in case of client roaming a new global entry is added while a corresponding
local one is still present. In this case the node can safely pass the WIFI flag
from the local to the global entry

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 translation-table.c |   36 ++++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/translation-table.c b/translation-table.c
index 37ae4a9..2aacde9 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -500,21 +500,30 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
 		   tt_local_entry->common.addr, message);
 }
 
+static void __batadv_tt_local_remove(struct batadv_priv *bat_priv,
+				     struct batadv_tt_local_entry *tt_local,
+				     const char *message, bool roaming)
+{
+	uint16_t flags;
+
+	flags = BATADV_TT_CLIENT_DEL;
+	if (roaming)
+		flags |= BATADV_TT_CLIENT_ROAM;
+
+	batadv_tt_local_set_pending(bat_priv, tt_local, flags, message);
+}
+
 void batadv_tt_local_remove(struct batadv_priv *bat_priv, const uint8_t *addr,
 			    const char *message, bool roaming)
 {
 	struct batadv_tt_local_entry *tt_local_entry = NULL;
-	uint16_t flags;
 
 	tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr);
 	if (!tt_local_entry)
 		goto out;
 
-	flags = BATADV_TT_CLIENT_DEL;
-	if (roaming)
-		flags |= BATADV_TT_CLIENT_ROAM;
+	__batadv_tt_local_remove(bat_priv, tt_local_entry, message, roaming);
 
-	batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags, message);
 out:
 	if (tt_local_entry)
 		batadv_tt_local_entry_free_ref(tt_local_entry);
@@ -721,9 +730,11 @@ int batadv_tt_global_add(struct batadv_priv *bat_priv,
 			 uint8_t ttvn)
 {
 	struct batadv_tt_global_entry *tt_global_entry = NULL;
+	struct batadv_tt_local_entry *tt_local_entry = NULL;
 	int ret = 0;
 	int hash_added;
 	struct batadv_tt_common_entry *common;
+	uint16_t wifi_flag;
 
 	tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr);
 
@@ -789,14 +800,23 @@ int batadv_tt_global_add(struct batadv_priv *bat_priv,
 		   tt_global_entry->common.addr, orig_node->orig);
 
 out_remove:
+	tt_local_entry = batadv_tt_local_hash_find(bat_priv, tt_addr);
+	if (!tt_local_entry)
+		goto out;
+
+	wifi_flag = tt_local_entry->common.flags & BATADV_TT_CLIENT_WIFI;
+	tt_global_entry->common.flags |= wifi_flag;
+
 	/* remove address from local hash if present */
-	batadv_tt_local_remove(bat_priv, tt_global_entry->common.addr,
-			       "global tt received",
-			       flags & BATADV_TT_CLIENT_ROAM);
+	__batadv_tt_local_remove(bat_priv, tt_local_entry, "global tt received",
+				 flags & BATADV_TT_CLIENT_ROAM);
+
 	ret = 1;
 out:
 	if (tt_global_entry)
 		batadv_tt_global_entry_free_ref(tt_global_entry);
+	if (tt_local_entry)
+		batadv_tt_local_entry_free_ref(tt_local_entry);
 	return ret;
 }
 
-- 
1.7.9.4


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

end of thread, other threads:[~2012-08-22  0:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-29 23:15 [B.A.T.M.A.N.] [PATCH] batman-adv: pass the WIFI flag from the local to global entry Antonio Quartulli
2012-07-30  7:59 ` Marek Lindner
2012-07-30  9:23   ` Antonio Quartulli
2012-07-30  9:47     ` Marek Lindner
2012-07-30 10:07       ` Antonio Quartulli
2012-07-30 10:12         ` Marek Lindner
2012-07-30 10:16           ` Antonio Quartulli
2012-07-31 12:14 ` [B.A.T.M.A.N.] [PATCHv2] " Antonio Quartulli
2012-08-10 22:43   ` [B.A.T.M.A.N.] [PATCH v3] " Antonio Quartulli
2012-08-22  0:03     ` Marek Lindner
2012-08-22  0:07       ` Antonio Quartulli

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