mlme.c 3.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * cfg80211 MLME SAP interface
 *
 * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/nl80211.h>
#include <net/cfg80211.h>
#include "core.h"
#include "nl80211.h"

15
void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len, gfp_t gfp)
16 17 18
{
	struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
	struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
19
	nl80211_send_rx_auth(rdev, dev, buf, len, gfp);
20 21 22
}
EXPORT_SYMBOL(cfg80211_send_rx_auth);

23
void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len, gfp_t gfp)
24 25 26
{
	struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
	struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
27
	nl80211_send_rx_assoc(rdev, dev, buf, len, gfp);
28 29 30
}
EXPORT_SYMBOL(cfg80211_send_rx_assoc);

31
void cfg80211_send_deauth(struct net_device *dev, const u8 *buf, size_t len, gfp_t gfp)
32 33 34
{
	struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
	struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
35
	nl80211_send_deauth(rdev, dev, buf, len, gfp);
36
}
37
EXPORT_SYMBOL(cfg80211_send_deauth);
38

39
void cfg80211_send_disassoc(struct net_device *dev, const u8 *buf, size_t len, gfp_t gfp)
40 41 42
{
	struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
	struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
43
	nl80211_send_disassoc(rdev, dev, buf, len, gfp);
44
}
45
EXPORT_SYMBOL(cfg80211_send_disassoc);
46

47 48 49 50 51 52 53 54 55
static void cfg80211_wext_disconnected(struct net_device *dev)
{
#ifdef CONFIG_WIRELESS_EXT
	union iwreq_data wrqu;
	memset(&wrqu, 0, sizeof(wrqu));
	wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
#endif
}

56
void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr, gfp_t gfp)
57 58 59
{
	struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
	struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
60
	nl80211_send_auth_timeout(rdev, dev, addr, gfp);
61 62 63 64
	cfg80211_wext_disconnected(dev);
}
EXPORT_SYMBOL(cfg80211_send_auth_timeout);

65
void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr, gfp_t gfp)
66 67 68
{
	struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
	struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
69
	nl80211_send_assoc_timeout(rdev, dev, addr, gfp);
70 71 72 73
	cfg80211_wext_disconnected(dev);
}
EXPORT_SYMBOL(cfg80211_send_assoc_timeout);

74 75
void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
				  enum nl80211_key_type key_type, int key_id,
76
				  const u8 *tsc, gfp_t gfp)
77 78 79
{
	struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
	struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
80 81
#ifdef CONFIG_WIRELESS_EXT
	union iwreq_data wrqu;
82
	char *buf = kmalloc(128, gfp);
83 84 85 86 87 88 89 90 91 92 93 94 95

	if (buf) {
		sprintf(buf, "MLME-MICHAELMICFAILURE.indication("
			"keyid=%d %scast addr=%pM)", key_id,
			key_type == NL80211_KEYTYPE_GROUP ? "broad" : "uni",
			addr);
		memset(&wrqu, 0, sizeof(wrqu));
		wrqu.data.length = strlen(buf);
		wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
		kfree(buf);
	}
#endif

96
	nl80211_michael_mic_failure(rdev, dev, addr, key_type, key_id, tsc, gfp);
97 98
}
EXPORT_SYMBOL(cfg80211_michael_mic_failure);