Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright (C) B.A.T.M.A.N. contributors:
0003  *
0004  * Simon Wunderlich
0005  */
0006 
0007 #ifndef _NET_BATMAN_ADV_BLA_H_
0008 #define _NET_BATMAN_ADV_BLA_H_
0009 
0010 #include "main.h"
0011 
0012 #include <linux/compiler.h>
0013 #include <linux/netdevice.h>
0014 #include <linux/netlink.h>
0015 #include <linux/skbuff.h>
0016 #include <linux/stddef.h>
0017 #include <linux/types.h>
0018 
0019 /**
0020  * batadv_bla_is_loopdetect_mac() - check if the mac address is from a loop
0021  *  detect frame sent by bridge loop avoidance
0022  * @mac: mac address to check
0023  *
0024  * Return: true if the it looks like a loop detect frame
0025  * (mac starts with BA:BE), false otherwise
0026  */
0027 static inline bool batadv_bla_is_loopdetect_mac(const uint8_t *mac)
0028 {
0029     if (mac[0] == 0xba && mac[1] == 0xbe)
0030         return true;
0031 
0032     return false;
0033 }
0034 
0035 #ifdef CONFIG_BATMAN_ADV_BLA
0036 bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
0037            unsigned short vid, int packet_type);
0038 bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
0039            unsigned short vid);
0040 bool batadv_bla_is_backbone_gw(struct sk_buff *skb,
0041                    struct batadv_orig_node *orig_node,
0042                    int hdr_size);
0043 int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb);
0044 int batadv_bla_backbone_dump(struct sk_buff *msg, struct netlink_callback *cb);
0045 bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig,
0046                     unsigned short vid);
0047 bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
0048                     struct sk_buff *skb);
0049 void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
0050                     struct batadv_hard_iface *primary_if,
0051                     struct batadv_hard_iface *oldif);
0052 void batadv_bla_status_update(struct net_device *net_dev);
0053 int batadv_bla_init(struct batadv_priv *bat_priv);
0054 void batadv_bla_free(struct batadv_priv *bat_priv);
0055 #ifdef CONFIG_BATMAN_ADV_DAT
0056 bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
0057                 unsigned short vid);
0058 #endif
0059 #define BATADV_BLA_CRC_INIT 0
0060 #else /* ifdef CONFIG_BATMAN_ADV_BLA */
0061 
0062 static inline bool batadv_bla_rx(struct batadv_priv *bat_priv,
0063                  struct sk_buff *skb, unsigned short vid,
0064                  int packet_type)
0065 {
0066     return false;
0067 }
0068 
0069 static inline bool batadv_bla_tx(struct batadv_priv *bat_priv,
0070                  struct sk_buff *skb, unsigned short vid)
0071 {
0072     return false;
0073 }
0074 
0075 static inline bool batadv_bla_is_backbone_gw(struct sk_buff *skb,
0076                          struct batadv_orig_node *orig_node,
0077                          int hdr_size)
0078 {
0079     return false;
0080 }
0081 
0082 static inline bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv,
0083                           u8 *orig, unsigned short vid)
0084 {
0085     return false;
0086 }
0087 
0088 static inline bool
0089 batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
0090                    struct sk_buff *skb)
0091 {
0092     return false;
0093 }
0094 
0095 static inline void
0096 batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
0097                    struct batadv_hard_iface *primary_if,
0098                    struct batadv_hard_iface *oldif)
0099 {
0100 }
0101 
0102 static inline int batadv_bla_init(struct batadv_priv *bat_priv)
0103 {
0104     return 1;
0105 }
0106 
0107 static inline void batadv_bla_free(struct batadv_priv *bat_priv)
0108 {
0109 }
0110 
0111 static inline int batadv_bla_claim_dump(struct sk_buff *msg,
0112                     struct netlink_callback *cb)
0113 {
0114     return -EOPNOTSUPP;
0115 }
0116 
0117 static inline int batadv_bla_backbone_dump(struct sk_buff *msg,
0118                        struct netlink_callback *cb)
0119 {
0120     return -EOPNOTSUPP;
0121 }
0122 
0123 static inline
0124 bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
0125                 unsigned short vid)
0126 {
0127     return true;
0128 }
0129 
0130 #endif /* ifdef CONFIG_BATMAN_ADV_BLA */
0131 
0132 #endif /* ifndef _NET_BATMAN_ADV_BLA_H_ */