Commit 8a9faf3c authored by Al Viro's avatar Al Viro Committed by David S. Miller
Browse files

hostap annotations


Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 3eb9b41f
......@@ -5,52 +5,52 @@
#include <net/ieee80211_crypt.h>
struct hostap_ieee80211_mgmt {
u16 frame_control;
u16 duration;
__le16 frame_control;
__le16 duration;
u8 da[6];
u8 sa[6];
u8 bssid[6];
u16 seq_ctrl;
__le16 seq_ctrl;
union {
struct {
u16 auth_alg;
u16 auth_transaction;
u16 status_code;
__le16 auth_alg;
__le16 auth_transaction;
__le16 status_code;
/* possibly followed by Challenge text */
u8 variable[0];
} __attribute__ ((packed)) auth;
struct {
u16 reason_code;
__le16 reason_code;
} __attribute__ ((packed)) deauth;
struct {
u16 capab_info;
u16 listen_interval;
__le16 capab_info;
__le16 listen_interval;
/* followed by SSID and Supported rates */
u8 variable[0];
} __attribute__ ((packed)) assoc_req;
struct {
u16 capab_info;
u16 status_code;
u16 aid;
__le16 capab_info;
__le16 status_code;
__le16 aid;
/* followed by Supported rates */
u8 variable[0];
} __attribute__ ((packed)) assoc_resp, reassoc_resp;
struct {
u16 capab_info;
u16 listen_interval;
__le16 capab_info;
__le16 listen_interval;
u8 current_ap[6];
/* followed by SSID and Supported rates */
u8 variable[0];
} __attribute__ ((packed)) reassoc_req;
struct {
u16 reason_code;
__le16 reason_code;
} __attribute__ ((packed)) disassoc;
struct {
} __attribute__ ((packed)) probe_req;
struct {
u8 timestamp[8];
u16 beacon_int;
u16 capab_info;
__le16 beacon_int;
__le16 capab_info;
/* followed by some of SSID, Supported rates,
* FH Params, DS Params, CF Params, IBSS Params, TIM */
u8 variable[0];
......
......@@ -1039,7 +1039,7 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
} else {
u16 len;
__be16 len;
/* Leave Ethernet header part of hdr and full payload */
skb_pull(skb, hdrlen);
len = htons(skb->len);
......
......@@ -258,7 +258,7 @@ static void ap_handle_timer(unsigned long data)
sta->addr, ap->tx_callback_poll);
} else {
int deauth = sta->timeout_next == STA_DEAUTH;
u16 resp;
__le16 resp;
PDEBUG(DEBUG_AP, "%s: sending %s info to STA %s"
"(last=%lu, jiffies=%lu)\n",
local->dev->name,
......@@ -300,13 +300,13 @@ void hostap_deauth_all_stas(struct net_device *dev, struct ap_data *ap,
int resend)
{
u8 addr[ETH_ALEN];
u16 resp;
__le16 resp;
int i;
PDEBUG(DEBUG_AP, "%s: Deauthenticate all stations\n", dev->name);
memset(addr, 0xff, ETH_ALEN);
resp = __constant_cpu_to_le16(WLAN_REASON_PREV_AUTH_NOT_VALID);
resp = cpu_to_le16(WLAN_REASON_PREV_AUTH_NOT_VALID);
/* deauth message sent; try to resend it few times; the message is
* broadcast, so it may be delayed until next DTIM; there is not much
......@@ -462,7 +462,7 @@ void ap_control_flush_macs(struct mac_restrictions *mac_restrictions)
int ap_control_kick_mac(struct ap_data *ap, struct net_device *dev, u8 *mac)
{
struct sta_info *sta;
u16 resp;
__le16 resp;
spin_lock_bh(&ap->sta_table_lock);
sta = ap_get_sta(ap, mac);
......@@ -628,7 +628,8 @@ static void hostap_ap_tx_cb_auth(struct sk_buff *skb, int ok, void *data)
struct ap_data *ap = data;
struct net_device *dev = ap->local->dev;
struct ieee80211_hdr_4addr *hdr;
u16 fc, *pos, auth_alg, auth_transaction, status;
u16 fc, auth_alg, auth_transaction, status;
__le16 *pos;
struct sta_info *sta = NULL;
char *txt = NULL;
DECLARE_MAC_BUF(mac);
......@@ -649,7 +650,7 @@ static void hostap_ap_tx_cb_auth(struct sk_buff *skb, int ok, void *data)
return;
}
pos = (u16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);
pos = (__le16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);
auth_alg = le16_to_cpu(*pos++);
auth_transaction = le16_to_cpu(*pos++);
status = le16_to_cpu(*pos++);
......@@ -698,7 +699,8 @@ static void hostap_ap_tx_cb_assoc(struct sk_buff *skb, int ok, void *data)
struct ap_data *ap = data;
struct net_device *dev = ap->local->dev;
struct ieee80211_hdr_4addr *hdr;
u16 fc, *pos, status;
u16 fc, status;
__le16 *pos;
struct sta_info *sta = NULL;
char *txt = NULL;
DECLARE_MAC_BUF(mac);
......@@ -736,7 +738,7 @@ static void hostap_ap_tx_cb_assoc(struct sk_buff *skb, int ok, void *data)
goto done;
}
pos = (u16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);
pos = (__le16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);
pos++;
status = le16_to_cpu(*pos++);
if (status == WLAN_STATUS_SUCCESS) {
......@@ -1298,7 +1300,8 @@ static void handle_authen(local_info_t *local, struct sk_buff *skb,
struct ap_data *ap = local->ap;
char body[8 + WLAN_AUTH_CHALLENGE_LEN], *challenge = NULL;
int len, olen;
u16 auth_alg, auth_transaction, status_code, *pos;
u16 auth_alg, auth_transaction, status_code;
__le16 *pos;
u16 resp = WLAN_STATUS_SUCCESS, fc;
struct sta_info *sta = NULL;
struct ieee80211_crypt_data *crypt;
......@@ -1332,7 +1335,7 @@ static void handle_authen(local_info_t *local, struct sk_buff *skb,
crypt = local->crypt[idx];
}
pos = (u16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);
pos = (__le16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);
auth_alg = __le16_to_cpu(*pos);
pos++;
auth_transaction = __le16_to_cpu(*pos);
......@@ -1465,7 +1468,7 @@ static void handle_authen(local_info_t *local, struct sk_buff *skb,
}
fail:
pos = (u16 *) body;
pos = (__le16 *) body;
*pos = cpu_to_le16(auth_alg);
pos++;
*pos = cpu_to_le16(auth_transaction + 1);
......@@ -1510,7 +1513,7 @@ static void handle_assoc(local_info_t *local, struct sk_buff *skb,
struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *) skb->data;
char body[12], *p, *lpos;
int len, left;
u16 *pos;
__le16 *pos;
u16 resp = WLAN_STATUS_SUCCESS;
struct sta_info *sta = NULL;
int send_deauth = 0;
......@@ -1540,7 +1543,7 @@ static void handle_assoc(local_info_t *local, struct sk_buff *skb,
atomic_inc(&sta->users);
spin_unlock_bh(&local->ap->sta_table_lock);
pos = (u16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);
pos = (__le16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);
sta->capability = __le16_to_cpu(*pos);
pos++; left -= 2;
sta->listen_interval = __le16_to_cpu(*pos);
......@@ -1636,25 +1639,24 @@ static void handle_assoc(local_info_t *local, struct sk_buff *skb,
}
fail:
pos = (u16 *) body;
pos = (__le16 *) body;
if (send_deauth) {
*pos = __constant_cpu_to_le16(
WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH);
*pos = cpu_to_le16(WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH);
pos++;
} else {
/* FIX: CF-Pollable and CF-PollReq should be set to match the
* values in beacons/probe responses */
/* FIX: how about privacy and WEP? */
/* capability */
*pos = __constant_cpu_to_le16(WLAN_CAPABILITY_ESS);
*pos = cpu_to_le16(WLAN_CAPABILITY_ESS);
pos++;
/* status_code */
*pos = __cpu_to_le16(resp);
*pos = cpu_to_le16(resp);
pos++;
*pos = __cpu_to_le16((sta && sta->aid > 0 ? sta->aid : 0) |
*pos = cpu_to_le16((sta && sta->aid > 0 ? sta->aid : 0) |
BIT(14) | BIT(15)); /* AID */
pos++;
......@@ -1681,7 +1683,7 @@ static void handle_assoc(local_info_t *local, struct sk_buff *skb,
0x96 : 0x16;
(*lpos)++;
}
pos = (u16 *) p;
pos = (__le16 *) p;
}
prism2_send_mgmt(dev, IEEE80211_FTYPE_MGMT |
......@@ -1718,7 +1720,8 @@ static void handle_deauth(local_info_t *local, struct sk_buff *skb,
struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *) skb->data;
char *body = (char *) (skb->data + IEEE80211_MGMT_HDR_LEN);
int len;
u16 reason_code, *pos;
u16 reason_code;
__le16 *pos;
struct sta_info *sta = NULL;
DECLARE_MAC_BUF(mac);
......@@ -1729,8 +1732,8 @@ static void handle_deauth(local_info_t *local, struct sk_buff *skb,
return;
}
pos = (u16 *) body;
reason_code = __le16_to_cpu(*pos);
pos = (__le16 *) body;
reason_code = le16_to_cpu(*pos);
PDEBUG(DEBUG_AP, "%s: deauthentication: %s len=%d, "
"reason_code=%d\n", dev->name, print_mac(mac, hdr->addr2), len,
......@@ -1760,7 +1763,8 @@ static void handle_disassoc(local_info_t *local, struct sk_buff *skb,
struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *) skb->data;
char *body = skb->data + IEEE80211_MGMT_HDR_LEN;
int len;
u16 reason_code, *pos;
u16 reason_code;
__le16 *pos;
struct sta_info *sta = NULL;
DECLARE_MAC_BUF(mac);
......@@ -1771,8 +1775,8 @@ static void handle_disassoc(local_info_t *local, struct sk_buff *skb,
return;
}
pos = (u16 *) body;
reason_code = __le16_to_cpu(*pos);
pos = (__le16 *) body;
reason_code = le16_to_cpu(*pos);
PDEBUG(DEBUG_AP, "%s: disassociation: %s len=%d, "
"reason_code=%d\n", dev->name, print_mac(mac, hdr->addr2), len,
......@@ -1817,7 +1821,7 @@ static void ap_handle_dropped_data(local_info_t *local,
{
struct net_device *dev = local->dev;
struct sta_info *sta;
u16 reason;
__le16 reason;
spin_lock_bh(&local->ap->sta_table_lock);
sta = ap_get_sta(local->ap, hdr->addr2);
......@@ -1831,8 +1835,7 @@ static void ap_handle_dropped_data(local_info_t *local,
return;
}
reason = __constant_cpu_to_le16(
WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
reason = cpu_to_le16(WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
prism2_send_mgmt(dev, IEEE80211_FTYPE_MGMT |
((sta == NULL || !(sta->flags & WLAN_STA_ASSOC)) ?
IEEE80211_STYPE_DEAUTH : IEEE80211_STYPE_DISASSOC),
......@@ -1892,7 +1895,7 @@ static void handle_pspoll(local_info_t *local,
return;
}
aid = __le16_to_cpu(hdr->duration_id);
aid = le16_to_cpu(hdr->duration_id);
if ((aid & (BIT(15) | BIT(14))) != (BIT(15) | BIT(14))) {
PDEBUG(DEBUG_PS, " PSPOLL and AID[15:14] not set\n");
return;
......@@ -1998,7 +2001,8 @@ static void handle_beacon(local_info_t *local, struct sk_buff *skb,
struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *) skb->data;
char *body = skb->data + IEEE80211_MGMT_HDR_LEN;
int len, left;
u16 *pos, beacon_int, capability;
u16 beacon_int, capability;
__le16 *pos;
char *ssid = NULL;
unsigned char *supp_rates = NULL;
int ssid_len = 0, supp_rates_len = 0;
......@@ -2013,16 +2017,16 @@ static void handle_beacon(local_info_t *local, struct sk_buff *skb,
return;
}
pos = (u16 *) body;
pos = (__le16 *) body;
left = len;
/* Timestamp (8 octets) */
pos += 4; left -= 8;
/* Beacon interval (2 octets) */
beacon_int = __le16_to_cpu(*pos);
beacon_int = le16_to_cpu(*pos);
pos++; left -= 2;
/* Capability information (2 octets) */
capability = __le16_to_cpu(*pos);
capability = le16_to_cpu(*pos);
pos++; left -= 2;
if (local->ap->ap_policy != AP_OTHER_AP_EVEN_IBSS &&
......
......@@ -188,10 +188,10 @@
struct hfa384x_comp_ident
{
u16 id;
u16 variant;
u16 major;
u16 minor;
__le16 id;
__le16 variant;
__le16 major;
__le16 minor;
} __attribute__ ((packed));
#define HFA384X_COMP_ID_PRI 0x15
......@@ -200,33 +200,33 @@ struct hfa384x_comp_ident
struct hfa384x_sup_range
{
u16 role;
u16 id;
u16 variant;
u16 bottom;
u16 top;
__le16 role;
__le16 id;
__le16 variant;
__le16 bottom;
__le16 top;
} __attribute__ ((packed));
struct hfa384x_build_id
{
u16 pri_seq;
u16 sec_seq;
__le16 pri_seq;
__le16 sec_seq;
} __attribute__ ((packed));
/* FD01 - Download Buffer */
struct hfa384x_rid_download_buffer
{
u16 page;
u16 offset;
u16 length;
__le16 page;
__le16 offset;
__le16 length;
} __attribute__ ((packed));
/* BSS connection quality (RID FD43 range, RID FD51 dBm-normalized) */
struct hfa384x_comms_quality {
u16 comm_qual; /* 0 .. 92 */
u16 signal_level; /* 27 .. 154 */
u16 noise_level; /* 27 .. 154 */
__le16 comm_qual; /* 0 .. 92 */
__le16 signal_level; /* 27 .. 154 */
__le16 noise_level; /* 27 .. 154 */
} __attribute__ ((packed));
......
......@@ -100,7 +100,7 @@ static int hfa384x_from_aux(struct net_device *dev, unsigned int addr, int len,
#ifdef PRISM2_PCI
{
u16 *pos = (u16 *) buf;
__le16 *pos = (__le16 *) buf;
while (len > 0) {
*pos++ = HFA384X_INW_DATA(HFA384X_AUXDATA_OFF);
len -= 2;
......@@ -131,7 +131,7 @@ static int hfa384x_to_aux(struct net_device *dev, unsigned int addr, int len,
#ifdef PRISM2_PCI
{
u16 *pos = (u16 *) buf;
__le16 *pos = (__le16 *) buf;
while (len > 0) {
HFA384X_OUTW_DATA(*pos++, HFA384X_AUXDATA_OFF);
len -= 2;
......@@ -147,7 +147,7 @@ static int hfa384x_to_aux(struct net_device *dev, unsigned int addr, int len,
static int prism2_pda_ok(u8 *buf)
{
u16 *pda = (u16 *) buf;
__le16 *pda = (__le16 *) buf;
int pos;
u16 len, pdr;
......@@ -544,9 +544,9 @@ static int prism2_download_nonvolatile(local_info_t *local,
struct net_device *dev = local->dev;
int ret = 0, i;
struct {
u16 page;
u16 offset;
u16 len;
__le16 page;
__le16 offset;
__le16 len;
} dlbuffer;
u32 bufaddr;
......@@ -565,14 +565,12 @@ static int prism2_download_nonvolatile(local_info_t *local,
goto out;
}
dlbuffer.page = le16_to_cpu(dlbuffer.page);
dlbuffer.offset = le16_to_cpu(dlbuffer.offset);
dlbuffer.len = le16_to_cpu(dlbuffer.len);
printk(KERN_DEBUG "Download buffer: %d bytes at 0x%04x:0x%04x\n",
dlbuffer.len, dlbuffer.page, dlbuffer.offset);
le16_to_cpu(dlbuffer.len),
le16_to_cpu(dlbuffer.page),
le16_to_cpu(dlbuffer.offset));
bufaddr = (dlbuffer.page << 7) + dlbuffer.offset;
bufaddr = (le16_to_cpu(dlbuffer.page) << 7) + le16_to_cpu(dlbuffer.offset);
local->hw_downloading = 1;
......
......@@ -1075,7 +1075,7 @@ static int prism2_setup_rids(struct net_device *dev)
{
struct hostap_interface *iface;
local_info_t *local;
u16 tmp;
__le16 tmp;
int ret = 0;
iface = netdev_priv(dev);
......@@ -1084,11 +1084,11 @@ static int prism2_setup_rids(struct net_device *dev)
hostap_set_word(dev, HFA384X_RID_TICKTIME, 2000);
if (!local->fw_ap) {
tmp = hostap_get_porttype(local);
ret = hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE, tmp);
u16 tmp1 = hostap_get_porttype(local);
ret = hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE, tmp1);
if (ret) {
printk("%s: Port type setting to %d failed\n",
dev->name, tmp);
dev->name, tmp1);
goto fail;
}
}
......@@ -1117,7 +1117,7 @@ static int prism2_setup_rids(struct net_device *dev)
ret = -EINVAL;
goto fail;
}
local->channel_mask = __le16_to_cpu(tmp);
local->channel_mask = le16_to_cpu(tmp);
if (local->channel < 1 || local->channel > 14 ||
!(local->channel_mask & (1 << (local->channel - 1)))) {
......
......@@ -303,7 +303,7 @@ static void prism2_info_hostscanresults(local_info_t *local,
int i, result_size, copy_len, new_count;
struct hfa384x_hostscan_result *results, *prev;
unsigned long flags;
u16 *pos;
__le16 *pos;
u8 *ptr;
wake_up_interruptible(&local->hostscan_wq);
......@@ -314,7 +314,7 @@ static void prism2_info_hostscanresults(local_info_t *local,
return;
}
pos = (u16 *) buf;
pos = (__le16 *) buf;
copy_len = result_size = le16_to_cpu(*pos);
if (result_size == 0) {
printk(KERN_DEBUG "%s: invalid result_size (0) in "
......
......@@ -84,7 +84,7 @@ static int prism2_get_datarates(struct net_device *dev, u8 *rates)
if (len < 2)
return 0;
val = le16_to_cpu(*(u16 *) buf); /* string length */
val = le16_to_cpu(*(__le16 *) buf); /* string length */
if (len - 2 < val || val > 10)
return 0;
......@@ -496,7 +496,7 @@ static int prism2_ioctl_giwsens(struct net_device *dev,
{
struct hostap_interface *iface;
local_info_t *local;
u16 val;
__le16 val;
iface = netdev_priv(dev);
local = iface->local;
......@@ -506,7 +506,7 @@ static int prism2_ioctl_giwsens(struct net_device *dev,
0)
return -EINVAL;
sens->value = __le16_to_cpu(val);
sens->value = le16_to_cpu(val);
sens->fixed = 1;
return 0;
......@@ -561,17 +561,17 @@ static int prism2_ioctl_siwrts(struct net_device *dev,
{
struct hostap_interface *iface;
local_info_t *local;
u16 val;
__le16 val;
iface = netdev_priv(dev);
local = iface->local;
if (rts->disabled)
val = __constant_cpu_to_le16(2347);
val = cpu_to_le16(2347);
else if (rts->value < 0 || rts->value > 2347)
return -EINVAL;
else
val = __cpu_to_le16(rts->value);
val = cpu_to_le16(rts->value);
if (local->func->set_rid(dev, HFA384X_RID_RTSTHRESHOLD, &val, 2) ||
local->func->reset_port(dev))
......@@ -588,7 +588,7 @@ static int prism2_ioctl_giwrts(struct net_device *dev,
{
struct hostap_interface *iface;
local_info_t *local;
u16 val;
__le16 val;
iface = netdev_priv(dev);
local = iface->local;
......@@ -597,7 +597,7 @@ static int prism2_ioctl_giwrts(struct net_device *dev,
0)
return -EINVAL;
rts->value = __le16_to_cpu(val);
rts->value = le16_to_cpu(val);
rts->disabled = (rts->value == 2347);
rts->fixed = 1;
......@@ -611,17 +611,17 @@ static int prism2_ioctl_siwfrag(struct net_device *dev,
{
struct hostap_interface *iface;
local_info_t *local;
u16 val;
__le16 val;
iface = netdev_priv(dev);
local = iface->local;
if (rts->disabled)
val = __constant_cpu_to_le16(2346);
val = cpu_to_le16(2346);
else if (rts->value < 256 || rts->value > 2346)
return -EINVAL;
else
val = __cpu_to_le16(rts->value & ~0x1); /* even numbers only */
val = cpu_to_le16(rts->value & ~0x1); /* even numbers only */
local->fragm_threshold = rts->value & ~0x1;
if (local->func->set_rid(dev, HFA384X_RID_FRAGMENTATIONTHRESHOLD, &val,
......@@ -638,7 +638,7 @@ static int prism2_ioctl_giwfrag(struct net_device *dev,
{
struct hostap_interface *iface;
local_info_t *local;
u16 val;
__le16 val;
iface = netdev_priv(dev);
local = iface->local;
......@@ -647,7 +647,7 @@ static int prism2_ioctl_giwfrag(struct net_device *dev,
&val, 2, 1) < 0)
return -EINVAL;
rts->value = __le16_to_cpu(val);
rts->value = le16_to_cpu(val);
rts->disabled = (rts->value == 2346);
rts->fixed = 1;
......@@ -718,8 +718,8 @@ static int prism2_ioctl_siwap(struct net_device *dev,
if (local->host_roaming == 1 && local->iw_mode == IW_MODE_INFRA) {
struct hfa384x_scan_request scan_req;
memset(&scan_req, 0, sizeof(scan_req));
scan_req.channel_list = __constant_cpu_to_le16(0x3fff);
scan_req.txrate = __constant_cpu_to_le16(HFA384X_RATES_1MBPS);
scan_req.channel_list = cpu_to_le16(0x3fff);
scan_req.txrate =