]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/staging/batman-adv/packet.h
Merge branch 'for-2.6.38' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq
[mirror_ubuntu-artful-kernel.git] / drivers / staging / batman-adv / packet.h
CommitLineData
5beef3c9 1/*
9b6d10b7 2 * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors:
5beef3c9
AL
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
62c20720
SE
22#ifndef _NET_BATMAN_ADV_PACKET_H_
23#define _NET_BATMAN_ADV_PACKET_H_
24
5beef3c9
AL
25#define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
26
e63760e5
AL
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
5beef3c9
AL
33
34/* this file is included by batctl which needs these defines */
e63760e5 35#define COMPAT_VERSION 13
5beef3c9
AL
36#define DIRECTLINK 0x40
37#define VIS_SERVER 0x20
e35fd5ec 38#define PRIMARIES_FIRST_HOP 0x10
5beef3c9
AL
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
e63760e5
AL
51/* fragmentation defines */
52#define UNI_FRAG_HEAD 0x01
53
5beef3c9
AL
54struct batman_packet {
55 uint8_t packet_type;
56 uint8_t version; /* batman version field */
57 uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
58 uint8_t tq;
cf2d72ec 59 uint32_t seqno;
5beef3c9
AL
60 uint8_t orig[6];
61 uint8_t prev_sender[6];
62 uint8_t ttl;
63 uint8_t num_hna;
64} __attribute__((packed));
65
66#define BAT_PACKET_LEN sizeof(struct batman_packet)
67
68struct icmp_packet {
69 uint8_t packet_type;
70 uint8_t version; /* batman version field */
71 uint8_t msg_type; /* see ICMP message types above */
72 uint8_t ttl;
73 uint8_t dst[6];
74 uint8_t orig[6];
75 uint16_t seqno;
76 uint8_t uid;
77} __attribute__((packed));
78
e4cb3720
DS
79#define BAT_RR_LEN 16
80
81/* icmp_packet_rr must start with all fields from imcp_packet
1612ae99 82 * as this is assumed by code that handles ICMP packets */
e4cb3720
DS
83struct icmp_packet_rr {
84 uint8_t packet_type;
85 uint8_t version; /* batman version field */
86 uint8_t msg_type; /* see ICMP message types above */
87 uint8_t ttl;
88 uint8_t dst[6];
89 uint8_t orig[6];
90 uint16_t seqno;
91 uint8_t uid;
92 uint8_t rr_cur;
93 uint8_t rr[BAT_RR_LEN][ETH_ALEN];
94} __attribute__((packed));
95
5beef3c9
AL
96struct unicast_packet {
97 uint8_t packet_type;
98 uint8_t version; /* batman version field */
99 uint8_t dest[6];
100 uint8_t ttl;
101} __attribute__((packed));
102
e63760e5
AL
103struct unicast_frag_packet {
104 uint8_t packet_type;
105 uint8_t version; /* batman version field */
106 uint8_t dest[6];
107 uint8_t ttl;
108 uint8_t flags;
109 uint8_t orig[6];
110 uint16_t seqno;
111} __attribute__((packed));
112
5beef3c9
AL
113struct bcast_packet {
114 uint8_t packet_type;
115 uint8_t version; /* batman version field */
116 uint8_t orig[6];
cf2d72ec
SW
117 uint8_t ttl;
118 uint32_t seqno;
5beef3c9
AL
119} __attribute__((packed));
120
121struct vis_packet {
122 uint8_t packet_type;
123 uint8_t version; /* batman version field */
124 uint8_t vis_type; /* which type of vis-participant sent this? */
5beef3c9 125 uint8_t entries; /* number of entries behind this struct */
cf2d72ec 126 uint32_t seqno; /* sequence number */
5beef3c9
AL
127 uint8_t ttl; /* TTL */
128 uint8_t vis_orig[6]; /* originator that informs about its
5ea84fa3 129 * neighbors */
5beef3c9
AL
130 uint8_t target_orig[6]; /* who should receive this packet */
131 uint8_t sender_orig[6]; /* who sent or rebroadcasted this packet */
132} __attribute__((packed));
62c20720
SE
133
134#endif /* _NET_BATMAN_ADV_PACKET_H_ */