Merge branch 'for-2.6.36' of git://git.kernel.dk/linux-2.6-block
[pandora-kernel.git] / drivers / staging / batman-adv / packet.h
1 /*
2  * Copyright (C) 2007-2010 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 #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
33 /* this file is included by batctl which needs these defines */
34 #define COMPAT_VERSION 11
35 #define DIRECTLINK 0x40
36 #define VIS_SERVER 0x20
37 #define PRIMARIES_FIRST_HOP 0x10
38
39 /* ICMP message types */
40 #define ECHO_REPLY 0
41 #define DESTINATION_UNREACHABLE 3
42 #define ECHO_REQUEST 8
43 #define TTL_EXCEEDED 11
44 #define PARAMETER_PROBLEM 12
45
46 /* vis defines */
47 #define VIS_TYPE_SERVER_SYNC            0
48 #define VIS_TYPE_CLIENT_UPDATE          1
49
50 struct batman_packet {
51         uint8_t  packet_type;
52         uint8_t  version;  /* batman version field */
53         uint8_t  flags;    /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
54         uint8_t  tq;
55         uint32_t seqno;
56         uint8_t  orig[6];
57         uint8_t  prev_sender[6];
58         uint8_t  ttl;
59         uint8_t  num_hna;
60 } __attribute__((packed));
61
62 #define BAT_PACKET_LEN sizeof(struct batman_packet)
63
64 struct icmp_packet {
65         uint8_t  packet_type;
66         uint8_t  version;  /* batman version field */
67         uint8_t  msg_type; /* see ICMP message types above */
68         uint8_t  ttl;
69         uint8_t  dst[6];
70         uint8_t  orig[6];
71         uint16_t seqno;
72         uint8_t  uid;
73 } __attribute__((packed));
74
75 #define BAT_RR_LEN 16
76
77 /* icmp_packet_rr must start with all fields from imcp_packet
78    as this is assumed by code that handles ICMP packets */
79 struct icmp_packet_rr {
80         uint8_t  packet_type;
81         uint8_t  version;  /* batman version field */
82         uint8_t  msg_type; /* see ICMP message types above */
83         uint8_t  ttl;
84         uint8_t  dst[6];
85         uint8_t  orig[6];
86         uint16_t seqno;
87         uint8_t  uid;
88         uint8_t  rr_cur;
89         uint8_t  rr[BAT_RR_LEN][ETH_ALEN];
90 } __attribute__((packed));
91
92 struct unicast_packet {
93         uint8_t  packet_type;
94         uint8_t  version;  /* batman version field */
95         uint8_t  dest[6];
96         uint8_t  ttl;
97 } __attribute__((packed));
98
99 struct bcast_packet {
100         uint8_t  packet_type;
101         uint8_t  version;  /* batman version field */
102         uint8_t  orig[6];
103         uint8_t  ttl;
104         uint32_t seqno;
105 } __attribute__((packed));
106
107 struct vis_packet {
108         uint8_t  packet_type;
109         uint8_t  version;        /* batman version field */
110         uint8_t  vis_type;       /* which type of vis-participant sent this? */
111         uint8_t  entries;        /* number of entries behind this struct */
112         uint32_t seqno;          /* sequence number */
113         uint8_t  ttl;            /* TTL */
114         uint8_t  vis_orig[6];    /* originator that informs about its
115                                   * neighbors */
116         uint8_t  target_orig[6]; /* who should receive this packet */
117         uint8_t  sender_orig[6]; /* who sent or rebroadcasted this packet */
118 } __attribute__((packed));
119
120 #endif /* _NET_BATMAN_ADV_PACKET_H_ */