1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (C) 2011-2019 B.A.T.M.A.N. contributors: 3 * 4 * Simon Wunderlich 5 */ 6 7 #ifndef _NET_BATMAN_ADV_BLA_H_ 8 #define _NET_BATMAN_ADV_BLA_H_ 9 10 #include "main.h" 11 12 #include <linux/compiler.h> 13 #include <linux/stddef.h> 14 #include <linux/types.h> 15 16 struct net_device; 17 struct netlink_callback; 18 struct seq_file; 19 struct sk_buff; 20 21 /** 22 * batadv_bla_is_loopdetect_mac() - check if the mac address is from a loop 23 * detect frame sent by bridge loop avoidance 24 * @mac: mac address to check 25 * 26 * Return: true if the it looks like a loop detect frame 27 * (mac starts with BA:BE), false otherwise 28 */ 29 static inline bool batadv_bla_is_loopdetect_mac(const uint8_t *mac) 30 { 31 if (mac[0] == 0xba && mac[1] == 0xbe) 32 return true; 33 34 return false; 35 } 36 37 #ifdef CONFIG_BATMAN_ADV_BLA 38 bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, 39 unsigned short vid, bool is_bcast); 40 bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, 41 unsigned short vid); 42 bool batadv_bla_is_backbone_gw(struct sk_buff *skb, 43 struct batadv_orig_node *orig_node, 44 int hdr_size); 45 int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); 46 int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb); 47 int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, 48 void *offset); 49 int batadv_bla_backbone_dump(struct sk_buff *msg, struct netlink_callback *cb); 50 bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig, 51 unsigned short vid); 52 bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, 53 struct sk_buff *skb); 54 void batadv_bla_update_orig_address(struct batadv_priv *bat_priv, 55 struct batadv_hard_iface *primary_if, 56 struct batadv_hard_iface *oldif); 57 void batadv_bla_status_update(struct net_device *net_dev); 58 int batadv_bla_init(struct batadv_priv *bat_priv); 59 void batadv_bla_free(struct batadv_priv *bat_priv); 60 int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb); 61 #ifdef CONFIG_BATMAN_ADV_DAT 62 bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr, 63 unsigned short vid); 64 #endif 65 #define BATADV_BLA_CRC_INIT 0 66 #else /* ifdef CONFIG_BATMAN_ADV_BLA */ 67 68 static inline bool batadv_bla_rx(struct batadv_priv *bat_priv, 69 struct sk_buff *skb, unsigned short vid, 70 bool is_bcast) 71 { 72 return false; 73 } 74 75 static inline bool batadv_bla_tx(struct batadv_priv *bat_priv, 76 struct sk_buff *skb, unsigned short vid) 77 { 78 return false; 79 } 80 81 static inline bool batadv_bla_is_backbone_gw(struct sk_buff *skb, 82 struct batadv_orig_node *orig_node, 83 int hdr_size) 84 { 85 return false; 86 } 87 88 static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, 89 void *offset) 90 { 91 return 0; 92 } 93 94 static inline int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, 95 void *offset) 96 { 97 return 0; 98 } 99 100 static inline bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, 101 u8 *orig, unsigned short vid) 102 { 103 return false; 104 } 105 106 static inline bool 107 batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, 108 struct sk_buff *skb) 109 { 110 return false; 111 } 112 113 static inline void 114 batadv_bla_update_orig_address(struct batadv_priv *bat_priv, 115 struct batadv_hard_iface *primary_if, 116 struct batadv_hard_iface *oldif) 117 { 118 } 119 120 static inline int batadv_bla_init(struct batadv_priv *bat_priv) 121 { 122 return 1; 123 } 124 125 static inline void batadv_bla_free(struct batadv_priv *bat_priv) 126 { 127 } 128 129 static inline int batadv_bla_claim_dump(struct sk_buff *msg, 130 struct netlink_callback *cb) 131 { 132 return -EOPNOTSUPP; 133 } 134 135 static inline int batadv_bla_backbone_dump(struct sk_buff *msg, 136 struct netlink_callback *cb) 137 { 138 return -EOPNOTSUPP; 139 } 140 141 static inline 142 bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr, 143 unsigned short vid) 144 { 145 return true; 146 } 147 148 #endif /* ifdef CONFIG_BATMAN_ADV_BLA */ 149 150 #endif /* ifndef _NET_BATMAN_ADV_BLA_H_ */ 151