0001
0002
0003
0004
0005
0006
0007 #ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_
0008 #define _NET_BATMAN_ADV_HARD_INTERFACE_H_
0009
0010 #include "main.h"
0011
0012 #include <linux/compiler.h>
0013 #include <linux/kref.h>
0014 #include <linux/netdevice.h>
0015 #include <linux/notifier.h>
0016 #include <linux/rcupdate.h>
0017 #include <linux/stddef.h>
0018 #include <linux/types.h>
0019
0020
0021
0022
0023 enum batadv_hard_if_state {
0024
0025
0026
0027
0028 BATADV_IF_NOT_IN_USE,
0029
0030
0031
0032
0033
0034 BATADV_IF_TO_BE_REMOVED,
0035
0036
0037 BATADV_IF_INACTIVE,
0038
0039
0040 BATADV_IF_ACTIVE,
0041
0042
0043 BATADV_IF_TO_BE_ACTIVATED,
0044 };
0045
0046
0047
0048
0049 enum batadv_hard_if_bcast {
0050
0051 BATADV_HARDIF_BCAST_OK = 0,
0052
0053
0054
0055
0056
0057 BATADV_HARDIF_BCAST_NORECIPIENT,
0058
0059
0060
0061
0062
0063 BATADV_HARDIF_BCAST_DUPFWD,
0064
0065
0066 BATADV_HARDIF_BCAST_DUPORIG,
0067 };
0068
0069 extern struct notifier_block batadv_hard_if_notifier;
0070
0071 struct net_device *batadv_get_real_netdev(struct net_device *net_device);
0072 bool batadv_is_cfg80211_hardif(struct batadv_hard_iface *hard_iface);
0073 bool batadv_is_wifi_hardif(struct batadv_hard_iface *hard_iface);
0074 struct batadv_hard_iface*
0075 batadv_hardif_get_by_netdev(const struct net_device *net_dev);
0076 int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
0077 struct net_device *soft_iface);
0078 void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface);
0079 int batadv_hardif_min_mtu(struct net_device *soft_iface);
0080 void batadv_update_min_mtu(struct net_device *soft_iface);
0081 void batadv_hardif_release(struct kref *ref);
0082 int batadv_hardif_no_broadcast(struct batadv_hard_iface *if_outgoing,
0083 u8 *orig_addr, u8 *orig_neigh);
0084
0085
0086
0087
0088
0089
0090 static inline void batadv_hardif_put(struct batadv_hard_iface *hard_iface)
0091 {
0092 if (!hard_iface)
0093 return;
0094
0095 kref_put(&hard_iface->refcount, batadv_hardif_release);
0096 }
0097
0098
0099
0100
0101
0102
0103
0104 static inline struct batadv_hard_iface *
0105 batadv_primary_if_get_selected(struct batadv_priv *bat_priv)
0106 {
0107 struct batadv_hard_iface *hard_iface;
0108
0109 rcu_read_lock();
0110 hard_iface = rcu_dereference(bat_priv->primary_if);
0111 if (!hard_iface)
0112 goto out;
0113
0114 if (!kref_get_unless_zero(&hard_iface->refcount))
0115 hard_iface = NULL;
0116
0117 out:
0118 rcu_read_unlock();
0119 return hard_iface;
0120 }
0121
0122 #endif