Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 1 | /* |
Sven Eckelmann | 64afe35 | 2011-01-27 10:38:15 +0100 | [diff] [blame] | 2 | * Copyright (C) 2007-2011 B.A.T.M.A.N. contributors: |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 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 | |
Sven Eckelmann | e8958db | 2011-06-04 11:26:00 +0200 | [diff] [blame] | 27 | enum bat_packettype { |
| 28 | BAT_PACKET = 0x01, |
| 29 | BAT_ICMP = 0x02, |
| 30 | BAT_UNICAST = 0x03, |
| 31 | BAT_BCAST = 0x04, |
| 32 | BAT_VIS = 0x05, |
| 33 | BAT_UNICAST_FRAG = 0x06 |
| 34 | }; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 35 | |
| 36 | /* this file is included by batctl which needs these defines */ |
Antonio Quartulli | 3b27ffb | 2011-05-28 14:51:06 +0200 | [diff] [blame^] | 37 | #define COMPAT_VERSION 14 |
Sven Eckelmann | e8958db | 2011-06-04 11:26:00 +0200 | [diff] [blame] | 38 | |
| 39 | enum batman_flags { |
| 40 | PRIMARIES_FIRST_HOP = 1 << 4, |
| 41 | VIS_SERVER = 1 << 5, |
| 42 | DIRECTLINK = 1 << 6 |
| 43 | }; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 44 | |
| 45 | /* ICMP message types */ |
Sven Eckelmann | e8958db | 2011-06-04 11:26:00 +0200 | [diff] [blame] | 46 | enum icmp_packettype { |
| 47 | ECHO_REPLY = 0, |
| 48 | DESTINATION_UNREACHABLE = 3, |
| 49 | ECHO_REQUEST = 8, |
| 50 | TTL_EXCEEDED = 11, |
| 51 | PARAMETER_PROBLEM = 12 |
| 52 | }; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 53 | |
| 54 | /* vis defines */ |
Sven Eckelmann | e8958db | 2011-06-04 11:26:00 +0200 | [diff] [blame] | 55 | enum vis_packettype { |
| 56 | VIS_TYPE_SERVER_SYNC = 0, |
| 57 | VIS_TYPE_CLIENT_UPDATE = 1 |
| 58 | }; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 59 | |
| 60 | /* fragmentation defines */ |
Sven Eckelmann | e8958db | 2011-06-04 11:26:00 +0200 | [diff] [blame] | 61 | enum unicast_frag_flags { |
| 62 | UNI_FRAG_HEAD = 1 << 0, |
| 63 | UNI_FRAG_LARGETAIL = 1 << 1 |
| 64 | }; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 65 | |
| 66 | struct batman_packet { |
| 67 | uint8_t packet_type; |
| 68 | uint8_t version; /* batman version field */ |
Antonio Quartulli | 3b27ffb | 2011-05-28 14:51:06 +0200 | [diff] [blame^] | 69 | uint8_t ttl; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 70 | uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 71 | uint32_t seqno; |
| 72 | uint8_t orig[6]; |
| 73 | uint8_t prev_sender[6]; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 74 | uint8_t gw_flags; /* flags related to gateway class */ |
Antonio Quartulli | 3b27ffb | 2011-05-28 14:51:06 +0200 | [diff] [blame^] | 75 | uint8_t tq; |
| 76 | uint8_t num_tt; |
| 77 | uint8_t reserved; |
Sven Eckelmann | aa0adb1 | 2011-01-15 14:39:43 +0000 | [diff] [blame] | 78 | } __packed; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 79 | |
| 80 | #define BAT_PACKET_LEN sizeof(struct batman_packet) |
| 81 | |
| 82 | struct icmp_packet { |
| 83 | uint8_t packet_type; |
| 84 | uint8_t version; /* batman version field */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 85 | uint8_t ttl; |
Antonio Quartulli | 3b27ffb | 2011-05-28 14:51:06 +0200 | [diff] [blame^] | 86 | uint8_t msg_type; /* see ICMP message types above */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 87 | uint8_t dst[6]; |
| 88 | uint8_t orig[6]; |
| 89 | uint16_t seqno; |
| 90 | uint8_t uid; |
Antonio Quartulli | 3b27ffb | 2011-05-28 14:51:06 +0200 | [diff] [blame^] | 91 | uint8_t reserved; |
Sven Eckelmann | aa0adb1 | 2011-01-15 14:39:43 +0000 | [diff] [blame] | 92 | } __packed; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 93 | |
| 94 | #define BAT_RR_LEN 16 |
| 95 | |
| 96 | /* icmp_packet_rr must start with all fields from imcp_packet |
| 97 | * as this is assumed by code that handles ICMP packets */ |
| 98 | struct icmp_packet_rr { |
| 99 | uint8_t packet_type; |
| 100 | uint8_t version; /* batman version field */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 101 | uint8_t ttl; |
Antonio Quartulli | 3b27ffb | 2011-05-28 14:51:06 +0200 | [diff] [blame^] | 102 | uint8_t msg_type; /* see ICMP message types above */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 103 | uint8_t dst[6]; |
| 104 | uint8_t orig[6]; |
| 105 | uint16_t seqno; |
| 106 | uint8_t uid; |
| 107 | uint8_t rr_cur; |
| 108 | uint8_t rr[BAT_RR_LEN][ETH_ALEN]; |
Sven Eckelmann | aa0adb1 | 2011-01-15 14:39:43 +0000 | [diff] [blame] | 109 | } __packed; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 110 | |
| 111 | struct unicast_packet { |
| 112 | uint8_t packet_type; |
| 113 | uint8_t version; /* batman version field */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 114 | uint8_t ttl; |
Antonio Quartulli | 3b27ffb | 2011-05-28 14:51:06 +0200 | [diff] [blame^] | 115 | uint8_t reserved; |
| 116 | uint8_t dest[6]; |
Sven Eckelmann | aa0adb1 | 2011-01-15 14:39:43 +0000 | [diff] [blame] | 117 | } __packed; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 118 | |
| 119 | struct unicast_frag_packet { |
| 120 | uint8_t packet_type; |
| 121 | uint8_t version; /* batman version field */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 122 | uint8_t ttl; |
Antonio Quartulli | 3b27ffb | 2011-05-28 14:51:06 +0200 | [diff] [blame^] | 123 | uint8_t reserved; |
| 124 | uint8_t dest[6]; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 125 | uint8_t flags; |
Antonio Quartulli | 3b27ffb | 2011-05-28 14:51:06 +0200 | [diff] [blame^] | 126 | uint8_t align; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 127 | uint8_t orig[6]; |
| 128 | uint16_t seqno; |
Sven Eckelmann | aa0adb1 | 2011-01-15 14:39:43 +0000 | [diff] [blame] | 129 | } __packed; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 130 | |
| 131 | struct bcast_packet { |
| 132 | uint8_t packet_type; |
| 133 | uint8_t version; /* batman version field */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 134 | uint8_t ttl; |
Antonio Quartulli | 3b27ffb | 2011-05-28 14:51:06 +0200 | [diff] [blame^] | 135 | uint8_t reserved; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 136 | uint32_t seqno; |
Antonio Quartulli | 3b27ffb | 2011-05-28 14:51:06 +0200 | [diff] [blame^] | 137 | uint8_t orig[6]; |
Sven Eckelmann | aa0adb1 | 2011-01-15 14:39:43 +0000 | [diff] [blame] | 138 | } __packed; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 139 | |
| 140 | struct vis_packet { |
| 141 | uint8_t packet_type; |
| 142 | uint8_t version; /* batman version field */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 143 | uint8_t ttl; /* TTL */ |
Antonio Quartulli | 3b27ffb | 2011-05-28 14:51:06 +0200 | [diff] [blame^] | 144 | uint8_t vis_type; /* which type of vis-participant sent this? */ |
| 145 | uint32_t seqno; /* sequence number */ |
| 146 | uint8_t entries; /* number of entries behind this struct */ |
| 147 | uint8_t reserved; |
Sven Eckelmann | 6e215fd | 2011-05-08 12:45:45 +0200 | [diff] [blame] | 148 | uint8_t vis_orig[6]; /* originator that announces its neighbors */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 149 | uint8_t target_orig[6]; /* who should receive this packet */ |
| 150 | uint8_t sender_orig[6]; /* who sent or rebroadcasted this packet */ |
Sven Eckelmann | aa0adb1 | 2011-01-15 14:39:43 +0000 | [diff] [blame] | 151 | } __packed; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 152 | |
| 153 | #endif /* _NET_BATMAN_ADV_PACKET_H_ */ |