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

Commit ebed67d2 authored by Jouni Malinen's avatar Jouni Malinen Committed by Jeff Garzik
Browse files

[PATCH] hostap: Start using net/ieee80211.h



Preparations for starting to use net/ieee80211 instead of private
IEEE 802.11 implementation. Include net/ieee80211.h and
net/ieee80211_crypt.h into files that will be needed these in the
future. Remove duplicate definitions from hostap_common.h and
rename WLAN_FC_GET_{TYPE,STYPE} macros for now sinc net/ieee80211.h
is using incompatible definitions. This will be resolved in the
future by updating Host AP to use the versions that do not shift
type/stype.

Signed-off-by: default avatarJouni Malinen <jkmaline@cc.hut.fi>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent f3b10e16
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@
#include <linux/rtnetlink.h>
#include <linux/wireless.h>
#include <net/iw_handler.h>
#include <net/ieee80211.h>
#include <net/ieee80211_crypt.h>
#include <asm/uaccess.h>

#include "hostap_wlan.h"
@@ -596,7 +598,7 @@ void hostap_dump_rx_header(const char *name, const struct hfa384x_rx_frame *rx)
	fc = __le16_to_cpu(rx->frame_control);
	printk(KERN_DEBUG "   FC=0x%04x (type=%d:%d) dur=0x%04x seq=0x%04x "
	       "data_len=%d%s%s\n",
	       fc, WLAN_FC_GET_TYPE(fc), WLAN_FC_GET_STYPE(fc),
	       fc, HOSTAP_FC_GET_TYPE(fc), HOSTAP_FC_GET_STYPE(fc),
	       __le16_to_cpu(rx->duration_id), __le16_to_cpu(rx->seq_ctrl),
	       __le16_to_cpu(rx->data_len),
	       fc & WLAN_FC_TODS ? " [ToDS]" : "",
@@ -625,7 +627,7 @@ void hostap_dump_tx_header(const char *name, const struct hfa384x_tx_frame *tx)
	fc = __le16_to_cpu(tx->frame_control);
	printk(KERN_DEBUG "   FC=0x%04x (type=%d:%d) dur=0x%04x seq=0x%04x "
	       "data_len=%d%s%s\n",
	       fc, WLAN_FC_GET_TYPE(fc), WLAN_FC_GET_STYPE(fc),
	       fc, HOSTAP_FC_GET_TYPE(fc), HOSTAP_FC_GET_STYPE(fc),
	       __le16_to_cpu(tx->duration_id), __le16_to_cpu(tx->seq_ctrl),
	       __le16_to_cpu(tx->data_len),
	       fc & WLAN_FC_TODS ? " [ToDS]" : "",
@@ -668,13 +670,13 @@ int hostap_80211_get_hdrlen(u16 fc)
{
	int hdrlen = 24;

	switch (WLAN_FC_GET_TYPE(fc)) {
	switch (HOSTAP_FC_GET_TYPE(fc)) {
	case WLAN_FC_TYPE_DATA:
		if ((fc & WLAN_FC_FROMDS) && (fc & WLAN_FC_TODS))
			hdrlen = 30; /* Addr4 */
		break;
	case WLAN_FC_TYPE_CTRL:
		switch (WLAN_FC_GET_STYPE(fc)) {
		switch (HOSTAP_FC_GET_STYPE(fc)) {
		case WLAN_FC_STYPE_CTS:
		case WLAN_FC_STYPE_ACK:
			hdrlen = 10;
+6 −6
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ void hostap_dump_rx_80211(const char *name, struct sk_buff *skb,

	fc = le16_to_cpu(hdr->frame_control);
	printk(KERN_DEBUG "   FC=0x%04x (type=%d:%d)%s%s",
	       fc, WLAN_FC_GET_TYPE(fc), WLAN_FC_GET_STYPE(fc),
	       fc, HOSTAP_FC_GET_TYPE(fc), HOSTAP_FC_GET_STYPE(fc),
	       fc & WLAN_FC_TODS ? " [ToDS]" : "",
	       fc & WLAN_FC_FROMDS ? " [FromDS]" : "");

@@ -224,7 +224,7 @@ prism2_frag_cache_get(local_info_t *local, struct hostap_ieee80211_hdr *hdr)

	sc = le16_to_cpu(hdr->seq_ctrl);
	frag = WLAN_GET_SEQ_FRAG(sc);
	seq = WLAN_GET_SEQ_SEQ(sc);
	seq = WLAN_GET_SEQ_SEQ(sc) >> 4;

	if (frag == 0) {
		/* Reserve enough space to fit maximum frame length */
@@ -274,7 +274,7 @@ static int prism2_frag_cache_invalidate(local_info_t *local,
	struct prism2_frag_entry *entry;

	sc = le16_to_cpu(hdr->seq_ctrl);
	seq = WLAN_GET_SEQ_SEQ(sc);
	seq = WLAN_GET_SEQ_SEQ(sc) >> 4;

	entry = prism2_frag_cache_find(local, seq, -1, hdr->addr2, hdr->addr1);

@@ -719,8 +719,8 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
		goto rx_dropped;

	fc = le16_to_cpu(hdr->frame_control);
	type = WLAN_FC_GET_TYPE(fc);
	stype = WLAN_FC_GET_STYPE(fc);
	type = HOSTAP_FC_GET_TYPE(fc);
	stype = HOSTAP_FC_GET_STYPE(fc);
	sc = le16_to_cpu(hdr->seq_ctrl);
	frag = WLAN_GET_SEQ_FRAG(sc);
	hdrlen = hostap_80211_get_hdrlen(fc);
@@ -896,7 +896,7 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
			printk(KERN_DEBUG "%s: Rx cannot get skb from "
			       "fragment cache (morefrag=%d seq=%u frag=%u)\n",
			       dev->name, (fc & WLAN_FC_MOREFRAG) != 0,
			       WLAN_GET_SEQ_SEQ(sc), frag);
			       WLAN_GET_SEQ_SEQ(sc) >> 4, frag);
			goto rx_dropped;
		}

+6 −6
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ void hostap_dump_tx_80211(const char *name, struct sk_buff *skb)

	fc = le16_to_cpu(hdr->frame_control);
	printk(KERN_DEBUG "   FC=0x%04x (type=%d:%d)%s%s",
	       fc, WLAN_FC_GET_TYPE(fc), WLAN_FC_GET_STYPE(fc),
	       fc, HOSTAP_FC_GET_TYPE(fc), HOSTAP_FC_GET_STYPE(fc),
	       fc & WLAN_FC_TODS ? " [ToDS]" : "",
	       fc & WLAN_FC_FROMDS ? " [FromDS]" : "");

@@ -267,8 +267,8 @@ int hostap_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev)
	if (skb->len >= IEEE80211_DATA_HDR3_LEN + sizeof(rfc1042_header) + 2) {
		hdr = (struct hostap_ieee80211_hdr *) skb->data;
		fc = le16_to_cpu(hdr->frame_control);
		if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_DATA &&
		    WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_DATA) {
		if (HOSTAP_FC_GET_TYPE(fc) == WLAN_FC_TYPE_DATA &&
		    HOSTAP_FC_GET_STYPE(fc) == WLAN_FC_STYPE_DATA) {
			u8 *pos = &skb->data[IEEE80211_DATA_HDR3_LEN +
					     sizeof(rfc1042_header)];
			meta->ethertype = (pos[0] << 8) | pos[1];
@@ -409,7 +409,7 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
		break;
	case AP_TX_CONTINUE_NOT_AUTHORIZED:
		if (local->ieee_802_1x &&
		    WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_DATA &&
		    HOSTAP_FC_GET_TYPE(fc) == WLAN_FC_TYPE_DATA &&
		    meta->ethertype != ETH_P_PAE && !meta->wds) {
			printk(KERN_DEBUG "%s: dropped frame to unauthorized "
			       "port (IEEE 802.1X): ethertype=0x%04x\n",
@@ -446,7 +446,7 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
		hdr->frame_control = cpu_to_le16(fc);
	}

	if (WLAN_FC_GET_TYPE(fc) != WLAN_FC_TYPE_DATA) {
	if (HOSTAP_FC_GET_TYPE(fc) != WLAN_FC_TYPE_DATA) {
		no_encrypt = 1;
		tx.crypt = NULL;
	}
@@ -467,7 +467,7 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev)
		fc |= WLAN_FC_ISWEP;
		hdr->frame_control = cpu_to_le16(fc);
	} else if (local->drop_unencrypted &&
		   WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_DATA &&
		   HOSTAP_FC_GET_TYPE(fc) == WLAN_FC_TYPE_DATA &&
		   meta->ethertype != ETH_P_PAE) {
		if (net_ratelimit()) {
			printk(KERN_DEBUG "%s: dropped unencrypted TX data "
+12 −12
Original line number Diff line number Diff line
@@ -634,8 +634,8 @@ static void hostap_ap_tx_cb_auth(struct sk_buff *skb, int ok, void *data)

	hdr = (struct hostap_ieee80211_hdr *) skb->data;
	fc = le16_to_cpu(hdr->frame_control);
	if (WLAN_FC_GET_TYPE(fc) != WLAN_FC_TYPE_MGMT ||
	    WLAN_FC_GET_STYPE(fc) != WLAN_FC_STYPE_AUTH ||
	if (HOSTAP_FC_GET_TYPE(fc) != WLAN_FC_TYPE_MGMT ||
	    HOSTAP_FC_GET_STYPE(fc) != WLAN_FC_STYPE_AUTH ||
	    skb->len < IEEE80211_MGMT_HDR_LEN + 6) {
		printk(KERN_DEBUG "%s: hostap_ap_tx_cb_auth received invalid "
		       "frame\n", dev->name);
@@ -703,9 +703,9 @@ static void hostap_ap_tx_cb_assoc(struct sk_buff *skb, int ok, void *data)

	hdr = (struct hostap_ieee80211_hdr *) skb->data;
	fc = le16_to_cpu(hdr->frame_control);
	if (WLAN_FC_GET_TYPE(fc) != WLAN_FC_TYPE_MGMT ||
	    (WLAN_FC_GET_STYPE(fc) != WLAN_FC_STYPE_ASSOC_RESP &&
	     WLAN_FC_GET_STYPE(fc) != WLAN_FC_STYPE_REASSOC_RESP) ||
	if (HOSTAP_FC_GET_TYPE(fc) != WLAN_FC_TYPE_MGMT ||
	    (HOSTAP_FC_GET_STYPE(fc) != WLAN_FC_STYPE_ASSOC_RESP &&
	     HOSTAP_FC_GET_STYPE(fc) != WLAN_FC_STYPE_REASSOC_RESP) ||
	    skb->len < IEEE80211_MGMT_HDR_LEN + 4) {
		printk(KERN_DEBUG "%s: hostap_ap_tx_cb_assoc received invalid "
		       "frame\n", dev->name);
@@ -2145,8 +2145,8 @@ static void handle_ap_item(local_info_t *local, struct sk_buff *skb,
	 * buffer is long enough */
	hdr = (struct hostap_ieee80211_hdr *) skb->data;
	fc = le16_to_cpu(hdr->frame_control);
	type = WLAN_FC_GET_TYPE(fc);
	stype = WLAN_FC_GET_STYPE(fc);
	type = HOSTAP_FC_GET_TYPE(fc);
	stype = HOSTAP_FC_GET_STYPE(fc);

#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
	if (!local->hostapd && type == WLAN_FC_TYPE_DATA) {
@@ -2271,8 +2271,8 @@ void hostap_rx(struct net_device *dev, struct sk_buff *skb,
	fc = le16_to_cpu(hdr->frame_control);

	if (local->ap->ap_policy == AP_OTHER_AP_SKIP_ALL &&
	    WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
	    WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON)
	    HOSTAP_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT &&
	    HOSTAP_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON)
		goto drop;

	skb->protocol = __constant_htons(ETH_P_HOSTAP);
@@ -2907,7 +2907,7 @@ int hostap_update_sta_ps(local_info_t *local, struct hostap_ieee80211_hdr *hdr)

	fc = le16_to_cpu(hdr->frame_control);
	hostap_update_sta_ps2(local, sta, fc & WLAN_FC_PWRMGT,
			      WLAN_FC_GET_TYPE(fc), WLAN_FC_GET_STYPE(fc));
			      HOSTAP_FC_GET_TYPE(fc), HOSTAP_FC_GET_STYPE(fc));

	atomic_dec(&sta->users);
	return 0;
@@ -2932,8 +2932,8 @@ ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
	hdr = (struct hostap_ieee80211_hdr *) skb->data;

	fc = le16_to_cpu(hdr->frame_control);
	type = WLAN_FC_GET_TYPE(fc);
	stype = WLAN_FC_GET_STYPE(fc);
	type = HOSTAP_FC_GET_TYPE(fc);
	stype = HOSTAP_FC_GET_STYPE(fc);

	spin_lock(&local->ap->sta_table_lock);
	sta = ap_get_sta(local->ap, hdr->addr2);
+7 −66
Original line number Diff line number Diff line
@@ -27,14 +27,14 @@
#define WLAN_FC_ISWEP BIT(14)
#define WLAN_FC_ORDER BIT(15)

#define WLAN_FC_GET_TYPE(fc) (((fc) & (BIT(3) | BIT(2))) >> 2)
#define WLAN_FC_GET_STYPE(fc) \
/*
 * To be replaced with ieee80211.h WLAN_FC_GET_* once HostAP code is updated to
 * use the versions without right shift.
 */
#define HOSTAP_FC_GET_TYPE(fc) (((fc) & (BIT(3) | BIT(2))) >> 2)
#define HOSTAP_FC_GET_STYPE(fc) \
	(((fc) & (BIT(7) | BIT(6) | BIT(5) | BIT(4))) >> 4)

#define WLAN_GET_SEQ_FRAG(seq) ((seq) & (BIT(3) | BIT(2) | BIT(1) | BIT(0)))
#define WLAN_GET_SEQ_SEQ(seq) \
	(((seq) & (~(BIT(3) | BIT(2) | BIT(1) | BIT(0)))) >> 4)

#define WLAN_FC_TYPE_MGMT 0
#define WLAN_FC_TYPE_CTRL 1
#define WLAN_FC_TYPE_DATA 2
@@ -70,66 +70,7 @@
#define WLAN_FC_STYPE_CFPOLL 6
#define WLAN_FC_STYPE_CFACKPOLL 7

/* Authentication algorithms */
#define WLAN_AUTH_OPEN 0
#define WLAN_AUTH_SHARED_KEY 1

#define WLAN_AUTH_CHALLENGE_LEN 128

#define WLAN_CAPABILITY_ESS BIT(0)
#define WLAN_CAPABILITY_IBSS BIT(1)
#define WLAN_CAPABILITY_CF_POLLABLE BIT(2)
#define WLAN_CAPABILITY_CF_POLL_REQUEST BIT(3)
#define WLAN_CAPABILITY_PRIVACY BIT(4)

/* Status codes */
#define WLAN_STATUS_SUCCESS 0
#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
#define WLAN_STATUS_CAPS_UNSUPPORTED 10
#define WLAN_STATUS_REASSOC_NO_ASSOC 11
#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
#define WLAN_STATUS_CHALLENGE_FAIL 15
#define WLAN_STATUS_AUTH_TIMEOUT 16
#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
#define WLAN_STATUS_ASSOC_DENIED_RATES 18
/* 802.11b */
#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
/* IEEE 802.11i */
#define WLAN_STATUS_INVALID_IE 40
#define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41
#define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42
#define WLAN_STATUS_AKMP_NOT_VALID 43
#define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44
#define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45
#define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46

/* Reason codes */
#define WLAN_REASON_UNSPECIFIED 1
#define WLAN_REASON_PREV_AUTH_NOT_VALID 2
#define WLAN_REASON_DEAUTH_LEAVING 3
#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
#define WLAN_REASON_DISASSOC_AP_BUSY 5
#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
/* IEEE 802.11i */
#define WLAN_REASON_INVALID_IE 13
#define WLAN_REASON_MICHAEL_MIC_FAILURE 14
#define WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT 15
#define WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT 16
#define WLAN_REASON_IE_IN_4WAY_DIFFERS 17
#define WLAN_REASON_GROUP_CIPHER_NOT_VALID 18
#define WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID 19
#define WLAN_REASON_AKMP_NOT_VALID 20
#define WLAN_REASON_UNSUPPORTED_RSN_IE_VERSION 21
#define WLAN_REASON_INVALID_RSN_IE_CAPAB 22
#define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23
#define WLAN_REASON_CIPHER_SUITE_REJECTED 24
#define WLAN_CAPABILITY_ESS WLAN_CAPABILITY_BSS


/* Information Element IDs */
Loading