blob: eda99650e9f81ec7fbe7da8e7878747fe19ac709 [file] [log] [blame]
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00001/*
Sven Eckelmann64afe352011-01-27 10:38:15 +01002 * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors:
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00003 *
4 * Marek Lindner, Simon Wunderlich
5 *
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.
9 *
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.
14 *
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
18 * 02110-1301, USA
19 *
20 */
21
22#ifndef _NET_BATMAN_ADV_PACKET_H_
23#define _NET_BATMAN_ADV_PACKET_H_
24
25#define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
26
27#define BAT_PACKET 0x01
28#define BAT_ICMP 0x02
29#define BAT_UNICAST 0x03
30#define BAT_BCAST 0x04
31#define BAT_VIS 0x05
32#define BAT_UNICAST_FRAG 0x06
33
34/* this file is included by batctl which needs these defines */
35#define COMPAT_VERSION 12
36#define DIRECTLINK 0x40
37#define VIS_SERVER 0x20
38#define PRIMARIES_FIRST_HOP 0x10
39
40/* ICMP message types */
41#define ECHO_REPLY 0
42#define DESTINATION_UNREACHABLE 3
43#define ECHO_REQUEST 8
44#define TTL_EXCEEDED 11
45#define PARAMETER_PROBLEM 12
46
47/* vis defines */
48#define VIS_TYPE_SERVER_SYNC 0
49#define VIS_TYPE_CLIENT_UPDATE 1
50
51/* fragmentation defines */
52#define UNI_FRAG_HEAD 0x01
Sven Eckelmannae361ce2011-01-25 22:02:31 +000053#define UNI_FRAG_LARGETAIL 0x02
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000054
55struct batman_packet {
56 uint8_t packet_type;
57 uint8_t version; /* batman version field */
58 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
59 uint8_t tq;
60 uint32_t seqno;
61 uint8_t orig[6];
62 uint8_t prev_sender[6];
63 uint8_t ttl;
Antonio Quartulli2dafb492011-05-05 08:42:45 +020064 uint8_t num_tt;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000065 uint8_t gw_flags; /* flags related to gateway class */
66 uint8_t align;
Sven Eckelmannaa0adb12011-01-15 14:39:43 +000067} __packed;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000068
69#define BAT_PACKET_LEN sizeof(struct batman_packet)
70
71struct icmp_packet {
72 uint8_t packet_type;
73 uint8_t version; /* batman version field */
74 uint8_t msg_type; /* see ICMP message types above */
75 uint8_t ttl;
76 uint8_t dst[6];
77 uint8_t orig[6];
78 uint16_t seqno;
79 uint8_t uid;
Sven Eckelmannaa0adb12011-01-15 14:39:43 +000080} __packed;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000081
82#define BAT_RR_LEN 16
83
84/* icmp_packet_rr must start with all fields from imcp_packet
85 * as this is assumed by code that handles ICMP packets */
86struct icmp_packet_rr {
87 uint8_t packet_type;
88 uint8_t version; /* batman version field */
89 uint8_t msg_type; /* see ICMP message types above */
90 uint8_t ttl;
91 uint8_t dst[6];
92 uint8_t orig[6];
93 uint16_t seqno;
94 uint8_t uid;
95 uint8_t rr_cur;
96 uint8_t rr[BAT_RR_LEN][ETH_ALEN];
Sven Eckelmannaa0adb12011-01-15 14:39:43 +000097} __packed;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000098
99struct unicast_packet {
100 uint8_t packet_type;
101 uint8_t version; /* batman version field */
102 uint8_t dest[6];
103 uint8_t ttl;
Sven Eckelmannaa0adb12011-01-15 14:39:43 +0000104} __packed;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000105
106struct unicast_frag_packet {
107 uint8_t packet_type;
108 uint8_t version; /* batman version field */
109 uint8_t dest[6];
110 uint8_t ttl;
111 uint8_t flags;
112 uint8_t orig[6];
113 uint16_t seqno;
Sven Eckelmannaa0adb12011-01-15 14:39:43 +0000114} __packed;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000115
116struct bcast_packet {
117 uint8_t packet_type;
118 uint8_t version; /* batman version field */
119 uint8_t orig[6];
120 uint8_t ttl;
121 uint32_t seqno;
Sven Eckelmannaa0adb12011-01-15 14:39:43 +0000122} __packed;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000123
124struct vis_packet {
125 uint8_t packet_type;
126 uint8_t version; /* batman version field */
127 uint8_t vis_type; /* which type of vis-participant sent this? */
128 uint8_t entries; /* number of entries behind this struct */
129 uint32_t seqno; /* sequence number */
130 uint8_t ttl; /* TTL */
Sven Eckelmann6e215fd2011-05-08 12:45:45 +0200131 uint8_t vis_orig[6]; /* originator that announces its neighbors */
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000132 uint8_t target_orig[6]; /* who should receive this packet */
133 uint8_t sender_orig[6]; /* who sent or rebroadcasted this packet */
Sven Eckelmannaa0adb12011-01-15 14:39:43 +0000134} __packed;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000135
136#endif /* _NET_BATMAN_ADV_PACKET_H_ */