blob: a81c41b636f9310d1aa9042dce1451aa62f3e55c [file] [log] [blame]
Sven Eckelmann7db7d9f2017-11-19 15:05:11 +01001/* SPDX-License-Identifier: GPL-2.0 */
Sven Eckelmann68e039f2020-01-01 00:00:01 +01002/* Copyright (C) 2011-2020 B.A.T.M.A.N. contributors:
Simon Wunderlich23721382012-01-22 20:00:19 +01003 *
4 * Simon Wunderlich
Simon Wunderlich23721382012-01-22 20:00:19 +01005 */
6
7#ifndef _NET_BATMAN_ADV_BLA_H_
8#define _NET_BATMAN_ADV_BLA_H_
9
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020010#include "main.h"
11
Simon Wunderlichd3e97682016-11-24 16:11:01 +010012#include <linux/compiler.h>
Sven Eckelmann68a600d2019-05-24 20:11:17 +020013#include <linux/netdevice.h>
14#include <linux/netlink.h>
15#include <linux/seq_file.h>
16#include <linux/skbuff.h>
Simon Wunderlichd3e97682016-11-24 16:11:01 +010017#include <linux/stddef.h>
Sven Eckelmann1e2c2a42015-04-17 19:40:28 +020018#include <linux/types.h>
19
Simon Wunderlichd3e97682016-11-24 16:11:01 +010020/**
Sven Eckelmann7e9a8c22017-12-02 19:51:47 +010021 * batadv_bla_is_loopdetect_mac() - check if the mac address is from a loop
22 * detect frame sent by bridge loop avoidance
Simon Wunderlichd3e97682016-11-24 16:11:01 +010023 * @mac: mac address to check
24 *
25 * Return: true if the it looks like a loop detect frame
26 * (mac starts with BA:BE), false otherwise
27 */
28static inline bool batadv_bla_is_loopdetect_mac(const uint8_t *mac)
29{
30 if (mac[0] == 0xba && mac[1] == 0xbe)
31 return true;
32
33 return false;
34}
35
Simon Wunderlich7a5cc242012-01-22 20:00:27 +010036#ifdef CONFIG_BATMAN_ADV_BLA
Sven Eckelmann4b426b12016-02-22 21:02:39 +010037bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
Linus Lüssing74c09b72020-09-15 09:54:09 +020038 unsigned short vid, int packet_type);
Sven Eckelmann4b426b12016-02-22 21:02:39 +010039bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
40 unsigned short vid);
41bool batadv_bla_is_backbone_gw(struct sk_buff *skb,
42 struct batadv_orig_node *orig_node,
43 int hdr_size);
Sven Eckelmann08adf152012-05-12 13:38:47 +020044int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);
Andrew Lunn04f3f5b2016-07-03 13:31:45 +020045int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb);
Simon Wunderlich536a23f2012-06-18 18:39:26 +020046int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq,
47 void *offset);
Simon Wunderlichea4152e2016-07-03 13:31:47 +020048int batadv_bla_backbone_dump(struct sk_buff *msg, struct netlink_callback *cb);
Sven Eckelmann6b5e9712015-05-26 18:34:26 +020049bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig,
Antonio Quartullicfd4f752013-08-07 18:28:56 +020050 unsigned short vid);
Sven Eckelmann4b426b12016-02-22 21:02:39 +010051bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
52 struct sk_buff *skb);
Sven Eckelmann56303d32012-06-05 22:31:31 +020053void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
54 struct batadv_hard_iface *primary_if,
55 struct batadv_hard_iface *oldif);
Simon Wunderlichd68081a2015-11-09 16:20:52 +010056void batadv_bla_status_update(struct net_device *net_dev);
Sven Eckelmann56303d32012-06-05 22:31:31 +020057int batadv_bla_init(struct batadv_priv *bat_priv);
58void batadv_bla_free(struct batadv_priv *bat_priv);
Andrew Lunn04f3f5b2016-07-03 13:31:45 +020059int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb);
Andreas Pape00311de2016-09-05 13:20:25 +020060#ifdef CONFIG_BATMAN_ADV_DAT
61bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
62 unsigned short vid);
63#endif
Sven Eckelmann3964f722012-06-03 22:19:10 +020064#define BATADV_BLA_CRC_INIT 0
Simon Wunderlich7a5cc242012-01-22 20:00:27 +010065#else /* ifdef CONFIG_BATMAN_ADV_BLA */
66
Sven Eckelmann4b426b12016-02-22 21:02:39 +010067static inline bool batadv_bla_rx(struct batadv_priv *bat_priv,
68 struct sk_buff *skb, unsigned short vid,
Linus Lüssing74c09b72020-09-15 09:54:09 +020069 int packet_type)
Simon Wunderlich7a5cc242012-01-22 20:00:27 +010070{
Sven Eckelmann4b426b12016-02-22 21:02:39 +010071 return false;
Simon Wunderlich7a5cc242012-01-22 20:00:27 +010072}
73
Sven Eckelmann4b426b12016-02-22 21:02:39 +010074static inline bool batadv_bla_tx(struct batadv_priv *bat_priv,
75 struct sk_buff *skb, unsigned short vid)
Simon Wunderlich7a5cc242012-01-22 20:00:27 +010076{
Sven Eckelmann4b426b12016-02-22 21:02:39 +010077 return false;
Simon Wunderlich7a5cc242012-01-22 20:00:27 +010078}
79
Sven Eckelmann4b426b12016-02-22 21:02:39 +010080static inline bool batadv_bla_is_backbone_gw(struct sk_buff *skb,
81 struct batadv_orig_node *orig_node,
82 int hdr_size)
Simon Wunderlich7a5cc242012-01-22 20:00:27 +010083{
Sven Eckelmann4b426b12016-02-22 21:02:39 +010084 return false;
Simon Wunderlich7a5cc242012-01-22 20:00:27 +010085}
86
Sven Eckelmann08adf152012-05-12 13:38:47 +020087static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq,
88 void *offset)
Simon Wunderlich7a5cc242012-01-22 20:00:27 +010089{
90 return 0;
91}
92
Simon Wunderlich536a23f2012-06-18 18:39:26 +020093static inline int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq,
94 void *offset)
95{
96 return 0;
97}
98
Antonio Quartullicfd4f752013-08-07 18:28:56 +020099static inline bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv,
Sven Eckelmann6b5e9712015-05-26 18:34:26 +0200100 u8 *orig, unsigned short vid)
Simon Wunderlich7a5cc242012-01-22 20:00:27 +0100101{
Antonio Quartullicfd4f752013-08-07 18:28:56 +0200102 return false;
Simon Wunderlich7a5cc242012-01-22 20:00:27 +0100103}
104
Sven Eckelmann4b426b12016-02-22 21:02:39 +0100105static inline bool
Sven Eckelmann56303d32012-06-05 22:31:31 +0200106batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
Simon Wunderlich004e86f2012-10-18 13:47:42 +0200107 struct sk_buff *skb)
Simon Wunderlich7a5cc242012-01-22 20:00:27 +0100108{
Sven Eckelmann4b426b12016-02-22 21:02:39 +0100109 return false;
Simon Wunderlich7a5cc242012-01-22 20:00:27 +0100110}
111
Sven Eckelmann08adf152012-05-12 13:38:47 +0200112static inline void
Sven Eckelmann56303d32012-06-05 22:31:31 +0200113batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
114 struct batadv_hard_iface *primary_if,
115 struct batadv_hard_iface *oldif)
Simon Wunderlich7a5cc242012-01-22 20:00:27 +0100116{
117}
118
Sven Eckelmann56303d32012-06-05 22:31:31 +0200119static inline int batadv_bla_init(struct batadv_priv *bat_priv)
Simon Wunderlich7a5cc242012-01-22 20:00:27 +0100120{
121 return 1;
122}
123
Sven Eckelmann56303d32012-06-05 22:31:31 +0200124static inline void batadv_bla_free(struct batadv_priv *bat_priv)
Simon Wunderlich7a5cc242012-01-22 20:00:27 +0100125{
126}
127
Andrew Lunn04f3f5b2016-07-03 13:31:45 +0200128static inline int batadv_bla_claim_dump(struct sk_buff *msg,
129 struct netlink_callback *cb)
130{
131 return -EOPNOTSUPP;
132}
133
Simon Wunderlichea4152e2016-07-03 13:31:47 +0200134static inline int batadv_bla_backbone_dump(struct sk_buff *msg,
135 struct netlink_callback *cb)
136{
137 return -EOPNOTSUPP;
138}
139
Andreas Pape00311de2016-09-05 13:20:25 +0200140static inline
141bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
142 unsigned short vid)
143{
144 return true;
145}
146
Simon Wunderlich7a5cc242012-01-22 20:00:27 +0100147#endif /* ifdef CONFIG_BATMAN_ADV_BLA */
Simon Wunderlich23721382012-01-22 20:00:19 +0100148
149#endif /* ifndef _NET_BATMAN_ADV_BLA_H_ */