Sven Eckelmann | 7db7d9f | 2017-11-19 15:05:11 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Sven Eckelmann | 68e039f | 2020-01-01 00:00:01 +0100 | [diff] [blame] | 2 | /* Copyright (C) 2011-2020 B.A.T.M.A.N. contributors: |
Simon Wunderlich | 2372138 | 2012-01-22 20:00:19 +0100 | [diff] [blame] | 3 | * |
| 4 | * Simon Wunderlich |
Simon Wunderlich | 2372138 | 2012-01-22 20:00:19 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef _NET_BATMAN_ADV_BLA_H_ |
| 8 | #define _NET_BATMAN_ADV_BLA_H_ |
| 9 | |
Sven Eckelmann | 1e2c2a4 | 2015-04-17 19:40:28 +0200 | [diff] [blame] | 10 | #include "main.h" |
| 11 | |
Simon Wunderlich | d3e9768 | 2016-11-24 16:11:01 +0100 | [diff] [blame] | 12 | #include <linux/compiler.h> |
Sven Eckelmann | 68a600d | 2019-05-24 20:11:17 +0200 | [diff] [blame] | 13 | #include <linux/netdevice.h> |
| 14 | #include <linux/netlink.h> |
| 15 | #include <linux/seq_file.h> |
| 16 | #include <linux/skbuff.h> |
Simon Wunderlich | d3e9768 | 2016-11-24 16:11:01 +0100 | [diff] [blame] | 17 | #include <linux/stddef.h> |
Sven Eckelmann | 1e2c2a4 | 2015-04-17 19:40:28 +0200 | [diff] [blame] | 18 | #include <linux/types.h> |
| 19 | |
Simon Wunderlich | d3e9768 | 2016-11-24 16:11:01 +0100 | [diff] [blame] | 20 | /** |
Sven Eckelmann | 7e9a8c2 | 2017-12-02 19:51:47 +0100 | [diff] [blame] | 21 | * batadv_bla_is_loopdetect_mac() - check if the mac address is from a loop |
| 22 | * detect frame sent by bridge loop avoidance |
Simon Wunderlich | d3e9768 | 2016-11-24 16:11:01 +0100 | [diff] [blame] | 23 | * @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 | */ |
| 28 | static 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 Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 36 | #ifdef CONFIG_BATMAN_ADV_BLA |
Sven Eckelmann | 4b426b1 | 2016-02-22 21:02:39 +0100 | [diff] [blame] | 37 | bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, |
Linus Lüssing | 74c09b7 | 2020-09-15 09:54:09 +0200 | [diff] [blame] | 38 | unsigned short vid, int packet_type); |
Sven Eckelmann | 4b426b1 | 2016-02-22 21:02:39 +0100 | [diff] [blame] | 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); |
Sven Eckelmann | 08adf15 | 2012-05-12 13:38:47 +0200 | [diff] [blame] | 44 | int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); |
Andrew Lunn | 04f3f5b | 2016-07-03 13:31:45 +0200 | [diff] [blame] | 45 | int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb); |
Simon Wunderlich | 536a23f | 2012-06-18 18:39:26 +0200 | [diff] [blame] | 46 | int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, |
| 47 | void *offset); |
Simon Wunderlich | ea4152e | 2016-07-03 13:31:47 +0200 | [diff] [blame] | 48 | int batadv_bla_backbone_dump(struct sk_buff *msg, struct netlink_callback *cb); |
Sven Eckelmann | 6b5e971 | 2015-05-26 18:34:26 +0200 | [diff] [blame] | 49 | bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig, |
Antonio Quartulli | cfd4f75 | 2013-08-07 18:28:56 +0200 | [diff] [blame] | 50 | unsigned short vid); |
Sven Eckelmann | 4b426b1 | 2016-02-22 21:02:39 +0100 | [diff] [blame] | 51 | bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, |
| 52 | struct sk_buff *skb); |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 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); |
Simon Wunderlich | d68081a | 2015-11-09 16:20:52 +0100 | [diff] [blame] | 56 | void batadv_bla_status_update(struct net_device *net_dev); |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 57 | int batadv_bla_init(struct batadv_priv *bat_priv); |
| 58 | void batadv_bla_free(struct batadv_priv *bat_priv); |
Andrew Lunn | 04f3f5b | 2016-07-03 13:31:45 +0200 | [diff] [blame] | 59 | int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb); |
Andreas Pape | 00311de | 2016-09-05 13:20:25 +0200 | [diff] [blame] | 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 |
Sven Eckelmann | 3964f72 | 2012-06-03 22:19:10 +0200 | [diff] [blame] | 64 | #define BATADV_BLA_CRC_INIT 0 |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 65 | #else /* ifdef CONFIG_BATMAN_ADV_BLA */ |
| 66 | |
Sven Eckelmann | 4b426b1 | 2016-02-22 21:02:39 +0100 | [diff] [blame] | 67 | static inline bool batadv_bla_rx(struct batadv_priv *bat_priv, |
| 68 | struct sk_buff *skb, unsigned short vid, |
Linus Lüssing | 74c09b7 | 2020-09-15 09:54:09 +0200 | [diff] [blame] | 69 | int packet_type) |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 70 | { |
Sven Eckelmann | 4b426b1 | 2016-02-22 21:02:39 +0100 | [diff] [blame] | 71 | return false; |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 72 | } |
| 73 | |
Sven Eckelmann | 4b426b1 | 2016-02-22 21:02:39 +0100 | [diff] [blame] | 74 | static inline bool batadv_bla_tx(struct batadv_priv *bat_priv, |
| 75 | struct sk_buff *skb, unsigned short vid) |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 76 | { |
Sven Eckelmann | 4b426b1 | 2016-02-22 21:02:39 +0100 | [diff] [blame] | 77 | return false; |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 78 | } |
| 79 | |
Sven Eckelmann | 4b426b1 | 2016-02-22 21:02:39 +0100 | [diff] [blame] | 80 | static inline bool batadv_bla_is_backbone_gw(struct sk_buff *skb, |
| 81 | struct batadv_orig_node *orig_node, |
| 82 | int hdr_size) |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 83 | { |
Sven Eckelmann | 4b426b1 | 2016-02-22 21:02:39 +0100 | [diff] [blame] | 84 | return false; |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 85 | } |
| 86 | |
Sven Eckelmann | 08adf15 | 2012-05-12 13:38:47 +0200 | [diff] [blame] | 87 | static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, |
| 88 | void *offset) |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 89 | { |
| 90 | return 0; |
| 91 | } |
| 92 | |
Simon Wunderlich | 536a23f | 2012-06-18 18:39:26 +0200 | [diff] [blame] | 93 | static inline int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, |
| 94 | void *offset) |
| 95 | { |
| 96 | return 0; |
| 97 | } |
| 98 | |
Antonio Quartulli | cfd4f75 | 2013-08-07 18:28:56 +0200 | [diff] [blame] | 99 | static inline bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, |
Sven Eckelmann | 6b5e971 | 2015-05-26 18:34:26 +0200 | [diff] [blame] | 100 | u8 *orig, unsigned short vid) |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 101 | { |
Antonio Quartulli | cfd4f75 | 2013-08-07 18:28:56 +0200 | [diff] [blame] | 102 | return false; |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 103 | } |
| 104 | |
Sven Eckelmann | 4b426b1 | 2016-02-22 21:02:39 +0100 | [diff] [blame] | 105 | static inline bool |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 106 | batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, |
Simon Wunderlich | 004e86f | 2012-10-18 13:47:42 +0200 | [diff] [blame] | 107 | struct sk_buff *skb) |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 108 | { |
Sven Eckelmann | 4b426b1 | 2016-02-22 21:02:39 +0100 | [diff] [blame] | 109 | return false; |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 110 | } |
| 111 | |
Sven Eckelmann | 08adf15 | 2012-05-12 13:38:47 +0200 | [diff] [blame] | 112 | static inline void |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 113 | batadv_bla_update_orig_address(struct batadv_priv *bat_priv, |
| 114 | struct batadv_hard_iface *primary_if, |
| 115 | struct batadv_hard_iface *oldif) |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 116 | { |
| 117 | } |
| 118 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 119 | static inline int batadv_bla_init(struct batadv_priv *bat_priv) |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 120 | { |
| 121 | return 1; |
| 122 | } |
| 123 | |
Sven Eckelmann | 56303d3 | 2012-06-05 22:31:31 +0200 | [diff] [blame] | 124 | static inline void batadv_bla_free(struct batadv_priv *bat_priv) |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 125 | { |
| 126 | } |
| 127 | |
Andrew Lunn | 04f3f5b | 2016-07-03 13:31:45 +0200 | [diff] [blame] | 128 | static inline int batadv_bla_claim_dump(struct sk_buff *msg, |
| 129 | struct netlink_callback *cb) |
| 130 | { |
| 131 | return -EOPNOTSUPP; |
| 132 | } |
| 133 | |
Simon Wunderlich | ea4152e | 2016-07-03 13:31:47 +0200 | [diff] [blame] | 134 | static inline int batadv_bla_backbone_dump(struct sk_buff *msg, |
| 135 | struct netlink_callback *cb) |
| 136 | { |
| 137 | return -EOPNOTSUPP; |
| 138 | } |
| 139 | |
Andreas Pape | 00311de | 2016-09-05 13:20:25 +0200 | [diff] [blame] | 140 | static inline |
| 141 | bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr, |
| 142 | unsigned short vid) |
| 143 | { |
| 144 | return true; |
| 145 | } |
| 146 | |
Simon Wunderlich | 7a5cc24 | 2012-01-22 20:00:27 +0100 | [diff] [blame] | 147 | #endif /* ifdef CONFIG_BATMAN_ADV_BLA */ |
Simon Wunderlich | 2372138 | 2012-01-22 20:00:19 +0100 | [diff] [blame] | 148 | |
| 149 | #endif /* ifndef _NET_BATMAN_ADV_BLA_H_ */ |