aboutsummaryrefslogtreecommitdiff
path: root/net/batman-adv/packet.h
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2011-11-20 15:47:38 +0100
committerMarek Lindner <lindner_marek@yahoo.de>2012-02-17 02:50:19 +0800
commit76543d14aec6ce5cb3fc7be9b39c50fcebd2043b (patch)
tree4f739cfadaee8ec9a06d7855956f3accc1dcc2be /net/batman-adv/packet.h
parent17071578888c7c18709e48e74fae228c04581b9a (diff)
batman-adv: Explicitly mark the common header structure
All batman-adv packets have a common 3 byte header. It can be used to share some code between different code paths, but it was never explicit stated that this header has to be always the same for all packets. Therefore, new code changes always have the problem that they may accidently introduce regressions by moving some elements around. A new structure is introduced that contains the common header and makes it easier visible that these 3 bytes have to be the same for all on-wire packets. Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv/packet.h')
-rw-r--r--net/batman-adv/packet.h38
1 files changed, 13 insertions, 25 deletions
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 4d9e54c57a3..88c717b9344 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -90,10 +90,14 @@ enum tt_client_flags {
TT_CLIENT_PENDING = 1 << 10
};
-struct batman_ogm_packet {
+struct batman_header {
uint8_t packet_type;
uint8_t version; /* batman version field */
uint8_t ttl;
+} __packed;
+
+struct batman_ogm_packet {
+ struct batman_header header;
uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
uint32_t seqno;
uint8_t orig[6];
@@ -108,9 +112,7 @@ struct batman_ogm_packet {
#define BATMAN_OGM_LEN sizeof(struct batman_ogm_packet)
struct icmp_packet {
- uint8_t packet_type;
- uint8_t version; /* batman version field */
- uint8_t ttl;
+ struct batman_header header;
uint8_t msg_type; /* see ICMP message types above */
uint8_t dst[6];
uint8_t orig[6];
@@ -124,9 +126,7 @@ struct icmp_packet {
/* icmp_packet_rr must start with all fields from imcp_packet
* as this is assumed by code that handles ICMP packets */
struct icmp_packet_rr {
- uint8_t packet_type;
- uint8_t version; /* batman version field */
- uint8_t ttl;
+ struct batman_header header;
uint8_t msg_type; /* see ICMP message types above */
uint8_t dst[6];
uint8_t orig[6];
@@ -137,17 +137,13 @@ struct icmp_packet_rr {
} __packed;
struct unicast_packet {
- uint8_t packet_type;
- uint8_t version; /* batman version field */
- uint8_t ttl;
+ struct batman_header header;
uint8_t ttvn; /* destination translation table version number */
uint8_t dest[6];
} __packed;
struct unicast_frag_packet {
- uint8_t packet_type;
- uint8_t version; /* batman version field */
- uint8_t ttl;
+ struct batman_header header;
uint8_t ttvn; /* destination translation table version number */
uint8_t dest[6];
uint8_t flags;
@@ -157,18 +153,14 @@ struct unicast_frag_packet {
} __packed;
struct bcast_packet {
- uint8_t packet_type;
- uint8_t version; /* batman version field */
- uint8_t ttl;
+ struct batman_header header;
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 */
+ struct batman_header header;
uint8_t vis_type; /* which type of vis-participant sent this? */
uint32_t seqno; /* sequence number */
uint8_t entries; /* number of entries behind this struct */
@@ -179,9 +171,7 @@ struct vis_packet {
} __packed;
struct tt_query_packet {
- uint8_t packet_type;
- uint8_t version; /* batman version field */
- uint8_t ttl;
+ struct batman_header header;
/* the flag field is a combination of:
* - TT_REQUEST or TT_RESPONSE
* - TT_FULL_TABLE */
@@ -202,9 +192,7 @@ struct tt_query_packet {
} __packed;
struct roam_adv_packet {
- uint8_t packet_type;
- uint8_t version;
- uint8_t ttl;
+ struct batman_header header;
uint8_t reserved;
uint8_t dst[ETH_ALEN];
uint8_t src[ETH_ALEN];