b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH] batman-adv: clean up the tt_query flags field
@ 2011-06-13 17:38 Antonio Quartulli
  2011-06-13 20:46 ` Sven Eckelmann
  2011-06-13 20:51 ` [B.A.T.M.A.N.] [PATCHv2] " Sven Eckelmann
  0 siblings, 2 replies; 4+ messages in thread
From: Antonio Quartulli @ 2011-06-13 17:38 UTC (permalink / raw)
  To: B.A.T.M.A.N

The tt_query subtype is represented by the two leading bits (lsb) of
the tt_query->flags field. Therefore it cannot be handled by simple
"flags" but by two bits wide integer. The TT_QUERY_TYPE_MASK is used to
extract the relevant bits that can be compared to the related enum
values (TT_RESPONSE, TT_REQUEST)

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 packet.h  |   10 ++++++++--
 routing.c |   30 ++++++++++++++++--------------
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/packet.h b/packet.h
index ef7476f..c5f081d 100644
--- a/packet.h
+++ b/packet.h
@@ -65,10 +65,16 @@ enum unicast_frag_flags {
 	UNI_FRAG_LARGETAIL = 1 << 1
 };
 
+/* TT_QUERY subtypes */
+#define TT_QUERY_TYPE_MASK 0x3
+
+enum tt_query_packettype {
+	TT_REQUEST    = 0,
+	TT_RESPONSE   = 1
+};
+
 /* TT_QUERY flags */
 enum tt_query_flags {
-	TT_RESPONSE   = 1 << 0,
-	TT_REQUEST    = 1 << 1,
 	TT_FULL_TABLE = 1 << 2
 };
 
diff --git a/routing.c b/routing.c
index 7f458e9..027e988 100644
--- a/routing.c
+++ b/routing.c
@@ -1218,7 +1218,8 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
 
 	tt_query->tt_data = ntohs(tt_query->tt_data);
 
