From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCH-sven] batman-adv: Unify the first 4 bytes in each packet
Date: Sat, 28 May 2011 10:43:03 +0200 [thread overview]
Message-ID: <1306572183-25950-1-git-send-email-sven@narfation.org> (raw)
In-Reply-To: <201105280926.32059.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>
---
just my suggestion
packet.h | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/packet.h b/packet.h
index eda9965..c84f325 100644
--- a/packet.h
+++ b/packet.h
@@ -32,7 +32,7 @@
#define BAT_UNICAST_FRAG 0x06
/* this file is included by batctl which needs these defines */
-#define COMPAT_VERSION 12
+#define COMPAT_VERSION 14
#define DIRECTLINK 0x40
#define VIS_SERVER 0x20
#define PRIMARIES_FIRST_HOP 0x10
@@ -55,12 +55,13 @@
struct batman_packet {
uint8_t packet_type;
uint8_t version; /* batman version field */
+ uint8_t ttl;
+ uint8_t reserved;
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;
@@ -71,8 +72,9 @@ 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 reserved;
+ uint8_t msg_type; /* see ICMP message types above */
uint8_t dst[6];
uint8_t orig[6];
uint16_t seqno;
@@ -86,8 +88,9 @@ 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 reserved;
+ uint8_t msg_type; /* see ICMP message types above */
uint8_t dst[6];
uint8_t orig[6];
uint16_t seqno;
@@ -99,16 +102,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;
@@ -116,8 +122,9 @@ 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;
+ uint8_t orig[6];
uint32_t seqno;
} __packed;
--
1.7.5.1
next prev parent reply other threads:[~2011-05-28 8:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-27 22:10 [B.A.T.M.A.N.] [PATCH] batman-adv: move the ttl field to the third position of unicast_* packets Antonio Quartulli
2011-05-27 22:20 ` Sven Eckelmann
2011-05-27 22:35 ` Marek Lindner
2011-05-28 7:26 ` Sven Eckelmann
2011-05-28 8:43 ` Sven Eckelmann [this message]
2011-05-28 11:45 ` [B.A.T.M.A.N.] [PATCH-marek] batman-adv: Unify the first 3 bytes in each packet Marek Lindner
2011-05-28 12:07 ` Sven Eckelmann
2011-05-28 12:17 ` Marek Lindner
2011-05-28 12:43 ` Sven Eckelmann
2011-05-28 12:51 ` [B.A.T.M.A.N.] [PATCHv3-sven] " Sven Eckelmann
2011-05-28 15:08 ` Marek Lindner
2011-05-28 11:46 ` [B.A.T.M.A.N.] [PATCH-sven] batman-adv: Unify the first 4 " Sven Eckelmann
2011-05-28 11:46 ` [B.A.T.M.A.N.] [PATCHv2-sven] batman-adv: Unify the first 3 " Sven Eckelmann
2011-05-28 11:20 ` [B.A.T.M.A.N.] [PATCH] batman-adv: move the ttl field to the third position of unicast_* packets Marek Lindner
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=1306572183-25950-1-git-send-email-sven@narfation.org \
--to=sven@narfation.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.