b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCH 05/12] batman-adv: Unify the first 3 bytes in each packet
Date: Mon, 20 Jun 2011 12:16:58 +0200	[thread overview]
Message-ID: <1308565025-21293-6-git-send-email-sven@narfation.org> (raw)
In-Reply-To: <1308565025-21293-1-git-send-email-sven@narfation.org>

From: Antonio Quartulli <ordex@autistici.org>

The amount of duplicated code in the receive and routing code can be
reduced when all headers provide the packet type, version and ttl in the
same first bytes.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 net/batman-adv/packet.h |   30 ++++++++++++++++++------------
 1 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 9f77086..6ddbfd8 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -34,7 +34,7 @@ enum bat_packettype {
 };
 
 /* this file is included by batctl which needs these defines */
-#define COMPAT_VERSION 12
+#define COMPAT_VERSION 14
 
 enum batman_flags {
 	PRIMARIES_FIRST_HOP = 1 << 4,
@@ -66,15 +66,15 @@ enum unicast_frag_flags {
 struct batman_packet {
 	uint8_t  packet_type;
 	uint8_t  version;  /* batman version field */
+	uint8_t  ttl;
 	uint8_t  flags;    /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
-	uint8_t  tq;
 	uint32_t seqno;
 	uint8_t  orig[6];
 	uint8_t  prev_sender[6];
-	uint8_t  ttl;
-	uint8_t  num_tt;
 	uint8_t  gw_flags;  /* flags related to gateway class */
-	uint8_t  align;
+	uint8_t  tq;
+	uint8_t  num_tt;
+	uint8_t  reserved;
 } __packed;
 
 #define BAT_PACKET_LEN sizeof(struct batman_packet)
@@ -82,12 +82,13 @@ struct batman_packet {
 struct icmp_packet {
 	uint8_t  packet_type;
 	uint8_t  version;  /* batman version field */
-	uint8_t  msg_type; /* see ICMP message types above */
 	uint8_t  ttl;
+	uint8_t  msg_type; /* see ICMP message types above */
 	uint8_t  dst[6];
 	uint8_t  orig[6];
 	uint16_t seqno;
 	uint8_t  uid;
+	uint8_t  reserved;
 } __packed;
 
 #define BAT_RR_LEN 16
@@ -97,8 +98,8 @@ struct icmp_packet {
 struct icmp_packet_rr {
 	uint8_t  packet_type;
 	uint8_t  version;  /* batman version field */
-	uint8_t  msg_type; /* see ICMP message types above */
 	uint8_t  ttl;
+	uint8_t  msg_type; /* see ICMP message types above */
 	uint8_t  dst[6];
 	uint8_t  orig[6];
 	uint16_t seqno;
@@ -110,16 +111,19 @@ struct icmp_packet_rr {
 struct unicast_packet {
 	uint8_t  packet_type;
 	uint8_t  version;  /* batman version field */
-	uint8_t  dest[6];
 	uint8_t  ttl;
+	uint8_t  reserved;
+	uint8_t  dest[6];
 } __packed;
 
 struct unicast_frag_packet {
 	uint8_t  packet_type;
 	uint8_t  version;  /* batman version field */
-	uint8_t  dest[6];
 	uint8_t  ttl;
+	uint8_t  reserved;
+	uint8_t  dest[6];
 	uint8_t  flags;
+	uint8_t  align;
 	uint8_t  orig[6];
 	uint16_t seqno;
 } __packed;
@@ -127,18 +131,20 @@ struct unicast_frag_packet {
 struct bcast_packet {
 	uint8_t  packet_type;
 	uint8_t  version;  /* batman version field */
-	uint8_t  orig[6];
 	uint8_t  ttl;
+	uint8_t  reserved;
 	uint32_t seqno;
+	uint8_t  orig[6];
 } __packed;
 
 struct vis_packet {
 	uint8_t  packet_type;
 	uint8_t  version;        /* batman version field */
+	uint8_t  ttl;		 /* TTL */
 	uint8_t  vis_type;	 /* which type of vis-participant sent this? */
-	uint8_t  entries;	 /* number of entries behind this struct */
 	uint32_t seqno;		 /* sequence number */
-	uint8_t  ttl;		 /* TTL */
+	uint8_t  entries;	 /* number of entries behind this struct */
+	uint8_t  reserved;
 	uint8_t  vis_orig[6];	 /* originator that announces its neighbors */
 	uint8_t  target_orig[6]; /* who should receive this packet */
 	uint8_t  sender_orig[6]; /* who sent or rebroadcasted this packet */
-- 
1.7.5.3


  parent reply	other threads:[~2011-06-20 10:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-20 10:16 [B.A.T.M.A.N.] pull request: batman-adv 2011-06-20 Sven Eckelmann
2011-06-20 10:16 ` [B.A.T.M.A.N.] [PATCH 01/12] batman-adv: Move compare_orig to originator.c Sven Eckelmann
2011-06-20 10:16 ` [B.A.T.M.A.N.] [PATCH 02/12] batman-adv: Keep interface_tx as local function Sven Eckelmann
2011-06-20 10:16 ` [B.A.T.M.A.N.] [PATCH 03/12] batman-adv: count_real_packets() in batman-adv assumes char is signed Sven Eckelmann
2011-06-20 10:16 ` [B.A.T.M.A.N.] [PATCH 04/12] batman-adv: Reduce usage of char Sven Eckelmann
2011-06-20 10:16 ` Sven Eckelmann [this message]
2011-06-20 10:16 ` [B.A.T.M.A.N.] [PATCH 06/12] batman-adv: improved client announcement mechanism Sven Eckelmann
2011-06-20 10:17 ` [B.A.T.M.A.N.] [PATCH 07/12] batman-adv: improved roaming mechanism Sven Eckelmann
2011-06-20 10:17 ` [B.A.T.M.A.N.] [PATCH 08/12] batman-adv: protect the local and the global trans-tables with rcu Sven Eckelmann
2011-06-20 10:17 ` [B.A.T.M.A.N.] [PATCH 09/12] batman-adv: add wrapper function to throw uevent in userspace Sven Eckelmann
2011-06-20 10:17 ` [B.A.T.M.A.N.] [PATCH 10/12] batman-adv: gateway election code refactoring Sven Eckelmann
2011-06-20 10:17 ` [B.A.T.M.A.N.] [PATCH 11/12] batman-adv: throw uevent in userspace on gateway add/change/del event Sven Eckelmann
2011-06-20 10:17 ` [B.A.T.M.A.N.] [PATCH 12/12] batman-adv: improved gateway tq-based selection Sven Eckelmann
2011-06-20 20:01 ` [B.A.T.M.A.N.] pull request: batman-adv 2011-06-20 David Miller

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=1308565025-21293-6-git-send-email-sven@narfation.org \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).