-	if (tt_query->flags & TT_REQUEST) {
+	switch (tt_query->flags & TT_QUERY_TYPE_MASK) {
+	case TT_REQUEST:
 		/* If we cannot provide an answer the tt_request is
 		 * forwarded */
 		if (!send_tt_response(bat_priv, tt_query)) {
@@ -1229,22 +1230,23 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
 			tt_query->tt_data = htons(tt_query->tt_data);
 			return route_unicast_packet(skb, recv_if);
 		}
-		ret = NET_RX_SUCCESS;
-		goto out;
-	}
-	/* packet needs to be linearised to access the TT changes records */
-	if (skb_linearize(skb) < 0)
-		goto out;
+		break;
+	case TT_RESPONSE:
+		/* packet needs to be linearised to access the TT changes records */
+		if (skb_linearize(skb) < 0)
+			goto out;
 
-	if (is_my_mac(tt_query->dst))
-		handle_tt_response(bat_priv, tt_query);
-	else {
-		bat_dbg(DBG_TT, bat_priv,
+		if (is_my_mac(tt_query->dst))
+			handle_tt_response(bat_priv, tt_query);
+		else {
+			bat_dbg(DBG_TT, bat_priv,
 			"Routing TT_RESPONSE to %pM [%c]\n",
 			tt_query->dst,
 			(tt_query->flags & TT_FULL_TABLE ? 'F' : '.'));
-		tt_query->tt_data = htons(tt_query->tt_data);
-		return route_unicast_packet(skb, recv_if);
+			tt_query->tt_data = htons(tt_query->tt_data);
+			return route_unicast_packet(skb, recv_if);
+		}
+		break;
 	}
 	ret = NET_RX_SUCCESS;
 
-- 
1.7.3.4


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

* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: clean up the tt_query flags field
  2011-06-13 17:38 [B.A.T.M.A.N.] [PATCH] batman-adv: clean up the tt_query flags field Antonio Quartulli
@ 2011-06-13 20:46 ` Sven Eckelmann
  2011-06-13 20:51 ` [B.A.T.M.A.N.] [PATCHv2] " Sven Eckelmann
  1 sibling, 0 replies; 4+ messages in thread
From: Sven Eckelmann @ 2011-06-13 20:46 UTC (permalink / raw)
  To: b.a.t.m.a.n

[-- Attachment #1: Type: Text/Plain, Size: 459 bytes --]

>  			"Routing TT_RESPONSE to %pM [%c]\n",
>  			tt_query->dst,
>  			(tt_query->flags & TT_FULL_TABLE ? 'F' : '.'));
> -		tt_query->tt_data = htons(tt_query->tt_data);
> -		return route_unicast_packet(skb, recv_if);
> +			tt_query->tt_data = htons(tt_query->tt_data);
> +			return route_unicast_packet(skb, recv_if);

Could you indent everything (except the return) with one more tab?

The rest:

Acked-by; Sven Eckelmann <sven@narfation.org>

Thanks,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [B.A.T.M.A.N.] [PATCHv2] batman-adv: clean up the tt_query flags field
  2011-06-13 17:38 [B.A.T.M.A.N.] [PATCH] batman-adv: clean up the tt_query flags field Antonio Quartulli
  2011-06-13 20:46 ` Sven Eckelmann
@ 2011-06-13 20:51 ` Sven Eckelmann
  2011-06-14 12:59   ` Marek Lindner
  1 sibling, 1 reply; 4+ messages in thread
From: Sven Eckelmann @ 2011-06-13 20:51 UTC (permalink / raw)
  To: b.a.t.m.a.n

From: Antonio Quartulli <ordex@autistici.org>

The tt_query subtype is represented by the two leading bits (lsb) of
the tt_query->flags field. Therefore it cannot be handled by simple
"flags" but by two bits wide integer. The TT_QUERY_TYPE_MASK is used to
extract the relevant bits that can be compared to the related enum
values (TT_RESPONSE, TT_REQUEST)

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 * Just added three missing tabs as mentioned in the last mail.

 packet.h  |   10 ++++++++--
 routing.c |   34 ++++++++++++++++++----------------
 2 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/packet.h b/packet.h
index ef7476f..c5f081d 100644
--- a/packet.h
+++ b/packet.h
@@ -65,10 +65,16 @@ enum unicast_frag_flags {
 	UNI_FRAG_LARGETAIL = 1 << 1
 };
 
+/* TT_QUERY subtypes */
+#define TT_QUERY_TYPE_MASK 0x3
+
+enum tt_query_packettype {
+	TT_REQUEST    = 0,
+	TT_RESPONSE   = 1
+};
+
 /* TT_QUERY flags */
 enum tt_query_flags {
-	TT_RESPONSE   = 1 << 0,
-	TT_REQUEST    = 1 << 1,
 	TT_FULL_TABLE = 1 << 2
 };
 
diff --git a/routing.c b/routing.c
index 7f458e9..3a3cfb8 100644
--- a/routing.c
+++ b/routing.c
@@ -1218,7 +1218,8 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
 
 	tt_query->tt_data = ntohs(tt_query->tt_data);
 
-	if (tt_query->flags & TT_REQUEST) {
+	switch (tt_query->flags & TT_QUERY_TYPE_MASK) {
+	case TT_REQUEST:
 		/* If we cannot provide an answer the tt_request is
 		 * forwarded */
 		if (!send_tt_response(bat_priv, tt_query)) {
@@ -1229,22 +1230,23 @@ int recv_tt_query(struct sk_buff *skb, struct hard_iface *recv_if)
 			tt_query->tt_data = htons(tt_query->tt_data);
 			return route_unicast_packet(skb, recv_if);
 		}
-		ret = NET_RX_SUCCESS;
-		goto out;
-	}
-	/* packet needs to be linearised to access the TT changes records */
-	if (skb_linearize(skb) < 0)
-		goto out;
+		break;
+	case TT_RESPONSE:
+		/* packet needs to be linearised to access the TT changes records */
+		if (skb_linearize(skb) < 0)
+			goto out;
 
-	if (is_my_mac(tt_query->dst))
-		handle_tt_response(bat_priv, tt_query);
-	else {
-		bat_dbg(DBG_TT, bat_priv,
-			"Routing TT_RESPONSE to %pM [%c]\n",
-			tt_query->dst,
-			(tt_query->flags & TT_FULL_TABLE ? 'F' : '.'));
-		tt_query->tt_data = htons(tt_query->tt_data);
-		return route_unicast_packet(skb, recv_if);
+		if (is_my_mac(tt_query->dst))
+			handle_tt_response(bat_priv, tt_query);
+		else {
+			bat_dbg(DBG_TT, bat_priv,
+				"Routing TT_RESPONSE to %pM [%c]\n",
+				tt_query->dst,
+				(tt_query->flags & TT_FULL_TABLE ? 'F' : '.'));
+			tt_query->tt_data = htons(tt_query->tt_data);
+			return route_unicast_packet(skb, recv_if);
+		}
+		break;
 	}
 	ret = NET_RX_SUCCESS;
 
-- 
1.7.5.4


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

* Re: [B.A.T.M.A.N.] [PATCHv2] batman-adv: clean up the tt_query flags field
  2011-06-13 20:51 ` [B.A.T.M.A.N.] [PATCHv2] " Sven Eckelmann
@ 2011-06-14 12:59   ` Marek Lindner
  0 siblings, 0 replies; 4+ messages in thread
From: Marek Lindner @ 2011-06-14 12:59 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Monday, June 13, 2011 10:51:40 PM Sven Eckelmann wrote:
> From: Antonio Quartulli <ordex@autistici.org>
> 
> The tt_query subtype is represented by the two leading bits (lsb) of
> the tt_query->flags field. Therefore it cannot be handled by simple
> "flags" but by two bits wide integer. The TT_QUERY_TYPE_MASK is used to
> extract the relevant bits that can be compared to the related enum
> values (TT_RESPONSE, TT_REQUEST)

Applied in revision 02585b0.

Thanks,
Marek

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

end of thread, other threads:[~2011-06-14 12:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-13 17:38 [B.A.T.M.A.N.] [PATCH] batman-adv: clean up the tt_query flags field Antonio Quartulli
2011-06-13 20:46 ` Sven Eckelmann
2011-06-13 20:51 ` [B.A.T.M.A.N.] [PATCHv2] " Sven Eckelmann
2011-06-14 12:59   ` Marek Lindner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).