Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 136158
b: refs/heads/master
c: 636a5d3
h: refs/heads/master
v: v3
  • Loading branch information
Jouni Malinen authored and John W. Linville committed Mar 28, 2009
1 parent 4629543 commit 723e37e
Show file tree
Hide file tree
Showing 9 changed files with 602 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6039f6d23fe792d615da5449e9fa1c6b43caacf6
refs/heads/master: 636a5d3625993c5ca59abc81794b9ded93cdb740
1 change: 1 addition & 0 deletions trunk/include/linux/ieee80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ struct ieee80211_ht_info {
/* Authentication algorithms */
#define WLAN_AUTH_OPEN 0
#define WLAN_AUTH_SHARED_KEY 1
#define WLAN_AUTH_FT 2
#define WLAN_AUTH_LEAP 128

#define WLAN_AUTH_CHALLENGE_LEN 128
Expand Down
58 changes: 48 additions & 10 deletions trunk/include/linux/nl80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,24 +161,37 @@
* %NL80211_REG_TYPE_COUNTRY the alpha2 to which we have moved on
* to (%NL80211_ATTR_REG_ALPHA2).
*
* @NL80211_CMD_AUTHENTICATE: authentication notification (on the "mlme"
* multicast group). This event reports reception of an Authentication
* @NL80211_CMD_AUTHENTICATE: authentication request and notification.
* This command is used both as a command (request to authenticate) and
* as an event on the "mlme" multicast group indicating completion of the
* authentication process.
* When used as a command, %NL80211_ATTR_IFINDEX is used to identify the
* interface. %NL80211_ATTR_MAC is used to specify PeerSTAAddress (and
* BSSID in case of station mode). %NL80211_ATTR_SSID is used to specify
* the SSID (mainly for association, but is included in authentication
* request, too, to help BSS selection. %NL80211_ATTR_WIPHY_FREQ is used
* to specify the frequence of the channel in MHz. %NL80211_ATTR_AUTH_TYPE
* is used to specify the authentication type. %NL80211_ATTR_IE is used to
* define IEs (VendorSpecificInfo, but also including RSN IE and FT IEs)
* to be added to the frame.
* When used as an event, this reports reception of an Authentication
* frame in station and IBSS modes when the local MLME processed the
* frame, i.e., it was for the local STA and was received in correct
* state. This is similar to MLME-AUTHENTICATE.confirm primitive in the
* MLME SAP interface (kernel providing MLME, userspace SME). The
* included NL80211_ATTR_FRAME attribute contains the management frame
* (including both the header and frame body, but not FCS).
* @NL80211_CMD_ASSOCIATE: association notification; like
* NL80211_CMD_AUTHENTICATE but for Association Response and Reassociation
* Response frames (similar to MLME-ASSOCIATE.confirm or
* MLME-REASSOCIATE.confirm primitives).
* @NL80211_CMD_DEAUTHENTICATE: deauthentication notification; like
* @NL80211_CMD_ASSOCIATE: association request and notification; like
* NL80211_CMD_AUTHENTICATE but for Association and Reassociation
* (similar to MLME-ASSOCIATE.request, MLME-REASSOCIATE.request,
* MLME-ASSOCIATE.confirm or MLME-REASSOCIATE.confirm primitives).
* @NL80211_CMD_DEAUTHENTICATE: deauthentication request and notification; like
* NL80211_CMD_AUTHENTICATE but for Deauthentication frames (similar to
* MLME-DEAUTHENTICATE.indication primitive).
* @NL80211_CMD_DISASSOCIATE: disassociation notification; like
* MLME-DEAUTHENTICATION.request and MLME-DEAUTHENTICATE.indication
* primitives).
* @NL80211_CMD_DISASSOCIATE: disassociation request and notification; like
* NL80211_CMD_AUTHENTICATE but for Disassociation frames (similar to
* MLME-DISASSOCIATE.indication primitive).
* MLME-DISASSOCIATE.request and MLME-DISASSOCIATE.indication primitives).
*
* @NL80211_CMD_MAX: highest used command number
* @__NL80211_CMD_AFTER_LAST: internal use
Expand Down Expand Up @@ -383,6 +396,11 @@ enum nl80211_commands {
* @NL80211_ATTR_FRAME: frame data (binary attribute), including frame header
* and body, but not FCS; used, e.g., with NL80211_CMD_AUTHENTICATE and
* NL80211_CMD_ASSOCIATE events
* @NL80211_ATTR_SSID: SSID (binary attribute, 0..32 octets)
* @NL80211_ATTR_AUTH_TYPE: AuthenticationType, see &enum nl80211_auth_type,
* represented as a u32
* @NL80211_ATTR_REASON_CODE: ReasonCode for %NL80211_CMD_DEAUTHENTICATE and
* %NL80211_CMD_DISASSOCIATE, u16
*
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
Expand Down Expand Up @@ -464,6 +482,9 @@ enum nl80211_attrs {
NL80211_ATTR_SUPPORTED_COMMANDS,

NL80211_ATTR_FRAME,
NL80211_ATTR_SSID,
NL80211_ATTR_AUTH_TYPE,
NL80211_ATTR_REASON_CODE,

/* add attributes here, update the policy in nl80211.c */

Expand All @@ -485,6 +506,9 @@ enum nl80211_attrs {
#define NL80211_ATTR_REG_INITIATOR NL80211_ATTR_REG_INITIATOR
#define NL80211_ATTR_REG_TYPE NL80211_ATTR_REG_TYPE
#define NL80211_ATTR_FRAME NL80211_ATTR_FRAME
#define NL80211_ATTR_SSID NL80211_ATTR_SSID
#define NL80211_ATTR_AUTH_TYPE NL80211_ATTR_AUTH_TYPE
#define NL80211_ATTR_REASON_CODE NL80211_ATTR_REASON_CODE

#define NL80211_MAX_SUPP_RATES 32
#define NL80211_MAX_SUPP_REG_RULES 32
Expand Down Expand Up @@ -1018,4 +1042,18 @@ enum nl80211_bss {
NL80211_BSS_MAX = __NL80211_BSS_AFTER_LAST - 1
};

/**
* enum nl80211_auth_type - AuthenticationType
*
* @NL80211_AUTHTYPE_OPEN_SYSTEM: Open System authentication
* @NL80211_AUTHTYPE_SHARED_KEY: Shared Key authentication (WEP only)
* @NL80211_AUTHTYPE_FT: Fast BSS Transition (IEEE 802.11r)
* @NL80211_AUTHTYPE_NETWORK_EAP: Network EAP (some Cisco APs and mainly LEAP)
*/
enum nl80211_auth_type {
NL80211_AUTHTYPE_OPEN_SYSTEM,
NL80211_AUTHTYPE_SHARED_KEY,
NL80211_AUTHTYPE_FT,
NL80211_AUTHTYPE_NETWORK_EAP,
};
#endif /* __LINUX_NL80211_H */
113 changes: 113 additions & 0 deletions trunk/include/net/cfg80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,105 @@ struct cfg80211_bss {
u8 priv[0] __attribute__((__aligned__(sizeof(void *))));
};

/**
* struct cfg80211_auth_request - Authentication request data
*
* This structure provides information needed to complete IEEE 802.11
* authentication.
* NOTE: This structure will likely change when more code from mac80211 is
* moved into cfg80211 so that non-mac80211 drivers can benefit from it, too.
* Before using this in a driver that does not use mac80211, it would be better
* to check the status of that work and better yet, volunteer to work on it.
*
* @chan: The channel to use or %NULL if not specified (auto-select based on
* scan results)
* @peer_addr: The address of the peer STA (AP BSSID in infrastructure case);
* this field is required to be present; if the driver wants to help with
* BSS selection, it should use (yet to be added) MLME event to allow user
* space SME to be notified of roaming candidate, so that the SME can then
* use the authentication request with the recommended BSSID and whatever
* other data may be needed for authentication/association
* @ssid: SSID or %NULL if not yet available
* @ssid_len: Length of ssid in octets
* @auth_type: Authentication type (algorithm)
* @ie: Extra IEs to add to Authentication frame or %NULL
* @ie_len: Length of ie buffer in octets
*/
struct cfg80211_auth_request {
struct ieee80211_channel *chan;
u8 *peer_addr;
const u8 *ssid;
size_t ssid_len;
enum nl80211_auth_type auth_type;
const u8 *ie;
size_t ie_len;
};

/**
* struct cfg80211_assoc_request - (Re)Association request data
*
* This structure provides information needed to complete IEEE 802.11
* (re)association.
* NOTE: This structure will likely change when more code from mac80211 is
* moved into cfg80211 so that non-mac80211 drivers can benefit from it, too.
* Before using this in a driver that does not use mac80211, it would be better
* to check the status of that work and better yet, volunteer to work on it.
*
* @chan: The channel to use or %NULL if not specified (auto-select based on
* scan results)
* @peer_addr: The address of the peer STA (AP BSSID); this field is required
* to be present and the STA must be in State 2 (authenticated) with the
* peer STA
* @ssid: SSID
* @ssid_len: Length of ssid in octets
* @ie: Extra IEs to add to (Re)Association Request frame or %NULL
* @ie_len: Length of ie buffer in octets
*/
struct cfg80211_assoc_request {
struct ieee80211_channel *chan;
u8 *peer_addr;
const u8 *ssid;
size_t ssid_len;
const u8 *ie;
size_t ie_len;
};

/**
* struct cfg80211_deauth_request - Deauthentication request data
*
* This structure provides information needed to complete IEEE 802.11
* deauthentication.
*
* @peer_addr: The address of the peer STA (AP BSSID); this field is required
* to be present and the STA must be authenticated with the peer STA
* @ie: Extra IEs to add to Deauthentication frame or %NULL
* @ie_len: Length of ie buffer in octets
*/
struct cfg80211_deauth_request {
u8 *peer_addr;
u16 reason_code;
const u8 *ie;
size_t ie_len;
};

/**
* struct cfg80211_disassoc_request - Disassociation request data
*
* This structure provides information needed to complete IEEE 802.11
* disassocation.
*
* @peer_addr: The address of the peer STA (AP BSSID); this field is required
* to be present and the STA must be associated with the peer STA
* @ie: Extra IEs to add to Disassociation frame or %NULL
* @ie_len: Length of ie buffer in octets
*/
struct cfg80211_disassoc_request {
u8 *peer_addr;
u16 reason_code;
const u8 *ie;
size_t ie_len;
};

/**
* struct cfg80211_ops - backend description for wireless configuration
*
Expand Down Expand Up @@ -650,6 +749,11 @@ struct cfg80211_bss {
* the driver, and will be valid until passed to cfg80211_scan_done().
* For scan results, call cfg80211_inform_bss(); you can call this outside
* the scan/scan_done bracket too.
*
* @auth: Request to authenticate with the specified peer
* @assoc: Request to (re)associate with the specified peer
* @deauth: Request to deauthenticate from the specified peer
* @disassoc: Request to disassociate from the specified peer
*/
struct cfg80211_ops {
int (*suspend)(struct wiphy *wiphy);
Expand Down Expand Up @@ -730,6 +834,15 @@ struct cfg80211_ops {

int (*scan)(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_scan_request *request);

int (*auth)(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_auth_request *req);
int (*assoc)(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_assoc_request *req);
int (*deauth)(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_deauth_request *req);
int (*disassoc)(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_disassoc_request *req);
};

/* temporary wext handlers */
Expand Down
140 changes: 140 additions & 0 deletions trunk/net/mac80211/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,142 @@ static int ieee80211_scan(struct wiphy *wiphy,
return ieee80211_request_scan(sdata, req);
}

static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_auth_request *req)
{
struct ieee80211_sub_if_data *sdata;

if (!netif_running(dev))
return -ENETDOWN;

sdata = IEEE80211_DEV_TO_SUB_IF(dev);

if (sdata->vif.type != NL80211_IFTYPE_STATION)
return -EOPNOTSUPP;

switch (req->auth_type) {
case NL80211_AUTHTYPE_OPEN_SYSTEM:
sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_OPEN;
break;
case NL80211_AUTHTYPE_SHARED_KEY:
sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_SHARED_KEY;
break;
case NL80211_AUTHTYPE_FT:
sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_FT;
break;
case NL80211_AUTHTYPE_NETWORK_EAP:
sdata->u.mgd.auth_algs = IEEE80211_AUTH_ALG_LEAP;
break;
default:
return -EOPNOTSUPP;
}

memcpy(sdata->u.mgd.bssid, req->peer_addr, ETH_ALEN);
sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL;
sdata->u.mgd.flags |= IEEE80211_STA_BSSID_SET;

/* TODO: req->chan */
sdata->u.mgd.flags |= IEEE80211_STA_AUTO_CHANNEL_SEL;

if (req->ssid) {
sdata->u.mgd.flags |= IEEE80211_STA_SSID_SET;
memcpy(sdata->u.mgd.ssid, req->ssid, req->ssid_len);
sdata->u.mgd.ssid_len = req->ssid_len;
sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_SSID_SEL;
}

kfree(sdata->u.mgd.sme_auth_ie);
sdata->u.mgd.sme_auth_ie = NULL;
sdata->u.mgd.sme_auth_ie_len = 0;
if (req->ie) {
sdata->u.mgd.sme_auth_ie = kmalloc(req->ie_len, GFP_KERNEL);
if (sdata->u.mgd.sme_auth_ie == NULL)
return -ENOMEM;
memcpy(sdata->u.mgd.sme_auth_ie, req->ie, req->ie_len);
sdata->u.mgd.sme_auth_ie_len = req->ie_len;
}

sdata->u.mgd.flags |= IEEE80211_STA_EXT_SME;
sdata->u.mgd.state = IEEE80211_STA_MLME_DIRECT_PROBE;
ieee80211_sta_req_auth(sdata);
return 0;
}

static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_assoc_request *req)
{
struct ieee80211_sub_if_data *sdata;
int ret;

if (!netif_running(dev))
return -ENETDOWN;

sdata = IEEE80211_DEV_TO_SUB_IF(dev);

if (sdata->vif.type != NL80211_IFTYPE_STATION)
return -EOPNOTSUPP;

if (memcmp(sdata->u.mgd.bssid, req->peer_addr, ETH_ALEN) != 0 ||
!(sdata->u.mgd.flags & IEEE80211_STA_AUTHENTICATED))
return -ENOLINK; /* not authenticated */

sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL;
sdata->u.mgd.flags |= IEEE80211_STA_BSSID_SET;

/* TODO: req->chan */
sdata->u.mgd.flags |= IEEE80211_STA_AUTO_CHANNEL_SEL;

if (req->ssid) {
sdata->u.mgd.flags |= IEEE80211_STA_SSID_SET;
memcpy(sdata->u.mgd.ssid, req->ssid, req->ssid_len);
sdata->u.mgd.ssid_len = req->ssid_len;
sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_SSID_SEL;
} else
sdata->u.mgd.flags |= IEEE80211_STA_AUTO_SSID_SEL;

ret = ieee80211_sta_set_extra_ie(sdata, req->ie, req->ie_len);
if (ret)
return ret;

sdata->u.mgd.flags |= IEEE80211_STA_EXT_SME;
sdata->u.mgd.state = IEEE80211_STA_MLME_ASSOCIATE;
ieee80211_sta_req_auth(sdata);
return 0;
}

static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_deauth_request *req)
{
struct ieee80211_sub_if_data *sdata;

if (!netif_running(dev))
return -ENETDOWN;

sdata = IEEE80211_DEV_TO_SUB_IF(dev);
if (sdata->vif.type != NL80211_IFTYPE_STATION)
return -EOPNOTSUPP;

/* TODO: req->ie */
return ieee80211_sta_deauthenticate(sdata, req->reason_code);
}

static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_disassoc_request *req)
{
struct ieee80211_sub_if_data *sdata;

if (!netif_running(dev))
return -ENETDOWN;

sdata = IEEE80211_DEV_TO_SUB_IF(dev);

if (sdata->vif.type != NL80211_IFTYPE_STATION)
return -EOPNOTSUPP;

/* TODO: req->ie */
return ieee80211_sta_disassociate(sdata, req->reason_code);
}

struct cfg80211_ops mac80211_config_ops = {
.add_virtual_intf = ieee80211_add_iface,
.del_virtual_intf = ieee80211_del_iface,
Expand Down Expand Up @@ -1333,4 +1469,8 @@ struct cfg80211_ops mac80211_config_ops = {
.suspend = ieee80211_suspend,
.resume = ieee80211_resume,
.scan = ieee80211_scan,
.auth = ieee80211_auth,
.assoc = ieee80211_assoc,
.deauth = ieee80211_deauth,
.disassoc = ieee80211_disassoc,
};
Loading

0 comments on commit 723e37e

Please sign in to comment.