Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc279080 authored by Antonio Quartulli's avatar Antonio Quartulli Committed by Marek Lindner
Browse files

batman-adv: detect clients connected through a 802.11 device



Clients connected through a 802.11 device are now marked with the
TT_CLIENT_WIFI flag. This flag is also advertised with the tt
announcement.

Signed-off-by: default avatarAntonio Quartulli <ordex@autistici.org>
Signed-off-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
parent 015758d0
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -681,6 +681,36 @@ err_out:
	return NET_RX_DROP;
}

/* This function returns true if the interface represented by ifindex is a
 * 802.11 wireless device */
bool is_wifi_iface(int ifindex)
{
	struct net_device *net_device = NULL;
	bool ret = false;

	if (ifindex == NULL_IFINDEX)
		goto out;

	net_device = dev_get_by_index(&init_net, ifindex);
	if (!net_device)
		goto out;

#ifdef CONFIG_WIRELESS_EXT
	/* pre-cfg80211 drivers have to implement WEXT, so it is possible to
	 * check for wireless_handlers != NULL */
	if (net_device->wireless_handlers)
		ret = true;
	else
#endif
		/* cfg80211 drivers have to set ieee80211_ptr */
		if (net_device->ieee80211_ptr)
			ret = true;
out:
	if (net_device)
		dev_put(net_device);
	return ret;
}

struct notifier_block hard_if_notifier = {
	.notifier_call = hard_if_event,
};
+1 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ void hardif_remove_interfaces(void);
int hardif_min_mtu(struct net_device *soft_iface);
void update_min_mtu(struct net_device *soft_iface);
void hardif_free_rcu(struct rcu_head *rcu);
bool is_wifi_iface(int ifindex);

static inline void hardif_free_ref(struct hard_iface *hard_iface)
{
+1 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ int mesh_init(struct net_device *soft_iface)
	if (tt_init(bat_priv) < 1)
		goto err;

	tt_local_add(soft_iface, soft_iface->dev_addr);
	tt_local_add(soft_iface, soft_iface->dev_addr, NULL_IFINDEX);

	if (vis_init(bat_priv) < 1)
		goto err;
+2 −0
Original line number Diff line number Diff line
@@ -62,6 +62,8 @@

#define NO_FLAGS 0

#define NULL_IFINDEX 0 /* dummy ifindex used to avoid iface checks */

#define NUM_WORDS (TQ_LOCAL_WINDOW_SIZE / WORD_BIT_SIZE)

#define LOG_BUF_LEN 8192	  /* has to be a power of 2 */
+1 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ enum tt_query_flags {
enum tt_client_flags {
	TT_CLIENT_DEL     = 1 << 0,
	TT_CLIENT_ROAM    = 1 << 1,
	TT_CLIENT_WIFI    = 1 << 2,
	TT_CLIENT_NOPURGE = 1 << 8,
	TT_CLIENT_NEW     = 1 << 9,
	TT_CLIENT_PENDING = 1 << 10
Loading