2 * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors:
4 * Marek Lindner, Simon Wunderlich
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of version 2 of the GNU General Public
8 * License as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #ifndef _NET_BATMAN_ADV_PACKET_H_
23 #define _NET_BATMAN_ADV_PACKET_H_
25 #define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
33 BAT_UNICAST_FRAG = 0x06,
37 /* this file is included by batctl which needs these defines */
38 #define COMPAT_VERSION 14
41 PRIMARIES_FIRST_HOP = 1 << 4,
46 /* ICMP message types */
47 enum icmp_packettype {
49 DESTINATION_UNREACHABLE = 3,
52 PARAMETER_PROBLEM = 12
57 VIS_TYPE_SERVER_SYNC = 0,
58 VIS_TYPE_CLIENT_UPDATE = 1
61 /* fragmentation defines */
62 enum unicast_frag_flags {
63 UNI_FRAG_HEAD = 1 << 0,
64 UNI_FRAG_LARGETAIL = 1 << 1
67 /* TT_QUERY subtypes */
68 #define TT_QUERY_TYPE_MASK 0x3
70 enum tt_query_packettype {
77 TT_FULL_TABLE = 1 << 2
81 enum tt_change_flags {
86 struct batman_packet {
88 uint8_t version; /* batman version field */
90 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
93 uint8_t prev_sender[6];
94 uint8_t gw_flags; /* flags related to gateway class */
96 uint8_t tt_num_changes;
97 uint8_t ttvn; /* translation table version number */
101 #define BAT_PACKET_LEN sizeof(struct batman_packet)
105 uint8_t version; /* batman version field */
107 uint8_t msg_type; /* see ICMP message types above */
115 #define BAT_RR_LEN 16
117 /* icmp_packet_rr must start with all fields from imcp_packet
118 * as this is assumed by code that handles ICMP packets */
119 struct icmp_packet_rr {
121 uint8_t version; /* batman version field */
123 uint8_t msg_type; /* see ICMP message types above */
129 uint8_t rr[BAT_RR_LEN][ETH_ALEN];
132 struct unicast_packet {
134 uint8_t version; /* batman version field */
136 uint8_t ttvn; /* destination translation table version number */
140 struct unicast_frag_packet {
142 uint8_t version; /* batman version field */
144 uint8_t ttvn; /* destination translation table version number */
152 struct bcast_packet {
154 uint8_t version; /* batman version field */
163 uint8_t version; /* batman version field */
164 uint8_t ttl; /* TTL */
165 uint8_t vis_type; /* which type of vis-participant sent this? */
166 uint32_t seqno; /* sequence number */
167 uint8_t entries; /* number of entries behind this struct */
169 uint8_t vis_orig[6]; /* originator that announces its neighbors */
170 uint8_t target_orig[6]; /* who should receive this packet */
171 uint8_t sender_orig[6]; /* who sent or rebroadcasted this packet */
174 struct tt_query_packet {
176 uint8_t version; /* batman version field */
178 /* the flag field is a combination of:
179 * - TT_REQUEST or TT_RESPONSE
182 uint8_t dst[ETH_ALEN];
183 uint8_t src[ETH_ALEN];
184 /* the ttvn field is:
185 * if TT_REQUEST: ttvn that triggered the
187 * if TT_RESPONSE: new ttvn for the src
191 * if TT_REQUEST: crc associated with the
193 * if TT_RESPONSE: table_size */
199 uint8_t addr[ETH_ALEN];
202 #endif /* _NET_BATMAN_ADV_PACKET_H_ */