blob: c4e6d4b84a46ba994717bf4618decd83e42b81d3 [file] [log] [blame]
Jouni Malinen6039f6d2009-03-19 13:39:21 +02001/*
2 * cfg80211 MLME SAP interface
3 *
4 * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
5 */
6
7#include <linux/kernel.h>
8#include <linux/module.h>
9#include <linux/netdevice.h>
10#include <linux/nl80211.h>
11#include <net/cfg80211.h>
12#include "core.h"
13#include "nl80211.h"
14
Johannes Berge6d6e342009-07-01 21:26:47 +020015void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len, gfp_t gfp)
Jouni Malinen6039f6d2009-03-19 13:39:21 +020016{
17 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
18 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berge6d6e342009-07-01 21:26:47 +020019 nl80211_send_rx_auth(rdev, dev, buf, len, gfp);
Jouni Malinen6039f6d2009-03-19 13:39:21 +020020}
21EXPORT_SYMBOL(cfg80211_send_rx_auth);
22
Johannes Berge6d6e342009-07-01 21:26:47 +020023void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len, gfp_t gfp)
Jouni Malinen6039f6d2009-03-19 13:39:21 +020024{
25 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
26 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berge6d6e342009-07-01 21:26:47 +020027 nl80211_send_rx_assoc(rdev, dev, buf, len, gfp);
Jouni Malinen6039f6d2009-03-19 13:39:21 +020028}
29EXPORT_SYMBOL(cfg80211_send_rx_assoc);
30
Johannes Berge6d6e342009-07-01 21:26:47 +020031void cfg80211_send_deauth(struct net_device *dev, const u8 *buf, size_t len, gfp_t gfp)
Jouni Malinen6039f6d2009-03-19 13:39:21 +020032{
33 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
34 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berge6d6e342009-07-01 21:26:47 +020035 nl80211_send_deauth(rdev, dev, buf, len, gfp);
Jouni Malinen6039f6d2009-03-19 13:39:21 +020036}
Jouni Malinen53b46b82009-03-27 20:53:56 +020037EXPORT_SYMBOL(cfg80211_send_deauth);
Jouni Malinen6039f6d2009-03-19 13:39:21 +020038
Johannes Berge6d6e342009-07-01 21:26:47 +020039void cfg80211_send_disassoc(struct net_device *dev, const u8 *buf, size_t len, gfp_t gfp)
Jouni Malinen6039f6d2009-03-19 13:39:21 +020040{
41 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
42 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berge6d6e342009-07-01 21:26:47 +020043 nl80211_send_disassoc(rdev, dev, buf, len, gfp);
Jouni Malinen6039f6d2009-03-19 13:39:21 +020044}
Jouni Malinen53b46b82009-03-27 20:53:56 +020045EXPORT_SYMBOL(cfg80211_send_disassoc);
Jouni Malinena3b8b052009-03-27 21:59:49 +020046
Jouni Malinen1965c852009-04-22 21:38:25 +030047static void cfg80211_wext_disconnected(struct net_device *dev)
48{
49#ifdef CONFIG_WIRELESS_EXT
50 union iwreq_data wrqu;
51 memset(&wrqu, 0, sizeof(wrqu));
52 wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
53#endif
54}
55
Johannes Berge6d6e342009-07-01 21:26:47 +020056void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr, gfp_t gfp)
Jouni Malinen1965c852009-04-22 21:38:25 +030057{
58 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
59 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berge6d6e342009-07-01 21:26:47 +020060 nl80211_send_auth_timeout(rdev, dev, addr, gfp);
Jouni Malinen1965c852009-04-22 21:38:25 +030061 cfg80211_wext_disconnected(dev);
62}
63EXPORT_SYMBOL(cfg80211_send_auth_timeout);
64
Johannes Berge6d6e342009-07-01 21:26:47 +020065void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr, gfp_t gfp)
Jouni Malinen1965c852009-04-22 21:38:25 +030066{
67 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
68 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Berge6d6e342009-07-01 21:26:47 +020069 nl80211_send_assoc_timeout(rdev, dev, addr, gfp);
Jouni Malinen1965c852009-04-22 21:38:25 +030070 cfg80211_wext_disconnected(dev);
71}
72EXPORT_SYMBOL(cfg80211_send_assoc_timeout);
73
Jouni Malinena3b8b052009-03-27 21:59:49 +020074void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr,
75 enum nl80211_key_type key_type, int key_id,
Johannes Berge6d6e342009-07-01 21:26:47 +020076 const u8 *tsc, gfp_t gfp)
Jouni Malinena3b8b052009-03-27 21:59:49 +020077{
78 struct wiphy *wiphy = dev->ieee80211_ptr->wiphy;
79 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
Johannes Bergf58d4ed2009-06-19 02:45:21 +020080#ifdef CONFIG_WIRELESS_EXT
81 union iwreq_data wrqu;
Johannes Berge6d6e342009-07-01 21:26:47 +020082 char *buf = kmalloc(128, gfp);
Johannes Bergf58d4ed2009-06-19 02:45:21 +020083
84 if (buf) {
85 sprintf(buf, "MLME-MICHAELMICFAILURE.indication("
86 "keyid=%d %scast addr=%pM)", key_id,
87 key_type == NL80211_KEYTYPE_GROUP ? "broad" : "uni",
88 addr);
89 memset(&wrqu, 0, sizeof(wrqu));
90 wrqu.data.length = strlen(buf);
91 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
92 kfree(buf);
93 }
94#endif
95
Johannes Berge6d6e342009-07-01 21:26:47 +020096 nl80211_michael_mic_failure(rdev, dev, addr, key_type, key_id, tsc, gfp);
Jouni Malinena3b8b052009-03-27 21:59:49 +020097}
98EXPORT_SYMBOL(cfg80211_michael_mic_failure);