blob: 5627ca326018c7e8dda6b4f53004722d5c5d47e3 [file] [log] [blame]
Andrew Lunn5beef3c2009-11-09 21:20:10 +01001/*
2 * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors:
3 *
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#define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
23
24#define BAT_PACKET 0x01
25#define BAT_ICMP 0x02
26#define BAT_UNICAST 0x03
27#define BAT_BCAST 0x04
28#define BAT_VIS 0x05
29
30/* this file is included by batctl which needs these defines */
31#define COMPAT_VERSION 8
32#define DIRECTLINK 0x40
33#define VIS_SERVER 0x20
34
35/* ICMP message types */
36#define ECHO_REPLY 0
37#define DESTINATION_UNREACHABLE 3
38#define ECHO_REQUEST 8
39#define TTL_EXCEEDED 11
40#define PARAMETER_PROBLEM 12
41
42/* vis defines */
43#define VIS_TYPE_SERVER_SYNC 0
44#define VIS_TYPE_CLIENT_UPDATE 1
45
46struct batman_packet {
47 uint8_t packet_type;
48 uint8_t version; /* batman version field */
49 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
50 uint8_t tq;
51 uint16_t seqno;
52 uint8_t orig[6];
53 uint8_t prev_sender[6];
54 uint8_t ttl;
55 uint8_t num_hna;
56} __attribute__((packed));
57
58#define BAT_PACKET_LEN sizeof(struct batman_packet)
59
60struct icmp_packet {
61 uint8_t packet_type;
62 uint8_t version; /* batman version field */
63 uint8_t msg_type; /* see ICMP message types above */
64 uint8_t ttl;
65 uint8_t dst[6];
66 uint8_t orig[6];
67 uint16_t seqno;
68 uint8_t uid;
69} __attribute__((packed));
70
71struct unicast_packet {
72 uint8_t packet_type;
73 uint8_t version; /* batman version field */
74 uint8_t dest[6];
75 uint8_t ttl;
76} __attribute__((packed));
77
78struct bcast_packet {
79 uint8_t packet_type;
80 uint8_t version; /* batman version field */
81 uint8_t orig[6];
82 uint16_t seqno;
83} __attribute__((packed));
84
85struct vis_packet {
86 uint8_t packet_type;
87 uint8_t version; /* batman version field */
88 uint8_t vis_type; /* which type of vis-participant sent this? */
89 uint8_t seqno; /* sequence number */
90 uint8_t entries; /* number of entries behind this struct */
91 uint8_t ttl; /* TTL */
92 uint8_t vis_orig[6]; /* originator that informs about its
93 * neighbours */
94 uint8_t target_orig[6]; /* who should receive this packet */
95 uint8_t sender_orig[6]; /* who sent or rebroadcasted this packet */
96} __attribute__((packed));