Linux 5.7.7
[linux/fpc-iii.git] / net / batman-adv / bridge_loop_avoidance.h
blob41edb2c4a3277032d807100783d22a404414d49e
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2011-2020 B.A.T.M.A.N. contributors:
4 * Simon Wunderlich
5 */
7 #ifndef _NET_BATMAN_ADV_BLA_H_
8 #define _NET_BATMAN_ADV_BLA_H_
10 #include "main.h"
12 #include <linux/compiler.h>
13 #include <linux/netdevice.h>
14 #include <linux/netlink.h>
15 #include <linux/seq_file.h>
16 #include <linux/skbuff.h>
17 #include <linux/stddef.h>
18 #include <linux/types.h>
20 /**
21 * batadv_bla_is_loopdetect_mac() - check if the mac address is from a loop
22 * detect frame sent by bridge loop avoidance
23 * @mac: mac address to check
25 * Return: true if the it looks like a loop detect frame
26 * (mac starts with BA:BE), false otherwise
28 static inline bool batadv_bla_is_loopdetect_mac(const uint8_t *mac)
30 if (mac[0] == 0xba && mac[1] == 0xbe)
31 return true;
33 return false;
36 #ifdef CONFIG_BATMAN_ADV_BLA
37 bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
38 unsigned short vid, bool is_bcast);
39 bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
40 unsigned short vid);
41 bool batadv_bla_is_backbone_gw(struct sk_buff *skb,
42 struct batadv_orig_node *orig_node,
43 int hdr_size);
44 int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);
45 int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb);
46 int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq,
47 void *offset);
48 int batadv_bla_backbone_dump(struct sk_buff *msg, struct netlink_callback *cb);
49 bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig,
50 unsigned short vid);
51 bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
52 struct sk_buff *skb);
53 void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
54 struct batadv_hard_iface *primary_if,
55 struct batadv_hard_iface *oldif);
56 void batadv_bla_status_update(struct net_device *net_dev);
57 int batadv_bla_init(struct batadv_priv *bat_priv);
58 void batadv_bla_free(struct batadv_priv *bat_priv);
59 int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb);
60 #ifdef CONFIG_BATMAN_ADV_DAT
61 bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
62 unsigned short vid);
63 #endif
64 #define BATADV_BLA_CRC_INIT 0
65 #else /* ifdef CONFIG_BATMAN_ADV_BLA */
67 static inline bool batadv_bla_rx(struct batadv_priv *bat_priv,
68 struct sk_buff *skb, unsigned short vid,
69 bool is_bcast)
71 return false;
74 static inline bool batadv_bla_tx(struct batadv_priv *bat_priv,
75 struct sk_buff *skb, unsigned short vid)
77 return false;
80 static inline bool batadv_bla_is_backbone_gw(struct sk_buff *skb,
81 struct batadv_orig_node *orig_node,
82 int hdr_size)
84 return false;
87 static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq,
88 void *offset)
90 return 0;
93 static inline int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq,
94 void *offset)
96 return 0;
99 static inline bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv,
100 u8 *orig, unsigned short vid)
102 return false;
105 static inline bool
106 batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
107 struct sk_buff *skb)
109 return false;
112 static inline void
113 batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
114 struct batadv_hard_iface *primary_if,
115 struct batadv_hard_iface *oldif)
119 static inline int batadv_bla_init(struct batadv_priv *bat_priv)
121 return 1;
124 static inline void batadv_bla_free(struct batadv_priv *bat_priv)
128 static inline int batadv_bla_claim_dump(struct sk_buff *msg,
129 struct netlink_callback *cb)
131 return -EOPNOTSUPP;
134 static inline int batadv_bla_backbone_dump(struct sk_buff *msg,
135 struct netlink_callback *cb)
137 return -EOPNOTSUPP;
140 static inline
141 bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
142 unsigned short vid)
144 return true;
147 #endif /* ifdef CONFIG_BATMAN_ADV_BLA */
149 #endif /* ifndef _NET_BATMAN_ADV_BLA_H_ */