273-batman-adv-Convert-packet.h-to-uapi-header.patch 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665
  1. From: Sven Eckelmann <sven.eckelmann@openmesh.com>
  2. Date: Thu, 21 Dec 2017 10:17:41 +0100
  3. Subject: [PATCH] batman-adv: Convert packet.h to uapi header
  4. The header file is used by different userspace programs to inject packets
  5. or to decode sniffed packets. It should therefore be available to them as
  6. userspace header.
  7. Also other components in the kernel (like the flow dissector) require
  8. access to the packet definitions to be able to decode ETH_P_BATMAN ethernet
  9. packets.
  10. Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
  11. Signed-off-by: David S. Miller <davem@davemloft.net>
  12. ---
  13. rename net/batman-adv/packet.h => include/uapi/linux/batadv_packet.h (99%)
  14. --- a/MAINTAINERS
  15. +++ b/MAINTAINERS
  16. @@ -2551,6 +2551,7 @@ S: Maintained
  17. F: Documentation/ABI/testing/sysfs-class-net-batman-adv
  18. F: Documentation/ABI/testing/sysfs-class-net-mesh
  19. F: Documentation/networking/batman-adv.rst
  20. +F: include/uapi/linux/batadv_packet.h
  21. F: include/uapi/linux/batman_adv.h
  22. F: net/batman-adv/
  23. --- a/net/batman-adv/bat_iv_ogm.c
  24. +++ b/net/batman-adv/bat_iv_ogm.c
  25. @@ -52,6 +52,7 @@
  26. #include <linux/workqueue.h>
  27. #include <net/genetlink.h>
  28. #include <net/netlink.h>
  29. +#include <uapi/linux/batadv_packet.h>
  30. #include <uapi/linux/batman_adv.h>
  31. #include "bat_algo.h"
  32. @@ -63,7 +64,6 @@
  33. #include "netlink.h"
  34. #include "network-coding.h"
  35. #include "originator.h"
  36. -#include "packet.h"
  37. #include "routing.h"
  38. #include "send.h"
  39. #include "translation-table.h"
  40. --- a/net/batman-adv/bat_v.c
  41. +++ b/net/batman-adv/bat_v.c
  42. @@ -36,6 +36,7 @@
  43. #include <linux/workqueue.h>
  44. #include <net/genetlink.h>
  45. #include <net/netlink.h>
  46. +#include <uapi/linux/batadv_packet.h>
  47. #include <uapi/linux/batman_adv.h>
  48. #include "bat_algo.h"
  49. @@ -48,7 +49,6 @@
  50. #include "log.h"
  51. #include "netlink.h"
  52. #include "originator.h"
  53. -#include "packet.h"
  54. struct sk_buff;
  55. --- a/net/batman-adv/bat_v_elp.c
  56. +++ b/net/batman-adv/bat_v_elp.c
  57. @@ -41,13 +41,13 @@
  58. #include <linux/types.h>
  59. #include <linux/workqueue.h>
  60. #include <net/cfg80211.h>
  61. +#include <uapi/linux/batadv_packet.h>
  62. #include "bat_algo.h"
  63. #include "bat_v_ogm.h"
  64. #include "hard-interface.h"
  65. #include "log.h"
  66. #include "originator.h"
  67. -#include "packet.h"
  68. #include "routing.h"
  69. #include "send.h"
  70. --- a/net/batman-adv/bat_v_ogm.c
  71. +++ b/net/batman-adv/bat_v_ogm.c
  72. @@ -40,13 +40,13 @@
  73. #include <linux/string.h>
  74. #include <linux/types.h>
  75. #include <linux/workqueue.h>
  76. +#include <uapi/linux/batadv_packet.h>
  77. #include "bat_algo.h"
  78. #include "hard-interface.h"
  79. #include "hash.h"
  80. #include "log.h"
  81. #include "originator.h"
  82. -#include "packet.h"
  83. #include "routing.h"
  84. #include "send.h"
  85. #include "translation-table.h"
  86. --- a/net/batman-adv/bridge_loop_avoidance.c
  87. +++ b/net/batman-adv/bridge_loop_avoidance.c
  88. @@ -49,6 +49,7 @@
  89. #include <net/genetlink.h>
  90. #include <net/netlink.h>
  91. #include <net/sock.h>
  92. +#include <uapi/linux/batadv_packet.h>
  93. #include <uapi/linux/batman_adv.h>
  94. #include "hard-interface.h"
  95. @@ -56,7 +57,6 @@
  96. #include "log.h"
  97. #include "netlink.h"
  98. #include "originator.h"
  99. -#include "packet.h"
  100. #include "soft-interface.h"
  101. #include "sysfs.h"
  102. #include "translation-table.h"
  103. --- a/net/batman-adv/distributed-arp-table.h
  104. +++ b/net/batman-adv/distributed-arp-table.h
  105. @@ -23,9 +23,9 @@
  106. #include <linux/compiler.h>
  107. #include <linux/netdevice.h>
  108. #include <linux/types.h>
  109. +#include <uapi/linux/batadv_packet.h>
  110. #include "originator.h"
  111. -#include "packet.h"
  112. struct seq_file;
  113. struct sk_buff;
  114. --- a/net/batman-adv/fragmentation.c
  115. +++ b/net/batman-adv/fragmentation.c
  116. @@ -32,10 +32,10 @@
  117. #include <linux/slab.h>
  118. #include <linux/spinlock.h>
  119. #include <linux/string.h>
  120. +#include <uapi/linux/batadv_packet.h>
  121. #include "hard-interface.h"
  122. #include "originator.h"
  123. -#include "packet.h"
  124. #include "routing.h"
  125. #include "send.h"
  126. #include "soft-interface.h"
  127. --- a/net/batman-adv/gateway_client.c
  128. +++ b/net/batman-adv/gateway_client.c
  129. @@ -43,6 +43,7 @@
  130. #include <linux/stddef.h>
  131. #include <linux/udp.h>
  132. #include <net/sock.h>
  133. +#include <uapi/linux/batadv_packet.h>
  134. #include <uapi/linux/batman_adv.h>
  135. #include "gateway_common.h"
  136. @@ -50,7 +51,6 @@
  137. #include "log.h"
  138. #include "netlink.h"
  139. #include "originator.h"
  140. -#include "packet.h"
  141. #include "routing.h"
  142. #include "soft-interface.h"
  143. #include "sysfs.h"
  144. --- a/net/batman-adv/gateway_common.c
  145. +++ b/net/batman-adv/gateway_common.c
  146. @@ -26,10 +26,10 @@
  147. #include <linux/netdevice.h>
  148. #include <linux/stddef.h>
  149. #include <linux/string.h>
  150. +#include <uapi/linux/batadv_packet.h>
  151. #include "gateway_client.h"
  152. #include "log.h"
  153. -#include "packet.h"
  154. #include "tvlv.h"
  155. /**
  156. --- a/net/batman-adv/hard-interface.c
  157. +++ b/net/batman-adv/hard-interface.c
  158. @@ -37,6 +37,7 @@
  159. #include <linux/spinlock.h>
  160. #include <net/net_namespace.h>
  161. #include <net/rtnetlink.h>
  162. +#include <uapi/linux/batadv_packet.h>
  163. #include "bat_v.h"
  164. #include "bridge_loop_avoidance.h"
  165. @@ -45,7 +46,6 @@
  166. #include "gateway_client.h"
  167. #include "log.h"
  168. #include "originator.h"
  169. -#include "packet.h"
  170. #include "send.h"
  171. #include "soft-interface.h"
  172. #include "sysfs.h"
  173. --- a/net/batman-adv/icmp_socket.c
  174. +++ b/net/batman-adv/icmp_socket.c
  175. @@ -42,11 +42,11 @@
  176. #include <linux/string.h>
  177. #include <linux/uaccess.h>
  178. #include <linux/wait.h>
  179. +#include <uapi/linux/batadv_packet.h>
  180. #include "hard-interface.h"
  181. #include "log.h"
  182. #include "originator.h"
  183. -#include "packet.h"
  184. #include "send.h"
  185. static struct batadv_socket_client *batadv_socket_client_hash[256];
  186. --- a/net/batman-adv/main.c
  187. +++ b/net/batman-adv/main.c
  188. @@ -45,6 +45,7 @@
  189. #include <linux/workqueue.h>
  190. #include <net/dsfield.h>
  191. #include <net/rtnetlink.h>
  192. +#include <uapi/linux/batadv_packet.h>
  193. #include <uapi/linux/batman_adv.h>
  194. #include "bat_algo.h"
  195. @@ -62,7 +63,6 @@
  196. #include "netlink.h"
  197. #include "network-coding.h"
  198. #include "originator.h"
  199. -#include "packet.h"
  200. #include "routing.h"
  201. #include "send.h"
  202. #include "soft-interface.h"
  203. --- a/net/batman-adv/main.h
  204. +++ b/net/batman-adv/main.h
  205. @@ -190,8 +190,8 @@ enum batadv_uev_type {
  206. #include <linux/jiffies.h>
  207. #include <linux/percpu.h>
  208. #include <linux/types.h>
  209. +#include <uapi/linux/batadv_packet.h>
  210. -#include "packet.h"
  211. #include "types.h"
  212. struct net_device;
  213. --- a/net/batman-adv/multicast.c
  214. +++ b/net/batman-adv/multicast.c
  215. @@ -54,11 +54,11 @@
  216. #include <net/if_inet6.h>
  217. #include <net/ip.h>
  218. #include <net/ipv6.h>
  219. +#include <uapi/linux/batadv_packet.h>
  220. #include "hard-interface.h"
  221. #include "hash.h"
  222. #include "log.h"
  223. -#include "packet.h"
  224. #include "translation-table.h"
  225. #include "tvlv.h"
  226. --- a/net/batman-adv/netlink.c
  227. +++ b/net/batman-adv/netlink.c
  228. @@ -39,6 +39,7 @@
  229. #include <net/genetlink.h>
  230. #include <net/netlink.h>
  231. #include <net/sock.h>
  232. +#include <uapi/linux/batadv_packet.h>
  233. #include <uapi/linux/batman_adv.h>
  234. #include "bat_algo.h"
  235. @@ -46,7 +47,6 @@
  236. #include "gateway_client.h"
  237. #include "hard-interface.h"
  238. #include "originator.h"
  239. -#include "packet.h"
  240. #include "soft-interface.h"
  241. #include "tp_meter.h"
  242. #include "translation-table.h"
  243. --- a/net/batman-adv/network-coding.c
  244. +++ b/net/batman-adv/network-coding.c
  245. @@ -47,12 +47,12 @@
  246. #include <linux/stddef.h>
  247. #include <linux/string.h>
  248. #include <linux/workqueue.h>
  249. +#include <uapi/linux/batadv_packet.h>
  250. #include "hard-interface.h"
  251. #include "hash.h"
  252. #include "log.h"
  253. #include "originator.h"
  254. -#include "packet.h"
  255. #include "routing.h"
  256. #include "send.h"
  257. #include "tvlv.h"
  258. --- a/net/batman-adv/packet.h
  259. +++ /dev/null
  260. @@ -1,622 +0,0 @@
  261. -/* Copyright (C) 2007-2017 B.A.T.M.A.N. contributors:
  262. - *
  263. - * Marek Lindner, Simon Wunderlich
  264. - *
  265. - * This program is free software; you can redistribute it and/or
  266. - * modify it under the terms of version 2 of the GNU General Public
  267. - * License as published by the Free Software Foundation.
  268. - *
  269. - * This program is distributed in the hope that it will be useful, but
  270. - * WITHOUT ANY WARRANTY; without even the implied warranty of
  271. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  272. - * General Public License for more details.
  273. - *
  274. - * You should have received a copy of the GNU General Public License
  275. - * along with this program; if not, see <http://www.gnu.org/licenses/>.
  276. - */
  277. -
  278. -#ifndef _NET_BATMAN_ADV_PACKET_H_
  279. -#define _NET_BATMAN_ADV_PACKET_H_
  280. -
  281. -#include <asm/byteorder.h>
  282. -#include <linux/if_ether.h>
  283. -#include <linux/types.h>
  284. -
  285. -#define batadv_tp_is_error(n) ((__u8)(n) > 127 ? 1 : 0)
  286. -
  287. -/**
  288. - * enum batadv_packettype - types for batman-adv encapsulated packets
  289. - * @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV
  290. - * @BATADV_BCAST: broadcast packets carrying broadcast payload
  291. - * @BATADV_CODED: network coded packets
  292. - * @BATADV_ELP: echo location packets for B.A.T.M.A.N. V
  293. - * @BATADV_OGM2: originator messages for B.A.T.M.A.N. V
  294. - *
  295. - * @BATADV_UNICAST: unicast packets carrying unicast payload traffic
  296. - * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original
  297. - * payload packet
  298. - * @BATADV_UNICAST_4ADDR: unicast packet including the originator address of
  299. - * the sender
  300. - * @BATADV_ICMP: unicast packet like IP ICMP used for ping or traceroute
  301. - * @BATADV_UNICAST_TVLV: unicast packet carrying TVLV containers
  302. - */
  303. -enum batadv_packettype {
  304. - /* 0x00 - 0x3f: local packets or special rules for handling */
  305. - BATADV_IV_OGM = 0x00,
  306. - BATADV_BCAST = 0x01,
  307. - BATADV_CODED = 0x02,
  308. - BATADV_ELP = 0x03,
  309. - BATADV_OGM2 = 0x04,
  310. - /* 0x40 - 0x7f: unicast */
  311. -#define BATADV_UNICAST_MIN 0x40
  312. - BATADV_UNICAST = 0x40,
  313. - BATADV_UNICAST_FRAG = 0x41,
  314. - BATADV_UNICAST_4ADDR = 0x42,
  315. - BATADV_ICMP = 0x43,
  316. - BATADV_UNICAST_TVLV = 0x44,
  317. -#define BATADV_UNICAST_MAX 0x7f
  318. - /* 0x80 - 0xff: reserved */
  319. -};
  320. -
  321. -/**
  322. - * enum batadv_subtype - packet subtype for unicast4addr
  323. - * @BATADV_P_DATA: user payload
  324. - * @BATADV_P_DAT_DHT_GET: DHT request message
  325. - * @BATADV_P_DAT_DHT_PUT: DHT store message
  326. - * @BATADV_P_DAT_CACHE_REPLY: ARP reply generated by DAT
  327. - */
  328. -enum batadv_subtype {
  329. - BATADV_P_DATA = 0x01,
  330. - BATADV_P_DAT_DHT_GET = 0x02,
  331. - BATADV_P_DAT_DHT_PUT = 0x03,
  332. - BATADV_P_DAT_CACHE_REPLY = 0x04,
  333. -};
  334. -
  335. -/* this file is included by batctl which needs these defines */
  336. -#define BATADV_COMPAT_VERSION 15
  337. -
  338. -/**
  339. - * enum batadv_iv_flags - flags used in B.A.T.M.A.N. IV OGM packets
  340. - * @BATADV_NOT_BEST_NEXT_HOP: flag is set when ogm packet is forwarded and was
  341. - * previously received from someone else than the best neighbor.
  342. - * @BATADV_PRIMARIES_FIRST_HOP: flag unused.
  343. - * @BATADV_DIRECTLINK: flag is for the first hop or if rebroadcasted from a
  344. - * one hop neighbor on the interface where it was originally received.
  345. - */
  346. -enum batadv_iv_flags {
  347. - BATADV_NOT_BEST_NEXT_HOP = 1UL << 0,
  348. - BATADV_PRIMARIES_FIRST_HOP = 1UL << 1,
  349. - BATADV_DIRECTLINK = 1UL << 2,
  350. -};
  351. -
  352. -/* ICMP message types */
  353. -enum batadv_icmp_packettype {
  354. - BATADV_ECHO_REPLY = 0,
  355. - BATADV_DESTINATION_UNREACHABLE = 3,
  356. - BATADV_ECHO_REQUEST = 8,
  357. - BATADV_TTL_EXCEEDED = 11,
  358. - BATADV_PARAMETER_PROBLEM = 12,
  359. - BATADV_TP = 15,
  360. -};
  361. -
  362. -/**
  363. - * enum batadv_mcast_flags - flags for multicast capabilities and settings
  364. - * @BATADV_MCAST_WANT_ALL_UNSNOOPABLES: we want all packets destined for
  365. - * 224.0.0.0/24 or ff02::1
  366. - * @BATADV_MCAST_WANT_ALL_IPV4: we want all IPv4 multicast packets
  367. - * @BATADV_MCAST_WANT_ALL_IPV6: we want all IPv6 multicast packets
  368. - */
  369. -enum batadv_mcast_flags {
  370. - BATADV_MCAST_WANT_ALL_UNSNOOPABLES = 1UL << 0,
  371. - BATADV_MCAST_WANT_ALL_IPV4 = 1UL << 1,
  372. - BATADV_MCAST_WANT_ALL_IPV6 = 1UL << 2,
  373. -};
  374. -
  375. -/* tt data subtypes */
  376. -#define BATADV_TT_DATA_TYPE_MASK 0x0F
  377. -
  378. -/**
  379. - * enum batadv_tt_data_flags - flags for tt data tvlv
  380. - * @BATADV_TT_OGM_DIFF: TT diff propagated through OGM
  381. - * @BATADV_TT_REQUEST: TT request message
  382. - * @BATADV_TT_RESPONSE: TT response message
  383. - * @BATADV_TT_FULL_TABLE: contains full table to replace existing table
  384. - */
  385. -enum batadv_tt_data_flags {
  386. - BATADV_TT_OGM_DIFF = 1UL << 0,
  387. - BATADV_TT_REQUEST = 1UL << 1,
  388. - BATADV_TT_RESPONSE = 1UL << 2,
  389. - BATADV_TT_FULL_TABLE = 1UL << 4,
  390. -};
  391. -
  392. -/**
  393. - * enum batadv_vlan_flags - flags for the four MSB of any vlan ID field
  394. - * @BATADV_VLAN_HAS_TAG: whether the field contains a valid vlan tag or not
  395. - */
  396. -enum batadv_vlan_flags {
  397. - BATADV_VLAN_HAS_TAG = 1UL << 15,
  398. -};
  399. -
  400. -/* claim frame types for the bridge loop avoidance */
  401. -enum batadv_bla_claimframe {
  402. - BATADV_CLAIM_TYPE_CLAIM = 0x00,
  403. - BATADV_CLAIM_TYPE_UNCLAIM = 0x01,
  404. - BATADV_CLAIM_TYPE_ANNOUNCE = 0x02,
  405. - BATADV_CLAIM_TYPE_REQUEST = 0x03,
  406. - BATADV_CLAIM_TYPE_LOOPDETECT = 0x04,
  407. -};
  408. -
  409. -/**
  410. - * enum batadv_tvlv_type - tvlv type definitions
  411. - * @BATADV_TVLV_GW: gateway tvlv
  412. - * @BATADV_TVLV_DAT: distributed arp table tvlv
  413. - * @BATADV_TVLV_NC: network coding tvlv
  414. - * @BATADV_TVLV_TT: translation table tvlv
  415. - * @BATADV_TVLV_ROAM: roaming advertisement tvlv
  416. - * @BATADV_TVLV_MCAST: multicast capability tvlv
  417. - */
  418. -enum batadv_tvlv_type {
  419. - BATADV_TVLV_GW = 0x01,
  420. - BATADV_TVLV_DAT = 0x02,
  421. - BATADV_TVLV_NC = 0x03,
  422. - BATADV_TVLV_TT = 0x04,
  423. - BATADV_TVLV_ROAM = 0x05,
  424. - BATADV_TVLV_MCAST = 0x06,
  425. -};
  426. -
  427. -#pragma pack(2)
  428. -/* the destination hardware field in the ARP frame is used to
  429. - * transport the claim type and the group id
  430. - */
  431. -struct batadv_bla_claim_dst {
  432. - __u8 magic[3]; /* FF:43:05 */
  433. - __u8 type; /* bla_claimframe */
  434. - __be16 group; /* group id */
  435. -};
  436. -
  437. -#pragma pack()
  438. -
  439. -/**
  440. - * struct batadv_ogm_packet - ogm (routing protocol) packet
  441. - * @packet_type: batman-adv packet type, part of the general header
  442. - * @version: batman-adv protocol version, part of the genereal header
  443. - * @ttl: time to live for this packet, part of the genereal header
  444. - * @flags: contains routing relevant flags - see enum batadv_iv_flags
  445. - * @seqno: sequence identification
  446. - * @orig: address of the source node
  447. - * @prev_sender: address of the previous sender
  448. - * @reserved: reserved byte for alignment
  449. - * @tq: transmission quality
  450. - * @tvlv_len: length of tvlv data following the ogm header
  451. - */
  452. -struct batadv_ogm_packet {
  453. - __u8 packet_type;
  454. - __u8 version;
  455. - __u8 ttl;
  456. - __u8 flags;
  457. - __be32 seqno;
  458. - __u8 orig[ETH_ALEN];
  459. - __u8 prev_sender[ETH_ALEN];
  460. - __u8 reserved;
  461. - __u8 tq;
  462. - __be16 tvlv_len;
  463. - /* __packed is not needed as the struct size is divisible by 4,
  464. - * and the largest data type in this struct has a size of 4.
  465. - */
  466. -};
  467. -
  468. -#define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
  469. -
  470. -/**
  471. - * struct batadv_ogm2_packet - ogm2 (routing protocol) packet
  472. - * @packet_type: batman-adv packet type, part of the general header
  473. - * @version: batman-adv protocol version, part of the general header
  474. - * @ttl: time to live for this packet, part of the general header
  475. - * @flags: reseved for routing relevant flags - currently always 0
  476. - * @seqno: sequence number
  477. - * @orig: originator mac address
  478. - * @tvlv_len: length of the appended tvlv buffer (in bytes)
  479. - * @throughput: the currently flooded path throughput
  480. - */
  481. -struct batadv_ogm2_packet {
  482. - __u8 packet_type;
  483. - __u8 version;
  484. - __u8 ttl;
  485. - __u8 flags;
  486. - __be32 seqno;
  487. - __u8 orig[ETH_ALEN];
  488. - __be16 tvlv_len;
  489. - __be32 throughput;
  490. - /* __packed is not needed as the struct size is divisible by 4,
  491. - * and the largest data type in this struct has a size of 4.
  492. - */
  493. -};
  494. -
  495. -#define BATADV_OGM2_HLEN sizeof(struct batadv_ogm2_packet)
  496. -
  497. -/**
  498. - * struct batadv_elp_packet - elp (neighbor discovery) packet
  499. - * @packet_type: batman-adv packet type, part of the general header
  500. - * @version: batman-adv protocol version, part of the genereal header
  501. - * @orig: originator mac address
  502. - * @seqno: sequence number
  503. - * @elp_interval: currently used ELP sending interval in ms
  504. - */
  505. -struct batadv_elp_packet {
  506. - __u8 packet_type;
  507. - __u8 version;
  508. - __u8 orig[ETH_ALEN];
  509. - __be32 seqno;
  510. - __be32 elp_interval;
  511. -};
  512. -
  513. -#define BATADV_ELP_HLEN sizeof(struct batadv_elp_packet)
  514. -
  515. -/**
  516. - * struct batadv_icmp_header - common members among all the ICMP packets
  517. - * @packet_type: batman-adv packet type, part of the general header
  518. - * @version: batman-adv protocol version, part of the genereal header
  519. - * @ttl: time to live for this packet, part of the genereal header
  520. - * @msg_type: ICMP packet type
  521. - * @dst: address of the destination node
  522. - * @orig: address of the source node
  523. - * @uid: local ICMP socket identifier
  524. - * @align: not used - useful for alignment purposes only
  525. - *
  526. - * This structure is used for ICMP packets parsing only and it is never sent
  527. - * over the wire. The alignment field at the end is there to ensure that
  528. - * members are padded the same way as they are in real packets.
  529. - */
  530. -struct batadv_icmp_header {
  531. - __u8 packet_type;
  532. - __u8 version;
  533. - __u8 ttl;
  534. - __u8 msg_type; /* see ICMP message types above */
  535. - __u8 dst[ETH_ALEN];
  536. - __u8 orig[ETH_ALEN];
  537. - __u8 uid;
  538. - __u8 align[3];
  539. -};
  540. -
  541. -/**
  542. - * struct batadv_icmp_packet - ICMP packet
  543. - * @packet_type: batman-adv packet type, part of the general header
  544. - * @version: batman-adv protocol version, part of the genereal header
  545. - * @ttl: time to live for this packet, part of the genereal header
  546. - * @msg_type: ICMP packet type
  547. - * @dst: address of the destination node
  548. - * @orig: address of the source node
  549. - * @uid: local ICMP socket identifier
  550. - * @reserved: not used - useful for alignment
  551. - * @seqno: ICMP sequence number
  552. - */
  553. -struct batadv_icmp_packet {
  554. - __u8 packet_type;
  555. - __u8 version;
  556. - __u8 ttl;
  557. - __u8 msg_type; /* see ICMP message types above */
  558. - __u8 dst[ETH_ALEN];
  559. - __u8 orig[ETH_ALEN];
  560. - __u8 uid;
  561. - __u8 reserved;
  562. - __be16 seqno;
  563. -};
  564. -
  565. -/**
  566. - * struct batadv_icmp_tp_packet - ICMP TP Meter packet
  567. - * @packet_type: batman-adv packet type, part of the general header
  568. - * @version: batman-adv protocol version, part of the genereal header
  569. - * @ttl: time to live for this packet, part of the genereal header
  570. - * @msg_type: ICMP packet type
  571. - * @dst: address of the destination node
  572. - * @orig: address of the source node
  573. - * @uid: local ICMP socket identifier
  574. - * @subtype: TP packet subtype (see batadv_icmp_tp_subtype)
  575. - * @session: TP session identifier
  576. - * @seqno: the TP sequence number
  577. - * @timestamp: time when the packet has been sent. This value is filled in a
  578. - * TP_MSG and echoed back in the next TP_ACK so that the sender can compute the
  579. - * RTT. Since it is read only by the host which wrote it, there is no need to
  580. - * store it using network order
  581. - */
  582. -struct batadv_icmp_tp_packet {
  583. - __u8 packet_type;
  584. - __u8 version;
  585. - __u8 ttl;
  586. - __u8 msg_type; /* see ICMP message types above */
  587. - __u8 dst[ETH_ALEN];
  588. - __u8 orig[ETH_ALEN];
  589. - __u8 uid;
  590. - __u8 subtype;
  591. - __u8 session[2];
  592. - __be32 seqno;
  593. - __be32 timestamp;
  594. -};
  595. -
  596. -/**
  597. - * enum batadv_icmp_tp_subtype - ICMP TP Meter packet subtypes
  598. - * @BATADV_TP_MSG: Msg from sender to receiver
  599. - * @BATADV_TP_ACK: acknowledgment from receiver to sender
  600. - */
  601. -enum batadv_icmp_tp_subtype {
  602. - BATADV_TP_MSG = 0,
  603. - BATADV_TP_ACK,
  604. -};
  605. -
  606. -#define BATADV_RR_LEN 16
  607. -
  608. -/**
  609. - * struct batadv_icmp_packet_rr - ICMP RouteRecord packet
  610. - * @packet_type: batman-adv packet type, part of the general header
  611. - * @version: batman-adv protocol version, part of the genereal header
  612. - * @ttl: time to live for this packet, part of the genereal header
  613. - * @msg_type: ICMP packet type
  614. - * @dst: address of the destination node
  615. - * @orig: address of the source node
  616. - * @uid: local ICMP socket identifier
  617. - * @rr_cur: number of entries the rr array
  618. - * @seqno: ICMP sequence number
  619. - * @rr: route record array
  620. - */
  621. -struct batadv_icmp_packet_rr {
  622. - __u8 packet_type;
  623. - __u8 version;
  624. - __u8 ttl;
  625. - __u8 msg_type; /* see ICMP message types above */
  626. - __u8 dst[ETH_ALEN];
  627. - __u8 orig[ETH_ALEN];
  628. - __u8 uid;
  629. - __u8 rr_cur;
  630. - __be16 seqno;
  631. - __u8 rr[BATADV_RR_LEN][ETH_ALEN];
  632. -};
  633. -
  634. -#define BATADV_ICMP_MAX_PACKET_SIZE sizeof(struct batadv_icmp_packet_rr)
  635. -
  636. -/* All packet headers in front of an ethernet header have to be completely
  637. - * divisible by 2 but not by 4 to make the payload after the ethernet
  638. - * header again 4 bytes boundary aligned.
  639. - *
  640. - * A packing of 2 is necessary to avoid extra padding at the end of the struct
  641. - * caused by a structure member which is larger than two bytes. Otherwise
  642. - * the structure would not fulfill the previously mentioned rule to avoid the
  643. - * misalignment of the payload after the ethernet header. It may also lead to
  644. - * leakage of information when the padding it not initialized before sending.
  645. - */
  646. -#pragma pack(2)
  647. -
  648. -/**
  649. - * struct batadv_unicast_packet - unicast packet for network payload
  650. - * @packet_type: batman-adv packet type, part of the general header
  651. - * @version: batman-adv protocol version, part of the genereal header
  652. - * @ttl: time to live for this packet, part of the genereal header
  653. - * @ttvn: translation table version number
  654. - * @dest: originator destination of the unicast packet
  655. - */
  656. -struct batadv_unicast_packet {
  657. - __u8 packet_type;
  658. - __u8 version;
  659. - __u8 ttl;
  660. - __u8 ttvn; /* destination translation table version number */
  661. - __u8 dest[ETH_ALEN];
  662. - /* "4 bytes boundary + 2 bytes" long to make the payload after the
  663. - * following ethernet header again 4 bytes boundary aligned
  664. - */
  665. -};
  666. -
  667. -/**
  668. - * struct batadv_unicast_4addr_packet - extended unicast packet
  669. - * @u: common unicast packet header
  670. - * @src: address of the source
  671. - * @subtype: packet subtype
  672. - * @reserved: reserved byte for alignment
  673. - */
  674. -struct batadv_unicast_4addr_packet {
  675. - struct batadv_unicast_packet u;
  676. - __u8 src[ETH_ALEN];
  677. - __u8 subtype;
  678. - __u8 reserved;
  679. - /* "4 bytes boundary + 2 bytes" long to make the payload after the
  680. - * following ethernet header again 4 bytes boundary aligned
  681. - */
  682. -};
  683. -
  684. -/**
  685. - * struct batadv_frag_packet - fragmented packet
  686. - * @packet_type: batman-adv packet type, part of the general header
  687. - * @version: batman-adv protocol version, part of the genereal header
  688. - * @ttl: time to live for this packet, part of the genereal header
  689. - * @dest: final destination used when routing fragments
  690. - * @orig: originator of the fragment used when merging the packet
  691. - * @no: fragment number within this sequence
  692. - * @priority: priority of frame, from ToS IP precedence or 802.1p
  693. - * @reserved: reserved byte for alignment
  694. - * @seqno: sequence identification
  695. - * @total_size: size of the merged packet
  696. - */
  697. -struct batadv_frag_packet {
  698. - __u8 packet_type;
  699. - __u8 version; /* batman version field */
  700. - __u8 ttl;
  701. -#if defined(__BIG_ENDIAN_BITFIELD)
  702. - __u8 no:4;
  703. - __u8 priority:3;
  704. - __u8 reserved:1;
  705. -#elif defined(__LITTLE_ENDIAN_BITFIELD)
  706. - __u8 reserved:1;
  707. - __u8 priority:3;
  708. - __u8 no:4;
  709. -#else
  710. -#error "unknown bitfield endianness"
  711. -#endif
  712. - __u8 dest[ETH_ALEN];
  713. - __u8 orig[ETH_ALEN];
  714. - __be16 seqno;
  715. - __be16 total_size;
  716. -};
  717. -
  718. -/**
  719. - * struct batadv_bcast_packet - broadcast packet for network payload
  720. - * @packet_type: batman-adv packet type, part of the general header
  721. - * @version: batman-adv protocol version, part of the genereal header
  722. - * @ttl: time to live for this packet, part of the genereal header
  723. - * @reserved: reserved byte for alignment
  724. - * @seqno: sequence identification
  725. - * @orig: originator of the broadcast packet
  726. - */
  727. -struct batadv_bcast_packet {
  728. - __u8 packet_type;
  729. - __u8 version; /* batman version field */
  730. - __u8 ttl;
  731. - __u8 reserved;
  732. - __be32 seqno;
  733. - __u8 orig[ETH_ALEN];
  734. - /* "4 bytes boundary + 2 bytes" long to make the payload after the
  735. - * following ethernet header again 4 bytes boundary aligned
  736. - */
  737. -};
  738. -
  739. -/**
  740. - * struct batadv_coded_packet - network coded packet
  741. - * @packet_type: batman-adv packet type, part of the general header
  742. - * @version: batman-adv protocol version, part of the genereal header
  743. - * @ttl: time to live for this packet, part of the genereal header
  744. - * @first_source: original source of first included packet
  745. - * @first_orig_dest: original destinal of first included packet
  746. - * @first_crc: checksum of first included packet
  747. - * @first_ttvn: tt-version number of first included packet
  748. - * @second_ttl: ttl of second packet
  749. - * @second_dest: second receiver of this coded packet
  750. - * @second_source: original source of second included packet
  751. - * @second_orig_dest: original destination of second included packet
  752. - * @second_crc: checksum of second included packet
  753. - * @second_ttvn: tt version number of second included packet
  754. - * @coded_len: length of network coded part of the payload
  755. - */
  756. -struct batadv_coded_packet {
  757. - __u8 packet_type;
  758. - __u8 version; /* batman version field */
  759. - __u8 ttl;
  760. - __u8 first_ttvn;
  761. - /* __u8 first_dest[ETH_ALEN]; - saved in mac header destination */
  762. - __u8 first_source[ETH_ALEN];
  763. - __u8 first_orig_dest[ETH_ALEN];
  764. - __be32 first_crc;
  765. - __u8 second_ttl;
  766. - __u8 second_ttvn;
  767. - __u8 second_dest[ETH_ALEN];
  768. - __u8 second_source[ETH_ALEN];
  769. - __u8 second_orig_dest[ETH_ALEN];
  770. - __be32 second_crc;
  771. - __be16 coded_len;
  772. -};
  773. -
  774. -#pragma pack()
  775. -
  776. -/**
  777. - * struct batadv_unicast_tvlv_packet - generic unicast packet with tvlv payload
  778. - * @packet_type: batman-adv packet type, part of the general header
  779. - * @version: batman-adv protocol version, part of the genereal header
  780. - * @ttl: time to live for this packet, part of the genereal header
  781. - * @reserved: reserved field (for packet alignment)
  782. - * @src: address of the source
  783. - * @dst: address of the destination
  784. - * @tvlv_len: length of tvlv data following the unicast tvlv header
  785. - * @align: 2 bytes to align the header to a 4 byte boundary
  786. - */
  787. -struct batadv_unicast_tvlv_packet {
  788. - __u8 packet_type;
  789. - __u8 version; /* batman version field */
  790. - __u8 ttl;
  791. - __u8 reserved;
  792. - __u8 dst[ETH_ALEN];
  793. - __u8 src[ETH_ALEN];
  794. - __be16 tvlv_len;
  795. - __u16 align;
  796. -};
  797. -
  798. -/**
  799. - * struct batadv_tvlv_hdr - base tvlv header struct
  800. - * @type: tvlv container type (see batadv_tvlv_type)
  801. - * @version: tvlv container version
  802. - * @len: tvlv container length
  803. - */
  804. -struct batadv_tvlv_hdr {
  805. - __u8 type;
  806. - __u8 version;
  807. - __be16 len;
  808. -};
  809. -
  810. -/**
  811. - * struct batadv_tvlv_gateway_data - gateway data propagated through gw tvlv
  812. - * container
  813. - * @bandwidth_down: advertised uplink download bandwidth
  814. - * @bandwidth_up: advertised uplink upload bandwidth
  815. - */
  816. -struct batadv_tvlv_gateway_data {
  817. - __be32 bandwidth_down;
  818. - __be32 bandwidth_up;
  819. -};
  820. -
  821. -/**
  822. - * struct batadv_tvlv_tt_data - tt data propagated through the tt tvlv container
  823. - * @flags: translation table flags (see batadv_tt_data_flags)
  824. - * @ttvn: translation table version number
  825. - * @num_vlan: number of announced VLANs. In the TVLV this struct is followed by
  826. - * one batadv_tvlv_tt_vlan_data object per announced vlan
  827. - */
  828. -struct batadv_tvlv_tt_data {
  829. - __u8 flags;
  830. - __u8 ttvn;
  831. - __be16 num_vlan;
  832. -};
  833. -
  834. -/**
  835. - * struct batadv_tvlv_tt_vlan_data - vlan specific tt data propagated through
  836. - * the tt tvlv container
  837. - * @crc: crc32 checksum of the entries belonging to this vlan
  838. - * @vid: vlan identifier
  839. - * @reserved: unused, useful for alignment purposes
  840. - */
  841. -struct batadv_tvlv_tt_vlan_data {
  842. - __be32 crc;
  843. - __be16 vid;
  844. - __u16 reserved;
  845. -};
  846. -
  847. -/**
  848. - * struct batadv_tvlv_tt_change - translation table diff data
  849. - * @flags: status indicators concerning the non-mesh client (see
  850. - * batadv_tt_client_flags)
  851. - * @reserved: reserved field - useful for alignment purposes only
  852. - * @addr: mac address of non-mesh client that triggered this tt change
  853. - * @vid: VLAN identifier
  854. - */
  855. -struct batadv_tvlv_tt_change {
  856. - __u8 flags;
  857. - __u8 reserved[3];
  858. - __u8 addr[ETH_ALEN];
  859. - __be16 vid;
  860. -};
  861. -
  862. -/**
  863. - * struct batadv_tvlv_roam_adv - roaming advertisement
  864. - * @client: mac address of roaming client
  865. - * @vid: VLAN identifier
  866. - */
  867. -struct batadv_tvlv_roam_adv {
  868. - __u8 client[ETH_ALEN];
  869. - __be16 vid;
  870. -};
  871. -
  872. -/**
  873. - * struct batadv_tvlv_mcast_data - payload of a multicast tvlv
  874. - * @flags: multicast flags announced by the orig node
  875. - * @reserved: reserved field
  876. - */
  877. -struct batadv_tvlv_mcast_data {
  878. - __u8 flags;
  879. - __u8 reserved[3];
  880. -};
  881. -
  882. -#endif /* _NET_BATMAN_ADV_PACKET_H_ */
  883. --- a/net/batman-adv/routing.c
  884. +++ b/net/batman-adv/routing.c
  885. @@ -33,6 +33,7 @@
  886. #include <linux/skbuff.h>
  887. #include <linux/spinlock.h>
  888. #include <linux/stddef.h>
  889. +#include <uapi/linux/batadv_packet.h>
  890. #include "bitarray.h"
  891. #include "bridge_loop_avoidance.h"
  892. @@ -43,7 +44,6 @@
  893. #include "log.h"
  894. #include "network-coding.h"
  895. #include "originator.h"
  896. -#include "packet.h"
  897. #include "send.h"
  898. #include "soft-interface.h"
  899. #include "tp_meter.h"
  900. --- a/net/batman-adv/send.h
  901. +++ b/net/batman-adv/send.h
  902. @@ -23,8 +23,7 @@
  903. #include <linux/compiler.h>
  904. #include <linux/spinlock.h>
  905. #include <linux/types.h>
  906. -
  907. -#include "packet.h"
  908. +#include <uapi/linux/batadv_packet.h>
  909. struct sk_buff;
  910. --- a/net/batman-adv/soft-interface.c
  911. +++ b/net/batman-adv/soft-interface.c
  912. @@ -48,6 +48,7 @@
  913. #include <linux/stddef.h>
  914. #include <linux/string.h>
  915. #include <linux/types.h>
  916. +#include <uapi/linux/batadv_packet.h>
  917. #include "bat_algo.h"
  918. #include "bridge_loop_avoidance.h"
  919. @@ -59,7 +60,6 @@
  920. #include "multicast.h"
  921. #include "network-coding.h"
  922. #include "originator.h"
  923. -#include "packet.h"
  924. #include "send.h"
  925. #include "sysfs.h"
  926. #include "translation-table.h"
  927. --- a/net/batman-adv/sysfs.c
  928. +++ b/net/batman-adv/sysfs.c
  929. @@ -37,6 +37,7 @@
  930. #include <linux/string.h>
  931. #include <linux/stringify.h>
  932. #include <linux/workqueue.h>
  933. +#include <uapi/linux/batadv_packet.h>
  934. #include "bridge_loop_avoidance.h"
  935. #include "distributed-arp-table.h"
  936. @@ -45,7 +46,6 @@
  937. #include "hard-interface.h"
  938. #include "log.h"
  939. #include "network-coding.h"
  940. -#include "packet.h"
  941. #include "soft-interface.h"
  942. static struct net_device *batadv_kobj_to_netdev(struct kobject *obj)
  943. --- a/net/batman-adv/tp_meter.c
  944. +++ b/net/batman-adv/tp_meter.c
  945. @@ -48,13 +48,13 @@
  946. #include <linux/timer.h>
  947. #include <linux/wait.h>
  948. #include <linux/workqueue.h>
  949. +#include <uapi/linux/batadv_packet.h>
  950. #include <uapi/linux/batman_adv.h>
  951. #include "hard-interface.h"
  952. #include "log.h"
  953. #include "netlink.h"
  954. #include "originator.h"
  955. -#include "packet.h"
  956. #include "send.h"
  957. /**
  958. --- a/net/batman-adv/translation-table.c
  959. +++ b/net/batman-adv/translation-table.c
  960. @@ -50,6 +50,7 @@
  961. #include <net/genetlink.h>
  962. #include <net/netlink.h>
  963. #include <net/sock.h>
  964. +#include <uapi/linux/batadv_packet.h>
  965. #include <uapi/linux/batman_adv.h>
  966. #include "bridge_loop_avoidance.h"
  967. @@ -58,7 +59,6 @@
  968. #include "log.h"
  969. #include "netlink.h"
  970. #include "originator.h"
  971. -#include "packet.h"
  972. #include "soft-interface.h"
  973. #include "tvlv.h"
  974. --- a/net/batman-adv/tvlv.c
  975. +++ b/net/batman-adv/tvlv.c
  976. @@ -35,9 +35,9 @@
  977. #include <linux/stddef.h>
  978. #include <linux/string.h>
  979. #include <linux/types.h>
  980. +#include <uapi/linux/batadv_packet.h>
  981. #include "originator.h"
  982. -#include "packet.h"
  983. #include "send.h"
  984. #include "tvlv.h"
  985. --- a/net/batman-adv/types.h
  986. +++ b/net/batman-adv/types.h
  987. @@ -35,10 +35,9 @@
  988. #include <linux/types.h>
  989. #include <linux/wait.h>
  990. #include <linux/workqueue.h>
  991. +#include <uapi/linux/batadv_packet.h>
  992. #include <uapi/linux/batman_adv.h>
  993. -#include "packet.h"
  994. -
  995. struct seq_file;
  996. #ifdef CONFIG_BATMAN_ADV_DAT
  997. --- /dev/null
  998. +++ b/include/uapi/linux/batadv_packet.h
  999. @@ -0,0 +1,623 @@
  1000. +/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) */
  1001. +/* Copyright (C) 2007-2017 B.A.T.M.A.N. contributors:
  1002. + *
  1003. + * Marek Lindner, Simon Wunderlich
  1004. + *
  1005. + * This program is free software; you can redistribute it and/or
  1006. + * modify it under the terms of version 2 of the GNU General Public
  1007. + * License as published by the Free Software Foundation.
  1008. + *
  1009. + * This program is distributed in the hope that it will be useful, but
  1010. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  1011. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1012. + * General Public License for more details.
  1013. + *
  1014. + * You should have received a copy of the GNU General Public License
  1015. + * along with this program; if not, see <http://www.gnu.org/licenses/>.
  1016. + */
  1017. +
  1018. +#ifndef _UAPI_LINUX_BATADV_PACKET_H_
  1019. +#define _UAPI_LINUX_BATADV_PACKET_H_
  1020. +
  1021. +#include <asm/byteorder.h>
  1022. +#include <linux/if_ether.h>
  1023. +#include <linux/types.h>
  1024. +
  1025. +#define batadv_tp_is_error(n) ((__u8)(n) > 127 ? 1 : 0)
  1026. +
  1027. +/**
  1028. + * enum batadv_packettype - types for batman-adv encapsulated packets
  1029. + * @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV
  1030. + * @BATADV_BCAST: broadcast packets carrying broadcast payload
  1031. + * @BATADV_CODED: network coded packets
  1032. + * @BATADV_ELP: echo location packets for B.A.T.M.A.N. V
  1033. + * @BATADV_OGM2: originator messages for B.A.T.M.A.N. V
  1034. + *
  1035. + * @BATADV_UNICAST: unicast packets carrying unicast payload traffic
  1036. + * @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original
  1037. + * payload packet
  1038. + * @BATADV_UNICAST_4ADDR: unicast packet including the originator address of
  1039. + * the sender
  1040. + * @BATADV_ICMP: unicast packet like IP ICMP used for ping or traceroute
  1041. + * @BATADV_UNICAST_TVLV: unicast packet carrying TVLV containers
  1042. + */
  1043. +enum batadv_packettype {
  1044. + /* 0x00 - 0x3f: local packets or special rules for handling */
  1045. + BATADV_IV_OGM = 0x00,
  1046. + BATADV_BCAST = 0x01,
  1047. + BATADV_CODED = 0x02,
  1048. + BATADV_ELP = 0x03,
  1049. + BATADV_OGM2 = 0x04,
  1050. + /* 0x40 - 0x7f: unicast */
  1051. +#define BATADV_UNICAST_MIN 0x40
  1052. + BATADV_UNICAST = 0x40,
  1053. + BATADV_UNICAST_FRAG = 0x41,
  1054. + BATADV_UNICAST_4ADDR = 0x42,
  1055. + BATADV_ICMP = 0x43,
  1056. + BATADV_UNICAST_TVLV = 0x44,
  1057. +#define BATADV_UNICAST_MAX 0x7f
  1058. + /* 0x80 - 0xff: reserved */
  1059. +};
  1060. +
  1061. +/**
  1062. + * enum batadv_subtype - packet subtype for unicast4addr
  1063. + * @BATADV_P_DATA: user payload
  1064. + * @BATADV_P_DAT_DHT_GET: DHT request message
  1065. + * @BATADV_P_DAT_DHT_PUT: DHT store message
  1066. + * @BATADV_P_DAT_CACHE_REPLY: ARP reply generated by DAT
  1067. + */
  1068. +enum batadv_subtype {
  1069. + BATADV_P_DATA = 0x01,
  1070. + BATADV_P_DAT_DHT_GET = 0x02,
  1071. + BATADV_P_DAT_DHT_PUT = 0x03,
  1072. + BATADV_P_DAT_CACHE_REPLY = 0x04,
  1073. +};
  1074. +
  1075. +/* this file is included by batctl which needs these defines */
  1076. +#define BATADV_COMPAT_VERSION 15
  1077. +
  1078. +/**
  1079. + * enum batadv_iv_flags - flags used in B.A.T.M.A.N. IV OGM packets
  1080. + * @BATADV_NOT_BEST_NEXT_HOP: flag is set when ogm packet is forwarded and was
  1081. + * previously received from someone else than the best neighbor.
  1082. + * @BATADV_PRIMARIES_FIRST_HOP: flag unused.
  1083. + * @BATADV_DIRECTLINK: flag is for the first hop or if rebroadcasted from a
  1084. + * one hop neighbor on the interface where it was originally received.
  1085. + */
  1086. +enum batadv_iv_flags {
  1087. + BATADV_NOT_BEST_NEXT_HOP = 1UL << 0,
  1088. + BATADV_PRIMARIES_FIRST_HOP = 1UL << 1,
  1089. + BATADV_DIRECTLINK = 1UL << 2,
  1090. +};
  1091. +
  1092. +/* ICMP message types */
  1093. +enum batadv_icmp_packettype {
  1094. + BATADV_ECHO_REPLY = 0,
  1095. + BATADV_DESTINATION_UNREACHABLE = 3,
  1096. + BATADV_ECHO_REQUEST = 8,
  1097. + BATADV_TTL_EXCEEDED = 11,
  1098. + BATADV_PARAMETER_PROBLEM = 12,
  1099. + BATADV_TP = 15,
  1100. +};
  1101. +
  1102. +/**
  1103. + * enum batadv_mcast_flags - flags for multicast capabilities and settings
  1104. + * @BATADV_MCAST_WANT_ALL_UNSNOOPABLES: we want all packets destined for
  1105. + * 224.0.0.0/24 or ff02::1
  1106. + * @BATADV_MCAST_WANT_ALL_IPV4: we want all IPv4 multicast packets
  1107. + * @BATADV_MCAST_WANT_ALL_IPV6: we want all IPv6 multicast packets
  1108. + */
  1109. +enum batadv_mcast_flags {
  1110. + BATADV_MCAST_WANT_ALL_UNSNOOPABLES = 1UL << 0,
  1111. + BATADV_MCAST_WANT_ALL_IPV4 = 1UL << 1,
  1112. + BATADV_MCAST_WANT_ALL_IPV6 = 1UL << 2,
  1113. +};
  1114. +
  1115. +/* tt data subtypes */
  1116. +#define BATADV_TT_DATA_TYPE_MASK 0x0F
  1117. +
  1118. +/**
  1119. + * enum batadv_tt_data_flags - flags for tt data tvlv
  1120. + * @BATADV_TT_OGM_DIFF: TT diff propagated through OGM
  1121. + * @BATADV_TT_REQUEST: TT request message
  1122. + * @BATADV_TT_RESPONSE: TT response message
  1123. + * @BATADV_TT_FULL_TABLE: contains full table to replace existing table
  1124. + */
  1125. +enum batadv_tt_data_flags {
  1126. + BATADV_TT_OGM_DIFF = 1UL << 0,
  1127. + BATADV_TT_REQUEST = 1UL << 1,
  1128. + BATADV_TT_RESPONSE = 1UL << 2,
  1129. + BATADV_TT_FULL_TABLE = 1UL << 4,
  1130. +};
  1131. +
  1132. +/**
  1133. + * enum batadv_vlan_flags - flags for the four MSB of any vlan ID field
  1134. + * @BATADV_VLAN_HAS_TAG: whether the field contains a valid vlan tag or not
  1135. + */
  1136. +enum batadv_vlan_flags {
  1137. + BATADV_VLAN_HAS_TAG = 1UL << 15,
  1138. +};
  1139. +
  1140. +/* claim frame types for the bridge loop avoidance */
  1141. +enum batadv_bla_claimframe {
  1142. + BATADV_CLAIM_TYPE_CLAIM = 0x00,
  1143. + BATADV_CLAIM_TYPE_UNCLAIM = 0x01,
  1144. + BATADV_CLAIM_TYPE_ANNOUNCE = 0x02,
  1145. + BATADV_CLAIM_TYPE_REQUEST = 0x03,
  1146. + BATADV_CLAIM_TYPE_LOOPDETECT = 0x04,
  1147. +};
  1148. +
  1149. +/**
  1150. + * enum batadv_tvlv_type - tvlv type definitions
  1151. + * @BATADV_TVLV_GW: gateway tvlv
  1152. + * @BATADV_TVLV_DAT: distributed arp table tvlv
  1153. + * @BATADV_TVLV_NC: network coding tvlv
  1154. + * @BATADV_TVLV_TT: translation table tvlv
  1155. + * @BATADV_TVLV_ROAM: roaming advertisement tvlv
  1156. + * @BATADV_TVLV_MCAST: multicast capability tvlv
  1157. + */
  1158. +enum batadv_tvlv_type {
  1159. + BATADV_TVLV_GW = 0x01,
  1160. + BATADV_TVLV_DAT = 0x02,
  1161. + BATADV_TVLV_NC = 0x03,
  1162. + BATADV_TVLV_TT = 0x04,
  1163. + BATADV_TVLV_ROAM = 0x05,
  1164. + BATADV_TVLV_MCAST = 0x06,
  1165. +};
  1166. +
  1167. +#pragma pack(2)
  1168. +/* the destination hardware field in the ARP frame is used to
  1169. + * transport the claim type and the group id
  1170. + */
  1171. +struct batadv_bla_claim_dst {
  1172. + __u8 magic[3]; /* FF:43:05 */
  1173. + __u8 type; /* bla_claimframe */
  1174. + __be16 group; /* group id */
  1175. +};
  1176. +
  1177. +#pragma pack()
  1178. +
  1179. +/**
  1180. + * struct batadv_ogm_packet - ogm (routing protocol) packet
  1181. + * @packet_type: batman-adv packet type, part of the general header
  1182. + * @version: batman-adv protocol version, part of the genereal header
  1183. + * @ttl: time to live for this packet, part of the genereal header
  1184. + * @flags: contains routing relevant flags - see enum batadv_iv_flags
  1185. + * @seqno: sequence identification
  1186. + * @orig: address of the source node
  1187. + * @prev_sender: address of the previous sender
  1188. + * @reserved: reserved byte for alignment
  1189. + * @tq: transmission quality
  1190. + * @tvlv_len: length of tvlv data following the ogm header
  1191. + */
  1192. +struct batadv_ogm_packet {
  1193. + __u8 packet_type;
  1194. + __u8 version;
  1195. + __u8 ttl;
  1196. + __u8 flags;
  1197. + __be32 seqno;
  1198. + __u8 orig[ETH_ALEN];
  1199. + __u8 prev_sender[ETH_ALEN];
  1200. + __u8 reserved;
  1201. + __u8 tq;
  1202. + __be16 tvlv_len;
  1203. + /* __packed is not needed as the struct size is divisible by 4,
  1204. + * and the largest data type in this struct has a size of 4.
  1205. + */
  1206. +};
  1207. +
  1208. +#define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
  1209. +
  1210. +/**
  1211. + * struct batadv_ogm2_packet - ogm2 (routing protocol) packet
  1212. + * @packet_type: batman-adv packet type, part of the general header
  1213. + * @version: batman-adv protocol version, part of the general header
  1214. + * @ttl: time to live for this packet, part of the general header
  1215. + * @flags: reseved for routing relevant flags - currently always 0
  1216. + * @seqno: sequence number
  1217. + * @orig: originator mac address
  1218. + * @tvlv_len: length of the appended tvlv buffer (in bytes)
  1219. + * @throughput: the currently flooded path throughput
  1220. + */
  1221. +struct batadv_ogm2_packet {
  1222. + __u8 packet_type;
  1223. + __u8 version;
  1224. + __u8 ttl;
  1225. + __u8 flags;
  1226. + __be32 seqno;
  1227. + __u8 orig[ETH_ALEN];
  1228. + __be16 tvlv_len;
  1229. + __be32 throughput;
  1230. + /* __packed is not needed as the struct size is divisible by 4,
  1231. + * and the largest data type in this struct has a size of 4.
  1232. + */
  1233. +};
  1234. +
  1235. +#define BATADV_OGM2_HLEN sizeof(struct batadv_ogm2_packet)
  1236. +
  1237. +/**
  1238. + * struct batadv_elp_packet - elp (neighbor discovery) packet
  1239. + * @packet_type: batman-adv packet type, part of the general header
  1240. + * @version: batman-adv protocol version, part of the genereal header
  1241. + * @orig: originator mac address
  1242. + * @seqno: sequence number
  1243. + * @elp_interval: currently used ELP sending interval in ms
  1244. + */
  1245. +struct batadv_elp_packet {
  1246. + __u8 packet_type;
  1247. + __u8 version;
  1248. + __u8 orig[ETH_ALEN];
  1249. + __be32 seqno;
  1250. + __be32 elp_interval;
  1251. +};
  1252. +
  1253. +#define BATADV_ELP_HLEN sizeof(struct batadv_elp_packet)
  1254. +
  1255. +/**
  1256. + * struct batadv_icmp_header - common members among all the ICMP packets
  1257. + * @packet_type: batman-adv packet type, part of the general header
  1258. + * @version: batman-adv protocol version, part of the genereal header
  1259. + * @ttl: time to live for this packet, part of the genereal header
  1260. + * @msg_type: ICMP packet type
  1261. + * @dst: address of the destination node
  1262. + * @orig: address of the source node
  1263. + * @uid: local ICMP socket identifier
  1264. + * @align: not used - useful for alignment purposes only
  1265. + *
  1266. + * This structure is used for ICMP packets parsing only and it is never sent
  1267. + * over the wire. The alignment field at the end is there to ensure that
  1268. + * members are padded the same way as they are in real packets.
  1269. + */
  1270. +struct batadv_icmp_header {
  1271. + __u8 packet_type;
  1272. + __u8 version;
  1273. + __u8 ttl;
  1274. + __u8 msg_type; /* see ICMP message types above */
  1275. + __u8 dst[ETH_ALEN];
  1276. + __u8 orig[ETH_ALEN];
  1277. + __u8 uid;
  1278. + __u8 align[3];
  1279. +};
  1280. +
  1281. +/**
  1282. + * struct batadv_icmp_packet - ICMP packet
  1283. + * @packet_type: batman-adv packet type, part of the general header
  1284. + * @version: batman-adv protocol version, part of the genereal header
  1285. + * @ttl: time to live for this packet, part of the genereal header
  1286. + * @msg_type: ICMP packet type
  1287. + * @dst: address of the destination node
  1288. + * @orig: address of the source node
  1289. + * @uid: local ICMP socket identifier
  1290. + * @reserved: not used - useful for alignment
  1291. + * @seqno: ICMP sequence number
  1292. + */
  1293. +struct batadv_icmp_packet {
  1294. + __u8 packet_type;
  1295. + __u8 version;
  1296. + __u8 ttl;
  1297. + __u8 msg_type; /* see ICMP message types above */
  1298. + __u8 dst[ETH_ALEN];
  1299. + __u8 orig[ETH_ALEN];
  1300. + __u8 uid;
  1301. + __u8 reserved;
  1302. + __be16 seqno;
  1303. +};
  1304. +
  1305. +/**
  1306. + * struct batadv_icmp_tp_packet - ICMP TP Meter packet
  1307. + * @packet_type: batman-adv packet type, part of the general header
  1308. + * @version: batman-adv protocol version, part of the genereal header
  1309. + * @ttl: time to live for this packet, part of the genereal header
  1310. + * @msg_type: ICMP packet type
  1311. + * @dst: address of the destination node
  1312. + * @orig: address of the source node
  1313. + * @uid: local ICMP socket identifier
  1314. + * @subtype: TP packet subtype (see batadv_icmp_tp_subtype)
  1315. + * @session: TP session identifier
  1316. + * @seqno: the TP sequence number
  1317. + * @timestamp: time when the packet has been sent. This value is filled in a
  1318. + * TP_MSG and echoed back in the next TP_ACK so that the sender can compute the
  1319. + * RTT. Since it is read only by the host which wrote it, there is no need to
  1320. + * store it using network order
  1321. + */
  1322. +struct batadv_icmp_tp_packet {
  1323. + __u8 packet_type;
  1324. + __u8 version;
  1325. + __u8 ttl;
  1326. + __u8 msg_type; /* see ICMP message types above */
  1327. + __u8 dst[ETH_ALEN];
  1328. + __u8 orig[ETH_ALEN];
  1329. + __u8 uid;
  1330. + __u8 subtype;
  1331. + __u8 session[2];
  1332. + __be32 seqno;
  1333. + __be32 timestamp;
  1334. +};
  1335. +
  1336. +/**
  1337. + * enum batadv_icmp_tp_subtype - ICMP TP Meter packet subtypes
  1338. + * @BATADV_TP_MSG: Msg from sender to receiver
  1339. + * @BATADV_TP_ACK: acknowledgment from receiver to sender
  1340. + */
  1341. +enum batadv_icmp_tp_subtype {
  1342. + BATADV_TP_MSG = 0,
  1343. + BATADV_TP_ACK,
  1344. +};
  1345. +
  1346. +#define BATADV_RR_LEN 16
  1347. +
  1348. +/**
  1349. + * struct batadv_icmp_packet_rr - ICMP RouteRecord packet
  1350. + * @packet_type: batman-adv packet type, part of the general header
  1351. + * @version: batman-adv protocol version, part of the genereal header
  1352. + * @ttl: time to live for this packet, part of the genereal header
  1353. + * @msg_type: ICMP packet type
  1354. + * @dst: address of the destination node
  1355. + * @orig: address of the source node
  1356. + * @uid: local ICMP socket identifier
  1357. + * @rr_cur: number of entries the rr array
  1358. + * @seqno: ICMP sequence number
  1359. + * @rr: route record array
  1360. + */
  1361. +struct batadv_icmp_packet_rr {
  1362. + __u8 packet_type;
  1363. + __u8 version;
  1364. + __u8 ttl;
  1365. + __u8 msg_type; /* see ICMP message types above */
  1366. + __u8 dst[ETH_ALEN];
  1367. + __u8 orig[ETH_ALEN];
  1368. + __u8 uid;
  1369. + __u8 rr_cur;
  1370. + __be16 seqno;
  1371. + __u8 rr[BATADV_RR_LEN][ETH_ALEN];
  1372. +};
  1373. +
  1374. +#define BATADV_ICMP_MAX_PACKET_SIZE sizeof(struct batadv_icmp_packet_rr)
  1375. +
  1376. +/* All packet headers in front of an ethernet header have to be completely
  1377. + * divisible by 2 but not by 4 to make the payload after the ethernet
  1378. + * header again 4 bytes boundary aligned.
  1379. + *
  1380. + * A packing of 2 is necessary to avoid extra padding at the end of the struct
  1381. + * caused by a structure member which is larger than two bytes. Otherwise
  1382. + * the structure would not fulfill the previously mentioned rule to avoid the
  1383. + * misalignment of the payload after the ethernet header. It may also lead to
  1384. + * leakage of information when the padding it not initialized before sending.
  1385. + */
  1386. +#pragma pack(2)
  1387. +
  1388. +/**
  1389. + * struct batadv_unicast_packet - unicast packet for network payload
  1390. + * @packet_type: batman-adv packet type, part of the general header
  1391. + * @version: batman-adv protocol version, part of the genereal header
  1392. + * @ttl: time to live for this packet, part of the genereal header
  1393. + * @ttvn: translation table version number
  1394. + * @dest: originator destination of the unicast packet
  1395. + */
  1396. +struct batadv_unicast_packet {
  1397. + __u8 packet_type;
  1398. + __u8 version;
  1399. + __u8 ttl;
  1400. + __u8 ttvn; /* destination translation table version number */
  1401. + __u8 dest[ETH_ALEN];
  1402. + /* "4 bytes boundary + 2 bytes" long to make the payload after the
  1403. + * following ethernet header again 4 bytes boundary aligned
  1404. + */
  1405. +};
  1406. +
  1407. +/**
  1408. + * struct batadv_unicast_4addr_packet - extended unicast packet
  1409. + * @u: common unicast packet header
  1410. + * @src: address of the source
  1411. + * @subtype: packet subtype
  1412. + * @reserved: reserved byte for alignment
  1413. + */
  1414. +struct batadv_unicast_4addr_packet {
  1415. + struct batadv_unicast_packet u;
  1416. + __u8 src[ETH_ALEN];
  1417. + __u8 subtype;
  1418. + __u8 reserved;
  1419. + /* "4 bytes boundary + 2 bytes" long to make the payload after the
  1420. + * following ethernet header again 4 bytes boundary aligned
  1421. + */
  1422. +};
  1423. +
  1424. +/**
  1425. + * struct batadv_frag_packet - fragmented packet
  1426. + * @packet_type: batman-adv packet type, part of the general header
  1427. + * @version: batman-adv protocol version, part of the genereal header
  1428. + * @ttl: time to live for this packet, part of the genereal header
  1429. + * @dest: final destination used when routing fragments
  1430. + * @orig: originator of the fragment used when merging the packet
  1431. + * @no: fragment number within this sequence
  1432. + * @priority: priority of frame, from ToS IP precedence or 802.1p
  1433. + * @reserved: reserved byte for alignment
  1434. + * @seqno: sequence identification
  1435. + * @total_size: size of the merged packet
  1436. + */
  1437. +struct batadv_frag_packet {
  1438. + __u8 packet_type;
  1439. + __u8 version; /* batman version field */
  1440. + __u8 ttl;
  1441. +#if defined(__BIG_ENDIAN_BITFIELD)
  1442. + __u8 no:4;
  1443. + __u8 priority:3;
  1444. + __u8 reserved:1;
  1445. +#elif defined(__LITTLE_ENDIAN_BITFIELD)
  1446. + __u8 reserved:1;
  1447. + __u8 priority:3;
  1448. + __u8 no:4;
  1449. +#else
  1450. +#error "unknown bitfield endianness"
  1451. +#endif
  1452. + __u8 dest[ETH_ALEN];
  1453. + __u8 orig[ETH_ALEN];
  1454. + __be16 seqno;
  1455. + __be16 total_size;
  1456. +};
  1457. +
  1458. +/**
  1459. + * struct batadv_bcast_packet - broadcast packet for network payload
  1460. + * @packet_type: batman-adv packet type, part of the general header
  1461. + * @version: batman-adv protocol version, part of the genereal header
  1462. + * @ttl: time to live for this packet, part of the genereal header
  1463. + * @reserved: reserved byte for alignment
  1464. + * @seqno: sequence identification
  1465. + * @orig: originator of the broadcast packet
  1466. + */
  1467. +struct batadv_bcast_packet {
  1468. + __u8 packet_type;
  1469. + __u8 version; /* batman version field */
  1470. + __u8 ttl;
  1471. + __u8 reserved;
  1472. + __be32 seqno;
  1473. + __u8 orig[ETH_ALEN];
  1474. + /* "4 bytes boundary + 2 bytes" long to make the payload after the
  1475. + * following ethernet header again 4 bytes boundary aligned
  1476. + */
  1477. +};
  1478. +
  1479. +/**
  1480. + * struct batadv_coded_packet - network coded packet
  1481. + * @packet_type: batman-adv packet type, part of the general header
  1482. + * @version: batman-adv protocol version, part of the genereal header
  1483. + * @ttl: time to live for this packet, part of the genereal header
  1484. + * @first_source: original source of first included packet
  1485. + * @first_orig_dest: original destinal of first included packet
  1486. + * @first_crc: checksum of first included packet
  1487. + * @first_ttvn: tt-version number of first included packet
  1488. + * @second_ttl: ttl of second packet
  1489. + * @second_dest: second receiver of this coded packet
  1490. + * @second_source: original source of second included packet
  1491. + * @second_orig_dest: original destination of second included packet
  1492. + * @second_crc: checksum of second included packet
  1493. + * @second_ttvn: tt version number of second included packet
  1494. + * @coded_len: length of network coded part of the payload
  1495. + */
  1496. +struct batadv_coded_packet {
  1497. + __u8 packet_type;
  1498. + __u8 version; /* batman version field */
  1499. + __u8 ttl;
  1500. + __u8 first_ttvn;
  1501. + /* __u8 first_dest[ETH_ALEN]; - saved in mac header destination */
  1502. + __u8 first_source[ETH_ALEN];
  1503. + __u8 first_orig_dest[ETH_ALEN];
  1504. + __be32 first_crc;
  1505. + __u8 second_ttl;
  1506. + __u8 second_ttvn;
  1507. + __u8 second_dest[ETH_ALEN];
  1508. + __u8 second_source[ETH_ALEN];
  1509. + __u8 second_orig_dest[ETH_ALEN];
  1510. + __be32 second_crc;
  1511. + __be16 coded_len;
  1512. +};
  1513. +
  1514. +#pragma pack()
  1515. +
  1516. +/**
  1517. + * struct batadv_unicast_tvlv_packet - generic unicast packet with tvlv payload
  1518. + * @packet_type: batman-adv packet type, part of the general header
  1519. + * @version: batman-adv protocol version, part of the genereal header
  1520. + * @ttl: time to live for this packet, part of the genereal header
  1521. + * @reserved: reserved field (for packet alignment)
  1522. + * @src: address of the source
  1523. + * @dst: address of the destination
  1524. + * @tvlv_len: length of tvlv data following the unicast tvlv header
  1525. + * @align: 2 bytes to align the header to a 4 byte boundary
  1526. + */
  1527. +struct batadv_unicast_tvlv_packet {
  1528. + __u8 packet_type;
  1529. + __u8 version; /* batman version field */
  1530. + __u8 ttl;
  1531. + __u8 reserved;
  1532. + __u8 dst[ETH_ALEN];
  1533. + __u8 src[ETH_ALEN];
  1534. + __be16 tvlv_len;
  1535. + __u16 align;
  1536. +};
  1537. +
  1538. +/**
  1539. + * struct batadv_tvlv_hdr - base tvlv header struct
  1540. + * @type: tvlv container type (see batadv_tvlv_type)
  1541. + * @version: tvlv container version
  1542. + * @len: tvlv container length
  1543. + */
  1544. +struct batadv_tvlv_hdr {
  1545. + __u8 type;
  1546. + __u8 version;
  1547. + __be16 len;
  1548. +};
  1549. +
  1550. +/**
  1551. + * struct batadv_tvlv_gateway_data - gateway data propagated through gw tvlv
  1552. + * container
  1553. + * @bandwidth_down: advertised uplink download bandwidth
  1554. + * @bandwidth_up: advertised uplink upload bandwidth
  1555. + */
  1556. +struct batadv_tvlv_gateway_data {
  1557. + __be32 bandwidth_down;
  1558. + __be32 bandwidth_up;
  1559. +};
  1560. +
  1561. +/**
  1562. + * struct batadv_tvlv_tt_data - tt data propagated through the tt tvlv container
  1563. + * @flags: translation table flags (see batadv_tt_data_flags)
  1564. + * @ttvn: translation table version number
  1565. + * @num_vlan: number of announced VLANs. In the TVLV this struct is followed by
  1566. + * one batadv_tvlv_tt_vlan_data object per announced vlan
  1567. + */
  1568. +struct batadv_tvlv_tt_data {
  1569. + __u8 flags;
  1570. + __u8 ttvn;
  1571. + __be16 num_vlan;
  1572. +};
  1573. +
  1574. +/**
  1575. + * struct batadv_tvlv_tt_vlan_data - vlan specific tt data propagated through
  1576. + * the tt tvlv container
  1577. + * @crc: crc32 checksum of the entries belonging to this vlan
  1578. + * @vid: vlan identifier
  1579. + * @reserved: unused, useful for alignment purposes
  1580. + */
  1581. +struct batadv_tvlv_tt_vlan_data {
  1582. + __be32 crc;
  1583. + __be16 vid;
  1584. + __u16 reserved;
  1585. +};
  1586. +
  1587. +/**
  1588. + * struct batadv_tvlv_tt_change - translation table diff data
  1589. + * @flags: status indicators concerning the non-mesh client (see
  1590. + * batadv_tt_client_flags)
  1591. + * @reserved: reserved field - useful for alignment purposes only
  1592. + * @addr: mac address of non-mesh client that triggered this tt change
  1593. + * @vid: VLAN identifier
  1594. + */
  1595. +struct batadv_tvlv_tt_change {
  1596. + __u8 flags;
  1597. + __u8 reserved[3];
  1598. + __u8 addr[ETH_ALEN];
  1599. + __be16 vid;
  1600. +};
  1601. +
  1602. +/**
  1603. + * struct batadv_tvlv_roam_adv - roaming advertisement
  1604. + * @client: mac address of roaming client
  1605. + * @vid: VLAN identifier
  1606. + */
  1607. +struct batadv_tvlv_roam_adv {
  1608. + __u8 client[ETH_ALEN];
  1609. + __be16 vid;
  1610. +};
  1611. +
  1612. +/**
  1613. + * struct batadv_tvlv_mcast_data - payload of a multicast tvlv
  1614. + * @flags: multicast flags announced by the orig node
  1615. + * @reserved: reserved field
  1616. + */
  1617. +struct batadv_tvlv_mcast_data {
  1618. + __u8 flags;
  1619. + __u8 reserved[3];
  1620. +};
  1621. +
  1622. +#endif /* _UAPI_LINUX_BATADV_PACKET_H_ */