aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/packet.h
diff options
context:
space:
mode:
authorAntonio Quartulli <ordex@autistici.org>2011-05-28 08:51:06 -0400
committerSven Eckelmann <sven@narfation.org>2011-06-20 05:37:21 -0400
commit3b27ffb00fbe9d9189715ea13ce8712e2f0cb0c5 (patch)
treef1c37577167e4d6eecae2f7c87078fcf26ccfa3e /net/batman-adv/packet.h
parentb4e1705417c6cc7d46d9020259a2c8f457cf82bd (diff)
batman-adv: Unify the first 3 bytes in each packet
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>
Diffstat (limited to 'net/batman-adv/packet.h')
-rw-r--r--net/batman-adv/packet.h30
1 files changed, 18 insertions, 12 deletions
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 9f77086a546..6ddbfd83078 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -34,7 +34,7 @@ enum bat_packettype {
34}; 34};
35 35
36/* this file is included by batctl which needs these defines */ 36/* this file is included by batctl which needs these defines */
37#define COMPAT_VERSION 12 37#define COMPAT_VERSION 14
38 38
39enum batman_flags { 39enum batman_flags {
40 PRIMARIES_FIRST_HOP = 1 << 4, 40 PRIMARIES_FIRST_HOP = 1 << 4,
@@ -66,15 +66,15 @@ enum unicast_frag_flags {
66struct batman_packet { 66struct batman_packet {
67 uint8_t packet_type; 67 uint8_t packet_type;
68 uint8_t version; /* batman version field */ 68 uint8_t version; /* batman version field */
69 uint8_t ttl;
69 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */ 70 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
70 uint8_t tq;
71 uint32_t seqno; 71 uint32_t seqno;
72 uint8_t orig[6]; 72 uint8_t orig[6];
73 uint8_t prev_sender[6]; 73 uint8_t prev_sender[6];
74 uint8_t ttl;
75 uint8_t num_tt;
76 uint8_t gw_flags; /* flags related to gateway class */ 74 uint8_t gw_flags; /* flags related to gateway class */
77 uint8_t align; 75 uint8_t tq;
76 uint8_t num_tt;
77 uint8_t reserved;
78} __packed; 78} __packed;
79 79
80#define BAT_PACKET_LEN sizeof(struct batman_packet) 80#define BAT_PACKET_LEN sizeof(struct batman_packet)
@@ -82,12 +82,13 @@ struct batman_packet {
82struct icmp_packet { 82struct icmp_packet {
83 uint8_t packet_type; 83 uint8_t packet_type;
84 uint8_t version; /* batman version field */ 84 uint8_t version; /* batman version field */
85 uint8_t msg_type; /* see ICMP message types above */
86 uint8_t ttl; 85 uint8_t ttl;
86 uint8_t msg_type; /* see ICMP message types above */
87 uint8_t dst[6]; 87 uint8_t dst[6];
88 uint8_t orig[6]; 88 uint8_t orig[6];
89 uint16_t seqno; 89 uint16_t seqno;
90 uint8_t uid; 90 uint8_t uid;
91 uint8_t reserved;
91} __packed; 92} __packed;
92 93
93#define BAT_RR_LEN 16 94#define BAT_RR_LEN 16
@@ -97,8 +98,8 @@ struct icmp_packet {
97struct icmp_packet_rr { 98struct icmp_packet_rr {
98 uint8_t packet_type; 99 uint8_t packet_type;
99 uint8_t version; /* batman version field */ 100 uint8_t version; /* batman version field */
100 uint8_t msg_type; /* see ICMP message types above */
101 uint8_t ttl; 101 uint8_t ttl;
102 uint8_t msg_type; /* see ICMP message types above */
102 uint8_t dst[6]; 103 uint8_t dst[6];
103 uint8_t orig[6]; 104 uint8_t orig[6];
104 uint16_t seqno; 105 uint16_t seqno;
@@ -110,16 +111,19 @@ struct icmp_packet_rr {
110struct unicast_packet { 111struct unicast_packet {
111 uint8_t packet_type; 112 uint8_t packet_type;
112 uint8_t version; /* batman version field */ 113 uint8_t version; /* batman version field */
113 uint8_t dest[6];
114 uint8_t ttl; 114 uint8_t ttl;
115 uint8_t reserved;
116 uint8_t dest[6];
115} __packed; 117} __packed;
116 118
117struct unicast_frag_packet { 119struct unicast_frag_packet {
118 uint8_t packet_type; 120 uint8_t packet_type;
119 uint8_t version; /* batman version field */ 121 uint8_t version; /* batman version field */
120 uint8_t dest[6];
121 uint8_t ttl; 122 uint8_t ttl;
123 uint8_t reserved;
124 uint8_t dest[6];
122 uint8_t flags; 125 uint8_t flags;
126 uint8_t align;
123 uint8_t orig[6]; 127 uint8_t orig[6];
124 uint16_t seqno; 128 uint16_t seqno;
125} __packed; 129} __packed;
@@ -127,18 +131,20 @@ struct unicast_frag_packet {
127struct bcast_packet { 131struct bcast_packet {
128 uint8_t packet_type; 132 uint8_t packet_type;
129 uint8_t version; /* batman version field */ 133 uint8_t version; /* batman version field */
130 uint8_t orig[6];
131 uint8_t ttl; 134 uint8_t ttl;
135 uint8_t reserved;
132 uint32_t seqno; 136 uint32_t seqno;
137 uint8_t orig[6];
133} __packed; 138} __packed;
134 139
135struct vis_packet { 140struct vis_packet {
136 uint8_t packet_type; 141 uint8_t packet_type;
137 uint8_t version; /* batman version field */ 142 uint8_t version; /* batman version field */
143 uint8_t ttl; /* TTL */
138 uint8_t vis_type; /* which type of vis-participant sent this? */ 144 uint8_t vis_type; /* which type of vis-participant sent this? */
139 uint8_t entries; /* number of entries behind this struct */
140 uint32_t seqno; /* sequence number */ 145 uint32_t seqno; /* sequence number */
141 uint8_t ttl; /* TTL */ 146 uint8_t entries; /* number of entries behind this struct */
147 uint8_t reserved;
142 uint8_t vis_orig[6]; /* originator that announces its neighbors */ 148 uint8_t vis_orig[6]; /* originator that announces its neighbors */
143 uint8_t target_orig[6]; /* who should receive this packet */ 149 uint8_t target_orig[6]; /* who should receive this packet */
144 uint8_t sender_orig[6]; /* who sent or rebroadcasted this packet */ 150 uint8_t sender_orig[6]; /* who sent or rebroadcasted this packet */