aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/packet.h
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2011-11-20 09:47:38 -0500
committerMarek Lindner <lindner_marek@yahoo.de>2012-02-16 13:50:19 -0500
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 4d9e54c57a36..88c717b9344d 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -90,10 +90,14 @@ enum tt_client_flags {
90 TT_CLIENT_PENDING = 1 << 10 90 TT_CLIENT_PENDING = 1 << 10
91}; 91};
92 92
93struct batman_ogm_packet { 93struct batman_header {
94 uint8_t packet_type; 94 uint8_t packet_type;
95 uint8_t version; /* batman version field */ 95 uint8_t version; /* batman version field */
96 uint8_t ttl; 96 uint8_t ttl;
97} __packed;
98
99struct batman_ogm_packet {
100 struct batman_header header;
97 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */ 101 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
98 uint32_t seqno; 102 uint32_t seqno;
99 uint8_t orig[6]; 103 uint8_t orig[6];
@@ -108,9 +112,7 @@ struct batman_ogm_packet {
108#define BATMAN_OGM_LEN sizeof(struct batman_ogm_packet) 112#define BATMAN_OGM_LEN sizeof(struct batman_ogm_packet)
109 113
110struct icmp_packet { 114struct icmp_packet {
111 uint8_t packet_type; 115 struct batman_header header;
112 uint8_t version; /* batman version field */
113 uint8_t ttl;
114 uint8_t msg_type; /* see ICMP message types above */ 116 uint8_t msg_type; /* see ICMP message types above */
115 uint8_t dst[6]; 117 uint8_t dst[6];
116 uint8_t orig[6]; 118 uint8_t orig[6];
@@ -124,9 +126,7 @@ struct icmp_packet {
124/* icmp_packet_rr must start with all fields from imcp_packet 126/* icmp_packet_rr must start with all fields from imcp_packet
125 * as this is assumed by code that handles ICMP packets */ 127 * as this is assumed by code that handles ICMP packets */
126struct icmp_packet_rr { 128struct icmp_packet_rr {
127 uint8_t packet_type; 129 struct batman_header header;
128 uint8_t version; /* batman version field */
129 uint8_t ttl;
130 uint8_t msg_type; /* see ICMP message types above */ 130 uint8_t msg_type; /* see ICMP message types above */
131 uint8_t dst[6]; 131 uint8_t dst[6];
132 uint8_t orig[6]; 132 uint8_t orig[6];
@@ -137,17 +137,13 @@ struct icmp_packet_rr {
137} __packed; 137} __packed;
138 138
139struct unicast_packet { 139struct unicast_packet {
140 uint8_t packet_type; 140 struct batman_header header;
141 uint8_t version; /* batman version field */
142 uint8_t ttl;
143 uint8_t ttvn; /* destination translation table version number */ 141 uint8_t ttvn; /* destination translation table version number */
144 uint8_t dest[6]; 142 uint8_t dest[6];
145} __packed; 143} __packed;
146 144
147struct unicast_frag_packet { 145struct unicast_frag_packet {
148 uint8_t packet_type; 146 struct batman_header header;
149 uint8_t version; /* batman version field */
150 uint8_t ttl;
151 uint8_t ttvn; /* destination translation table version number */ 147 uint8_t ttvn; /* destination translation table version number */
152 uint8_t dest[6]; 148 uint8_t dest[6];
153 uint8_t flags; 149 uint8_t flags;
@@ -157,18 +153,14 @@ struct unicast_frag_packet {
157} __packed; 153} __packed;
158 154
159struct bcast_packet { 155struct bcast_packet {
160 uint8_t packet_type; 156 struct batman_header header;
161 uint8_t version; /* batman version field */
162 uint8_t ttl;
163 uint8_t reserved; 157 uint8_t reserved;
164 uint32_t seqno; 158 uint32_t seqno;
165 uint8_t orig[6]; 159 uint8_t orig[6];
166} __packed; 160} __packed;
167 161
168struct vis_packet { 162struct vis_packet {
169 uint8_t packet_type; 163 struct batman_header header;
170 uint8_t version; /* batman version field */
171 uint8_t ttl; /* TTL */
172 uint8_t vis_type; /* which type of vis-participant sent this? */ 164 uint8_t vis_type; /* which type of vis-participant sent this? */
173 uint32_t seqno; /* sequence number */ 165 uint32_t seqno; /* sequence number */
174 uint8_t entries; /* number of entries behind this struct */ 166 uint8_t entries; /* number of entries behind this struct */
@@ -179,9 +171,7 @@ struct vis_packet {
179} __packed; 171} __packed;
180 172
181struct tt_query_packet { 173struct tt_query_packet {
182 uint8_t packet_type; 174 struct batman_header header;
183 uint8_t version; /* batman version field */
184 uint8_t ttl;
185 /* the flag field is a combination of: 175 /* the flag field is a combination of:
186 * - TT_REQUEST or TT_RESPONSE 176 * - TT_REQUEST or TT_RESPONSE
187 * - TT_FULL_TABLE */ 177 * - TT_FULL_TABLE */
@@ -202,9 +192,7 @@ struct tt_query_packet {
202} __packed; 192} __packed;
203 193
204struct roam_adv_packet { 194struct roam_adv_packet {
205 uint8_t packet_type; 195 struct batman_header header;
206 uint8_t version;
207 uint8_t ttl;
208 uint8_t reserved; 196 uint8_t reserved;
209 uint8_t dst[ETH_ALEN]; 197 uint8_t dst[ETH_ALEN];
210 uint8_t src[ETH_ALEN]; 198 uint8_t src[ETH_ALEN];