mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-11-27 18:17:32 +02:00
add updated mac80211 - this no longer relies on patching includes in the kernel trees, but just uses its own instead
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@9290 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
7f80212b77
commit
31f26ea821
@ -21,58 +21,59 @@ define KernelPackage/mac80211
|
||||
SUBMENU:=Wireless Drivers
|
||||
TITLE:=Linux 802.11 Wireless Networking Stack
|
||||
DEPENDS:=@LINUX_2_6 +kmod-crypto-arc4 +kmod-crypto-aes
|
||||
KCONFIG:=CONFIG_MAC80211
|
||||
FILES:= \
|
||||
$(PKG_BUILD_DIR)/mac80211/mac80211.$(LINUX_KMOD_SUFFIX) \
|
||||
$(PKG_BUILD_DIR)/mac80211/rc80211_lowest.$(LINUX_KMOD_SUFFIX) \
|
||||
$(PKG_BUILD_DIR)/mac80211/rc80211_simple.$(LINUX_KMOD_SUFFIX) \
|
||||
$(PKG_BUILD_DIR)/wireless/cfg80211.$(LINUX_KMOD_SUFFIX)
|
||||
AUTOLOAD:=$(call AutoLoad,20,cfg80211 mac80211 rc80211_simple)
|
||||
endef
|
||||
|
||||
define KernelPackage/mac80211/description
|
||||
This package contains the DeviceScape 80211 wireless stack.
|
||||
Linux 802.11 Wireless Networking Stack
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
CONFOPTS:=MAC80211 CFG80211 NL80211
|
||||
|
||||
BUILDFLAGS:= \
|
||||
$(foreach opt,$(CONFOPTS),-DCONFIG_$(opt) ) \
|
||||
$(if $(CONFIG_LEDS_TRIGGERS), -DCONFIG_MAC80211_LEDS -DCONFIG_LEDS_TRIGGERS)
|
||||
|
||||
MAKE_OPTS:= \
|
||||
CROSS_COMPILE="$(TARGET_CROSS)" \
|
||||
ARCH="$(LINUX_KARCH)" \
|
||||
EXTRA_CFLAGS="$(BUILDFLAGS)" \
|
||||
$(foreach opt,$(CONFOPTS),CONFIG_$(opt)=m) \
|
||||
CONFIG_MAC80211_LEDS=$(CONFIG_LEDS_TRIGGERS) \
|
||||
LINUXINCLUDE="-I${CURDIR}/src/include -I$(LINUX_DIR)/include -include linux/autoconf.h" \
|
||||
V=1
|
||||
|
||||
|
||||
ifneq ($(findstring 2.6.23,$(LINUX_VERSION)),)
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)/mac80211
|
||||
$(CP) ./src/mac80211/* $(PKG_BUILD_DIR)/mac80211/
|
||||
mkdir -p $(PKG_BUILD_DIR)/wireless
|
||||
$(CP) ./src/wireless/* $(PKG_BUILD_DIR)/wireless/
|
||||
endef
|
||||
endef
|
||||
|
||||
ifneq ($(CONFIG_MAC80211),)
|
||||
|
||||
MAKE_OPTS:= \
|
||||
CROSS_COMPILE="$(TARGET_CROSS)" \
|
||||
ARCH="$(LINUX_KARCH)" \
|
||||
EXTRA_CFLAGS="$(BUILDFLAGS) -DCONFIG_MAC80211_LEDS -DCONFIG_LEDS_TRIGGERS" \
|
||||
CONFIG_MAC80211=m \
|
||||
CONFIG_MAC80211_LEDS=$(CONFIG_LEDS_TRIGGERS) \
|
||||
|
||||
define Build/Compile/it
|
||||
define Build/Compile
|
||||
$(MAKE) -C "$(LINUX_DIR)" $(MAKE_OPTS) SUBDIRS="$(PKG_BUILD_DIR)/wireless" modules
|
||||
$(MAKE) -C "$(LINUX_DIR)" $(MAKE_OPTS) SUBDIRS="$(PKG_BUILD_DIR)/mac80211" modules
|
||||
endef
|
||||
|
||||
endif
|
||||
|
||||
define Build/Compile
|
||||
$(call Build/Compile/it)
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
define Build/InstallDev
|
||||
mkdir -p $(1)/usr/include/mac80211
|
||||
$(CP) $(PKG_BUILD_DIR)/mac80211/{hostapd_ioctl,ieee80211_common}.h $(1)/usr/include/mac80211/
|
||||
endef
|
||||
$(CP) ./src/include $(1)/usr/include/mac80211/
|
||||
endef
|
||||
|
||||
define Build/UninstallDev
|
||||
define Build/UninstallDev
|
||||
rm -rf $(1)/usr/include/mac80211
|
||||
endef
|
||||
endef
|
||||
|
||||
define KernelPackage/mac80211/install
|
||||
define KernelPackage/mac80211/install
|
||||
$(INSTALL_DIR) $(1)/lib/wifi
|
||||
$(INSTALL_DATA) ./files/lib/wifi/mac80211.sh $(1)/lib/wifi
|
||||
endef
|
||||
endef
|
||||
endif
|
||||
|
||||
$(eval $(call KernelPackage,mac80211))
|
||||
|
414
package/mac80211/src/include/linux/ieee80211.h
Normal file
414
package/mac80211/src/include/linux/ieee80211.h
Normal file
@ -0,0 +1,414 @@
|
||||
/*
|
||||
* IEEE 802.11 defines
|
||||
*
|
||||
* Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
|
||||
* <jkmaline@cc.hut.fi>
|
||||
* Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
|
||||
* Copyright (c) 2005, Devicescape Software, Inc.
|
||||
* Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef IEEE80211_H
|
||||
#define IEEE80211_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#define FCS_LEN 4
|
||||
|
||||
#define IEEE80211_FCTL_VERS 0x0003
|
||||
#define IEEE80211_FCTL_FTYPE 0x000c
|
||||
#define IEEE80211_FCTL_STYPE 0x00f0
|
||||
#define IEEE80211_FCTL_TODS 0x0100
|
||||
#define IEEE80211_FCTL_FROMDS 0x0200
|
||||
#define IEEE80211_FCTL_MOREFRAGS 0x0400
|
||||
#define IEEE80211_FCTL_RETRY 0x0800
|
||||
#define IEEE80211_FCTL_PM 0x1000
|
||||
#define IEEE80211_FCTL_MOREDATA 0x2000
|
||||
#define IEEE80211_FCTL_PROTECTED 0x4000
|
||||
#define IEEE80211_FCTL_ORDER 0x8000
|
||||
|
||||
#define IEEE80211_SCTL_FRAG 0x000F
|
||||
#define IEEE80211_SCTL_SEQ 0xFFF0
|
||||
|
||||
#define IEEE80211_FTYPE_MGMT 0x0000
|
||||
#define IEEE80211_FTYPE_CTL 0x0004
|
||||
#define IEEE80211_FTYPE_DATA 0x0008
|
||||
|
||||
/* management */
|
||||
#define IEEE80211_STYPE_ASSOC_REQ 0x0000
|
||||
#define IEEE80211_STYPE_ASSOC_RESP 0x0010
|
||||
#define IEEE80211_STYPE_REASSOC_REQ 0x0020
|
||||
#define IEEE80211_STYPE_REASSOC_RESP 0x0030
|
||||
#define IEEE80211_STYPE_PROBE_REQ 0x0040
|
||||
#define IEEE80211_STYPE_PROBE_RESP 0x0050
|
||||
#define IEEE80211_STYPE_BEACON 0x0080
|
||||
#define IEEE80211_STYPE_ATIM 0x0090
|
||||
#define IEEE80211_STYPE_DISASSOC 0x00A0
|
||||
#define IEEE80211_STYPE_AUTH 0x00B0
|
||||
#define IEEE80211_STYPE_DEAUTH 0x00C0
|
||||
#define IEEE80211_STYPE_ACTION 0x00D0
|
||||
|
||||
/* control */
|
||||
#define IEEE80211_STYPE_PSPOLL 0x00A0
|
||||
#define IEEE80211_STYPE_RTS 0x00B0
|
||||
#define IEEE80211_STYPE_CTS 0x00C0
|
||||
#define IEEE80211_STYPE_ACK 0x00D0
|
||||
#define IEEE80211_STYPE_CFEND 0x00E0
|
||||
#define IEEE80211_STYPE_CFENDACK 0x00F0
|
||||
|
||||
/* data */
|
||||
#define IEEE80211_STYPE_DATA 0x0000
|
||||
#define IEEE80211_STYPE_DATA_CFACK 0x0010
|
||||
#define IEEE80211_STYPE_DATA_CFPOLL 0x0020
|
||||
#define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
|
||||
#define IEEE80211_STYPE_NULLFUNC 0x0040
|
||||
#define IEEE80211_STYPE_CFACK 0x0050
|
||||
#define IEEE80211_STYPE_CFPOLL 0x0060
|
||||
#define IEEE80211_STYPE_CFACKPOLL 0x0070
|
||||
#define IEEE80211_STYPE_QOS_DATA 0x0080
|
||||
#define IEEE80211_STYPE_QOS_DATA_CFACK 0x0090
|
||||
#define IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0
|
||||
#define IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0
|
||||
#define IEEE80211_STYPE_QOS_NULLFUNC 0x00C0
|
||||
#define IEEE80211_STYPE_QOS_CFACK 0x00D0
|
||||
#define IEEE80211_STYPE_QOS_CFPOLL 0x00E0
|
||||
#define IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0
|
||||
|
||||
|
||||
/* miscellaneous IEEE 802.11 constants */
|
||||
#define IEEE80211_MAX_FRAG_THRESHOLD 2346
|
||||
#define IEEE80211_MAX_RTS_THRESHOLD 2347
|
||||
#define IEEE80211_MAX_AID 2007
|
||||
#define IEEE80211_MAX_TIM_LEN 251
|
||||
#define IEEE80211_MAX_DATA_LEN 2304
|
||||
/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
|
||||
6.2.1.1.2.
|
||||
|
||||
The figure in section 7.1.2 suggests a body size of up to 2312
|
||||
bytes is allowed, which is a bit confusing, I suspect this
|
||||
represents the 2304 bytes of real data, plus a possible 8 bytes of
|
||||
WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
|
||||
|
||||
#define IEEE80211_MAX_SSID_LEN 32
|
||||
|
||||
struct ieee80211_hdr {
|
||||
__le16 frame_control;
|
||||
__le16 duration_id;
|
||||
u8 addr1[6];
|
||||
u8 addr2[6];
|
||||
u8 addr3[6];
|
||||
__le16 seq_ctrl;
|
||||
u8 addr4[6];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
struct ieee80211_mgmt {
|
||||
__le16 frame_control;
|
||||
__le16 duration;
|
||||
u8 da[6];
|
||||
u8 sa[6];
|
||||
u8 bssid[6];
|
||||
__le16 seq_ctrl;
|
||||
union {
|
||||
struct {
|
||||
__le16 auth_alg;
|
||||
__le16 auth_transaction;
|
||||
__le16 status_code;
|
||||
/* possibly followed by Challenge text */
|
||||
u8 variable[0];
|
||||
} __attribute__ ((packed)) auth;
|
||||
struct {
|
||||
__le16 reason_code;
|
||||
} __attribute__ ((packed)) deauth;
|
||||
struct {
|
||||
__le16 capab_info;
|
||||
__le16 listen_interval;
|
||||
/* followed by SSID and Supported rates */
|
||||
u8 variable[0];
|
||||
} __attribute__ ((packed)) assoc_req;
|
||||
struct {
|
||||
__le16 capab_info;
|
||||
__le16 status_code;
|
||||
__le16 aid;
|
||||
/* followed by Supported rates */
|
||||
u8 variable[0];
|
||||
} __attribute__ ((packed)) assoc_resp, reassoc_resp;
|
||||
struct {
|
||||
__le16 capab_info;
|
||||
__le16 listen_interval;
|
||||
u8 current_ap[6];
|
||||
/* followed by SSID and Supported rates */
|
||||
u8 variable[0];
|
||||
} __attribute__ ((packed)) reassoc_req;
|
||||
struct {
|
||||
__le16 reason_code;
|
||||
} __attribute__ ((packed)) disassoc;
|
||||
struct {
|
||||
__le64 timestamp;
|
||||
__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];
|
||||
} __attribute__ ((packed)) beacon;
|
||||
struct {
|
||||
/* only variable items: SSID, Supported rates */
|
||||
u8 variable[0];
|
||||
} __attribute__ ((packed)) probe_req;
|
||||
struct {
|
||||
__le64 timestamp;
|
||||
__le16 beacon_int;
|
||||
__le16 capab_info;
|
||||
/* followed by some of SSID, Supported rates,
|
||||
* FH Params, DS Params, CF Params, IBSS Params */
|
||||
u8 variable[0];
|
||||
} __attribute__ ((packed)) probe_resp;
|
||||
struct {
|
||||
u8 category;
|
||||
union {
|
||||
struct {
|
||||
u8 action_code;
|
||||
u8 dialog_token;
|
||||
u8 status_code;
|
||||
u8 variable[0];
|
||||
} __attribute__ ((packed)) wme_action;
|
||||
struct{
|
||||
u8 action_code;
|
||||
u8 element_id;
|
||||
u8 length;
|
||||
u8 switch_mode;
|
||||
u8 new_chan;
|
||||
u8 switch_count;
|
||||
} __attribute__((packed)) chan_switch;
|
||||
} u;
|
||||
} __attribute__ ((packed)) action;
|
||||
} u;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
/* Control frames */
|
||||
struct ieee80211_rts {
|
||||
__le16 frame_control;
|
||||
__le16 duration;
|
||||
u8 ra[6];
|
||||
u8 ta[6];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct ieee80211_cts {
|
||||
__le16 frame_control;
|
||||
__le16 duration;
|
||||
u8 ra[6];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
/* Authentication algorithms */
|
||||
#define WLAN_AUTH_OPEN 0
|
||||
#define WLAN_AUTH_SHARED_KEY 1
|
||||
#define WLAN_AUTH_FAST_BSS_TRANSITION 2
|
||||
#define WLAN_AUTH_LEAP 128
|
||||
|
||||
#define WLAN_AUTH_CHALLENGE_LEN 128
|
||||
|
||||
#define WLAN_CAPABILITY_ESS (1<<0)
|
||||
#define WLAN_CAPABILITY_IBSS (1<<1)
|
||||
#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
|
||||
#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
|
||||
#define WLAN_CAPABILITY_PRIVACY (1<<4)
|
||||
#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
|
||||
#define WLAN_CAPABILITY_PBCC (1<<6)
|
||||
#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
|
||||
/* 802.11h */
|
||||
#define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
|
||||
#define WLAN_CAPABILITY_QOS (1<<9)
|
||||
#define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
|
||||
#define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
|
||||
|
||||
/* 802.11g ERP information element */
|
||||
#define WLAN_ERP_NON_ERP_PRESENT (1<<0)
|
||||
#define WLAN_ERP_USE_PROTECTION (1<<1)
|
||||
#define WLAN_ERP_BARKER_PREAMBLE (1<<2)
|
||||
|
||||
/* WLAN_ERP_BARKER_PREAMBLE values */
|
||||
enum {
|
||||
WLAN_ERP_PREAMBLE_SHORT = 0,
|
||||
WLAN_ERP_PREAMBLE_LONG = 1,
|
||||
};
|
||||
|
||||
/* Status codes */
|
||||
enum ieee80211_statuscode {
|
||||
WLAN_STATUS_SUCCESS = 0,
|
||||
WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
|
||||
WLAN_STATUS_CAPS_UNSUPPORTED = 10,
|
||||
WLAN_STATUS_REASSOC_NO_ASSOC = 11,
|
||||
WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
|
||||
WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
|
||||
WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
|
||||
WLAN_STATUS_CHALLENGE_FAIL = 15,
|
||||
WLAN_STATUS_AUTH_TIMEOUT = 16,
|
||||
WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
|
||||
WLAN_STATUS_ASSOC_DENIED_RATES = 18,
|
||||
/* 802.11b */
|
||||
WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
|
||||
WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
|
||||
WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
|
||||
/* 802.11h */
|
||||
WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
|
||||
WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
|
||||
WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
|
||||
/* 802.11g */
|
||||
WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
|
||||
WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
|
||||
/* 802.11i */
|
||||
WLAN_STATUS_INVALID_IE = 40,
|
||||
WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
|
||||
WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
|
||||
WLAN_STATUS_INVALID_AKMP = 43,
|
||||
WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
|
||||
WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
|
||||
WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
|
||||
};
|
||||
|
||||
|
||||
/* Reason codes */
|
||||
enum ieee80211_reasoncode {
|
||||
WLAN_REASON_UNSPECIFIED = 1,
|
||||
WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
|
||||
WLAN_REASON_DEAUTH_LEAVING = 3,
|
||||
WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
|
||||
WLAN_REASON_DISASSOC_AP_BUSY = 5,
|
||||
WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
|
||||
WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
|
||||
WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
|
||||
WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
|
||||
/* 802.11h */
|
||||
WLAN_REASON_DISASSOC_BAD_POWER = 10,
|
||||
WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
|
||||
/* 802.11i */
|
||||
WLAN_REASON_INVALID_IE = 13,
|
||||
WLAN_REASON_MIC_FAILURE = 14,
|
||||
WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
|
||||
WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
|
||||
WLAN_REASON_IE_DIFFERENT = 17,
|
||||
WLAN_REASON_INVALID_GROUP_CIPHER = 18,
|
||||
WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
|
||||
WLAN_REASON_INVALID_AKMP = 20,
|
||||
WLAN_REASON_UNSUPP_RSN_VERSION = 21,
|
||||
WLAN_REASON_INVALID_RSN_IE_CAP = 22,
|
||||
WLAN_REASON_IEEE8021X_FAILED = 23,
|
||||
WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
|
||||
};
|
||||
|
||||
|
||||
/* Information Element IDs */
|
||||
enum ieee80211_eid {
|
||||
WLAN_EID_SSID = 0,
|
||||
WLAN_EID_SUPP_RATES = 1,
|
||||
WLAN_EID_FH_PARAMS = 2,
|
||||
WLAN_EID_DS_PARAMS = 3,
|
||||
WLAN_EID_CF_PARAMS = 4,
|
||||
WLAN_EID_TIM = 5,
|
||||
WLAN_EID_IBSS_PARAMS = 6,
|
||||
WLAN_EID_CHALLENGE = 16,
|
||||
/* 802.11d */
|
||||
WLAN_EID_COUNTRY = 7,
|
||||
WLAN_EID_HP_PARAMS = 8,
|
||||
WLAN_EID_HP_TABLE = 9,
|
||||
WLAN_EID_REQUEST = 10,
|
||||
/* 802.11h */
|
||||
WLAN_EID_PWR_CONSTRAINT = 32,
|
||||
WLAN_EID_PWR_CAPABILITY = 33,
|
||||
WLAN_EID_TPC_REQUEST = 34,
|
||||
WLAN_EID_TPC_REPORT = 35,
|
||||
WLAN_EID_SUPPORTED_CHANNELS = 36,
|
||||
WLAN_EID_CHANNEL_SWITCH = 37,
|
||||
WLAN_EID_MEASURE_REQUEST = 38,
|
||||
WLAN_EID_MEASURE_REPORT = 39,
|
||||
WLAN_EID_QUIET = 40,
|
||||
WLAN_EID_IBSS_DFS = 41,
|
||||
/* 802.11g */
|
||||
WLAN_EID_ERP_INFO = 42,
|
||||
WLAN_EID_EXT_SUPP_RATES = 50,
|
||||
/* 802.11i */
|
||||
WLAN_EID_RSN = 48,
|
||||
WLAN_EID_WPA = 221,
|
||||
WLAN_EID_GENERIC = 221,
|
||||
WLAN_EID_VENDOR_SPECIFIC = 221,
|
||||
WLAN_EID_QOS_PARAMETER = 222
|
||||
};
|
||||
|
||||
/* cipher suite selectors */
|
||||
#define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
|
||||
#define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
|
||||
#define WLAN_CIPHER_SUITE_TKIP 0x000FAC02
|
||||
/* reserved: 0x000FAC03 */
|
||||
#define WLAN_CIPHER_SUITE_CCMP 0x000FAC04
|
||||
#define WLAN_CIPHER_SUITE_WEP104 0x000FAC05
|
||||
|
||||
#define WLAN_MAX_KEY_LEN 32
|
||||
|
||||
/**
|
||||
* ieee80211_get_SA - get pointer to SA
|
||||
*
|
||||
* Given an 802.11 frame, this function returns the offset
|
||||
* to the source address (SA). It does not verify that the
|
||||
* header is long enough to contain the address, and the
|
||||
* header must be long enough to contain the frame control
|
||||
* field.
|
||||
*
|
||||
* @hdr: the frame
|
||||
*/
|
||||
static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
|
||||
{
|
||||
u8 *raw = (u8 *) hdr;
|
||||
u8 tofrom = (*(raw+1)) & 3; /* get the TODS and FROMDS bits */
|
||||
|
||||
switch (tofrom) {
|
||||
case 2:
|
||||
return hdr->addr3;
|
||||
case 3:
|
||||
return hdr->addr4;
|
||||
}
|
||||
return hdr->addr2;
|
||||
}
|
||||
|
||||
/**
|
||||
* ieee80211_get_DA - get pointer to DA
|
||||
*
|
||||
* Given an 802.11 frame, this function returns the offset
|
||||
* to the destination address (DA). It does not verify that
|
||||
* the header is long enough to contain the address, and the
|
||||
* header must be long enough to contain the frame control
|
||||
* field.
|
||||
*
|
||||
* @hdr: the frame
|
||||
*/
|
||||
static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
|
||||
{
|
||||
u8 *raw = (u8 *) hdr;
|
||||
u8 to_ds = (*(raw+1)) & 1; /* get the TODS bit */
|
||||
|
||||
if (to_ds)
|
||||
return hdr->addr3;
|
||||
return hdr->addr1;
|
||||
}
|
||||
|
||||
/**
|
||||
* ieee80211_get_morefrag - determine whether the MOREFRAGS bit is set
|
||||
*
|
||||
* This function determines whether the "more fragments" bit is set
|
||||
* in the frame.
|
||||
*
|
||||
* @hdr: the frame
|
||||
*/
|
||||
static inline int ieee80211_get_morefrag(struct ieee80211_hdr *hdr)
|
||||
{
|
||||
return (le16_to_cpu(hdr->frame_control) &
|
||||
IEEE80211_FCTL_MOREFRAGS) != 0;
|
||||
}
|
||||
|
||||
#endif /* IEEE80211_H */
|
129
package/mac80211/src/include/linux/nl80211.h
Normal file
129
package/mac80211/src/include/linux/nl80211.h
Normal file
@ -0,0 +1,129 @@
|
||||
#ifndef __LINUX_NL80211_H
|
||||
#define __LINUX_NL80211_H
|
||||
/*
|
||||
* 802.11 netlink interface public header
|
||||
*
|
||||
* Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net>
|
||||
*/
|
||||
|
||||
/**
|
||||
* enum nl80211_commands - supported nl80211 commands
|
||||
*
|
||||
* @NL80211_CMD_UNSPEC: unspecified command to catch errors
|
||||
*
|
||||
* @NL80211_CMD_GET_WIPHY: request information about a wiphy or dump request
|
||||
* to get a list of all present wiphys.
|
||||
* @NL80211_CMD_SET_WIPHY: set wiphy name, needs %NL80211_ATTR_WIPHY and
|
||||
* %NL80211_ATTR_WIPHY_NAME.
|
||||
* @NL80211_CMD_NEW_WIPHY: Newly created wiphy, response to get request
|
||||
* or rename notification. Has attributes %NL80211_ATTR_WIPHY and
|
||||
* %NL80211_ATTR_WIPHY_NAME.
|
||||
* @NL80211_CMD_DEL_WIPHY: Wiphy deleted. Has attributes
|
||||
* %NL80211_ATTR_WIPHY and %NL80211_ATTR_WIPHY_NAME.
|
||||
*
|
||||
* @NL80211_CMD_GET_INTERFACE: Request an interface's configuration;
|
||||
* either a dump request on a %NL80211_ATTR_WIPHY or a specific get
|
||||
* on an %NL80211_ATTR_IFINDEX is supported.
|
||||
* @NL80211_CMD_SET_INTERFACE: Set type of a virtual interface, requires
|
||||
%NL80211_ATTR_IFINDEX and %NL80211_ATTR_IFTYPE.
|
||||
* @NL80211_CMD_NEW_INTERFACE: Newly created virtual interface or response
|
||||
* to %NL80211_CMD_GET_INTERFACE. Has %NL80211_ATTR_IFINDEX,
|
||||
* %NL80211_ATTR_WIPHY and %NL80211_ATTR_IFTYPE attributes. Can also
|
||||
* be sent from userspace to request creation of a new virtual interface,
|
||||
* then requires attributes %NL80211_ATTR_WIPHY, %NL80211_ATTR_IFTYPE and
|
||||
* %NL80211_ATTR_IFNAME.
|
||||
* @NL80211_CMD_DEL_INTERFACE: Virtual interface was deleted, has attributes
|
||||
* %NL80211_ATTR_IFINDEX and %NL80211_ATTR_WIPHY. Can also be sent from
|
||||
* userspace to request deletion of a virtual interface, then requires
|
||||
* attribute %NL80211_ATTR_IFINDEX.
|
||||
*
|
||||
* @NL80211_CMD_MAX: highest used command number
|
||||
* @__NL80211_CMD_AFTER_LAST: internal use
|
||||
*/
|
||||
enum nl80211_commands {
|
||||
/* don't change the order or add anything inbetween, this is ABI! */
|
||||
NL80211_CMD_UNSPEC,
|
||||
|
||||
NL80211_CMD_GET_WIPHY, /* can dump */
|
||||
NL80211_CMD_SET_WIPHY,
|
||||
NL80211_CMD_NEW_WIPHY,
|
||||
NL80211_CMD_DEL_WIPHY,
|
||||
|
||||
NL80211_CMD_GET_INTERFACE, /* can dump */
|
||||
NL80211_CMD_SET_INTERFACE,
|
||||
NL80211_CMD_NEW_INTERFACE,
|
||||
NL80211_CMD_DEL_INTERFACE,
|
||||
|
||||
/* add commands here */
|
||||
|
||||
/* used to define NL80211_CMD_MAX below */
|
||||
__NL80211_CMD_AFTER_LAST,
|
||||
NL80211_CMD_MAX = __NL80211_CMD_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* enum nl80211_attrs - nl80211 netlink attributes
|
||||
*
|
||||
* @NL80211_ATTR_UNSPEC: unspecified attribute to catch errors
|
||||
*
|
||||
* @NL80211_ATTR_WIPHY: index of wiphy to operate on, cf.
|
||||
* /sys/class/ieee80211/<phyname>/index
|
||||
* @NL80211_ATTR_WIPHY_NAME: wiphy name (used for renaming)
|
||||
*
|
||||
* @NL80211_ATTR_IFINDEX: network interface index of the device to operate on
|
||||
* @NL80211_ATTR_IFNAME: network interface name
|
||||
* @NL80211_ATTR_IFTYPE: type of virtual interface, see &enum nl80211_iftype
|
||||
*
|
||||
* @NL80211_ATTR_MAX: highest attribute number currently defined
|
||||
* @__NL80211_ATTR_AFTER_LAST: internal use
|
||||
*/
|
||||
enum nl80211_attrs {
|
||||
/* don't change the order or add anything inbetween, this is ABI! */
|
||||
NL80211_ATTR_UNSPEC,
|
||||
|
||||
NL80211_ATTR_WIPHY,
|
||||
NL80211_ATTR_WIPHY_NAME,
|
||||
|
||||
NL80211_ATTR_IFINDEX,
|
||||
NL80211_ATTR_IFNAME,
|
||||
NL80211_ATTR_IFTYPE,
|
||||
|
||||
/* add attributes here, update the policy in nl80211.c */
|
||||
|
||||
__NL80211_ATTR_AFTER_LAST,
|
||||
NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
/**
|
||||
* enum nl80211_iftype - (virtual) interface types
|
||||
*
|
||||
* @NL80211_IFTYPE_UNSPECIFIED: unspecified type, driver decides
|
||||
* @NL80211_IFTYPE_ADHOC: independent BSS member
|
||||
* @NL80211_IFTYPE_STATION: managed BSS member
|
||||
* @NL80211_IFTYPE_AP: access point
|
||||
* @NL80211_IFTYPE_AP_VLAN: VLAN interface for access points
|
||||
* @NL80211_IFTYPE_WDS: wireless distribution interface
|
||||
* @NL80211_IFTYPE_MONITOR: monitor interface receiving all frames
|
||||
* @NL80211_IFTYPE_MAX: highest interface type number currently defined
|
||||
* @__NL80211_IFTYPE_AFTER_LAST: internal use
|
||||
*
|
||||
* These values are used with the %NL80211_ATTR_IFTYPE
|
||||
* to set the type of an interface.
|
||||
*
|
||||
*/
|
||||
enum nl80211_iftype {
|
||||
NL80211_IFTYPE_UNSPECIFIED,
|
||||
NL80211_IFTYPE_ADHOC,
|
||||
NL80211_IFTYPE_STATION,
|
||||
NL80211_IFTYPE_AP,
|
||||
NL80211_IFTYPE_AP_VLAN,
|
||||
NL80211_IFTYPE_WDS,
|
||||
NL80211_IFTYPE_MONITOR,
|
||||
|
||||
/* keep last */
|
||||
__NL80211_IFTYPE_AFTER_LAST,
|
||||
NL80211_IFTYPE_MAX = __NL80211_IFTYPE_AFTER_LAST - 1
|
||||
};
|
||||
|
||||
#endif /* __LINUX_NL80211_H */
|
83
package/mac80211/src/include/net/cfg80211.h
Normal file
83
package/mac80211/src/include/net/cfg80211.h
Normal file
@ -0,0 +1,83 @@
|
||||
#ifndef __NET_CFG80211_H
|
||||
#define __NET_CFG80211_H
|
||||
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/nl80211.h>
|
||||
#include <net/genetlink.h>
|
||||
|
||||
/*
|
||||
* 802.11 configuration in-kernel interface
|
||||
*
|
||||
* Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net>
|
||||
*/
|
||||
|
||||
/* Radiotap header iteration
|
||||
* implemented in net/wireless/radiotap.c
|
||||
* docs in Documentation/networking/radiotap-headers.txt
|
||||
*/
|
||||
/**
|
||||
* struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
|
||||
* @rtheader: pointer to the radiotap header we are walking through
|
||||
* @max_length: length of radiotap header in cpu byte ordering
|
||||
* @this_arg_index: IEEE80211_RADIOTAP_... index of current arg
|
||||
* @this_arg: pointer to current radiotap arg
|
||||
* @arg_index: internal next argument index
|
||||
* @arg: internal next argument pointer
|
||||
* @next_bitmap: internal pointer to next present u32
|
||||
* @bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
|
||||
*/
|
||||
|
||||
struct ieee80211_radiotap_iterator {
|
||||
struct ieee80211_radiotap_header *rtheader;
|
||||
int max_length;
|
||||
int this_arg_index;
|
||||
u8 *this_arg;
|
||||
|
||||
int arg_index;
|
||||
u8 *arg;
|
||||
__le32 *next_bitmap;
|
||||
u32 bitmap_shifter;
|
||||
};
|
||||
|
||||
extern int ieee80211_radiotap_iterator_init(
|
||||
struct ieee80211_radiotap_iterator *iterator,
|
||||
struct ieee80211_radiotap_header *radiotap_header,
|
||||
int max_length);
|
||||
|
||||
extern int ieee80211_radiotap_iterator_next(
|
||||
struct ieee80211_radiotap_iterator *iterator);
|
||||
|
||||
|
||||
/* from net/wireless.h */
|
||||
struct wiphy;
|
||||
|
||||
/**
|
||||
* struct cfg80211_ops - backend description for wireless configuration
|
||||
*
|
||||
* This struct is registered by fullmac card drivers and/or wireless stacks
|
||||
* in order to handle configuration requests on their interfaces.
|
||||
*
|
||||
* All callbacks except where otherwise noted should return 0
|
||||
* on success or a negative error code.
|
||||
*
|
||||
* All operations are currently invoked under rtnl for consistency with the
|
||||
* wireless extensions but this is subject to reevaluation as soon as this
|
||||
* code is used more widely and we have a first user without wext.
|
||||
*
|
||||
* @add_virtual_intf: create a new virtual interface with the given name
|
||||
*
|
||||
* @del_virtual_intf: remove the virtual interface determined by ifindex.
|
||||
*
|
||||
* @change_virtual_intf: change type of virtual interface
|
||||
*
|
||||
*/
|
||||
struct cfg80211_ops {
|
||||
int (*add_virtual_intf)(struct wiphy *wiphy, char *name,
|
||||
enum nl80211_iftype type);
|
||||
int (*del_virtual_intf)(struct wiphy *wiphy, int ifindex);
|
||||
int (*change_virtual_intf)(struct wiphy *wiphy, int ifindex,
|
||||
enum nl80211_iftype type);
|
||||
};
|
||||
|
||||
#endif /* __NET_CFG80211_H */
|
268
package/mac80211/src/include/net/ieee80211_radiotap.h
Normal file
268
package/mac80211/src/include/net/ieee80211_radiotap.h
Normal file
@ -0,0 +1,268 @@
|
||||
/* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */
|
||||
/* $NetBSD: ieee80211_radiotap.h,v 1.11 2005/06/22 06:16:02 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003, 2004 David Young. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of David Young may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
|
||||
* YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modifications to fit into the linux IEEE 802.11 stack,
|
||||
* Mike Kershaw (dragorn@kismetwireless.net)
|
||||
*/
|
||||
|
||||
#ifndef IEEE80211RADIOTAP_H
|
||||
#define IEEE80211RADIOTAP_H
|
||||
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
/* Radiotap header version (from official NetBSD feed) */
|
||||
#define IEEE80211RADIOTAP_VERSION "1.5"
|
||||
/* Base version of the radiotap packet header data */
|
||||
#define PKTHDR_RADIOTAP_VERSION 0
|
||||
|
||||
/* A generic radio capture format is desirable. There is one for
|
||||
* Linux, but it is neither rigidly defined (there were not even
|
||||
* units given for some fields) nor easily extensible.
|
||||
*
|
||||
* I suggest the following extensible radio capture format. It is
|
||||
* based on a bitmap indicating which fields are present.
|
||||
*
|
||||
* I am trying to describe precisely what the application programmer
|
||||
* should expect in the following, and for that reason I tell the
|
||||
* units and origin of each measurement (where it applies), or else I
|
||||
* use sufficiently weaselly language ("is a monotonically nondecreasing
|
||||
* function of...") that I cannot set false expectations for lawyerly
|
||||
* readers.
|
||||
*/
|
||||
|
||||
/* XXX tcpdump/libpcap do not tolerate variable-length headers,
|
||||
* yet, so we pad every radiotap header to 64 bytes. Ugh.
|
||||
*/
|
||||
#define IEEE80211_RADIOTAP_HDRLEN 64
|
||||
|
||||
/* The radio capture header precedes the 802.11 header.
|
||||
* All data in the header is little endian on all platforms.
|
||||
*/
|
||||
struct ieee80211_radiotap_header {
|
||||
u8 it_version; /* Version 0. Only increases
|
||||
* for drastic changes,
|
||||
* introduction of compatible
|
||||
* new fields does not count.
|
||||
*/
|
||||
u8 it_pad;
|
||||
__le16 it_len; /* length of the whole
|
||||
* header in bytes, including
|
||||
* it_version, it_pad,
|
||||
* it_len, and data fields.
|
||||
*/
|
||||
__le32 it_present; /* A bitmap telling which
|
||||
* fields are present. Set bit 31
|
||||
* (0x80000000) to extend the
|
||||
* bitmap by another 32 bits.
|
||||
* Additional extensions are made
|
||||
* by setting bit 31.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Name Data type Units
|
||||
* ---- --------- -----
|
||||
*
|
||||
* IEEE80211_RADIOTAP_TSFT __le64 microseconds
|
||||
*
|
||||
* Value in microseconds of the MAC's 64-bit 802.11 Time
|
||||
* Synchronization Function timer when the first bit of the
|
||||
* MPDU arrived at the MAC. For received frames, only.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_CHANNEL 2 x __le16 MHz, bitmap
|
||||
*
|
||||
* Tx/Rx frequency in MHz, followed by flags (see below).
|
||||
*
|
||||
* IEEE80211_RADIOTAP_FHSS __le16 see below
|
||||
*
|
||||
* For frequency-hopping radios, the hop set (first byte)
|
||||
* and pattern (second byte).
|
||||
*
|
||||
* IEEE80211_RADIOTAP_RATE u8 500kb/s
|
||||
*
|
||||
* Tx/Rx data rate
|
||||
*
|
||||
* IEEE80211_RADIOTAP_DBM_ANTSIGNAL s8 decibels from
|
||||
* one milliwatt (dBm)
|
||||
*
|
||||
* RF signal power at the antenna, decibel difference from
|
||||
* one milliwatt.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_DBM_ANTNOISE s8 decibels from
|
||||
* one milliwatt (dBm)
|
||||
*
|
||||
* RF noise power at the antenna, decibel difference from one
|
||||
* milliwatt.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_DB_ANTSIGNAL u8 decibel (dB)
|
||||
*
|
||||
* RF signal power at the antenna, decibel difference from an
|
||||
* arbitrary, fixed reference.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_DB_ANTNOISE u8 decibel (dB)
|
||||
*
|
||||
* RF noise power at the antenna, decibel difference from an
|
||||
* arbitrary, fixed reference point.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_LOCK_QUALITY __le16 unitless
|
||||
*
|
||||
* Quality of Barker code lock. Unitless. Monotonically
|
||||
* nondecreasing with "better" lock strength. Called "Signal
|
||||
* Quality" in datasheets. (Is there a standard way to measure
|
||||
* this?)
|
||||
*
|
||||
* IEEE80211_RADIOTAP_TX_ATTENUATION __le16 unitless
|
||||
*
|
||||
* Transmit power expressed as unitless distance from max
|
||||
* power set at factory calibration. 0 is max power.
|
||||
* Monotonically nondecreasing with lower power levels.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_DB_TX_ATTENUATION __le16 decibels (dB)
|
||||
*
|
||||
* Transmit power expressed as decibel distance from max power
|
||||
* set at factory calibration. 0 is max power. Monotonically
|
||||
* nondecreasing with lower power levels.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_DBM_TX_POWER s8 decibels from
|
||||
* one milliwatt (dBm)
|
||||
*
|
||||
* Transmit power expressed as dBm (decibels from a 1 milliwatt
|
||||
* reference). This is the absolute power level measured at
|
||||
* the antenna port.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_FLAGS u8 bitmap
|
||||
*
|
||||
* Properties of transmitted and received frames. See flags
|
||||
* defined below.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_ANTENNA u8 antenna index
|
||||
*
|
||||
* Unitless indication of the Rx/Tx antenna for this packet.
|
||||
* The first antenna is antenna 0.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_RX_FLAGS __le16 bitmap
|
||||
*
|
||||
* Properties of received frames. See flags defined below.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_TX_FLAGS __le16 bitmap
|
||||
*
|
||||
* Properties of transmitted frames. See flags defined below.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_RTS_RETRIES u8 data
|
||||
*
|
||||
* Number of rts retries a transmitted frame used.
|
||||
*
|
||||
* IEEE80211_RADIOTAP_DATA_RETRIES u8 data
|
||||
*
|
||||
* Number of unicast retries a transmitted frame used.
|
||||
*
|
||||
*/
|
||||
enum ieee80211_radiotap_type {
|
||||
IEEE80211_RADIOTAP_TSFT = 0,
|
||||
IEEE80211_RADIOTAP_FLAGS = 1,
|
||||
IEEE80211_RADIOTAP_RATE = 2,
|
||||
IEEE80211_RADIOTAP_CHANNEL = 3,
|
||||
IEEE80211_RADIOTAP_FHSS = 4,
|
||||
IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
|
||||
IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
|
||||
IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
|
||||
IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
|
||||
IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
|
||||
IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
|
||||
IEEE80211_RADIOTAP_ANTENNA = 11,
|
||||
IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
|
||||
IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
|
||||
IEEE80211_RADIOTAP_RX_FLAGS = 14,
|
||||
IEEE80211_RADIOTAP_TX_FLAGS = 15,
|
||||
IEEE80211_RADIOTAP_RTS_RETRIES = 16,
|
||||
IEEE80211_RADIOTAP_DATA_RETRIES = 17,
|
||||
IEEE80211_RADIOTAP_EXT = 31
|
||||
};
|
||||
|
||||
/* Channel flags. */
|
||||
#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
|
||||
#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
|
||||
#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
|
||||
#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */
|
||||
#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
|
||||
#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
|
||||
#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
|
||||
#define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */
|
||||
|
||||
/* For IEEE80211_RADIOTAP_FLAGS */
|
||||
#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
|
||||
* during CFP
|
||||
*/
|
||||
#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
|
||||
* with short
|
||||
* preamble
|
||||
*/
|
||||
#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
|
||||
* with WEP encryption
|
||||
*/
|
||||
#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
|
||||
* with fragmentation
|
||||
*/
|
||||
#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
|
||||
#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
|
||||
* 802.11 header and payload
|
||||
* (to 32-bit boundary)
|
||||
*/
|
||||
/* For IEEE80211_RADIOTAP_RX_FLAGS */
|
||||
#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
|
||||
|
||||
/* For IEEE80211_RADIOTAP_TX_FLAGS */
|
||||
#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive
|
||||
* retries */
|
||||
#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */
|
||||
#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */
|
||||
|
||||
/* Ugly macro to convert literal channel numbers into their mhz equivalents
|
||||
* There are certianly some conditions that will break this (like feeding it '30')
|
||||
* but they shouldn't arise since nothing talks on channel 30. */
|
||||
#define ieee80211chan2mhz(x) \
|
||||
(((x) <= 14) ? \
|
||||
(((x) == 14) ? 2484 : ((x) * 5) + 2407) : \
|
||||
((x) + 1000) * 5)
|
||||
|
||||
/* helpers */
|
||||
static inline int ieee80211_get_radiotap_len(unsigned char *data)
|
||||
{
|
||||
struct ieee80211_radiotap_header *hdr =
|
||||
(struct ieee80211_radiotap_header *)data;
|
||||
|
||||
return le16_to_cpu(get_unaligned(&hdr->it_len));
|
||||
}
|
||||
|
||||
#endif /* IEEE80211_RADIOTAP_H */
|
1429
package/mac80211/src/include/net/mac80211.h
Normal file
1429
package/mac80211/src/include/net/mac80211.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -64,10 +64,6 @@ config MAC80211_DEBUG_COUNTERS
|
||||
bool "Extra statistics for TX/RX debugging"
|
||||
depends on MAC80211_DEBUG
|
||||
|
||||
config HOSTAPD_WPA_TESTING
|
||||
bool "Support for TKIP countermeasures testing"
|
||||
depends on MAC80211_DEBUG
|
||||
|
||||
config MAC80211_IBSS_DEBUG
|
||||
bool "Support for IBSS testing"
|
||||
depends on MAC80211_DEBUG
|
||||
|
@ -1,7 +1,8 @@
|
||||
obj-$(CONFIG_MAC80211) += mac80211.o rc80211_simple.o rc80211_lowest.o
|
||||
obj-$(CONFIG_MAC80211) += mac80211.o rc80211_simple.o
|
||||
|
||||
mac80211-objs-$(CONFIG_MAC80211_LEDS) += ieee80211_led.o
|
||||
mac80211-objs-$(CONFIG_MAC80211_DEBUGFS) += debugfs.o debugfs_sta.o debugfs_netdev.o debugfs_key.o
|
||||
mac80211-objs-$(CONFIG_NET_SCHED) += wme.o
|
||||
|
||||
mac80211-objs := \
|
||||
ieee80211.o \
|
||||
@ -16,6 +17,10 @@ mac80211-objs := \
|
||||
regdomain.o \
|
||||
tkip.o \
|
||||
aes_ccm.o \
|
||||
wme.o \
|
||||
ieee80211_cfg.o \
|
||||
cfg.o \
|
||||
rx.o \
|
||||
tx.o \
|
||||
key.o \
|
||||
util.o \
|
||||
event.o \
|
||||
$(mac80211-objs-y)
|
||||
|
105
package/mac80211/src/mac80211/cfg.c
Normal file
105
package/mac80211/src/mac80211/cfg.c
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* mac80211 configuration hooks for cfg80211
|
||||
*
|
||||
* Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
|
||||
*
|
||||
* This file is GPLv2 as found in COPYING.
|
||||
*/
|
||||
|
||||
#include <linux/nl80211.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <net/cfg80211.h>
|
||||
#include "ieee80211_i.h"
|
||||
#include "cfg.h"
|
||||
|
||||
static enum ieee80211_if_types
|
||||
nl80211_type_to_mac80211_type(enum nl80211_iftype type)
|
||||
{
|
||||
switch (type) {
|
||||
case NL80211_IFTYPE_UNSPECIFIED:
|
||||
return IEEE80211_IF_TYPE_STA;
|
||||
case NL80211_IFTYPE_ADHOC:
|
||||
return IEEE80211_IF_TYPE_IBSS;
|
||||
case NL80211_IFTYPE_STATION:
|
||||
return IEEE80211_IF_TYPE_STA;
|
||||
case NL80211_IFTYPE_MONITOR:
|
||||
return IEEE80211_IF_TYPE_MNTR;
|
||||
default:
|
||||
return IEEE80211_IF_TYPE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
static int ieee80211_add_iface(struct wiphy *wiphy, char *name,
|
||||
enum nl80211_iftype type)
|
||||
{
|
||||
struct ieee80211_local *local = wiphy_priv(wiphy);
|
||||
enum ieee80211_if_types itype;
|
||||
|
||||
if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED))
|
||||
return -ENODEV;
|
||||
|
||||
itype = nl80211_type_to_mac80211_type(type);
|
||||
if (itype == IEEE80211_IF_TYPE_INVALID)
|
||||
return -EINVAL;
|
||||
|
||||
return ieee80211_if_add(local->mdev, name, NULL, itype);
|
||||
}
|
||||
|
||||
static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex)
|
||||
{
|
||||
struct ieee80211_local *local = wiphy_priv(wiphy);
|
||||
struct net_device *dev;
|
||||
char *name;
|
||||
|
||||
if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED))
|
||||
return -ENODEV;
|
||||
|
||||
/* we're under RTNL */
|
||||
dev = __dev_get_by_index(ifindex);
|
||||
if (!dev)
|
||||
return 0;
|
||||
|
||||
name = dev->name;
|
||||
|
||||
return ieee80211_if_remove(local->mdev, name, -1);
|
||||
}
|
||||
|
||||
static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex,
|
||||
enum nl80211_iftype type)
|
||||
{
|
||||
struct ieee80211_local *local = wiphy_priv(wiphy);
|
||||
struct net_device *dev;
|
||||
enum ieee80211_if_types itype;
|
||||
struct ieee80211_sub_if_data *sdata;
|
||||
|
||||
if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED))
|
||||
return -ENODEV;
|
||||
|
||||
/* we're under RTNL */
|
||||
dev = __dev_get_by_index(ifindex);
|
||||
if (!dev)
|
||||
return -ENODEV;
|
||||
|
||||
if (netif_running(dev))
|
||||
return -EBUSY;
|
||||
|
||||
itype = nl80211_type_to_mac80211_type(type);
|
||||
if (itype == IEEE80211_IF_TYPE_INVALID)
|
||||
return -EINVAL;
|
||||
|
||||
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||
|
||||
if (sdata->type == IEEE80211_IF_TYPE_VLAN)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
ieee80211_if_reinit(dev);
|
||||
ieee80211_if_set_type(dev, itype);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct cfg80211_ops mac80211_config_ops = {
|
||||
.add_virtual_intf = ieee80211_add_iface,
|
||||
.del_virtual_intf = ieee80211_del_iface,
|
||||
.change_virtual_intf = ieee80211_change_iface,
|
||||
};
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
* mac80211 configuration hooks for cfg80211
|
||||
*/
|
||||
#ifndef __IEEE80211_CFG_H
|
||||
#define __IEEE80211_CFG_H
|
||||
#ifndef __CFG_H
|
||||
#define __CFG_H
|
||||
|
||||
extern struct cfg80211_ops mac80211_config_ops;
|
||||
|
||||
#endif /* __IEEE80211_CFG_H */
|
||||
#endif /* __CFG_H */
|
@ -13,16 +13,6 @@
|
||||
#include "ieee80211_rate.h"
|
||||
#include "debugfs.h"
|
||||
|
||||
static inline int rtnl_lock_local(struct ieee80211_local *local)
|
||||
{
|
||||
rtnl_lock();
|
||||
if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED)) {
|
||||
rtnl_unlock();
|
||||
return -ENODEV;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mac80211_open_file_generic(struct inode *inode, struct file *file)
|
||||
{
|
||||
file->private_data = inode->i_private;
|
||||
@ -38,8 +28,6 @@ static const char *ieee80211_mode_str(int mode)
|
||||
return "IEEE 802.11b";
|
||||
case MODE_IEEE80211G:
|
||||
return "IEEE 802.11g";
|
||||
case MODE_ATHEROS_TURBO:
|
||||
return "Atheros Turbo (5 GHz)";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
@ -66,7 +54,7 @@ static const struct file_operations modes_ops = {
|
||||
.open = mac80211_open_file_generic,
|
||||
};
|
||||
|
||||
#define DEBUGFS_READ(name, buflen, fmt, value...) \
|
||||
#define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \
|
||||
static ssize_t name## _read(struct file *file, char __user *userbuf, \
|
||||
size_t count, loff_t *ppos) \
|
||||
{ \
|
||||
@ -77,20 +65,16 @@ static ssize_t name## _read(struct file *file, char __user *userbuf, \
|
||||
res = scnprintf(buf, buflen, fmt "\n", ##value); \
|
||||
return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
|
||||
} \
|
||||
|
||||
#define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \
|
||||
DEBUGFS_READ(name, buflen, fmt, ## value) \
|
||||
\
|
||||
static const struct file_operations name## _ops = { \
|
||||
.read = name## _read, \
|
||||
.open = mac80211_open_file_generic, \
|
||||
};
|
||||
|
||||
#define DEBUGFS_ADD_MODE(name, mode) \
|
||||
local->debugfs.name = debugfs_create_file(#name, mode, phyd, \
|
||||
#define DEBUGFS_ADD(name) \
|
||||
local->debugfs.name = debugfs_create_file(#name, 0444, phyd, \
|
||||
local, &name## _ops);
|
||||
|
||||
#define DEBUGFS_ADD(name) DEBUGFS_ADD_MODE(name, 0444)
|
||||
|
||||
#define DEBUGFS_DEL(name) \
|
||||
debugfs_remove(local->debugfs.name); \
|
||||
local->debugfs.name = NULL;
|
||||
@ -100,16 +84,12 @@ DEBUGFS_READONLY_FILE(channel, 20, "%d",
|
||||
local->hw.conf.channel);
|
||||
DEBUGFS_READONLY_FILE(frequency, 20, "%d",
|
||||
local->hw.conf.freq);
|
||||
DEBUGFS_READONLY_FILE(radar_detect, 20, "%d",
|
||||
local->hw.conf.radar_detect);
|
||||
DEBUGFS_READONLY_FILE(antenna_sel_tx, 20, "%d",
|
||||
local->hw.conf.antenna_sel_tx);
|
||||
DEBUGFS_READONLY_FILE(antenna_sel_rx, 20, "%d",
|
||||
local->hw.conf.antenna_sel_rx);
|
||||
DEBUGFS_READONLY_FILE(bridge_packets, 20, "%d",
|
||||
local->bridge_packets);
|
||||
DEBUGFS_READONLY_FILE(key_tx_rx_threshold, 20, "%d",
|
||||
local->key_tx_rx_threshold);
|
||||
DEBUGFS_READONLY_FILE(rts_threshold, 20, "%d",
|
||||
local->rts_threshold);
|
||||
DEBUGFS_READONLY_FILE(fragmentation_threshold, 20, "%d",
|
||||
@ -124,41 +104,21 @@ DEBUGFS_READONLY_FILE(mode, 20, "%s",
|
||||
ieee80211_mode_str(local->hw.conf.phymode));
|
||||
DEBUGFS_READONLY_FILE(wep_iv, 20, "%#06x",
|
||||
local->wep_iv & 0xffffff);
|
||||
DEBUGFS_READONLY_FILE(tx_power_reduction, 20, "%d.%d dBm",
|
||||
local->hw.conf.tx_power_reduction / 10,
|
||||
local->hw.conf.tx_power_reduction & 10);
|
||||
|
||||
DEBUGFS_READ(rate_ctrl_alg, 100, "%s",
|
||||
local->rate_ctrl ? local->rate_ctrl->ops->name : "<unset>");
|
||||
|
||||
static ssize_t rate_ctrl_alg_write(struct file *file, const char __user *userbuf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct ieee80211_local *local = file->private_data;
|
||||
char buf[64];
|
||||
ssize_t buf_size;
|
||||
int res;
|
||||
|
||||
buf_size = min(count, ARRAY_SIZE(buf) - 1);
|
||||
if (copy_from_user(buf, userbuf, buf_size))
|
||||
return -EFAULT;
|
||||
buf[buf_size] = '\0';
|
||||
res = rtnl_lock_local(local);
|
||||
if (res)
|
||||
return res;
|
||||
res = ieee80211_init_rate_ctrl_alg(local, buf);
|
||||
rtnl_unlock();
|
||||
return res < 0 ? res : buf_size;
|
||||
}
|
||||
|
||||
static const struct file_operations rate_ctrl_alg_ops = {
|
||||
.read = rate_ctrl_alg_read,
|
||||
.write = rate_ctrl_alg_write,
|
||||
.open = mac80211_open_file_generic,
|
||||
};
|
||||
DEBUGFS_READONLY_FILE(rate_ctrl_alg, 100, "%s",
|
||||
local->rate_ctrl ? local->rate_ctrl->ops->name : "<unset>");
|
||||
|
||||
/* statistics stuff */
|
||||
|
||||
static inline int rtnl_lock_local(struct ieee80211_local *local)
|
||||
{
|
||||
rtnl_lock();
|
||||
if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED)) {
|
||||
rtnl_unlock();
|
||||
return -ENODEV;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define DEBUGFS_STATS_FILE(name, buflen, fmt, value...) \
|
||||
DEBUGFS_READONLY_FILE(stats_ ##name, buflen, fmt, ##value)
|
||||
|
||||
@ -336,11 +296,9 @@ void debugfs_hw_add(struct ieee80211_local *local)
|
||||
|
||||
DEBUGFS_ADD(channel);
|
||||
DEBUGFS_ADD(frequency);
|
||||
DEBUGFS_ADD(radar_detect);
|
||||
DEBUGFS_ADD(antenna_sel_tx);
|
||||
DEBUGFS_ADD(antenna_sel_rx);
|
||||
DEBUGFS_ADD(bridge_packets);
|
||||
DEBUGFS_ADD(key_tx_rx_threshold);
|
||||
DEBUGFS_ADD(rts_threshold);
|
||||
DEBUGFS_ADD(fragmentation_threshold);
|
||||
DEBUGFS_ADD(short_retry_limit);
|
||||
@ -348,8 +306,6 @@ void debugfs_hw_add(struct ieee80211_local *local)
|
||||
DEBUGFS_ADD(total_ps_buffered);
|
||||
DEBUGFS_ADD(mode);
|
||||
DEBUGFS_ADD(wep_iv);
|
||||
DEBUGFS_ADD(tx_power_reduction);
|
||||
DEBUGFS_ADD_MODE(rate_ctrl_alg, 0644);
|
||||
DEBUGFS_ADD(modes);
|
||||
|
||||
statsd = debugfs_create_dir("statistics", phyd);
|
||||
@ -402,11 +358,9 @@ void debugfs_hw_del(struct ieee80211_local *local)
|
||||
{
|
||||
DEBUGFS_DEL(channel);
|
||||
DEBUGFS_DEL(frequency);
|
||||
DEBUGFS_DEL(radar_detect);
|
||||
DEBUGFS_DEL(antenna_sel_tx);
|
||||
DEBUGFS_DEL(antenna_sel_rx);
|
||||
DEBUGFS_DEL(bridge_packets);
|
||||
DEBUGFS_DEL(key_tx_rx_threshold);
|
||||
DEBUGFS_DEL(rts_threshold);
|
||||
DEBUGFS_DEL(fragmentation_threshold);
|
||||
DEBUGFS_DEL(short_retry_limit);
|
||||
@ -414,8 +368,6 @@ void debugfs_hw_del(struct ieee80211_local *local)
|
||||
DEBUGFS_DEL(total_ps_buffered);
|
||||
DEBUGFS_DEL(mode);
|
||||
DEBUGFS_DEL(wep_iv);
|
||||
DEBUGFS_DEL(tx_power_reduction);
|
||||
DEBUGFS_DEL(rate_ctrl_alg);
|
||||
DEBUGFS_DEL(modes);
|
||||
|
||||
DEBUGFS_STATS_DEL(transmitted_fragment_count);
|
||||
|
@ -14,17 +14,18 @@
|
||||
#include "debugfs.h"
|
||||
#include "debugfs_key.h"
|
||||
|
||||
#define KEY_READ(name, buflen, format_string) \
|
||||
#define KEY_READ(name, prop, buflen, format_string) \
|
||||
static ssize_t key_##name##_read(struct file *file, \
|
||||
char __user *userbuf, \
|
||||
size_t count, loff_t *ppos) \
|
||||
{ \
|
||||
char buf[buflen]; \
|
||||
struct ieee80211_key *key = file->private_data; \
|
||||
int res = scnprintf(buf, buflen, format_string, key->name); \
|
||||
int res = scnprintf(buf, buflen, format_string, key->prop); \
|
||||
return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
|
||||
}
|
||||
#define KEY_READ_D(name) KEY_READ(name, 20, "%d\n")
|
||||
#define KEY_READ_D(name) KEY_READ(name, name, 20, "%d\n")
|
||||
#define KEY_READ_X(name) KEY_READ(name, name, 20, "0x%x\n")
|
||||
|
||||
#define KEY_OPS(name) \
|
||||
static const struct file_operations key_ ##name## _ops = { \
|
||||
@ -36,11 +37,27 @@ static const struct file_operations key_ ##name## _ops = { \
|
||||
KEY_READ_##format(name) \
|
||||
KEY_OPS(name)
|
||||
|
||||
KEY_FILE(keylen, D);
|
||||
KEY_FILE(force_sw_encrypt, D);
|
||||
KEY_FILE(keyidx, D);
|
||||
KEY_FILE(hw_key_idx, D);
|
||||
#define KEY_CONF_READ(name, buflen, format_string) \
|
||||
KEY_READ(conf_##name, conf.name, buflen, format_string)
|
||||
#define KEY_CONF_READ_D(name) KEY_CONF_READ(name, 20, "%d\n")
|
||||
|
||||
#define KEY_CONF_OPS(name) \
|
||||
static const struct file_operations key_ ##name## _ops = { \
|
||||
.read = key_conf_##name##_read, \
|
||||
.open = mac80211_open_file_generic, \
|
||||
}
|
||||
|
||||
#define KEY_CONF_FILE(name, format) \
|
||||
KEY_CONF_READ_##format(name) \
|
||||
KEY_CONF_OPS(name)
|
||||
|
||||
KEY_CONF_FILE(keylen, D);
|
||||
KEY_CONF_FILE(keyidx, D);
|
||||
KEY_CONF_FILE(hw_key_idx, D);
|
||||
KEY_FILE(flags, X);
|
||||
KEY_FILE(tx_rx_count, D);
|
||||
KEY_READ(ifindex, sdata->dev->ifindex, 20, "%d\n");
|
||||
KEY_OPS(ifindex);
|
||||
|
||||
static ssize_t key_algorithm_read(struct file *file,
|
||||
char __user *userbuf,
|
||||
@ -49,7 +66,7 @@ static ssize_t key_algorithm_read(struct file *file,
|
||||
char *alg;
|
||||
struct ieee80211_key *key = file->private_data;
|
||||
|
||||
switch (key->alg) {
|
||||
switch (key->conf.alg) {
|
||||
case ALG_WEP:
|
||||
alg = "WEP\n";
|
||||
break;
|
||||
@ -74,17 +91,20 @@ static ssize_t key_tx_spec_read(struct file *file, char __user *userbuf,
|
||||
int len;
|
||||
struct ieee80211_key *key = file->private_data;
|
||||
|
||||
switch (key->alg) {
|
||||
switch (key->conf.alg) {
|
||||
case ALG_WEP:
|
||||
len = scnprintf(buf, sizeof(buf), "\n");
|
||||
break;
|
||||
case ALG_TKIP:
|
||||
len = scnprintf(buf, sizeof(buf), "%08x %04x\n",
|
||||
key->u.tkip.iv32,
|
||||
key->u.tkip.iv16);
|
||||
break;
|
||||
case ALG_CCMP:
|
||||
tpn = key->u.ccmp.tx_pn;
|
||||
len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n",
|
||||
tpn[0], tpn[1], tpn[2], tpn[3], tpn[4], tpn[5]);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@ -100,9 +120,10 @@ static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
|
||||
int i, len;
|
||||
const u8 *rpn;
|
||||
|
||||
switch (key->alg) {
|
||||
switch (key->conf.alg) {
|
||||
case ALG_WEP:
|
||||
len = scnprintf(buf, sizeof(buf), "\n");
|
||||
break;
|
||||
case ALG_TKIP:
|
||||
for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
|
||||
p += scnprintf(p, sizeof(buf)+buf-p,
|
||||
@ -110,6 +131,7 @@ static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
|
||||
key->u.tkip.iv32_rx[i],
|
||||
key->u.tkip.iv16_rx[i]);
|
||||
len = p - buf;
|
||||
break;
|
||||
case ALG_CCMP:
|
||||
for (i = 0; i < NUM_RX_DATA_QUEUES; i++) {
|
||||
rpn = key->u.ccmp.rx_pn[i];
|
||||
@ -119,6 +141,7 @@ static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
|
||||
rpn[3], rpn[4], rpn[5]);
|
||||
}
|
||||
len = p - buf;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@ -133,7 +156,7 @@ static ssize_t key_replays_read(struct file *file, char __user *userbuf,
|
||||
char buf[20];
|
||||
int len;
|
||||
|
||||
if (key->alg != ALG_CCMP)
|
||||
if (key->conf.alg != ALG_CCMP)
|
||||
return 0;
|
||||
len = scnprintf(buf, sizeof(buf), "%u\n", key->u.ccmp.replays);
|
||||
return simple_read_from_buffer(userbuf, count, ppos, buf, len);
|
||||
@ -144,12 +167,12 @@ static ssize_t key_key_read(struct file *file, char __user *userbuf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct ieee80211_key *key = file->private_data;
|
||||
int i, res, bufsize = 2*key->keylen+2;
|
||||
int i, res, bufsize = 2 * key->conf.keylen + 2;
|
||||
char *buf = kmalloc(bufsize, GFP_KERNEL);
|
||||
char *p = buf;
|
||||
|
||||
for (i = 0; i < key->keylen; i++)
|
||||
p += scnprintf(p, bufsize+buf-p, "%02x", key->key[i]);
|
||||
for (i = 0; i < key->conf.keylen; i++)
|
||||
p += scnprintf(p, bufsize + buf - p, "%02x", key->conf.key[i]);
|
||||
p += scnprintf(p, bufsize+buf-p, "\n");
|
||||
res = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
|
||||
kfree(buf);
|
||||
@ -164,12 +187,14 @@ KEY_OPS(key);
|
||||
void ieee80211_debugfs_key_add(struct ieee80211_local *local,
|
||||
struct ieee80211_key *key)
|
||||
{
|
||||
static int keycount;
|
||||
char buf[20];
|
||||
|
||||
if (!local->debugfs.keys)
|
||||
return;
|
||||
|
||||
sprintf(buf, "%d", key->keyidx);
|
||||
sprintf(buf, "%d", keycount);
|
||||
keycount++;
|
||||
key->debugfs.dir = debugfs_create_dir(buf,
|
||||
local->debugfs.keys);
|
||||
|
||||
@ -177,7 +202,7 @@ void ieee80211_debugfs_key_add(struct ieee80211_local *local,
|
||||
return;
|
||||
|
||||
DEBUGFS_ADD(keylen);
|
||||
DEBUGFS_ADD(force_sw_encrypt);
|
||||
DEBUGFS_ADD(flags);
|
||||
DEBUGFS_ADD(keyidx);
|
||||
DEBUGFS_ADD(hw_key_idx);
|
||||
DEBUGFS_ADD(tx_rx_count);
|
||||
@ -186,6 +211,7 @@ void ieee80211_debugfs_key_add(struct ieee80211_local *local,
|
||||
DEBUGFS_ADD(rx_spec);
|
||||
DEBUGFS_ADD(replays);
|
||||
DEBUGFS_ADD(key);
|
||||
DEBUGFS_ADD(ifindex);
|
||||
};
|
||||
|
||||
#define DEBUGFS_DEL(name) \
|
||||
@ -197,7 +223,7 @@ void ieee80211_debugfs_key_remove(struct ieee80211_key *key)
|
||||
return;
|
||||
|
||||
DEBUGFS_DEL(keylen);
|
||||
DEBUGFS_DEL(force_sw_encrypt);
|
||||
DEBUGFS_DEL(flags);
|
||||
DEBUGFS_DEL(keyidx);
|
||||
DEBUGFS_DEL(hw_key_idx);
|
||||
DEBUGFS_DEL(tx_rx_count);
|
||||
@ -206,6 +232,7 @@ void ieee80211_debugfs_key_remove(struct ieee80211_key *key)
|
||||
DEBUGFS_DEL(rx_spec);
|
||||
DEBUGFS_DEL(replays);
|
||||
DEBUGFS_DEL(key);
|
||||
DEBUGFS_DEL(ifindex);
|
||||
|
||||
debugfs_remove(key->debugfs.stalink);
|
||||
key->debugfs.stalink = NULL;
|
||||
@ -219,7 +246,7 @@ void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata)
|
||||
if (!sdata->debugfsdir)
|
||||
return;
|
||||
|
||||
sprintf(buf, "../keys/%d", sdata->default_key->keyidx);
|
||||
sprintf(buf, "../keys/%d", sdata->default_key->conf.keyidx);
|
||||
sdata->debugfs.default_key =
|
||||
debugfs_create_symlink("default_key", sdata->debugfsdir, buf);
|
||||
}
|
||||
@ -239,7 +266,7 @@ void ieee80211_debugfs_key_sta_link(struct ieee80211_key *key,
|
||||
if (!key->debugfs.dir)
|
||||
return;
|
||||
|
||||
sprintf(buf, "../sta/" MAC_FMT, MAC_ARG(sta->addr));
|
||||
sprintf(buf, "../../stations/" MAC_FMT, MAC_ARG(sta->addr));
|
||||
key->debugfs.stalink =
|
||||
debugfs_create_symlink("station", key->debugfs.dir, buf);
|
||||
}
|
||||
|
@ -87,267 +87,6 @@ static const struct file_operations name##_ops = { \
|
||||
IEEE80211_IF_FMT_##format(name, field) \
|
||||
__IEEE80211_IF_FILE(name)
|
||||
|
||||
#define DEBUGFS_QOS_FILE(name, f) \
|
||||
static ssize_t qos_ ##name## _write(struct file *file, \
|
||||
const char __user *userbuf, \
|
||||
size_t count, loff_t *ppos) \
|
||||
{ \
|
||||
struct ieee80211_sub_if_data *sdata = file->private_data; \
|
||||
\
|
||||
f(sdata->dev, &sdata->u.sta, &sdata->u.sta.tspec); \
|
||||
\
|
||||
return count; \
|
||||
} \
|
||||
\
|
||||
static const struct file_operations qos_ ##name## _ops = { \
|
||||
.write = qos_ ##name## _write, \
|
||||
.open = mac80211_open_file_generic, \
|
||||
};
|
||||
|
||||
#define DEBUGFS_QOS_ADD(name) \
|
||||
sdata->debugfs.sta.qos.name = debugfs_create_file(#name, 0444, qosd,\
|
||||
sdata, &qos_ ##name## _ops);
|
||||
|
||||
#define DEBUGFS_QOS_DEL(name) \
|
||||
do { \
|
||||
debugfs_remove(sdata->debugfs.sta.qos.name); \
|
||||
sdata->debugfs.sta.qos.name = NULL; \
|
||||
} while (0)
|
||||
|
||||
DEBUGFS_QOS_FILE(addts_11e, ieee80211_send_addts);
|
||||
DEBUGFS_QOS_FILE(addts_wmm, wmm_send_addts);
|
||||
DEBUGFS_QOS_FILE(delts_11e, ieee80211_send_delts);
|
||||
DEBUGFS_QOS_FILE(delts_wmm, wmm_send_delts);
|
||||
|
||||
static ssize_t qos_if_dls_mac(const struct ieee80211_sub_if_data *sdata,
|
||||
char *buf, int buflen)
|
||||
{
|
||||
return scnprintf(buf, buflen, MAC_FMT "\n",
|
||||
MAC_ARG(sdata->u.sta.dls_mac));
|
||||
}
|
||||
|
||||
static ssize_t qos_dls_mac_read(struct file *file,
|
||||
char __user *userbuf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
return ieee80211_if_read(file->private_data,
|
||||
userbuf, count, ppos,
|
||||
qos_if_dls_mac);
|
||||
}
|
||||
|
||||
static ssize_t qos_dls_mac_write(struct file *file, const char __user *userbuf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct ieee80211_sub_if_data *sdata = file->private_data;
|
||||
char buf[20];
|
||||
size_t size;
|
||||
u8 m[ETH_ALEN];
|
||||
|
||||
size = min(sizeof(buf) - 1, count);
|
||||
buf[size] = '\0';
|
||||
if (copy_from_user(buf, userbuf, size))
|
||||
return -EFAULT;
|
||||
|
||||
if (sscanf(buf, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
|
||||
&((u8*)(m))[0], &((u8*)(m))[1], &((u8*)(m))[2],
|
||||
&((u8*)(m))[3], &((u8*)(m))[4], &((u8*)(m))[5]) != ETH_ALEN){
|
||||
printk(KERN_ERR "%s: sscanf input error\n", sdata->dev->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
memcpy(sdata->u.sta.dls_mac, m, ETH_ALEN);
|
||||
return count;
|
||||
}
|
||||
|
||||
static const struct file_operations qos_dls_mac_ops = {
|
||||
.read = qos_dls_mac_read,
|
||||
.write = qos_dls_mac_write,
|
||||
.open = mac80211_open_file_generic,
|
||||
};
|
||||
|
||||
static ssize_t qos_if_dls_op(const struct ieee80211_sub_if_data *sdata,
|
||||
char *buf, int buflen)
|
||||
{
|
||||
return scnprintf(buf, buflen,
|
||||
"DLS Operation: Setup = 1; Teardown = 2\n");
|
||||
}
|
||||
|
||||
static ssize_t qos_dls_op_read(struct file *file, char __user *userbuf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
return ieee80211_if_read(file->private_data,
|
||||
userbuf, count, ppos,
|
||||
qos_if_dls_op);
|
||||
}
|
||||
|
||||
static ssize_t qos_dls_op_write(struct file *file, const char __user *userbuf,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct ieee80211_sub_if_data *sdata = file->private_data;
|
||||
char buf[20];
|
||||
size_t size;
|
||||
unsigned int opt;
|
||||
|
||||
size = min(sizeof(buf) - 1, count);
|
||||
buf[size] = '\0';
|
||||
if (copy_from_user(buf, userbuf, size))
|
||||
return -EFAULT;
|
||||
|
||||
if (sscanf(buf, "%u", &opt) != 1) {
|
||||
printk(KERN_ERR "%s: sscanf input error\n", sdata->dev->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
switch (opt) {
|
||||
case 1:
|
||||
ieee80211_send_dls_req(sdata->dev, &sdata->u.sta,
|
||||
sdata->u.sta.dls_mac, 0);
|
||||
break;
|
||||
case 2:
|
||||
ieee80211_send_dls_teardown(sdata->dev, &sdata->u.sta,
|
||||
sdata->u.sta.dls_mac,
|
||||
WLAN_REASON_QSTA_NOT_USE);
|
||||
break;
|
||||
default:
|
||||
printk(KERN_ERR "Unknown DLS Operation: %d\n", opt);
|
||||
break;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static const struct file_operations qos_dls_op_ops = {
|
||||
.read = qos_dls_op_read,
|
||||
.write = qos_dls_op_write,
|
||||
.open = mac80211_open_file_generic,
|
||||
};
|
||||
|
||||
#define DEBUGFS_TSINFO_FILE(_name, min_val, max_val) \
|
||||
static ssize_t tsinfo_ ##_name## _read(struct file *file, \
|
||||
char __user *userbuf, \
|
||||
size_t count, loff_t *ppos) \
|
||||
{ \
|
||||
char buf[20]; \
|
||||
struct ieee80211_sub_if_data *sdata = file->private_data; \
|
||||
int res = scnprintf(buf, count, "%u\n", \
|
||||
IEEE80211_TSINFO_## _name (sdata->u.sta.tspec.ts_info));\
|
||||
return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
|
||||
} \
|
||||
\
|
||||
static ssize_t tsinfo_ ##_name## _write(struct file *file, \
|
||||
const char __user *userbuf, \
|
||||
size_t count, loff_t *ppos) \
|
||||
{ \
|
||||
char buf[20]; \
|
||||
size_t size; \
|
||||
int val; \
|
||||
struct ieee80211_sub_if_data *sdata = file->private_data; \
|
||||
\
|
||||
size = min(sizeof(buf) - 1, count); \
|
||||
buf[size] = '\0'; \
|
||||
if (copy_from_user(buf, userbuf, size)) \
|
||||
return -EFAULT; \
|
||||
\
|
||||
val = simple_strtoul(buf, NULL, 0); \
|
||||
if ((val < min_val) || (val > max_val)) { \
|
||||
printk(KERN_ERR "%s: set value (%u) out of range " \
|
||||
"[%u, %u]\n",sdata->dev->name,val,min_val,max_val);\
|
||||
return -EINVAL; \
|
||||
} \
|
||||
IEEE80211_SET_TSINFO_ ##_name (sdata->u.sta.tspec.ts_info, val);\
|
||||
return count; \
|
||||
} \
|
||||
\
|
||||
static const struct file_operations tsinfo_ ##_name## _ops = { \
|
||||
.read = tsinfo_ ##_name## _read, \
|
||||
.write = tsinfo_ ##_name## _write, \
|
||||
.open = mac80211_open_file_generic, \
|
||||
};
|
||||
|
||||
#define DEBUGFS_TSINFO_ADD_TSID \
|
||||
sdata->debugfs.sta.tsinfo.tsid = \
|
||||
debugfs_create_file("tsid", 0444, tsinfod, \
|
||||
sdata, &tsinfo_TSID_ops);
|
||||
|
||||
#define DEBUGFS_TSINFO_ADD_DIR \
|
||||
sdata->debugfs.sta.tsinfo.direction = \
|
||||
debugfs_create_file("direction", 0444, tsinfod, \
|
||||
sdata, &tsinfo_DIR_ops);
|
||||
|
||||
#define DEBUGFS_TSINFO_ADD_UP \
|
||||
sdata->debugfs.sta.tsinfo.up = \
|
||||
debugfs_create_file("up", 0444, tsinfod, \
|
||||
sdata, &tsinfo_UP_ops);
|
||||
|
||||
#define DEBUGFS_TSINFO_DEL(name) \
|
||||
do { \
|
||||
debugfs_remove(sdata->debugfs.sta.tsinfo.name); \
|
||||
sdata->debugfs.sta.tsinfo.name = NULL; \
|
||||
} while (0)
|
||||
|
||||
DEBUGFS_TSINFO_FILE(TSID, 8, 15);
|
||||
DEBUGFS_TSINFO_FILE(DIR, 0, 3);
|
||||
DEBUGFS_TSINFO_FILE(UP, 0, 7);
|
||||
|
||||
#define DEBUGFS_TSPEC_FILE(name, format_string, endian_f1, endian_f2) \
|
||||
static ssize_t tspec_ ##name## _read(struct file *file, \
|
||||
char __user *userbuf, \
|
||||
size_t count, loff_t *ppos) \
|
||||
{ \
|
||||
char buf[20]; \
|
||||
struct ieee80211_sub_if_data *sdata = file->private_data; \
|
||||
int res = scnprintf(buf, count, format_string "\n", \
|
||||
endian_f1(sdata->u.sta.tspec.name)); \
|
||||
return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
|
||||
} \
|
||||
\
|
||||
static ssize_t tspec_ ##name## _write(struct file *file, \
|
||||
const char __user *userbuf, \
|
||||
size_t count, loff_t *ppos) \
|
||||
{ \
|
||||
char buf[20]; \
|
||||
size_t size; \
|
||||
struct ieee80211_sub_if_data *sdata = file->private_data; \
|
||||
\
|
||||
size = min(sizeof(buf) - 1, count); \
|
||||
buf[size] = '\0'; \
|
||||
if (copy_from_user(buf, userbuf, size)) \
|
||||
return -EFAULT; \
|
||||
\
|
||||
sdata->u.sta.tspec.name = endian_f2(simple_strtoul(buf, NULL, 0));\
|
||||
return count; \
|
||||
} \
|
||||
\
|
||||
static const struct file_operations tspec_ ##name## _ops = { \
|
||||
.read = tspec_ ##name## _read, \
|
||||
.write = tspec_ ##name## _write, \
|
||||
.open = mac80211_open_file_generic, \
|
||||
};
|
||||
|
||||
#define DEBUGFS_TSPEC_ADD(name) \
|
||||
sdata->debugfs.sta.tspec.name = debugfs_create_file(#name, \
|
||||
0444, tspecd, sdata, &tspec_ ##name## _ops);
|
||||
|
||||
#define DEBUGFS_TSPEC_DEL(name) \
|
||||
do { \
|
||||
debugfs_remove(sdata->debugfs.sta.tspec.name); \
|
||||
sdata->debugfs.sta.tspec.name = NULL; \
|
||||
} while (0)
|
||||
|
||||
DEBUGFS_TSPEC_FILE(nominal_msdu_size, "%hu", le16_to_cpu, cpu_to_le16);
|
||||
DEBUGFS_TSPEC_FILE(max_msdu_size, "%hu", le16_to_cpu, cpu_to_le16);
|
||||
DEBUGFS_TSPEC_FILE(min_service_interval, "%u", le32_to_cpu, cpu_to_le32);
|
||||
DEBUGFS_TSPEC_FILE(max_service_interval, "%u", le32_to_cpu, cpu_to_le32);
|
||||
DEBUGFS_TSPEC_FILE(inactivity_interval, "%u", le32_to_cpu, cpu_to_le32);
|
||||
DEBUGFS_TSPEC_FILE(suspension_interval, "%u", le32_to_cpu, cpu_to_le32);
|
||||
DEBUGFS_TSPEC_FILE(service_start_time, "%u", le32_to_cpu, cpu_to_le32);
|
||||
DEBUGFS_TSPEC_FILE(min_data_rate, "%u", le32_to_cpu, cpu_to_le32);
|
||||
DEBUGFS_TSPEC_FILE(mean_data_rate, "%u", le32_to_cpu, cpu_to_le32);
|
||||
DEBUGFS_TSPEC_FILE(peak_data_rate, "%u", le32_to_cpu, cpu_to_le32);
|
||||
DEBUGFS_TSPEC_FILE(burst_size, "%u", le32_to_cpu, cpu_to_le32);
|
||||
DEBUGFS_TSPEC_FILE(delay_bound, "%u", le32_to_cpu, cpu_to_le32);
|
||||
DEBUGFS_TSPEC_FILE(min_phy_rate, "%u", le32_to_cpu, cpu_to_le32);
|
||||
DEBUGFS_TSPEC_FILE(surplus_band_allow, "%hu", le16_to_cpu, cpu_to_le16);
|
||||
DEBUGFS_TSPEC_FILE(medium_time, "%hu", le16_to_cpu, cpu_to_le16);
|
||||
|
||||
|
||||
/* common attributes */
|
||||
IEEE80211_IF_FILE(channel_use, channel_use, DEC);
|
||||
IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC);
|
||||
@ -373,13 +112,13 @@ static ssize_t ieee80211_if_fmt_flags(
|
||||
const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
|
||||
{
|
||||
return scnprintf(buf, buflen, "%s%s%s%s%s%s%s\n",
|
||||
sdata->u.sta.ssid_set ? "SSID\n" : "",
|
||||
sdata->u.sta.bssid_set ? "BSSID\n" : "",
|
||||
sdata->u.sta.prev_bssid_set ? "prev BSSID\n" : "",
|
||||
sdata->u.sta.authenticated ? "AUTH\n" : "",
|
||||
sdata->u.sta.associated ? "ASSOC\n" : "",
|
||||
sdata->u.sta.probereq_poll ? "PROBEREQ POLL\n" : "",
|
||||
sdata->u.sta.use_protection ? "CTS prot\n" : "");
|
||||
sdata->u.sta.flags & IEEE80211_STA_SSID_SET ? "SSID\n" : "",
|
||||
sdata->u.sta.flags & IEEE80211_STA_BSSID_SET ? "BSSID\n" : "",
|
||||
sdata->u.sta.flags & IEEE80211_STA_PREV_BSSID_SET ? "prev BSSID\n" : "",
|
||||
sdata->u.sta.flags & IEEE80211_STA_AUTHENTICATED ? "AUTH\n" : "",
|
||||
sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED ? "ASSOC\n" : "",
|
||||
sdata->u.sta.flags & IEEE80211_STA_PROBEREQ_POLL ? "PROBEREQ POLL\n" : "",
|
||||
sdata->flags & IEEE80211_SDATA_USE_PROTECTION ? "CTS prot\n" : "");
|
||||
}
|
||||
__IEEE80211_IF_FILE(flags);
|
||||
|
||||
@ -422,33 +161,12 @@ __IEEE80211_IF_FILE(beacon_tail_len);
|
||||
/* WDS attributes */
|
||||
IEEE80211_IF_FILE(peer, u.wds.remote_addr, MAC);
|
||||
|
||||
/* VLAN attributes */
|
||||
IEEE80211_IF_FILE(vlan_id, u.vlan.id, DEC);
|
||||
|
||||
/* MONITOR attributes */
|
||||
static ssize_t ieee80211_if_fmt_mode(
|
||||
const struct ieee80211_sub_if_data *sdata, char *buf, int buflen)
|
||||
{
|
||||
struct ieee80211_local *local = sdata->local;
|
||||
|
||||
return scnprintf(buf, buflen, "%s\n",
|
||||
((local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER) ||
|
||||
local->open_count == local->monitors) ?
|
||||
"hard" : "soft");
|
||||
}
|
||||
__IEEE80211_IF_FILE(mode);
|
||||
|
||||
|
||||
#define DEBUGFS_ADD(name, type)\
|
||||
sdata->debugfs.type.name = debugfs_create_file(#name, 0444,\
|
||||
sdata->debugfsdir, sdata, &name##_ops);
|
||||
|
||||
static void add_sta_files(struct ieee80211_sub_if_data *sdata)
|
||||
{
|
||||
struct dentry *qosd;
|
||||
struct dentry *tsinfod;
|
||||
struct dentry *tspecd;
|
||||
|
||||
DEBUGFS_ADD(channel_use, sta);
|
||||
DEBUGFS_ADD(drop_unencrypted, sta);
|
||||
DEBUGFS_ADD(eapol, sta);
|
||||
@ -467,42 +185,6 @@ static void add_sta_files(struct ieee80211_sub_if_data *sdata)
|
||||
DEBUGFS_ADD(auth_alg, sta);
|
||||
DEBUGFS_ADD(auth_transaction, sta);
|
||||
DEBUGFS_ADD(flags, sta);
|
||||
|
||||
qosd = debugfs_create_dir("qos", sdata->debugfsdir);
|
||||
sdata->debugfs.sta.qos_dir = qosd;
|
||||
|
||||
DEBUGFS_QOS_ADD(addts_11e);
|
||||
DEBUGFS_QOS_ADD(addts_wmm);
|
||||
DEBUGFS_QOS_ADD(delts_11e);
|
||||
DEBUGFS_QOS_ADD(delts_wmm);
|
||||
DEBUGFS_QOS_ADD(dls_mac);
|
||||
DEBUGFS_QOS_ADD(dls_op);
|
||||
|
||||
tsinfod = debugfs_create_dir("ts_info", qosd);
|
||||
sdata->debugfs.sta.tsinfo_dir = tsinfod;
|
||||
|
||||
DEBUGFS_TSINFO_ADD_TSID;
|
||||
DEBUGFS_TSINFO_ADD_DIR;
|
||||
DEBUGFS_TSINFO_ADD_UP;
|
||||
|
||||
tspecd = debugfs_create_dir("tspec", qosd);
|
||||
sdata->debugfs.sta.tspec_dir = tspecd;
|
||||
|
||||
DEBUGFS_TSPEC_ADD(nominal_msdu_size);
|
||||
DEBUGFS_TSPEC_ADD(max_msdu_size);
|
||||
DEBUGFS_TSPEC_ADD(min_service_interval);
|
||||
DEBUGFS_TSPEC_ADD(max_service_interval);
|
||||
DEBUGFS_TSPEC_ADD(inactivity_interval);
|
||||
DEBUGFS_TSPEC_ADD(suspension_interval);
|
||||
DEBUGFS_TSPEC_ADD(service_start_time);
|
||||
DEBUGFS_TSPEC_ADD(min_data_rate);
|
||||
DEBUGFS_TSPEC_ADD(mean_data_rate);
|
||||
DEBUGFS_TSPEC_ADD(peak_data_rate);
|
||||
DEBUGFS_TSPEC_ADD(burst_size);
|
||||
DEBUGFS_TSPEC_ADD(delay_bound);
|
||||
DEBUGFS_TSPEC_ADD(min_phy_rate);
|
||||
DEBUGFS_TSPEC_ADD(surplus_band_allow);
|
||||
DEBUGFS_TSPEC_ADD(medium_time);
|
||||
}
|
||||
|
||||
static void add_ap_files(struct ieee80211_sub_if_data *sdata)
|
||||
@ -537,12 +219,10 @@ static void add_vlan_files(struct ieee80211_sub_if_data *sdata)
|
||||
DEBUGFS_ADD(drop_unencrypted, vlan);
|
||||
DEBUGFS_ADD(eapol, vlan);
|
||||
DEBUGFS_ADD(ieee8021_x, vlan);
|
||||
DEBUGFS_ADD(vlan_id, vlan);
|
||||
}
|
||||
|
||||
static void add_monitor_files(struct ieee80211_sub_if_data *sdata)
|
||||
{
|
||||
DEBUGFS_ADD(mode, monitor);
|
||||
}
|
||||
|
||||
static void add_files(struct ieee80211_sub_if_data *sdata)
|
||||
@ -598,40 +278,6 @@ static void del_sta_files(struct ieee80211_sub_if_data *sdata)
|
||||
DEBUGFS_DEL(auth_alg, sta);
|
||||
DEBUGFS_DEL(auth_transaction, sta);
|
||||
DEBUGFS_DEL(flags, sta);
|
||||
|
||||
DEBUGFS_TSINFO_DEL(tsid);
|
||||
DEBUGFS_TSINFO_DEL(direction);
|
||||
DEBUGFS_TSINFO_DEL(up);
|
||||
|
||||
DEBUGFS_TSPEC_DEL(nominal_msdu_size);
|
||||
DEBUGFS_TSPEC_DEL(max_msdu_size);
|
||||
DEBUGFS_TSPEC_DEL(min_service_interval);
|
||||
DEBUGFS_TSPEC_DEL(max_service_interval);
|
||||
DEBUGFS_TSPEC_DEL(inactivity_interval);
|
||||
DEBUGFS_TSPEC_DEL(suspension_interval);
|
||||
DEBUGFS_TSPEC_DEL(service_start_time);
|
||||
DEBUGFS_TSPEC_DEL(min_data_rate);
|
||||
DEBUGFS_TSPEC_DEL(mean_data_rate);
|
||||
DEBUGFS_TSPEC_DEL(peak_data_rate);
|
||||
DEBUGFS_TSPEC_DEL(burst_size);
|
||||
DEBUGFS_TSPEC_DEL(delay_bound);
|
||||
DEBUGFS_TSPEC_DEL(min_phy_rate);
|
||||
DEBUGFS_TSPEC_DEL(surplus_band_allow);
|
||||
DEBUGFS_TSPEC_DEL(medium_time);
|
||||
|
||||
DEBUGFS_QOS_DEL(addts_11e);
|
||||
DEBUGFS_QOS_DEL(addts_wmm);
|
||||
DEBUGFS_QOS_DEL(delts_11e);
|
||||
DEBUGFS_QOS_DEL(delts_wmm);
|
||||
DEBUGFS_QOS_DEL(dls_mac);
|
||||
DEBUGFS_QOS_DEL(dls_op);
|
||||
|
||||
debugfs_remove(sdata->debugfs.sta.tspec_dir);
|
||||
sdata->debugfs.sta.tspec_dir = NULL;
|
||||
debugfs_remove(sdata->debugfs.sta.tsinfo_dir);
|
||||
sdata->debugfs.sta.tsinfo_dir = NULL;
|
||||
debugfs_remove(sdata->debugfs.sta.qos_dir);
|
||||
sdata->debugfs.sta.qos_dir = NULL;
|
||||
}
|
||||
|
||||
static void del_ap_files(struct ieee80211_sub_if_data *sdata)
|
||||
@ -666,12 +312,10 @@ static void del_vlan_files(struct ieee80211_sub_if_data *sdata)
|
||||
DEBUGFS_DEL(drop_unencrypted, vlan);
|
||||
DEBUGFS_DEL(eapol, vlan);
|
||||
DEBUGFS_DEL(ieee8021_x, vlan);
|
||||
DEBUGFS_DEL(vlan_id, vlan);
|
||||
}
|
||||
|
||||
static void del_monitor_files(struct ieee80211_sub_if_data *sdata)
|
||||
{
|
||||
DEBUGFS_DEL(mode, monitor);
|
||||
}
|
||||
|
||||
static void del_files(struct ieee80211_sub_if_data *sdata, int type)
|
||||
@ -734,9 +378,9 @@ static int netdev_notify(struct notifier_block * nb,
|
||||
void *ndev)
|
||||
{
|
||||
struct net_device *dev = ndev;
|
||||
/* TODO
|
||||
struct dentry *dir;
|
||||
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||
char buf[10+IFNAMSIZ];
|
||||
*/
|
||||
|
||||
if (state != NETDEV_CHANGENAME)
|
||||
return 0;
|
||||
@ -747,10 +391,11 @@ static int netdev_notify(struct notifier_block * nb,
|
||||
if (dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid)
|
||||
return 0;
|
||||
|
||||
/* TODO
|
||||
sprintf(buf, "netdev:%s", dev->name);
|
||||
debugfs_rename(IEEE80211_DEV_TO_SUB_IF(dev)->debugfsdir, buf);
|
||||
*/
|
||||
dir = sdata->debugfsdir;
|
||||
if (!debugfs_rename(dir->d_parent, dir, dir->d_parent, buf))
|
||||
printk(KERN_ERR "mac80211: debugfs: failed to rename debugfs "
|
||||
"dir to %s\n", buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -60,9 +60,7 @@ static const struct file_operations sta_ ##name## _ops = { \
|
||||
STA_OPS(name)
|
||||
|
||||
STA_FILE(aid, aid, D);
|
||||
STA_FILE(key_idx_compression, key_idx_compression, D);
|
||||
STA_FILE(dev, dev->name, S);
|
||||
STA_FILE(vlan_id, vlan_id, D);
|
||||
STA_FILE(rx_packets, rx_packets, LU);
|
||||
STA_FILE(tx_packets, tx_packets, LU);
|
||||
STA_FILE(rx_bytes, rx_bytes, LU);
|
||||
@ -87,7 +85,7 @@ static ssize_t sta_flags_read(struct file *file, char __user *userbuf,
|
||||
{
|
||||
char buf[100];
|
||||
struct sta_info *sta = file->private_data;
|
||||
int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s",
|
||||
int res = scnprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s",
|
||||
sta->flags & WLAN_STA_AUTH ? "AUTH\n" : "",
|
||||
sta->flags & WLAN_STA_ASSOC ? "ASSOC\n" : "",
|
||||
sta->flags & WLAN_STA_PS ? "PS\n" : "",
|
||||
@ -96,7 +94,6 @@ static ssize_t sta_flags_read(struct file *file, char __user *userbuf,
|
||||
sta->flags & WLAN_STA_AUTHORIZED ? "AUTHORIZED\n" : "",
|
||||
sta->flags & WLAN_STA_SHORT_PREAMBLE ? "SHORT PREAMBLE\n" : "",
|
||||
sta->flags & WLAN_STA_WME ? "WME\n" : "",
|
||||
sta->flags & WLAN_STA_HT ? "HT\n" : "",
|
||||
sta->flags & WLAN_STA_WDS ? "WDS\n" : "");
|
||||
return simple_read_from_buffer(userbuf, count, ppos, buf, res);
|
||||
}
|
||||
|
42
package/mac80211/src/mac80211/event.c
Normal file
42
package/mac80211/src/mac80211/event.c
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* mac80211 - events
|
||||
*/
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
#include <net/iw_handler.h>
|
||||
#include "ieee80211_i.h"
|
||||
|
||||
/*
|
||||
* indicate a failed Michael MIC to userspace; the passed packet
|
||||
* (in the variable hdr) must be long enough to extract the TKIP
|
||||
* fields like TSC
|
||||
*/
|
||||
void mac80211_ev_michael_mic_failure(struct net_device *dev, int keyidx,
|
||||
struct ieee80211_hdr *hdr)
|
||||
{
|
||||
union iwreq_data wrqu;
|
||||
char *buf = kmalloc(128, GFP_ATOMIC);
|
||||
|
||||
if (buf) {
|
||||
/* TODO: needed parameters: count, key type, TSC */
|
||||
sprintf(buf, "MLME-MICHAELMICFAILURE.indication("
|
||||
"keyid=%d %scast addr=" MAC_FMT ")",
|
||||
keyidx, hdr->addr1[0] & 0x01 ? "broad" : "uni",
|
||||
MAC_ARG(hdr->addr2));
|
||||
memset(&wrqu, 0, sizeof(wrqu));
|
||||
wrqu.data.length = strlen(buf);
|
||||
wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
|
||||
kfree(buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: re-add support for sending MIC failure indication
|
||||
* with all info via nl80211
|
||||
*/
|
||||
}
|
@ -1,344 +0,0 @@
|
||||
/*
|
||||
* Host AP (software wireless LAN access point) user space daemon for
|
||||
* Host AP kernel driver
|
||||
* Copyright 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
|
||||
* Copyright 2002-2004, Instant802 Networks, Inc.
|
||||
* Copyright 2005, Devicescape Software, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef HOSTAPD_IOCTL_H
|
||||
#define HOSTAPD_IOCTL_H
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/types.h>
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#define PRISM2_IOCTL_PRISM2_PARAM (SIOCIWFIRSTPRIV + 0)
|
||||
#define PRISM2_IOCTL_GET_PRISM2_PARAM (SIOCIWFIRSTPRIV + 1)
|
||||
#define PRISM2_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 3)
|
||||
|
||||
/* PRISM2_IOCTL_PRISM2_PARAM ioctl() subtypes:
|
||||
* This table is no longer added to, the whole sub-ioctl
|
||||
* mess shall be deleted completely. */
|
||||
enum {
|
||||
PRISM2_PARAM_BEACON_INT = 3,
|
||||
PRISM2_PARAM_AP_BRIDGE_PACKETS = 10,
|
||||
PRISM2_PARAM_DTIM_PERIOD = 11,
|
||||
PRISM2_PARAM_AP_AUTH_ALGS = 15,
|
||||
PRISM2_PARAM_HOST_ENCRYPT = 17,
|
||||
PRISM2_PARAM_HOST_DECRYPT = 18,
|
||||
PRISM2_PARAM_IEEE_802_1X = 23,
|
||||
PRISM2_PARAM_ANTSEL_TX = 24,
|
||||
PRISM2_PARAM_ANTSEL_RX = 25,
|
||||
|
||||
/* Instant802 additions */
|
||||
PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES = 1001,
|
||||
PRISM2_PARAM_DROP_UNENCRYPTED = 1002,
|
||||
PRISM2_PARAM_PREAMBLE = 1003,
|
||||
PRISM2_PARAM_SHORT_SLOT_TIME = 1006,
|
||||
PRISM2_PARAM_NEXT_MODE = 1008,
|
||||
PRISM2_PARAM_CLEAR_KEYS = 1009,
|
||||
PRISM2_PARAM_RADIO_ENABLED = 1010,
|
||||
PRISM2_PARAM_ANTENNA_MODE = 1013,
|
||||
PRISM2_PARAM_PRIVACY_INVOKED = 1014,
|
||||
PRISM2_PARAM_BROADCAST_SSID = 1015,
|
||||
PRISM2_PARAM_STAT_TIME = 1016,
|
||||
PRISM2_PARAM_STA_ANTENNA_SEL = 1017,
|
||||
PRISM2_PARAM_FORCE_UNICAST_RATE = 1018,
|
||||
PRISM2_PARAM_RATE_CTRL_NUM_UP = 1019,
|
||||
PRISM2_PARAM_RATE_CTRL_NUM_DOWN = 1020,
|
||||
PRISM2_PARAM_MAX_RATECTRL_RATE = 1021,
|
||||
PRISM2_PARAM_TX_POWER_REDUCTION = 1022,
|
||||
PRISM2_PARAM_EAPOL = 1023,
|
||||
PRISM2_PARAM_KEY_TX_RX_THRESHOLD = 1024,
|
||||
PRISM2_PARAM_KEY_INDEX = 1025,
|
||||
PRISM2_PARAM_DEFAULT_WEP_ONLY = 1026,
|
||||
PRISM2_PARAM_WIFI_WME_NOACK_TEST = 1033,
|
||||
PRISM2_PARAM_ALLOW_BROADCAST_ALWAYS = 1034,
|
||||
PRISM2_PARAM_SCAN_FLAGS = 1035,
|
||||
PRISM2_PARAM_HW_MODES = 1036,
|
||||
PRISM2_PARAM_CREATE_IBSS = 1037,
|
||||
PRISM2_PARAM_WMM_ENABLED = 1038,
|
||||
PRISM2_PARAM_MIXED_CELL = 1039,
|
||||
PRISM2_PARAM_KEY_MGMT = 1040,
|
||||
PRISM2_PARAM_RADAR_DETECT = 1043,
|
||||
PRISM2_PARAM_SPECTRUM_MGMT = 1044,
|
||||
PRISM2_PARAM_USER_SPACE_MLME = 1045,
|
||||
PRISM2_PARAM_MGMT_IF = 1046,
|
||||
};
|
||||
|
||||
/* PRISM2_IOCTL_HOSTAPD ioctl() cmd:
|
||||
* This table is no longer added to, the hostapd ioctl
|
||||
* shall be deleted completely. */
|
||||
enum {
|
||||
PRISM2_HOSTAPD_FLUSH = 1,
|
||||
PRISM2_HOSTAPD_ADD_STA = 2,
|
||||
PRISM2_HOSTAPD_REMOVE_STA = 3,
|
||||
PRISM2_HOSTAPD_GET_INFO_STA = 4,
|
||||
PRISM2_SET_ENCRYPTION = 6,
|
||||
PRISM2_GET_ENCRYPTION = 7,
|
||||
PRISM2_HOSTAPD_SET_FLAGS_STA = 8,
|
||||
PRISM2_HOSTAPD_MLME = 13,
|
||||
|
||||
/* Instant802 additions */
|
||||
PRISM2_HOSTAPD_SET_BEACON = 1001,
|
||||
PRISM2_HOSTAPD_GET_HW_FEATURES = 1002,
|
||||
PRISM2_HOSTAPD_WPA_TRIGGER = 1004,
|
||||
PRISM2_HOSTAPD_SET_RATE_SETS = 1005,
|
||||
PRISM2_HOSTAPD_ADD_IF = 1006,
|
||||
PRISM2_HOSTAPD_REMOVE_IF = 1007,
|
||||
PRISM2_HOSTAPD_GET_DOT11COUNTERSTABLE = 1008,
|
||||
PRISM2_HOSTAPD_GET_LOAD_STATS = 1009,
|
||||
PRISM2_HOSTAPD_SET_STA_VLAN = 1010,
|
||||
PRISM2_HOSTAPD_SET_GENERIC_INFO_ELEM = 1011,
|
||||
PRISM2_HOSTAPD_SET_CHANNEL_FLAG = 1012,
|
||||
PRISM2_HOSTAPD_SET_REGULATORY_DOMAIN = 1013,
|
||||
PRISM2_HOSTAPD_SET_TX_QUEUE_PARAMS = 1014,
|
||||
PRISM2_HOSTAPD_GET_TX_STATS = 1016,
|
||||
PRISM2_HOSTAPD_UPDATE_IF = 1017,
|
||||
PRISM2_HOSTAPD_SCAN_REQ = 1019,
|
||||
PRISM2_STA_GET_STATE = 1020,
|
||||
PRISM2_HOSTAPD_FLUSH_IFS = 1021,
|
||||
PRISM2_HOSTAPD_SET_RADAR_PARAMS = 1023,
|
||||
PRISM2_HOSTAPD_SET_QUIET_PARAMS = 1024,
|
||||
};
|
||||
|
||||
#define PRISM2_HOSTAPD_MAX_BUF_SIZE 2048
|
||||
#define HOSTAP_CRYPT_ALG_NAME_LEN 16
|
||||
|
||||
#ifndef ALIGNED
|
||||
#define ALIGNED __attribute__ ((aligned))
|
||||
#endif
|
||||
|
||||
struct prism2_hostapd_param {
|
||||
u32 cmd;
|
||||
u8 sta_addr[ETH_ALEN];
|
||||
u8 pad[2];
|
||||
union {
|
||||
struct {
|
||||
u16 aid;
|
||||
u16 capability;
|
||||
u8 supp_rates[32];
|
||||
u8 wds_flags;
|
||||
#define IEEE80211_STA_DYNAMIC_ENC BIT(0)
|
||||
u8 enc_flags;
|
||||
u16 listen_interval;
|
||||
} add_sta;
|
||||
struct {
|
||||
u32 inactive_msec;
|
||||
u32 rx_packets;
|
||||
u32 tx_packets;
|
||||
u32 rx_bytes;
|
||||
u32 tx_bytes;
|
||||
u32 current_tx_rate; /* in 100 kbps */
|
||||
u32 channel_use;
|
||||
u32 flags;
|
||||
u32 num_ps_buf_frames;
|
||||
u32 tx_retry_failed;
|
||||
u32 tx_retry_count;
|
||||
u32 last_rssi;
|
||||
u32 last_ack_rssi;
|
||||
} get_info_sta;
|
||||
struct {
|
||||
char alg[HOSTAP_CRYPT_ALG_NAME_LEN];
|
||||
u32 flags;
|
||||
u32 err;
|
||||
u8 idx;
|
||||
#define HOSTAP_SEQ_COUNTER_SIZE 8
|
||||
u8 seq_counter[HOSTAP_SEQ_COUNTER_SIZE];
|
||||
u16 key_len;
|
||||
u8 key[0] ALIGNED;
|
||||
} crypt;
|
||||
struct {
|
||||
u32 flags_and;
|
||||
u32 flags_or;
|
||||
} set_flags_sta;
|
||||
struct {
|
||||
u16 head_len;
|
||||
u16 tail_len;
|
||||
u8 data[0] ALIGNED; /* head_len + tail_len bytes */
|
||||
} beacon;
|
||||
struct {
|
||||
u16 num_modes;
|
||||
u16 flags;
|
||||
u8 data[0] ALIGNED; /* num_modes * feature data */
|
||||
} hw_features;
|
||||
struct {
|
||||
u8 now;
|
||||
s8 our_mode_only;
|
||||
s16 last_rx;
|
||||
u16 channel;
|
||||
s16 interval; /* seconds */
|
||||
s32 listen; /* microseconds */
|
||||
} scan;
|
||||
struct {
|
||||
#define WPA_TRIGGER_FAIL_TX_MIC BIT(0)
|
||||
#define WPA_TRIGGER_FAIL_TX_ICV BIT(1)
|
||||
#define WPA_TRIGGER_FAIL_RX_MIC BIT(2)
|
||||
#define WPA_TRIGGER_FAIL_RX_ICV BIT(3)
|
||||
#define WPA_TRIGGER_TX_REPLAY BIT(4)
|
||||
#define WPA_TRIGGER_TX_REPLAY_FRAG BIT(5)
|
||||
#define WPA_TRIGGER_TX_SKIP_SEQ BIT(6)
|
||||
u32 trigger;
|
||||
} wpa_trigger;
|
||||
struct {
|
||||
u16 mode; /* MODE_* */
|
||||
u16 num_supported_rates;
|
||||
u16 num_basic_rates;
|
||||
u8 data[0] ALIGNED; /* num_supported_rates * u16 +
|
||||
* num_basic_rates * u16 */
|
||||
} set_rate_sets;
|
||||
struct {
|
||||
u8 type; /* WDS, VLAN, etc */
|
||||
u8 name[IFNAMSIZ];
|
||||
u8 data[0] ALIGNED;
|
||||
} if_info;
|
||||
struct dot11_counters {
|
||||
u32 dot11TransmittedFragmentCount;
|
||||
u32 dot11MulticastTransmittedFrameCount;
|
||||
u32 dot11FailedCount;
|
||||
u32 dot11ReceivedFragmentCount;
|
||||
u32 dot11MulticastReceivedFrameCount;
|
||||
u32 dot11FCSErrorCount;
|
||||
u32 dot11TransmittedFrameCount;
|
||||
u32 dot11WEPUndecryptableCount;
|
||||
u32 dot11ACKFailureCount;
|
||||
u32 dot11RTSFailureCount;
|
||||
u32 dot11RTSSuccessCount;
|
||||
} dot11CountersTable;
|
||||
struct {
|
||||
#define LOAD_STATS_CLEAR BIT(1)
|
||||
u32 flags;
|
||||
u32 channel_use;
|
||||
} get_load_stats;
|
||||
struct {
|
||||
char vlan_name[IFNAMSIZ];
|
||||
int vlan_id;
|
||||
} set_sta_vlan;
|
||||
struct {
|
||||
u8 len;
|
||||
u8 data[0] ALIGNED;
|
||||
} set_generic_info_elem;
|
||||
struct {
|
||||
u16 mode; /* MODE_* */
|
||||
u16 chan;
|
||||
u32 flag;
|
||||
u8 power_level; /* regulatory limit in dBm */
|
||||
u8 antenna_max;
|
||||
} set_channel_flag;
|
||||
struct {
|
||||
u32 rd;
|
||||
} set_regulatory_domain;
|
||||
struct {
|
||||
u32 queue;
|
||||
s32 aifs;
|
||||
u32 cw_min;
|
||||
u32 cw_max;
|
||||
u32 burst_time; /* maximum burst time in 0.1 ms, i.e.,
|
||||
* 10 = 1 ms */
|
||||
} tx_queue_params;
|
||||
struct ieee80211_tx_stats {
|
||||
struct {
|
||||
unsigned int len; /* num packets in queue */
|
||||
unsigned int limit; /* queue len (soft) limit
|
||||
*/
|
||||
unsigned int count; /* total num frames sent */
|
||||
} data[4];
|
||||
} get_tx_stats;
|
||||
struct {
|
||||
u8 ssid_len;
|
||||
u8 ssid[0] ALIGNED;
|
||||
} scan_req;
|
||||
struct {
|
||||
u32 state;
|
||||
} sta_get_state;
|
||||
struct {
|
||||
#define MLME_STA_DEAUTH 0
|
||||
#define MLME_STA_DISASSOC 1
|
||||
u16 cmd;
|
||||
u16 reason_code;
|
||||
} mlme;
|
||||
struct {
|
||||
u8 radar_firpwr_threshold;
|
||||
u8 radar_rssi_threshold;
|
||||
u8 pulse_height_threshold;
|
||||
u8 pulse_rssi_threshold;
|
||||
u8 pulse_inband_threshold;
|
||||
} radar;
|
||||
struct {
|
||||
unsigned int period;
|
||||
unsigned int offset;
|
||||
unsigned int duration;
|
||||
} quiet;
|
||||
struct {
|
||||
u8 dummy[80]; /* Make sizeof() this struct large enough
|
||||
* with some compiler versions. */
|
||||
} dummy;
|
||||
} u;
|
||||
};
|
||||
|
||||
#define HOSTAP_CRYPT_FLAG_SET_TX_KEY BIT(0)
|
||||
#define HOSTAP_CRYPT_FLAG_PERMANENT BIT(1)
|
||||
|
||||
#define HOSTAP_CRYPT_ERR_UNKNOWN_ALG 2
|
||||
#define HOSTAP_CRYPT_ERR_UNKNOWN_ADDR 3
|
||||
#define HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED 4
|
||||
#define HOSTAP_CRYPT_ERR_KEY_SET_FAILED 5
|
||||
#define HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED 6
|
||||
#define HOSTAP_CRYPT_ERR_CARD_CONF_FAILED 7
|
||||
|
||||
#define HOSTAP_HW_FLAG_NULLFUNC_OK BIT(0)
|
||||
|
||||
enum {
|
||||
IEEE80211_KEY_MGMT_NONE = 0,
|
||||
IEEE80211_KEY_MGMT_IEEE8021X = 1,
|
||||
IEEE80211_KEY_MGMT_WPA_PSK = 2,
|
||||
IEEE80211_KEY_MGMT_WPA_EAP = 3,
|
||||
};
|
||||
|
||||
|
||||
/* Data structures used for get_hw_features ioctl */
|
||||
struct hostapd_ioctl_hw_modes_hdr {
|
||||
int mode;
|
||||
int num_channels;
|
||||
int num_rates;
|
||||
};
|
||||
|
||||
struct ieee80211_channel_data {
|
||||
short chan; /* channel number (IEEE 802.11) */
|
||||
short freq; /* frequency in MHz */
|
||||
int flag; /* flag for hostapd use (IEEE80211_CHAN_*) */
|
||||
};
|
||||
|
||||
struct ieee80211_rate_data {
|
||||
int rate; /* rate in 100 kbps */
|
||||
int flags; /* IEEE80211_RATE_ flags */
|
||||
};
|
||||
|
||||
|
||||
/* ADD_IF, REMOVE_IF, and UPDATE_IF 'type' argument */
|
||||
enum {
|
||||
HOSTAP_IF_WDS = 1, HOSTAP_IF_VLAN = 2, HOSTAP_IF_BSS = 3,
|
||||
HOSTAP_IF_STA = 4
|
||||
};
|
||||
|
||||
struct hostapd_if_wds {
|
||||
u8 remote_addr[ETH_ALEN];
|
||||
};
|
||||
|
||||
struct hostapd_if_vlan {
|
||||
u8 id;
|
||||
};
|
||||
|
||||
struct hostapd_if_bss {
|
||||
u8 bssid[ETH_ALEN];
|
||||
};
|
||||
|
||||
struct hostapd_if_sta {
|
||||
};
|
||||
|
||||
#endif /* HOSTAPD_IOCTL_H */
|
File diff suppressed because it is too large
Load Diff
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* mac80211 configuration hooks for cfg80211
|
||||
*
|
||||
* Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
|
||||
*
|
||||
* This file is GPLv2 as found in COPYING.
|
||||
*/
|
||||
|
||||
#include <linux/nl80211.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <net/cfg80211.h>
|
||||
#include "ieee80211_i.h"
|
||||
#include "ieee80211_cfg.h"
|
||||
|
||||
static int ieee80211_add_iface(struct wiphy *wiphy, char *name,
|
||||
enum nl80211_iftype type)
|
||||
{
|
||||
struct ieee80211_local *local = wiphy_priv(wiphy);
|
||||
int itype;
|
||||
|
||||
if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED))
|
||||
return -ENODEV;
|
||||
|
||||
switch (type) {
|
||||
case NL80211_IFTYPE_UNSPECIFIED:
|
||||
itype = IEEE80211_IF_TYPE_STA;
|
||||
break;
|
||||
case NL80211_IFTYPE_ADHOC:
|
||||
itype = IEEE80211_IF_TYPE_IBSS;
|
||||
break;
|
||||
case NL80211_IFTYPE_STATION:
|
||||
itype = IEEE80211_IF_TYPE_STA;
|
||||
break;
|
||||
case NL80211_IFTYPE_AP:
|
||||
itype = IEEE80211_IF_TYPE_AP;
|
||||
break;
|
||||
case NL80211_IFTYPE_WDS:
|
||||
itype = IEEE80211_IF_TYPE_WDS;
|
||||
break;
|
||||
case NL80211_IFTYPE_MONITOR:
|
||||
itype = IEEE80211_IF_TYPE_MNTR;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return ieee80211_if_add(local->mdev, name, NULL, itype);
|
||||
}
|
||||
|
||||
static int ieee80211_del_iface(struct wiphy *wiphy, int ifindex)
|
||||
{
|
||||
struct ieee80211_local *local = wiphy_priv(wiphy);
|
||||
struct net_device *dev;
|
||||
char *name;
|
||||
|
||||
if (unlikely(local->reg_state != IEEE80211_DEV_REGISTERED))
|
||||
return -ENODEV;
|
||||
|
||||
dev = dev_get_by_index(ifindex);
|
||||
if (!dev)
|
||||
return 0;
|
||||
|
||||
name = dev->name;
|
||||
dev_put(dev);
|
||||
|
||||
return ieee80211_if_remove(local->mdev, name, -1);
|
||||
}
|
||||
|
||||
struct cfg80211_ops mac80211_config_ops = {
|
||||
.add_virtual_intf = ieee80211_add_iface,
|
||||
.del_virtual_intf = ieee80211_del_iface,
|
||||
};
|
@ -47,19 +47,14 @@ enum ieee80211_msg_type {
|
||||
ieee80211_msg_normal = 0,
|
||||
ieee80211_msg_tx_callback_ack = 1,
|
||||
ieee80211_msg_tx_callback_fail = 2,
|
||||
ieee80211_msg_passive_scan = 3,
|
||||
ieee80211_msg_wep_frame_unknown_key = 4,
|
||||
/* hole at 3, was ieee80211_msg_passive_scan but unused */
|
||||
/* hole at 4, was ieee80211_msg_wep_frame_unknown_key but now unused */
|
||||
ieee80211_msg_michael_mic_failure = 5,
|
||||
/* hole at 6, was monitor but never sent to userspace */
|
||||
ieee80211_msg_sta_not_assoc = 7,
|
||||
ieee80211_msg_set_aid_for_sta = 8 /* used by Intersil MVC driver */,
|
||||
ieee80211_msg_key_threshold_notification = 9,
|
||||
ieee80211_msg_radar = 11,
|
||||
};
|
||||
|
||||
struct ieee80211_msg_set_aid_for_sta {
|
||||
char sta_address[ETH_ALEN];
|
||||
u16 aid;
|
||||
/* 8 was ieee80211_msg_set_aid_for_sta */
|
||||
/* 9 was ieee80211_msg_key_threshold_notification */
|
||||
/* 11 was ieee80211_msg_radar */
|
||||
};
|
||||
|
||||
struct ieee80211_msg_key_notification {
|
||||
@ -78,8 +73,6 @@ enum ieee80211_phytype {
|
||||
ieee80211_phytype_ofdm_dot11_g = 6,
|
||||
ieee80211_phytype_pbcc_dot11_g = 7,
|
||||
ieee80211_phytype_ofdm_dot11_a = 8,
|
||||
ieee80211_phytype_dsss_dot11_turbog = 255,
|
||||
ieee80211_phytype_dsss_dot11_turbo = 256,
|
||||
};
|
||||
|
||||
enum ieee80211_ssi_type {
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <net/wireless.h>
|
||||
#include "ieee80211_key.h"
|
||||
#include "sta_info.h"
|
||||
@ -59,10 +60,6 @@ struct ieee80211_local;
|
||||
* increased memory use (about 2 kB of RAM per entry). */
|
||||
#define IEEE80211_FRAGMENT_MAX 4
|
||||
|
||||
/* Minimum and Maximum TSID used by EDCA. EDCA uses 0~7; HCCA uses 8~15 */
|
||||
#define EDCA_TSID_MIN 0
|
||||
#define EDCA_TSID_MAX 7
|
||||
|
||||
struct ieee80211_fragment_entry {
|
||||
unsigned long first_frag_time;
|
||||
unsigned int seq;
|
||||
@ -94,8 +91,6 @@ struct ieee80211_sta_bss {
|
||||
size_t rsn_ie_len;
|
||||
u8 *wmm_ie;
|
||||
size_t wmm_ie_len;
|
||||
u8 *ht_ie;
|
||||
size_t ht_ie_len;
|
||||
#define IEEE80211_MAX_SUPP_RATES 32
|
||||
u8 supp_rates[IEEE80211_MAX_SUPP_RATES];
|
||||
size_t supp_rates_len;
|
||||
@ -105,6 +100,12 @@ struct ieee80211_sta_bss {
|
||||
int probe_resp;
|
||||
unsigned long last_update;
|
||||
|
||||
/* during assocation, we save an ERP value from a probe response so
|
||||
* that we can feed ERP info to the driver when handling the
|
||||
* association completes. these fields probably won't be up-to-date
|
||||
* otherwise, you probably don't want to use them. */
|
||||
int has_erp_value;
|
||||
u8 erp_value;
|
||||
};
|
||||
|
||||
|
||||
@ -112,6 +113,16 @@ typedef enum {
|
||||
TXRX_CONTINUE, TXRX_DROP, TXRX_QUEUED
|
||||
} ieee80211_txrx_result;
|
||||
|
||||
/* flags used in struct ieee80211_txrx_data.flags */
|
||||
/* whether the MSDU was fragmented */
|
||||
#define IEEE80211_TXRXD_FRAGMENTED BIT(0)
|
||||
#define IEEE80211_TXRXD_TXUNICAST BIT(1)
|
||||
#define IEEE80211_TXRXD_TXPS_BUFFERED BIT(2)
|
||||
#define IEEE80211_TXRXD_TXPROBE_LAST_FRAG BIT(3)
|
||||
#define IEEE80211_TXRXD_RXIN_SCAN BIT(4)
|
||||
/* frame is destined to interface currently processed (incl. multicast frames) */
|
||||
#define IEEE80211_TXRXD_RXRA_MATCH BIT(5)
|
||||
#define IEEE80211_TXRXD_TX_INJECTED BIT(6)
|
||||
struct ieee80211_txrx_data {
|
||||
struct sk_buff *skb;
|
||||
struct net_device *dev;
|
||||
@ -120,14 +131,10 @@ struct ieee80211_txrx_data {
|
||||
struct sta_info *sta;
|
||||
u16 fc, ethertype;
|
||||
struct ieee80211_key *key;
|
||||
unsigned int fragmented:1; /* whether the MSDU was fragmented */
|
||||
unsigned int flags;
|
||||
union {
|
||||
struct {
|
||||
struct ieee80211_tx_control *control;
|
||||
unsigned int unicast:1;
|
||||
unsigned int ps_buffered:1;
|
||||
unsigned int short_preamble:1;
|
||||
unsigned int probe_last_frag:1;
|
||||
struct ieee80211_hw_mode *mode;
|
||||
struct ieee80211_rate *rate;
|
||||
/* use this rate (if set) for last fragment; rate can
|
||||
@ -135,7 +142,6 @@ struct ieee80211_txrx_data {
|
||||
* when using CTS protection with IEEE 802.11g. */
|
||||
struct ieee80211_rate *last_frag_rate;
|
||||
int last_frag_hwrate;
|
||||
int mgmt_interface;
|
||||
|
||||
/* Extra fragments (in addition to the first fragment
|
||||
* in skb) */
|
||||
@ -147,28 +153,22 @@ struct ieee80211_txrx_data {
|
||||
int sent_ps_buffered;
|
||||
int queue;
|
||||
int load;
|
||||
u16 qos_control;
|
||||
unsigned int in_scan:1;
|
||||
/* frame is destined to interface currently processed
|
||||
* (including multicast frames) */
|
||||
unsigned int ra_match:1;
|
||||
unsigned int is_agg_frame:1;
|
||||
u32 tkip_iv32;
|
||||
u16 tkip_iv16;
|
||||
} rx;
|
||||
} u;
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
int wpa_test;
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
};
|
||||
|
||||
/* flags used in struct ieee80211_tx_packet_data.flags */
|
||||
#define IEEE80211_TXPD_REQ_TX_STATUS BIT(0)
|
||||
#define IEEE80211_TXPD_DO_NOT_ENCRYPT BIT(1)
|
||||
#define IEEE80211_TXPD_REQUEUE BIT(2)
|
||||
/* Stored in sk_buff->cb */
|
||||
struct ieee80211_tx_packet_data {
|
||||
int ifindex;
|
||||
unsigned long jiffies;
|
||||
unsigned int req_tx_status:1;
|
||||
unsigned int do_not_encrypt:1;
|
||||
unsigned int requeue:1;
|
||||
unsigned int mgmt_iface:1;
|
||||
unsigned int queue:4;
|
||||
unsigned int flags;
|
||||
u8 queue;
|
||||
};
|
||||
|
||||
struct ieee80211_tx_stored_packet {
|
||||
@ -179,20 +179,7 @@ struct ieee80211_tx_stored_packet {
|
||||
int last_frag_rateidx;
|
||||
int last_frag_hwrate;
|
||||
struct ieee80211_rate *last_frag_rate;
|
||||
unsigned int last_frag_rate_ctrl_probe:1;
|
||||
};
|
||||
|
||||
struct sta_ts_data {
|
||||
enum {
|
||||
TS_STATUS_UNUSED = 0,
|
||||
TS_STATUS_ACTIVE = 1,
|
||||
TS_STATUS_INACTIVE = 2,
|
||||
TS_STATUS_THROTTLING = 3,
|
||||
} status;
|
||||
u8 dialog_token;
|
||||
u8 up;
|
||||
u32 admitted_time_usec;
|
||||
u32 used_time_usec;
|
||||
unsigned int last_frag_rate_ctrl_probe;
|
||||
};
|
||||
|
||||
typedef ieee80211_txrx_result (*ieee80211_tx_handler)
|
||||
@ -205,10 +192,10 @@ struct ieee80211_if_ap {
|
||||
u8 *beacon_head, *beacon_tail;
|
||||
int beacon_head_len, beacon_tail_len;
|
||||
|
||||
struct list_head vlans;
|
||||
|
||||
u8 ssid[IEEE80211_MAX_SSID_LEN];
|
||||
size_t ssid_len;
|
||||
u8 *generic_elem;
|
||||
size_t generic_elem_len;
|
||||
|
||||
/* yes, this looks ugly, but guarantees that we can later use
|
||||
* bitmap_empty :)
|
||||
@ -228,9 +215,23 @@ struct ieee80211_if_wds {
|
||||
};
|
||||
|
||||
struct ieee80211_if_vlan {
|
||||
u8 id;
|
||||
struct ieee80211_sub_if_data *ap;
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
/* flags used in struct ieee80211_if_sta.flags */
|
||||
#define IEEE80211_STA_SSID_SET BIT(0)
|
||||
#define IEEE80211_STA_BSSID_SET BIT(1)
|
||||
#define IEEE80211_STA_PREV_BSSID_SET BIT(2)
|
||||
#define IEEE80211_STA_AUTHENTICATED BIT(3)
|
||||
#define IEEE80211_STA_ASSOCIATED BIT(4)
|
||||
#define IEEE80211_STA_PROBEREQ_POLL BIT(5)
|
||||
#define IEEE80211_STA_CREATE_IBSS BIT(6)
|
||||
#define IEEE80211_STA_MIXED_CELL BIT(7)
|
||||
#define IEEE80211_STA_WMM_ENABLED BIT(8)
|
||||
#define IEEE80211_STA_AUTO_SSID_SEL BIT(10)
|
||||
#define IEEE80211_STA_AUTO_BSSID_SEL BIT(11)
|
||||
#define IEEE80211_STA_AUTO_CHANNEL_SEL BIT(12)
|
||||
struct ieee80211_if_sta {
|
||||
enum {
|
||||
IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
|
||||
@ -239,7 +240,6 @@ struct ieee80211_if_sta {
|
||||
} state;
|
||||
struct timer_list timer;
|
||||
struct work_struct work;
|
||||
struct timer_list admit_timer; /* Recompute EDCA admitted time */
|
||||
u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN];
|
||||
u8 ssid[IEEE80211_MAX_SSID_LEN];
|
||||
size_t ssid_len;
|
||||
@ -254,27 +254,14 @@ struct ieee80211_if_sta {
|
||||
|
||||
int auth_tries, assoc_tries;
|
||||
|
||||
unsigned int ssid_set:1;
|
||||
unsigned int bssid_set:1;
|
||||
unsigned int prev_bssid_set:1;
|
||||
unsigned int authenticated:1;
|
||||
unsigned int associated:1;
|
||||
unsigned int probereq_poll:1;
|
||||
unsigned int use_protection:1;
|
||||
unsigned int create_ibss:1;
|
||||
unsigned int mixed_cell:1;
|
||||
unsigned int wmm_enabled:1;
|
||||
unsigned int ht_enabled:1;
|
||||
unsigned int auto_ssid_sel:1;
|
||||
unsigned int auto_bssid_sel:1;
|
||||
unsigned int auto_channel_sel:1;
|
||||
unsigned int flags;
|
||||
#define IEEE80211_STA_REQ_SCAN 0
|
||||
#define IEEE80211_STA_REQ_AUTH 1
|
||||
#define IEEE80211_STA_REQ_RUN 2
|
||||
unsigned long request;
|
||||
struct sk_buff_head skb_queue;
|
||||
|
||||
int key_mgmt;
|
||||
int key_management_enabled;
|
||||
unsigned long last_probe;
|
||||
|
||||
#define IEEE80211_AUTH_ALG_OPEN BIT(0)
|
||||
@ -289,34 +276,32 @@ struct ieee80211_if_sta {
|
||||
u32 supp_rates_bits;
|
||||
|
||||
int wmm_last_param_set;
|
||||
|
||||
u32 dot11EDCAAveragingPeriod;
|
||||
u32 MPDUExchangeTime;
|
||||
#define STA_TSID_NUM 16
|
||||
#define STA_TSDIR_NUM 2
|
||||
/* EDCA: 0~7, HCCA: 8~15 */
|
||||
struct sta_ts_data ts_data[STA_TSID_NUM][STA_TSDIR_NUM];
|
||||
#ifdef CONFIG_MAC80211_DEBUGFS
|
||||
struct ieee80211_elem_tspec tspec;
|
||||
u8 dls_mac[ETH_ALEN];
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
/* flags used in struct ieee80211_sub_if_data.flags */
|
||||
#define IEEE80211_SDATA_ALLMULTI BIT(0)
|
||||
#define IEEE80211_SDATA_PROMISC BIT(1)
|
||||
#define IEEE80211_SDATA_USE_PROTECTION BIT(2) /* CTS protect ERP frames */
|
||||
/* use short preamble with IEEE 802.11b: this flag is set when the AP or beacon
|
||||
* generator reports that there are no present stations that cannot support short
|
||||
* preambles */
|
||||
#define IEEE80211_SDATA_SHORT_PREAMBLE BIT(3)
|
||||
#define IEEE80211_SDATA_USERSPACE_MLME BIT(4)
|
||||
struct ieee80211_sub_if_data {
|
||||
struct list_head list;
|
||||
unsigned int type;
|
||||
enum ieee80211_if_types type;
|
||||
|
||||
struct wireless_dev wdev;
|
||||
|
||||
/* keys */
|
||||
struct list_head key_list;
|
||||
|
||||
struct net_device *dev;
|
||||
struct ieee80211_local *local;
|
||||
|
||||
int mc_count;
|
||||
unsigned int allmulti:1;
|
||||
unsigned int promisc:1;
|
||||
unsigned int flags;
|
||||
|
||||
struct net_device_stats stats;
|
||||
int drop_unencrypted;
|
||||
int eapol; /* 0 = process EAPOL frames as normal data frames,
|
||||
* 1 = send EAPOL frames through wlan#ap to hostapd
|
||||
@ -367,39 +352,6 @@ struct ieee80211_sub_if_data {
|
||||
struct dentry *auth_alg;
|
||||
struct dentry *auth_transaction;
|
||||
struct dentry *flags;
|
||||
struct dentry *qos_dir;
|
||||
struct {
|
||||
struct dentry *addts_11e;
|
||||
struct dentry *addts_wmm;
|
||||
struct dentry *delts_11e;
|
||||
struct dentry *delts_wmm;
|
||||
struct dentry *dls_mac;
|
||||
struct dentry *dls_op;
|
||||
} qos;
|
||||
struct dentry *tsinfo_dir;
|
||||
struct {
|
||||
struct dentry *tsid;
|
||||
struct dentry *direction;
|
||||
struct dentry *up;
|
||||
} tsinfo;
|
||||
struct dentry *tspec_dir;
|
||||
struct {
|
||||
struct dentry *nominal_msdu_size;
|
||||
struct dentry *max_msdu_size;
|
||||
struct dentry *min_service_interval;
|
||||
struct dentry *max_service_interval;
|
||||
struct dentry *inactivity_interval;
|
||||
struct dentry *suspension_interval;
|
||||
struct dentry *service_start_time;
|
||||
struct dentry *min_data_rate;
|
||||
struct dentry *mean_data_rate;
|
||||
struct dentry *peak_data_rate;
|
||||
struct dentry *burst_size;
|
||||
struct dentry *delay_bound;
|
||||
struct dentry *min_phy_rate;
|
||||
struct dentry *surplus_band_allow;
|
||||
struct dentry *medium_time;
|
||||
} tspec;
|
||||
} sta;
|
||||
struct {
|
||||
struct dentry *channel_use;
|
||||
@ -428,7 +380,6 @@ struct ieee80211_sub_if_data {
|
||||
struct dentry *drop_unencrypted;
|
||||
struct dentry *eapol;
|
||||
struct dentry *ieee8021_x;
|
||||
struct dentry *vlan_id;
|
||||
} vlan;
|
||||
struct {
|
||||
struct dentry *mode;
|
||||
@ -457,11 +408,12 @@ struct ieee80211_local {
|
||||
struct list_head modes_list;
|
||||
|
||||
struct net_device *mdev; /* wmaster# - "master" 802.11 device */
|
||||
struct net_device *apdev; /* wlan#ap - management frames (hostapd) */
|
||||
int open_count;
|
||||
int monitors;
|
||||
unsigned int filter_flags; /* FIF_* */
|
||||
struct iw_statistics wstats;
|
||||
u8 wstats_flags;
|
||||
int tx_headroom; /* required headroom for hardware/radiotap */
|
||||
|
||||
enum {
|
||||
IEEE80211_DEV_UNINITIALIZED = 0,
|
||||
@ -479,10 +431,9 @@ struct ieee80211_local {
|
||||
struct sk_buff_head skb_queue_unreliable;
|
||||
|
||||
/* Station data structures */
|
||||
spinlock_t sta_lock; /* mutex for STA data structures */
|
||||
rwlock_t sta_lock; /* protects STA data structures */
|
||||
int num_sta; /* number of stations in sta_list */
|
||||
struct list_head sta_list;
|
||||
struct list_head deleted_sta_list;
|
||||
struct sta_info *sta_hash[STA_HASH_SIZE];
|
||||
struct timer_list sta_cleanup;
|
||||
|
||||
@ -490,35 +441,24 @@ struct ieee80211_local {
|
||||
struct ieee80211_tx_stored_packet pending_packet[NUM_TX_DATA_QUEUES];
|
||||
struct tasklet_struct tx_pending_tasklet;
|
||||
|
||||
int mc_count; /* total count of multicast entries in all interfaces */
|
||||
int iff_allmultis, iff_promiscs;
|
||||
/* number of interfaces with corresponding IFF_ flags */
|
||||
/* number of interfaces with corresponding IFF_ flags */
|
||||
atomic_t iff_allmultis, iff_promiscs;
|
||||
|
||||
struct rate_control_ref *rate_ctrl;
|
||||
|
||||
int next_mode; /* MODE_IEEE80211*
|
||||
* The mode preference for next channel change. This is
|
||||
* used to select .11g vs. .11b channels (or 4.9 GHz vs.
|
||||
* .11a) when the channel number is not unique. */
|
||||
|
||||
/* Supported and basic rate filters for different modes. These are
|
||||
* pointers to -1 terminated lists and rates in 100 kbps units. */
|
||||
int *supp_rates[NUM_IEEE80211_MODES];
|
||||
int *basic_rates[NUM_IEEE80211_MODES];
|
||||
|
||||
int rts_threshold;
|
||||
int cts_protect_erp_frames;
|
||||
int fragmentation_threshold;
|
||||
int short_retry_limit; /* dot11ShortRetryLimit */
|
||||
int long_retry_limit; /* dot11LongRetryLimit */
|
||||
int short_preamble; /* use short preamble with IEEE 802.11b */
|
||||
|
||||
struct crypto_blkcipher *wep_tx_tfm;
|
||||
struct crypto_blkcipher *wep_rx_tfm;
|
||||
u32 wep_iv;
|
||||
int key_tx_rx_threshold; /* number of times any key can be used in TX
|
||||
* or RX before generating a rekey
|
||||
* notification; 0 = notification disabled. */
|
||||
|
||||
int bridge_packets; /* bridge packets between associated stations and
|
||||
* deliver multicast frames both back to wireless
|
||||
@ -528,9 +468,8 @@ struct ieee80211_local {
|
||||
ieee80211_rx_handler *rx_handlers;
|
||||
ieee80211_tx_handler *tx_handlers;
|
||||
|
||||
rwlock_t sub_if_lock; /* Protects sub_if_list. Cannot be taken under
|
||||
* sta_bss_lock or sta_lock. */
|
||||
struct list_head sub_if_list;
|
||||
struct list_head interfaces;
|
||||
|
||||
int sta_scanning;
|
||||
int scan_channel_idx;
|
||||
enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
|
||||
@ -549,9 +488,6 @@ struct ieee80211_local {
|
||||
#define IEEE80211_SCAN_EXTRA_INFO BIT(2)
|
||||
int scan_flags;
|
||||
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
u32 wpa_trigger;
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
/* SNMP counters */
|
||||
/* dot11CountersTable */
|
||||
u32 dot11TransmittedFragmentCount;
|
||||
@ -567,27 +503,17 @@ struct ieee80211_local {
|
||||
|
||||
#ifdef CONFIG_MAC80211_LEDS
|
||||
int tx_led_counter, rx_led_counter;
|
||||
struct led_trigger *tx_led, *rx_led;
|
||||
char tx_led_name[32], rx_led_name[32];
|
||||
struct led_trigger *tx_led, *rx_led, *assoc_led;
|
||||
char tx_led_name[32], rx_led_name[32], assoc_led_name[32];
|
||||
#endif
|
||||
|
||||
u32 channel_use;
|
||||
u32 channel_use_raw;
|
||||
u32 stat_time;
|
||||
struct timer_list stat_timer;
|
||||
|
||||
#ifdef CONFIG_MAC80211_DEBUGFS
|
||||
struct work_struct sta_debugfs_add;
|
||||
#endif
|
||||
|
||||
enum {
|
||||
STA_ANTENNA_SEL_AUTO = 0,
|
||||
STA_ANTENNA_SEL_SW_CTRL = 1,
|
||||
STA_ANTENNA_SEL_SW_CTRL_DEBUG = 2
|
||||
} sta_antenna_sel;
|
||||
|
||||
int rate_ctrl_num_up, rate_ctrl_num_down;
|
||||
|
||||
#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
|
||||
/* TX/RX handler statistics */
|
||||
unsigned int tx_handlers_drop;
|
||||
@ -617,16 +543,9 @@ struct ieee80211_local {
|
||||
#endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
|
||||
|
||||
|
||||
int default_wep_only; /* only default WEP keys are used with this
|
||||
* interface; this is used to decide when hwaccel
|
||||
* can be used with default keys */
|
||||
int total_ps_buffered; /* total number of all buffered unicast and
|
||||
* multicast packets for power saving stations
|
||||
*/
|
||||
int allow_broadcast_always; /* whether to allow TX of broadcast frames
|
||||
* even when there are no associated STAs
|
||||
*/
|
||||
|
||||
int wifi_wme_noack_test;
|
||||
unsigned int wmm_acm; /* bit field of ACM bits (BIT(802.1D tag)) */
|
||||
|
||||
@ -635,17 +554,13 @@ struct ieee80211_local {
|
||||
unsigned int hw_modes; /* bitfield of supported hardware modes;
|
||||
* (1 << MODE_*) */
|
||||
|
||||
int user_space_mlme;
|
||||
|
||||
#ifdef CONFIG_MAC80211_DEBUGFS
|
||||
struct local_debugfsdentries {
|
||||
struct dentry *channel;
|
||||
struct dentry *frequency;
|
||||
struct dentry *radar_detect;
|
||||
struct dentry *antenna_sel_tx;
|
||||
struct dentry *antenna_sel_rx;
|
||||
struct dentry *bridge_packets;
|
||||
struct dentry *key_tx_rx_threshold;
|
||||
struct dentry *rts_threshold;
|
||||
struct dentry *fragmentation_threshold;
|
||||
struct dentry *short_retry_limit;
|
||||
@ -653,8 +568,6 @@ struct ieee80211_local {
|
||||
struct dentry *total_ps_buffered;
|
||||
struct dentry *mode;
|
||||
struct dentry *wep_iv;
|
||||
struct dentry *rate_ctrl_alg;
|
||||
struct dentry *tx_power_reduction;
|
||||
struct dentry *modes;
|
||||
struct dentry *statistics;
|
||||
struct local_debugfsdentries_statsdentries {
|
||||
@ -703,11 +616,6 @@ struct ieee80211_local {
|
||||
#endif
|
||||
};
|
||||
|
||||
enum sta_link_direction {
|
||||
STA_TS_UPLINK = 0,
|
||||
STA_TS_DOWNLINK = 1,
|
||||
};
|
||||
|
||||
static inline struct ieee80211_local *hw_to_local(
|
||||
struct ieee80211_hw *hw)
|
||||
{
|
||||
@ -731,38 +639,38 @@ struct sta_attribute {
|
||||
ssize_t (*store)(struct sta_info *, const char *buf, size_t count);
|
||||
};
|
||||
|
||||
static inline void __bss_tim_set(struct ieee80211_if_ap *bss, int aid)
|
||||
static inline void __bss_tim_set(struct ieee80211_if_ap *bss, u16 aid)
|
||||
{
|
||||
/*
|
||||
* This format has ben mandated by the IEEE specifications,
|
||||
* This format has been mandated by the IEEE specifications,
|
||||
* so this line may not be changed to use the __set_bit() format.
|
||||
*/
|
||||
bss->tim[(aid)/8] |= 1<<((aid) % 8);
|
||||
bss->tim[aid / 8] |= (1 << (aid % 8));
|
||||
}
|
||||
|
||||
static inline void bss_tim_set(struct ieee80211_local *local,
|
||||
struct ieee80211_if_ap *bss, int aid)
|
||||
struct ieee80211_if_ap *bss, u16 aid)
|
||||
{
|
||||
spin_lock_bh(&local->sta_lock);
|
||||
read_lock_bh(&local->sta_lock);
|
||||
__bss_tim_set(bss, aid);
|
||||
spin_unlock_bh(&local->sta_lock);
|
||||
read_unlock_bh(&local->sta_lock);
|
||||
}
|
||||
|
||||
static inline void __bss_tim_clear(struct ieee80211_if_ap *bss, int aid)
|
||||
static inline void __bss_tim_clear(struct ieee80211_if_ap *bss, u16 aid)
|
||||
{
|
||||
/*
|
||||
* This format has ben mandated by the IEEE specifications,
|
||||
* This format has been mandated by the IEEE specifications,
|
||||
* so this line may not be changed to use the __clear_bit() format.
|
||||
*/
|
||||
bss->tim[(aid)/8] &= !(1<<((aid) % 8));
|
||||
bss->tim[aid / 8] &= ~(1 << (aid % 8));
|
||||
}
|
||||
|
||||
static inline void bss_tim_clear(struct ieee80211_local *local,
|
||||
struct ieee80211_if_ap *bss, int aid)
|
||||
struct ieee80211_if_ap *bss, u16 aid)
|
||||
{
|
||||
spin_lock_bh(&local->sta_lock);
|
||||
read_lock_bh(&local->sta_lock);
|
||||
__bss_tim_clear(bss, aid);
|
||||
spin_unlock_bh(&local->sta_lock);
|
||||
read_unlock_bh(&local->sta_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -782,38 +690,28 @@ static inline int ieee80211_is_erp_rate(int phymode, int rate)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
|
||||
{
|
||||
return compare_ether_addr(raddr, addr) == 0 ||
|
||||
is_broadcast_ether_addr(raddr);
|
||||
}
|
||||
|
||||
|
||||
/* ieee80211.c */
|
||||
int ieee80211_hw_config(struct ieee80211_local *local);
|
||||
int ieee80211_if_config(struct net_device *dev);
|
||||
int ieee80211_if_config_beacon(struct net_device *dev);
|
||||
struct ieee80211_key_conf *
|
||||
ieee80211_key_data2conf(struct ieee80211_local *local,
|
||||
const struct ieee80211_key *data);
|
||||
struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
|
||||
int idx, size_t key_len, gfp_t flags);
|
||||
void ieee80211_key_free(struct ieee80211_key *key);
|
||||
void ieee80211_rx_mgmt(struct ieee80211_local *local, struct sk_buff *skb,
|
||||
struct ieee80211_rx_status *status, u32 msg_type);
|
||||
void ieee80211_prepare_rates(struct ieee80211_local *local,
|
||||
struct ieee80211_hw_mode *mode);
|
||||
void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx);
|
||||
int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr);
|
||||
void ieee80211_if_setup(struct net_device *dev);
|
||||
void ieee80211_if_mgmt_setup(struct net_device *dev);
|
||||
int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
|
||||
const char *name);
|
||||
struct net_device_stats *ieee80211_dev_stats(struct net_device *dev);
|
||||
struct ieee80211_rate *ieee80211_get_rate(struct ieee80211_local *local,
|
||||
int phymode, int hwrate);
|
||||
|
||||
/* ieee80211_ioctl.c */
|
||||
int ieee80211_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
|
||||
extern const struct iw_handler_def ieee80211_iw_handler_def;
|
||||
|
||||
/* Set hw encryption from ieee80211 */
|
||||
int ieee80211_set_hw_encryption(struct net_device *dev,
|
||||
struct sta_info *sta, u8 addr[ETH_ALEN],
|
||||
struct ieee80211_key *key);
|
||||
void ieee80211_update_default_wep_only(struct ieee80211_local *local);
|
||||
|
||||
|
||||
/* Least common multiple of the used rates (in 100 kbps). This is used to
|
||||
* calculate rate_inv values for each rate so that only integers are needed. */
|
||||
@ -841,7 +739,6 @@ int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq);
|
||||
/* ieee80211_sta.c */
|
||||
void ieee80211_sta_timer(unsigned long data);
|
||||
void ieee80211_sta_work(struct work_struct *work);
|
||||
void ieee80211_admit_refresh(unsigned long ptr);
|
||||
void ieee80211_sta_scan_work(struct work_struct *work);
|
||||
void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb,
|
||||
struct ieee80211_rx_status *rx_status);
|
||||
@ -862,28 +759,8 @@ struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
|
||||
u8 *addr);
|
||||
int ieee80211_sta_deauthenticate(struct net_device *dev, u16 reason);
|
||||
int ieee80211_sta_disassociate(struct net_device *dev, u16 reason);
|
||||
void ieee80211_send_addts(struct net_device *dev,
|
||||
struct ieee80211_if_sta *ifsta,
|
||||
struct ieee80211_elem_tspec *tspec);
|
||||
void wmm_send_addts(struct net_device *dev,
|
||||
struct ieee80211_if_sta *ifsta,
|
||||
struct ieee80211_elem_tspec *tspec);
|
||||
void ieee80211_send_delts(struct net_device *dev,
|
||||
struct ieee80211_if_sta *ifsta,
|
||||
struct ieee80211_elem_tspec *tp);
|
||||
void wmm_send_delts(struct net_device *dev,
|
||||
struct ieee80211_if_sta *ifsta,
|
||||
struct ieee80211_elem_tspec *tp);
|
||||
void ieee80211_send_dls_req(struct net_device *dev,
|
||||
struct ieee80211_if_sta *ifsta,
|
||||
u8 *addr, u16 timeout);
|
||||
void ieee80211_send_dls_teardown(struct net_device *dev,
|
||||
struct ieee80211_if_sta *ifsta,
|
||||
u8 *mac, u16 reason);
|
||||
struct sta_info *dls_info_get(struct ieee80211_local *local, u8 *addr);
|
||||
void dls_info_add(struct ieee80211_if_sta *ifsta, struct sta_info *dls);
|
||||
void dls_info_stop(struct ieee80211_if_sta *ifsta);
|
||||
int dls_link_status(struct ieee80211_local *local, u8 *addr);
|
||||
void ieee80211_erp_info_change_notify(struct net_device *dev, u8 changes);
|
||||
void ieee80211_reset_erp_info(struct net_device *dev);
|
||||
|
||||
/* ieee80211_iface.c */
|
||||
int ieee80211_if_add(struct net_device *dev, const char *name,
|
||||
@ -895,14 +772,32 @@ void __ieee80211_if_del(struct ieee80211_local *local,
|
||||
int ieee80211_if_remove(struct net_device *dev, const char *name, int id);
|
||||
void ieee80211_if_free(struct net_device *dev);
|
||||
void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata);
|
||||
int ieee80211_if_add_mgmt(struct ieee80211_local *local);
|
||||
void ieee80211_if_del_mgmt(struct ieee80211_local *local);
|
||||
|
||||
/* regdomain.c */
|
||||
void ieee80211_regdomain_init(void);
|
||||
void ieee80211_set_default_regdomain(struct ieee80211_hw_mode *mode);
|
||||
|
||||
/* for wiphy privid */
|
||||
extern void *mac80211_wiphy_privid;
|
||||
/* rx handling */
|
||||
extern ieee80211_rx_handler ieee80211_rx_pre_handlers[];
|
||||
extern ieee80211_rx_handler ieee80211_rx_handlers[];
|
||||
|
||||
/* tx handling */
|
||||
extern ieee80211_tx_handler ieee80211_tx_handlers[];
|
||||
void ieee80211_clear_tx_pending(struct ieee80211_local *local);
|
||||
void ieee80211_tx_pending(unsigned long data);
|
||||
int ieee80211_master_start_xmit(struct sk_buff *skb, struct net_device *dev);
|
||||
int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
|
||||
int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
|
||||
|
||||
/* utility functions/constants */
|
||||
extern void *mac80211_wiphy_privid; /* for wiphy privid */
|
||||
extern const unsigned char rfc1042_header[6];
|
||||
extern const unsigned char bridge_tunnel_header[6];
|
||||
u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len);
|
||||
int ieee80211_is_eapol(const struct sk_buff *skb);
|
||||
int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
|
||||
int rate, int erp, int short_preamble);
|
||||
void mac80211_ev_michael_mic_failure(struct net_device *dev, int keyidx,
|
||||
struct ieee80211_hdr *hdr);
|
||||
|
||||
#endif /* IEEE80211_I_H */
|
||||
|
@ -25,6 +25,8 @@ void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata)
|
||||
sdata->eapol = 1;
|
||||
for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++)
|
||||
skb_queue_head_init(&sdata->fragments[i].skb_list);
|
||||
|
||||
INIT_LIST_HEAD(&sdata->key_list);
|
||||
}
|
||||
|
||||
static void ieee80211_if_sdata_deinit(struct ieee80211_sub_if_data *sdata)
|
||||
@ -77,18 +79,15 @@ int ieee80211_if_add(struct net_device *dev, const char *name,
|
||||
ieee80211_debugfs_add_netdev(sdata);
|
||||
ieee80211_if_set_type(ndev, type);
|
||||
|
||||
write_lock_bh(&local->sub_if_lock);
|
||||
/* we're under RTNL so all this is fine */
|
||||
if (unlikely(local->reg_state == IEEE80211_DEV_UNREGISTERED)) {
|
||||
write_unlock_bh(&local->sub_if_lock);
|
||||
__ieee80211_if_del(local, sdata);
|
||||
return -ENODEV;
|
||||
}
|
||||
list_add(&sdata->list, &local->sub_if_list);
|
||||
list_add_tail_rcu(&sdata->list, &local->interfaces);
|
||||
|
||||
if (new_dev)
|
||||
*new_dev = ndev;
|
||||
write_unlock_bh(&local->sub_if_lock);
|
||||
|
||||
ieee80211_update_default_wep_only(local);
|
||||
|
||||
return 0;
|
||||
|
||||
@ -97,72 +96,35 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ieee80211_if_add_mgmt(struct ieee80211_local *local)
|
||||
{
|
||||
struct net_device *ndev;
|
||||
struct ieee80211_sub_if_data *nsdata;
|
||||
int ret;
|
||||
|
||||
ASSERT_RTNL();
|
||||
|
||||
ndev = alloc_netdev(sizeof(struct ieee80211_sub_if_data), "wmgmt%d",
|
||||
ieee80211_if_mgmt_setup);
|
||||
if (!ndev)
|
||||
return -ENOMEM;
|
||||
ret = dev_alloc_name(ndev, ndev->name);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
memcpy(ndev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
|
||||
SET_NETDEV_DEV(ndev, wiphy_dev(local->hw.wiphy));
|
||||
|
||||
nsdata = IEEE80211_DEV_TO_SUB_IF(ndev);
|
||||
ndev->ieee80211_ptr = &nsdata->wdev;
|
||||
nsdata->wdev.wiphy = local->hw.wiphy;
|
||||
nsdata->type = IEEE80211_IF_TYPE_MGMT;
|
||||
nsdata->dev = ndev;
|
||||
nsdata->local = local;
|
||||
ieee80211_if_sdata_init(nsdata);
|
||||
|
||||
ret = register_netdevice(ndev);
|
||||
if (ret)
|
||||
goto fail;
|
||||
|
||||
ieee80211_debugfs_add_netdev(nsdata);
|
||||
|
||||
if (local->open_count > 0)
|
||||
dev_open(ndev);
|
||||
local->apdev = ndev;
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
free_netdev(ndev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ieee80211_if_del_mgmt(struct ieee80211_local *local)
|
||||
{
|
||||
struct net_device *apdev;
|
||||
|
||||
ASSERT_RTNL();
|
||||
apdev = local->apdev;
|
||||
ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(apdev));
|
||||
local->apdev = NULL;
|
||||
unregister_netdevice(apdev);
|
||||
}
|
||||
|
||||
void ieee80211_if_set_type(struct net_device *dev, int type)
|
||||
{
|
||||
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
|
||||
int oldtype = sdata->type;
|
||||
|
||||
/*
|
||||
* We need to call this function on the master interface
|
||||
* which already has a hard_start_xmit routine assigned
|
||||
* which must not be changed.
|
||||
*/
|
||||
if (dev != sdata->local->mdev)
|
||||
dev->hard_start_xmit = ieee80211_subif_start_xmit;
|
||||
|
||||
/*
|
||||
* Called even when register_netdevice fails, it would
|
||||
* oops if assigned before initialising the rest.
|
||||
*/
|
||||
dev->uninit = ieee80211_if_reinit;
|
||||
|
||||
/* most have no BSS pointer */
|
||||
sdata->bss = NULL;
|
||||
sdata->type = type;
|
||||
|
||||
switch (type) {
|
||||
case IEEE80211_IF_TYPE_WDS:
|
||||
sdata->bss = NULL;
|
||||
/* nothing special */
|
||||
break;
|
||||
case IEEE80211_IF_TYPE_VLAN:
|
||||
sdata->u.vlan.ap = NULL;
|
||||
break;
|
||||
case IEEE80211_IF_TYPE_AP:
|
||||
sdata->u.ap.dtim_period = 2;
|
||||
@ -170,6 +132,7 @@ void ieee80211_if_set_type(struct net_device *dev, int type)
|
||||
sdata->u.ap.max_ratectrl_rateidx = -1;
|
||||
skb_queue_head_init(&sdata->u.ap.ps_bc_buf);
|
||||
sdata->bss = &sdata->u.ap;
|
||||
INIT_LIST_HEAD(&sdata->u.ap.vlans);
|
||||
break;
|
||||
case IEEE80211_IF_TYPE_STA:
|
||||
case IEEE80211_IF_TYPE_IBSS: {
|
||||
@ -182,30 +145,13 @@ void ieee80211_if_set_type(struct net_device *dev, int type)
|
||||
(unsigned long) sdata);
|
||||
skb_queue_head_init(&ifsta->skb_queue);
|
||||
|
||||
init_timer(&ifsta->admit_timer);
|
||||
ifsta->admit_timer.data = (unsigned long) dev;
|
||||
ifsta->admit_timer.function = ieee80211_admit_refresh;
|
||||
|
||||
ifsta->capab = WLAN_CAPABILITY_ESS;
|
||||
ifsta->auth_algs = IEEE80211_AUTH_ALG_OPEN |
|
||||
IEEE80211_AUTH_ALG_SHARED_KEY;
|
||||
ifsta->create_ibss = 1;
|
||||
ifsta->wmm_enabled = 1;
|
||||
ifsta->ht_enabled = 1;
|
||||
ifsta->auto_channel_sel = 1;
|
||||
ifsta->auto_bssid_sel = 1;
|
||||
|
||||
/* Initialize non-AP QSTA QoS Params */
|
||||
ifsta->dot11EDCAAveragingPeriod = 5;
|
||||
ifsta->MPDUExchangeTime = 0;
|
||||
#ifdef CONFIG_MAC80211_DEBUGFS
|
||||
ifsta->tspec.nominal_msdu_size = cpu_to_le16(200),
|
||||
ifsta->tspec.inactivity_interval = cpu_to_le32(40),
|
||||
ifsta->tspec.mean_data_rate = cpu_to_le32(40000),
|
||||
ifsta->tspec.min_phy_rate = cpu_to_le32(6000000),
|
||||
ifsta->tspec.surplus_band_allow = cpu_to_le16(8192),
|
||||
ifsta->tspec.medium_time = cpu_to_le16(30),
|
||||
#endif
|
||||
ifsta->flags |= IEEE80211_STA_CREATE_IBSS |
|
||||
IEEE80211_STA_WMM_ENABLED |
|
||||
IEEE80211_STA_AUTO_BSSID_SEL |
|
||||
IEEE80211_STA_AUTO_CHANNEL_SEL;
|
||||
|
||||
msdata = IEEE80211_DEV_TO_SUB_IF(sdata->local->mdev);
|
||||
sdata->bss = &msdata->u.ap;
|
||||
@ -213,13 +159,13 @@ void ieee80211_if_set_type(struct net_device *dev, int type)
|
||||
}
|
||||
case IEEE80211_IF_TYPE_MNTR:
|
||||
dev->type = ARPHRD_IEEE80211_RADIOTAP;
|
||||
dev->hard_start_xmit = ieee80211_monitor_start_xmit;
|
||||
break;
|
||||
default:
|
||||
printk(KERN_WARNING "%s: %s: Unknown interface type 0x%x",
|
||||
dev->name, __FUNCTION__, type);
|
||||
}
|
||||
ieee80211_debugfs_change_if_type(sdata, oldtype);
|
||||
ieee80211_update_default_wep_only(local);
|
||||
}
|
||||
|
||||
/* Must be called with rtnl lock held. */
|
||||
@ -228,57 +174,46 @@ void ieee80211_if_reinit(struct net_device *dev)
|
||||
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
|
||||
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||
struct sta_info *sta;
|
||||
int i;
|
||||
struct sk_buff *skb;
|
||||
|
||||
ASSERT_RTNL();
|
||||
|
||||
ieee80211_free_keys(sdata);
|
||||
|
||||
ieee80211_if_sdata_deinit(sdata);
|
||||
for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
|
||||
if (!sdata->keys[i])
|
||||
continue;
|
||||
#if 0
|
||||
/* The interface is down at the moment, so there is not
|
||||
* really much point in disabling the keys at this point. */
|
||||
memset(addr, 0xff, ETH_ALEN);
|
||||
if (local->ops->set_key)
|
||||
local->ops->set_key(local_to_hw(local), DISABLE_KEY, addr,
|
||||
local->keys[i], 0);
|
||||
#endif
|
||||
ieee80211_key_free(sdata->keys[i]);
|
||||
sdata->keys[i] = NULL;
|
||||
}
|
||||
|
||||
switch (sdata->type) {
|
||||
case IEEE80211_IF_TYPE_INVALID:
|
||||
/* cannot happen */
|
||||
WARN_ON(1);
|
||||
break;
|
||||
case IEEE80211_IF_TYPE_AP: {
|
||||
/* Remove all virtual interfaces that use this BSS
|
||||
* as their sdata->bss */
|
||||
struct ieee80211_sub_if_data *tsdata, *n;
|
||||
LIST_HEAD(tmp_list);
|
||||
|
||||
write_lock_bh(&local->sub_if_lock);
|
||||
list_for_each_entry_safe(tsdata, n, &local->sub_if_list, list) {
|
||||
list_for_each_entry_safe(tsdata, n, &local->interfaces, list) {
|
||||
if (tsdata != sdata && tsdata->bss == &sdata->u.ap) {
|
||||
printk(KERN_DEBUG "%s: removing virtual "
|
||||
"interface %s because its BSS interface"
|
||||
" is being removed\n",
|
||||
sdata->dev->name, tsdata->dev->name);
|
||||
list_move_tail(&tsdata->list, &tmp_list);
|
||||
list_del_rcu(&tsdata->list);
|
||||
/*
|
||||
* We have lots of time and can afford
|
||||
* to sync for each interface
|
||||
*/
|
||||
synchronize_rcu();
|
||||
__ieee80211_if_del(local, tsdata);
|
||||
}
|
||||
}
|
||||
write_unlock_bh(&local->sub_if_lock);
|
||||
|
||||
list_for_each_entry_safe(tsdata, n, &tmp_list, list)
|
||||
__ieee80211_if_del(local, tsdata);
|
||||
|
||||
kfree(sdata->u.ap.beacon_head);
|
||||
kfree(sdata->u.ap.beacon_tail);
|
||||
kfree(sdata->u.ap.generic_elem);
|
||||
|
||||
if (dev != local->mdev) {
|
||||
struct sk_buff *skb;
|
||||
while ((skb = skb_dequeue(&sdata->u.ap.ps_bc_buf))) {
|
||||
local->total_ps_buffered--;
|
||||
dev_kfree_skb(skb);
|
||||
}
|
||||
while ((skb = skb_dequeue(&sdata->u.ap.ps_bc_buf))) {
|
||||
local->total_ps_buffered--;
|
||||
dev_kfree_skb(skb);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -286,8 +221,8 @@ void ieee80211_if_reinit(struct net_device *dev)
|
||||
case IEEE80211_IF_TYPE_WDS:
|
||||
sta = sta_info_get(local, sdata->u.wds.remote_addr);
|
||||
if (sta) {
|
||||
sta_info_free(sta);
|
||||
sta_info_put(sta);
|
||||
sta_info_free(sta, 0);
|
||||
} else {
|
||||
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
|
||||
printk(KERN_DEBUG "%s: Someone had deleted my STA "
|
||||
@ -312,6 +247,9 @@ void ieee80211_if_reinit(struct net_device *dev)
|
||||
case IEEE80211_IF_TYPE_MNTR:
|
||||
dev->type = ARPHRD_ETHER;
|
||||
break;
|
||||
case IEEE80211_IF_TYPE_VLAN:
|
||||
sdata->u.vlan.ap = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* remove all STAs that are bound to this virtual interface */
|
||||
@ -341,29 +279,23 @@ int ieee80211_if_remove(struct net_device *dev, const char *name, int id)
|
||||
|
||||
ASSERT_RTNL();
|
||||
|
||||
write_lock_bh(&local->sub_if_lock);
|
||||
list_for_each_entry_safe(sdata, n, &local->sub_if_list, list) {
|
||||
list_for_each_entry_safe(sdata, n, &local->interfaces, list) {
|
||||
if ((sdata->type == id || id == -1) &&
|
||||
strcmp(name, sdata->dev->name) == 0 &&
|
||||
sdata->dev != local->mdev) {
|
||||
list_del(&sdata->list);
|
||||
write_unlock_bh(&local->sub_if_lock);
|
||||
list_del_rcu(&sdata->list);
|
||||
synchronize_rcu();
|
||||
__ieee80211_if_del(local, sdata);
|
||||
ieee80211_update_default_wep_only(local);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
write_unlock_bh(&local->sub_if_lock);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
void ieee80211_if_free(struct net_device *dev)
|
||||
{
|
||||
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
|
||||
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||
|
||||
/* local->apdev must be NULL when freeing management interface */
|
||||
BUG_ON(dev == local->apdev);
|
||||
ieee80211_if_sdata_deinit(sdata);
|
||||
free_netdev(dev);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@
|
||||
#define IEEE80211_KEY_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/kref.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <net/mac80211.h>
|
||||
|
||||
@ -41,11 +41,21 @@
|
||||
|
||||
#define NUM_RX_DATA_QUEUES 17
|
||||
|
||||
struct ieee80211_key {
|
||||
struct kref kref;
|
||||
struct ieee80211_local;
|
||||
struct ieee80211_sub_if_data;
|
||||
struct sta_info;
|
||||
|
||||
#define KEY_FLAG_UPLOADED_TO_HARDWARE (1<<0)
|
||||
|
||||
struct ieee80211_key {
|
||||
struct ieee80211_local *local;
|
||||
struct ieee80211_sub_if_data *sdata;
|
||||
struct sta_info *sta;
|
||||
|
||||
struct list_head list;
|
||||
|
||||
unsigned int flags;
|
||||
|
||||
int hw_key_idx; /* filled and used by low-level driver */
|
||||
ieee80211_key_alg alg;
|
||||
union {
|
||||
struct {
|
||||
/* last used TSC */
|
||||
@ -73,22 +83,16 @@ struct ieee80211_key {
|
||||
u8 rx_crypto_buf[6 * AES_BLOCK_LEN];
|
||||
} ccmp;
|
||||
} u;
|
||||
int tx_rx_count; /* number of times this key has been used */
|
||||
int keylen;
|
||||
|
||||
/* if the low level driver can provide hardware acceleration it should
|
||||
* clear this flag */
|
||||
unsigned int force_sw_encrypt:1;
|
||||
unsigned int default_tx_key:1; /* This key is the new default TX key
|
||||
* (used only for broadcast keys). */
|
||||
s8 keyidx; /* WEP key index */
|
||||
/* number of times this key has been used */
|
||||
int tx_rx_count;
|
||||
|
||||
#ifdef CONFIG_MAC80211_DEBUGFS
|
||||
struct {
|
||||
struct dentry *stalink;
|
||||
struct dentry *dir;
|
||||
struct dentry *keylen;
|
||||
struct dentry *force_sw_encrypt;
|
||||
struct dentry *flags;
|
||||
struct dentry *keyidx;
|
||||
struct dentry *hw_key_idx;
|
||||
struct dentry *tx_rx_count;
|
||||
@ -97,10 +101,27 @@ struct ieee80211_key {
|
||||
struct dentry *rx_spec;
|
||||
struct dentry *replays;
|
||||
struct dentry *key;
|
||||
struct dentry *ifindex;
|
||||
} debugfs;
|
||||
#endif
|
||||
|
||||
u8 key[0];
|
||||
/*
|
||||
* key config, must be last because it contains key
|
||||
* material as variable length member
|
||||
*/
|
||||
struct ieee80211_key_conf conf;
|
||||
};
|
||||
|
||||
struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
|
||||
struct sta_info *sta,
|
||||
enum ieee80211_key_alg alg,
|
||||
int idx,
|
||||
size_t key_len,
|
||||
const u8 *key_data);
|
||||
void ieee80211_key_free(struct ieee80211_key *key);
|
||||
void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx);
|
||||
void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata);
|
||||
void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata);
|
||||
void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata);
|
||||
|
||||
#endif /* IEEE80211_KEY_H */
|
||||
|
@ -33,33 +33,58 @@ void ieee80211_led_tx(struct ieee80211_local *local, int q)
|
||||
led_trigger_event(local->tx_led, LED_FULL);
|
||||
}
|
||||
|
||||
void ieee80211_led_assoc(struct ieee80211_local *local, bool associated)
|
||||
{
|
||||
if (unlikely(!local->assoc_led))
|
||||
return;
|
||||
if (associated)
|
||||
led_trigger_event(local->assoc_led, LED_FULL);
|
||||
else
|
||||
led_trigger_event(local->assoc_led, LED_OFF);
|
||||
}
|
||||
|
||||
void ieee80211_led_init(struct ieee80211_local *local)
|
||||
{
|
||||
local->rx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
|
||||
if (!local->rx_led)
|
||||
return;
|
||||
snprintf(local->rx_led_name, sizeof(local->rx_led_name),
|
||||
"%srx", wiphy_name(local->hw.wiphy));
|
||||
local->rx_led->name = local->rx_led_name;
|
||||
if (led_trigger_register(local->rx_led)) {
|
||||
kfree(local->rx_led);
|
||||
local->rx_led = NULL;
|
||||
if (local->rx_led) {
|
||||
snprintf(local->rx_led_name, sizeof(local->rx_led_name),
|
||||
"%srx", wiphy_name(local->hw.wiphy));
|
||||
local->rx_led->name = local->rx_led_name;
|
||||
if (led_trigger_register(local->rx_led)) {
|
||||
kfree(local->rx_led);
|
||||
local->rx_led = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
local->tx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
|
||||
if (!local->tx_led)
|
||||
return;
|
||||
snprintf(local->tx_led_name, sizeof(local->tx_led_name),
|
||||
"%stx", wiphy_name(local->hw.wiphy));
|
||||
local->tx_led->name = local->tx_led_name;
|
||||
if (led_trigger_register(local->tx_led)) {
|
||||
kfree(local->tx_led);
|
||||
local->tx_led = NULL;
|
||||
if (local->tx_led) {
|
||||
snprintf(local->tx_led_name, sizeof(local->tx_led_name),
|
||||
"%stx", wiphy_name(local->hw.wiphy));
|
||||
local->tx_led->name = local->tx_led_name;
|
||||
if (led_trigger_register(local->tx_led)) {
|
||||
kfree(local->tx_led);
|
||||
local->tx_led = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
local->assoc_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
|
||||
if (local->assoc_led) {
|
||||
snprintf(local->assoc_led_name, sizeof(local->assoc_led_name),
|
||||
"%sassoc", wiphy_name(local->hw.wiphy));
|
||||
local->assoc_led->name = local->assoc_led_name;
|
||||
if (led_trigger_register(local->assoc_led)) {
|
||||
kfree(local->assoc_led);
|
||||
local->assoc_led = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ieee80211_led_exit(struct ieee80211_local *local)
|
||||
{
|
||||
if (local->assoc_led) {
|
||||
led_trigger_unregister(local->assoc_led);
|
||||
kfree(local->assoc_led);
|
||||
}
|
||||
if (local->tx_led) {
|
||||
led_trigger_unregister(local->tx_led);
|
||||
kfree(local->tx_led);
|
||||
@ -70,6 +95,16 @@ void ieee80211_led_exit(struct ieee80211_local *local)
|
||||
}
|
||||
}
|
||||
|
||||
char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw)
|
||||
{
|
||||
struct ieee80211_local *local = hw_to_local(hw);
|
||||
|
||||
if (local->assoc_led)
|
||||
return local->assoc_led_name;
|
||||
return NULL;
|
||||
}
|
||||
EXPORT_SYMBOL(__ieee80211_get_assoc_led_name);
|
||||
|
||||
char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw)
|
||||
{
|
||||
struct ieee80211_local *local = hw_to_local(hw);
|
||||
|
@ -14,6 +14,8 @@
|
||||
#ifdef CONFIG_MAC80211_LEDS
|
||||
extern void ieee80211_led_rx(struct ieee80211_local *local);
|
||||
extern void ieee80211_led_tx(struct ieee80211_local *local, int q);
|
||||
extern void ieee80211_led_assoc(struct ieee80211_local *local,
|
||||
bool associated);
|
||||
extern void ieee80211_led_init(struct ieee80211_local *local);
|
||||
extern void ieee80211_led_exit(struct ieee80211_local *local);
|
||||
#else
|
||||
@ -23,6 +25,10 @@ static inline void ieee80211_led_rx(struct ieee80211_local *local)
|
||||
static inline void ieee80211_led_tx(struct ieee80211_local *local, int q)
|
||||
{
|
||||
}
|
||||
static inline void ieee80211_led_assoc(struct ieee80211_local *local,
|
||||
bool associated)
|
||||
{
|
||||
}
|
||||
static inline void ieee80211_led_init(struct ieee80211_local *local)
|
||||
{
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include "ieee80211_rate.h"
|
||||
#include "ieee80211_i.h"
|
||||
|
||||
@ -24,11 +25,10 @@ int ieee80211_rate_control_register(struct rate_control_ops *ops)
|
||||
{
|
||||
struct rate_control_alg *alg;
|
||||
|
||||
alg = kmalloc(sizeof(*alg), GFP_KERNEL);
|
||||
alg = kzalloc(sizeof(*alg), GFP_KERNEL);
|
||||
if (alg == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(alg, 0, sizeof(*alg));
|
||||
alg->ops = ops;
|
||||
|
||||
mutex_lock(&rate_ctrl_mutex);
|
||||
@ -138,3 +138,43 @@ void rate_control_put(struct rate_control_ref *ref)
|
||||
{
|
||||
kref_put(&ref->kref, rate_control_release);
|
||||
}
|
||||
|
||||
int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
|
||||
const char *name)
|
||||
{
|
||||
struct rate_control_ref *ref, *old;
|
||||
|
||||
ASSERT_RTNL();
|
||||
if (local->open_count || netif_running(local->mdev))
|
||||
return -EBUSY;
|
||||
|
||||
ref = rate_control_alloc(name, local);
|
||||
if (!ref) {
|
||||
printk(KERN_WARNING "%s: Failed to select rate control "
|
||||
"algorithm\n", wiphy_name(local->hw.wiphy));
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
old = local->rate_ctrl;
|
||||
local->rate_ctrl = ref;
|
||||
if (old) {
|
||||
rate_control_put(old);
|
||||
sta_info_flush(local, NULL);
|
||||
}
|
||||
|
||||
printk(KERN_DEBUG "%s: Selected rate control "
|
||||
"algorithm '%s'\n", wiphy_name(local->hw.wiphy),
|
||||
ref->ops->name);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rate_control_deinitialize(struct ieee80211_local *local)
|
||||
{
|
||||
struct rate_control_ref *ref;
|
||||
|
||||
ref = local->rate_ctrl;
|
||||
local->rate_ctrl = NULL;
|
||||
rate_control_put(ref);
|
||||
}
|
||||
|
@ -30,8 +30,6 @@ struct rate_control_extra {
|
||||
|
||||
/* parameters from the caller to rate_control_get_rate(): */
|
||||
struct ieee80211_hw_mode *mode;
|
||||
int mgmt_data; /* this is data frame that is used for management
|
||||
* (e.g., IEEE 802.1X EAPOL) */
|
||||
u16 ethertype;
|
||||
};
|
||||
|
||||
@ -141,4 +139,10 @@ static inline void rate_control_remove_sta_debugfs(struct sta_info *sta)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* functions for rate control related to a device */
|
||||
int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
|
||||
const char *name);
|
||||
void rate_control_deinitialize(struct ieee80211_local *local);
|
||||
|
||||
#endif /* IEEE80211_RATE_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
277
package/mac80211/src/mac80211/key.c
Normal file
277
package/mac80211/src/mac80211/key.c
Normal file
@ -0,0 +1,277 @@
|
||||
/*
|
||||
* Copyright 2002-2005, Instant802 Networks, Inc.
|
||||
* Copyright 2005-2006, Devicescape Software, Inc.
|
||||
* Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
|
||||
* Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/rcupdate.h>
|
||||
#include <net/mac80211.h>
|
||||
#include "ieee80211_i.h"
|
||||
#include "debugfs_key.h"
|
||||
#include "aes_ccm.h"
|
||||
|
||||
|
||||
/*
|
||||
* Key handling basics
|
||||
*
|
||||
* Key handling in mac80211 is done based on per-interface (sub_if_data)
|
||||
* keys and per-station keys. Since each station belongs to an interface,
|
||||
* each station key also belongs to that interface.
|
||||
*
|
||||
* Hardware acceleration is done on a best-effort basis, for each key
|
||||
* that is eligible the hardware is asked to enable that key but if
|
||||
* it cannot do that they key is simply kept for software encryption.
|
||||
* There is currently no way of knowing this except by looking into
|
||||
* debugfs.
|
||||
*
|
||||
* All operations here are called under RTNL so no extra locking is
|
||||
* required.
|
||||
*/
|
||||
|
||||
static const u8 bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
static const u8 zero_addr[ETH_ALEN];
|
||||
|
||||
static const u8 *get_mac_for_key(struct ieee80211_key *key)
|
||||
{
|
||||
const u8 *addr = bcast_addr;
|
||||
|
||||
/*
|
||||
* If we're an AP we won't ever receive frames with a non-WEP
|
||||
* group key so we tell the driver that by using the zero MAC
|
||||
* address to indicate a transmit-only key.
|
||||
*/
|
||||
if (key->conf.alg != ALG_WEP &&
|
||||
(key->sdata->type == IEEE80211_IF_TYPE_AP ||
|
||||
key->sdata->type == IEEE80211_IF_TYPE_VLAN))
|
||||
addr = zero_addr;
|
||||
|
||||
if (key->sta)
|
||||
addr = key->sta->addr;
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
|
||||
{
|
||||
const u8 *addr;
|
||||
int ret;
|
||||
|
||||
if (!key->local->ops->set_key)
|
||||
return;
|
||||
|
||||
addr = get_mac_for_key(key);
|
||||
|
||||
ret = key->local->ops->set_key(local_to_hw(key->local), SET_KEY,
|
||||
key->sdata->dev->dev_addr, addr,
|
||||
&key->conf);
|
||||
|
||||
if (!ret)
|
||||
key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
|
||||
|
||||
if (ret && ret != -ENOSPC && ret != -EOPNOTSUPP)
|
||||
printk(KERN_ERR "mac80211-%s: failed to set key "
|
||||
"(%d, " MAC_FMT ") to hardware (%d)\n",
|
||||
wiphy_name(key->local->hw.wiphy),
|
||||
key->conf.keyidx, MAC_ARG(addr), ret);
|
||||
}
|
||||
|
||||
static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
|
||||
{
|
||||
const u8 *addr;
|
||||
int ret;
|
||||
|
||||
if (!key->local->ops->set_key)
|
||||
return;
|
||||
|
||||
if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE))
|
||||
return;
|
||||
|
||||
addr = get_mac_for_key(key);
|
||||
|
||||
ret = key->local->ops->set_key(local_to_hw(key->local), DISABLE_KEY,
|
||||
key->sdata->dev->dev_addr, addr,
|
||||
&key->conf);
|
||||
|
||||
if (ret)
|
||||
printk(KERN_ERR "mac80211-%s: failed to remove key "
|
||||
"(%d, " MAC_FMT ") from hardware (%d)\n",
|
||||
wiphy_name(key->local->hw.wiphy),
|
||||
key->conf.keyidx, MAC_ARG(addr), ret);
|
||||
|
||||
key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
|
||||
}
|
||||
|
||||
struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
|
||||
struct sta_info *sta,
|
||||
enum ieee80211_key_alg alg,
|
||||
int idx,
|
||||
size_t key_len,
|
||||
const u8 *key_data)
|
||||
{
|
||||
struct ieee80211_key *key;
|
||||
|
||||
BUG_ON(idx < 0 || idx >= NUM_DEFAULT_KEYS);
|
||||
|
||||
key = kzalloc(sizeof(struct ieee80211_key) + key_len, GFP_KERNEL);
|
||||
if (!key)
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* Default to software encryption; we'll later upload the
|
||||
* key to the hardware if possible.
|
||||
*/
|
||||
key->conf.flags = 0;
|
||||
key->flags = 0;
|
||||
|
||||
key->conf.alg = alg;
|
||||
key->conf.keyidx = idx;
|
||||
key->conf.keylen = key_len;
|
||||
memcpy(key->conf.key, key_data, key_len);
|
||||
|
||||
key->local = sdata->local;
|
||||
key->sdata = sdata;
|
||||
key->sta = sta;
|
||||
|
||||
if (alg == ALG_CCMP) {
|
||||
/*
|
||||
* Initialize AES key state here as an optimization so that
|
||||
* it does not need to be initialized for every packet.
|
||||
*/
|
||||
key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt(key_data);
|
||||
if (!key->u.ccmp.tfm) {
|
||||
ieee80211_key_free(key);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
ieee80211_debugfs_key_add(key->local, key);
|
||||
|
||||
/* remove key first */
|
||||
if (sta)
|
||||
ieee80211_key_free(sta->key);
|
||||
else
|
||||
ieee80211_key_free(sdata->keys[idx]);
|
||||
|
||||
if (sta) {
|
||||
ieee80211_debugfs_key_sta_link(key, sta);
|
||||
|
||||
/*
|
||||
* some hardware cannot handle TKIP with QoS, so
|
||||
* we indicate whether QoS could be in use.
|
||||
*/
|
||||
if (sta->flags & WLAN_STA_WME)
|
||||
key->conf.flags |= IEEE80211_KEY_FLAG_WMM_STA;
|
||||
} else {
|
||||
if (sdata->type == IEEE80211_IF_TYPE_STA) {
|
||||
struct sta_info *ap;
|
||||
|
||||
/* same here, the AP could be using QoS */
|
||||
ap = sta_info_get(key->local, key->sdata->u.sta.bssid);
|
||||
if (ap) {
|
||||
if (ap->flags & WLAN_STA_WME)
|
||||
key->conf.flags |=
|
||||
IEEE80211_KEY_FLAG_WMM_STA;
|
||||
sta_info_put(ap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* enable hwaccel if appropriate */
|
||||
if (netif_running(key->sdata->dev))
|
||||
ieee80211_key_enable_hw_accel(key);
|
||||
|
||||
if (sta)
|
||||
rcu_assign_pointer(sta->key, key);
|
||||
else
|
||||
rcu_assign_pointer(sdata->keys[idx], key);
|
||||
|
||||
list_add(&key->list, &sdata->key_list);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
void ieee80211_key_free(struct ieee80211_key *key)
|
||||
{
|
||||
if (!key)
|
||||
return;
|
||||
|
||||
if (key->sta) {
|
||||
rcu_assign_pointer(key->sta->key, NULL);
|
||||
} else {
|
||||
if (key->sdata->default_key == key)
|
||||
ieee80211_set_default_key(key->sdata, -1);
|
||||
if (key->conf.keyidx >= 0 &&
|
||||
key->conf.keyidx < NUM_DEFAULT_KEYS)
|
||||
rcu_assign_pointer(key->sdata->keys[key->conf.keyidx],
|
||||
NULL);
|
||||
else
|
||||
WARN_ON(1);
|
||||
}
|
||||
|
||||
/* wait for all key users to complete */
|
||||
synchronize_rcu();
|
||||
|
||||
/* remove from hwaccel if appropriate */
|
||||
ieee80211_key_disable_hw_accel(key);
|
||||
|
||||
if (key->conf.alg == ALG_CCMP)
|
||||
ieee80211_aes_key_free(key->u.ccmp.tfm);
|
||||
ieee80211_debugfs_key_remove(key);
|
||||
|
||||
list_del(&key->list);
|
||||
|
||||
kfree(key);
|
||||
}
|
||||
|
||||
void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx)
|
||||
{
|
||||
struct ieee80211_key *key = NULL;
|
||||
|
||||
if (idx >= 0 && idx < NUM_DEFAULT_KEYS)
|
||||
key = sdata->keys[idx];
|
||||
|
||||
if (sdata->default_key != key) {
|
||||
ieee80211_debugfs_key_remove_default(sdata);
|
||||
|
||||
rcu_assign_pointer(sdata->default_key, key);
|
||||
|
||||
if (sdata->default_key)
|
||||
ieee80211_debugfs_key_add_default(sdata);
|
||||
}
|
||||
}
|
||||
|
||||
void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata)
|
||||
{
|
||||
struct ieee80211_key *key, *tmp;
|
||||
|
||||
list_for_each_entry_safe(key, tmp, &sdata->key_list, list)
|
||||
ieee80211_key_free(key);
|
||||
}
|
||||
|
||||
void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata)
|
||||
{
|
||||
struct ieee80211_key *key;
|
||||
|
||||
WARN_ON(!netif_running(sdata->dev));
|
||||
if (!netif_running(sdata->dev))
|
||||
return;
|
||||
|
||||
list_for_each_entry(key, &sdata->key_list, list)
|
||||
ieee80211_key_enable_hw_accel(key);
|
||||
}
|
||||
|
||||
void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata)
|
||||
{
|
||||
struct ieee80211_key *key;
|
||||
|
||||
list_for_each_entry(key, &sdata->key_list, list)
|
||||
ieee80211_key_disable_hw_accel(key);
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2005, Instant802 Networks, Inc.
|
||||
* Copyright 2005, Devicescape Software, Inc.
|
||||
* Copyright (c) 2006-2007 Jiri Benc <jbenc@suse.cz>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/compiler.h>
|
||||
|
||||
#include <net/mac80211.h>
|
||||
#include "ieee80211_i.h"
|
||||
#include "ieee80211_rate.h"
|
||||
#include "debugfs.h"
|
||||
|
||||
static void rate_control_lowest_tx_status(void *priv, struct net_device *dev,
|
||||
struct sk_buff *skb,
|
||||
struct ieee80211_tx_status *status)
|
||||
{
|
||||
}
|
||||
|
||||
static struct ieee80211_rate *
|
||||
rate_control_lowest_get_rate(void *priv, struct net_device *dev,
|
||||
struct sk_buff *skb,
|
||||
struct rate_control_extra *extra)
|
||||
{
|
||||
struct ieee80211_hw_mode *mode = extra->mode;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < mode->num_rates; i++) {
|
||||
struct ieee80211_rate *rate = &mode->rates[i];
|
||||
|
||||
if (rate->flags & IEEE80211_RATE_SUPPORTED)
|
||||
return rate;
|
||||
}
|
||||
return &mode->rates[0];
|
||||
}
|
||||
|
||||
static void rate_control_lowest_rate_init(void *priv, void *priv_sta,
|
||||
struct ieee80211_local *local,
|
||||
struct sta_info *sta)
|
||||
{
|
||||
sta->txrate = 0;
|
||||
}
|
||||
|
||||
static void *rate_control_lowest_alloc(struct ieee80211_local *local)
|
||||
{
|
||||
return local;
|
||||
}
|
||||
|
||||
static void rate_control_lowest_free(void *priv)
|
||||
{
|
||||
}
|
||||
|
||||
static void rate_control_lowest_clear(void *priv)
|
||||
{
|
||||
}
|
||||
|
||||
static void *rate_control_lowest_alloc_sta(void *priv, gfp_t gfp)
|
||||
{
|
||||
return priv;
|
||||
}
|
||||
|
||||
static void rate_control_lowest_free_sta(void *priv, void *priv_sta)
|
||||
{
|
||||
}
|
||||
|
||||
static struct rate_control_ops rate_control_lowest = {
|
||||
.module = THIS_MODULE,
|
||||
.name = "lowest",
|
||||
.tx_status = rate_control_lowest_tx_status,
|
||||
.get_rate = rate_control_lowest_get_rate,
|
||||
.rate_init = rate_control_lowest_rate_init,
|
||||
.clear = rate_control_lowest_clear,
|
||||
.alloc = rate_control_lowest_alloc,
|
||||
.free = rate_control_lowest_free,
|
||||
.alloc_sta = rate_control_lowest_alloc_sta,
|
||||
.free_sta = rate_control_lowest_free_sta,
|
||||
};
|
||||
|
||||
static int __init rate_control_lowest_init(void)
|
||||
{
|
||||
return ieee80211_rate_control_register(&rate_control_lowest);
|
||||
}
|
||||
|
||||
|
||||
static void __exit rate_control_lowest_exit(void)
|
||||
{
|
||||
ieee80211_rate_control_unregister(&rate_control_lowest);
|
||||
}
|
||||
|
||||
|
||||
module_init(rate_control_lowest_init);
|
||||
module_exit(rate_control_lowest_exit);
|
||||
|
||||
MODULE_DESCRIPTION("Forced 1 mbps rate control module for mac80211");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
@ -147,14 +147,6 @@ static void rate_control_simple_tx_status(void *priv, struct net_device *dev,
|
||||
srctrl = sta->rate_ctrl_priv;
|
||||
srctrl->tx_num_xmit++;
|
||||
if (status->excessive_retries) {
|
||||
sta->antenna_sel_tx = sta->antenna_sel_tx == 1 ? 2 : 1;
|
||||
sta->antenna_sel_rx = sta->antenna_sel_rx == 1 ? 2 : 1;
|
||||
if (local->sta_antenna_sel == STA_ANTENNA_SEL_SW_CTRL_DEBUG) {
|
||||
printk(KERN_DEBUG "%s: " MAC_FMT " TX antenna --> %d "
|
||||
"RX antenna --> %d (@%lu)\n",
|
||||
dev->name, MAC_ARG(hdr->addr1),
|
||||
sta->antenna_sel_tx, sta->antenna_sel_rx, jiffies);
|
||||
}
|
||||
srctrl->tx_num_failures++;
|
||||
sta->tx_retry_failed++;
|
||||
sta->tx_num_consecutive_failures++;
|
||||
@ -187,9 +179,13 @@ static void rate_control_simple_tx_status(void *priv, struct net_device *dev,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (per_failed > local->rate_ctrl_num_down) {
|
||||
/*
|
||||
* XXX: Make these configurable once we have an
|
||||
* interface to the rate control algorithms
|
||||
*/
|
||||
if (per_failed > RATE_CONTROL_NUM_DOWN) {
|
||||
rate_control_rate_dec(local, sta);
|
||||
} else if (per_failed < local->rate_ctrl_num_up) {
|
||||
} else if (per_failed < RATE_CONTROL_NUM_UP) {
|
||||
rate_control_rate_inc(local, sta);
|
||||
}
|
||||
srctrl->tx_avg_rate_sum += status->control.rate->rate;
|
||||
@ -427,7 +423,7 @@ static void __exit rate_control_simple_exit(void)
|
||||
}
|
||||
|
||||
|
||||
module_init(rate_control_simple_init);
|
||||
subsys_initcall(rate_control_simple_init);
|
||||
module_exit(rate_control_simple_exit);
|
||||
|
||||
MODULE_DESCRIPTION("Simple rate control algorithm for ieee80211");
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <net/mac80211.h>
|
||||
#include "ieee80211_i.h"
|
||||
|
||||
static int ieee80211_regdom = 0x10; /* FCC */
|
||||
module_param(ieee80211_regdom, int, 0444);
|
||||
@ -81,12 +82,6 @@ static void ieee80211_unmask_channel(int mode, struct ieee80211_channel *chan)
|
||||
|
||||
chan->flag = 0;
|
||||
|
||||
if (ieee80211_regdom == 64 &&
|
||||
(mode == MODE_ATHEROS_TURBO || mode == MODE_ATHEROS_TURBOG)) {
|
||||
/* Do not allow Turbo modes in Japan. */
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; channel_range[i].start_freq; i++) {
|
||||
const struct ieee80211_channel_range *r = &channel_range[i];
|
||||
if (r->start_freq <= chan->freq && r->end_freq >= chan->freq) {
|
||||
|
1579
package/mac80211/src/mac80211/rx.c
Normal file
1579
package/mac80211/src/mac80211/rx.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -19,7 +19,6 @@
|
||||
#include "ieee80211_i.h"
|
||||
#include "ieee80211_rate.h"
|
||||
#include "sta_info.h"
|
||||
#include "debugfs_key.h"
|
||||
#include "debugfs_sta.h"
|
||||
|
||||
/* Caller must hold local->sta_lock */
|
||||
@ -32,42 +31,34 @@ static void sta_info_hash_add(struct ieee80211_local *local,
|
||||
|
||||
|
||||
/* Caller must hold local->sta_lock */
|
||||
static void sta_info_hash_del(struct ieee80211_local *local,
|
||||
struct sta_info *sta, int dls)
|
||||
static int sta_info_hash_del(struct ieee80211_local *local,
|
||||
struct sta_info *sta)
|
||||
{
|
||||
struct sta_info *s;
|
||||
|
||||
s = local->sta_hash[STA_HASH(sta->addr)];
|
||||
if (!s)
|
||||
return;
|
||||
if (memcmp(s->addr, sta->addr, ETH_ALEN) == 0) {
|
||||
if (dls && !s->dls_sta)
|
||||
return;
|
||||
return -ENOENT;
|
||||
if (s == sta) {
|
||||
local->sta_hash[STA_HASH(sta->addr)] = s->hnext;
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (s->hnext && memcmp(s->hnext->addr, sta->addr, ETH_ALEN) != 0)
|
||||
while (s->hnext && s->hnext != sta)
|
||||
s = s->hnext;
|
||||
if (s->hnext) {
|
||||
if (dls && !s->hnext->dls_sta)
|
||||
return;
|
||||
s->hnext = s->hnext->hnext;
|
||||
} else
|
||||
printk(KERN_ERR "%s: could not remove STA " MAC_FMT " from "
|
||||
"hash table\n", local->mdev->name, MAC_ARG(sta->addr));
|
||||
}
|
||||
s->hnext = sta->hnext;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void __sta_info_get(struct sta_info *sta)
|
||||
{
|
||||
kref_get(&sta->kref);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
struct sta_info *sta_info_get(struct ieee80211_local *local, u8 *addr)
|
||||
{
|
||||
struct sta_info *sta;
|
||||
|
||||
spin_lock_bh(&local->sta_lock);
|
||||
read_lock_bh(&local->sta_lock);
|
||||
sta = local->sta_hash[STA_HASH(addr)];
|
||||
while (sta) {
|
||||
if (memcmp(sta->addr, addr, ETH_ALEN) == 0) {
|
||||
@ -76,34 +67,12 @@ struct sta_info *sta_info_get(struct ieee80211_local *local, u8 *addr)
|
||||
}
|
||||
sta = sta->hnext;
|
||||
}
|
||||
spin_unlock_bh(&local->sta_lock);
|
||||
read_unlock_bh(&local->sta_lock);
|
||||
|
||||
return sta;
|
||||
}
|
||||
EXPORT_SYMBOL(sta_info_get);
|
||||
|
||||
struct sta_info *dls_info_get(struct ieee80211_local *local, u8 *addr)
|
||||
{
|
||||
struct sta_info *sta;
|
||||
|
||||
spin_lock_bh(&local->sta_lock);
|
||||
sta = local->sta_hash[STA_HASH(addr)];
|
||||
while (sta) {
|
||||
if (memcmp(sta->addr, addr, ETH_ALEN) == 0) {
|
||||
if (!sta->dls_sta) {
|
||||
sta = NULL;
|
||||
break;
|
||||
}
|
||||
__sta_info_get(sta);
|
||||
break;
|
||||
}
|
||||
sta = sta->hnext;
|
||||
}
|
||||
spin_unlock_bh(&local->sta_lock);
|
||||
|
||||
return sta;
|
||||
}
|
||||
|
||||
int sta_info_min_txrate_get(struct ieee80211_local *local)
|
||||
{
|
||||
struct sta_info *sta;
|
||||
@ -111,7 +80,7 @@ int sta_info_min_txrate_get(struct ieee80211_local *local)
|
||||
int min_txrate = 9999999;
|
||||
int i;
|
||||
|
||||
spin_lock_bh(&local->sta_lock);
|
||||
read_lock_bh(&local->sta_lock);
|
||||
mode = local->oper_hw_mode;
|
||||
for (i = 0; i < STA_HASH_SIZE; i++) {
|
||||
sta = local->sta_hash[i];
|
||||
@ -121,7 +90,7 @@ int sta_info_min_txrate_get(struct ieee80211_local *local)
|
||||
sta = sta->hnext;
|
||||
}
|
||||
}
|
||||
spin_unlock_bh(&local->sta_lock);
|
||||
read_unlock_bh(&local->sta_lock);
|
||||
if (min_txrate == 9999999)
|
||||
min_txrate = 0;
|
||||
|
||||
@ -148,8 +117,6 @@ static void sta_info_release(struct kref *kref)
|
||||
}
|
||||
rate_control_free_sta(sta->rate_ctrl, sta->rate_ctrl_priv);
|
||||
rate_control_put(sta->rate_ctrl);
|
||||
if (sta->key)
|
||||
ieee80211_debugfs_key_sta_del(sta->key, sta);
|
||||
kfree(sta);
|
||||
}
|
||||
|
||||
@ -176,7 +143,6 @@ struct sta_info * sta_info_add(struct ieee80211_local *local,
|
||||
sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, gfp);
|
||||
if (!sta->rate_ctrl_priv) {
|
||||
rate_control_put(sta->rate_ctrl);
|
||||
kref_put(&sta->kref, sta_info_release);
|
||||
kfree(sta);
|
||||
return NULL;
|
||||
}
|
||||
@ -188,63 +154,40 @@ struct sta_info * sta_info_add(struct ieee80211_local *local,
|
||||
skb_queue_head_init(&sta->tx_filtered);
|
||||
__sta_info_get(sta); /* sta used by caller, decremented by
|
||||
* sta_info_put() */
|
||||
spin_lock_bh(&local->sta_lock);
|
||||
write_lock_bh(&local->sta_lock);
|
||||
list_add(&sta->list, &local->sta_list);
|
||||
local->num_sta++;
|
||||
sta_info_hash_add(local, sta);
|
||||
spin_unlock_bh(&local->sta_lock);
|
||||
if (local->ops->sta_table_notification)
|
||||
local->ops->sta_table_notification(local_to_hw(local),
|
||||
local->num_sta);
|
||||
sta->key_idx_compression = HW_KEY_IDX_INVALID;
|
||||
if (local->ops->sta_notify)
|
||||
local->ops->sta_notify(local_to_hw(local), dev->ifindex,
|
||||
STA_NOTIFY_ADD, addr);
|
||||
write_unlock_bh(&local->sta_lock);
|
||||
|
||||
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
|
||||
printk(KERN_DEBUG "%s: Added STA " MAC_FMT "\n",
|
||||
local->mdev->name, MAC_ARG(addr));
|
||||
wiphy_name(local->hw.wiphy), MAC_ARG(addr));
|
||||
#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
|
||||
|
||||
#ifdef CONFIG_MAC80211_DEBUGFS
|
||||
if (!in_interrupt()) {
|
||||
sta->debugfs_registered = 1;
|
||||
ieee80211_sta_debugfs_add(sta);
|
||||
rate_control_add_sta_debugfs(sta);
|
||||
} else {
|
||||
/* debugfs entry adding might sleep, so schedule process
|
||||
* context task for adding entry for STAs that do not yet
|
||||
* have one. */
|
||||
queue_work(local->hw.workqueue, &local->sta_debugfs_add);
|
||||
}
|
||||
/* debugfs entry adding might sleep, so schedule process
|
||||
* context task for adding entry for STAs that do not yet
|
||||
* have one. */
|
||||
queue_work(local->hw.workqueue, &local->sta_debugfs_add);
|
||||
#endif
|
||||
|
||||
return sta;
|
||||
}
|
||||
|
||||
static void finish_sta_info_free(struct ieee80211_local *local,
|
||||
struct sta_info *sta)
|
||||
{
|
||||
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
|
||||
printk(KERN_DEBUG "%s: Removed STA " MAC_FMT "\n",
|
||||
local->mdev->name, MAC_ARG(sta->addr));
|
||||
#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
|
||||
|
||||
if (sta->key) {
|
||||
ieee80211_debugfs_key_remove(sta->key);
|
||||
ieee80211_key_free(sta->key);
|
||||
sta->key = NULL;
|
||||
}
|
||||
|
||||
rate_control_remove_sta_debugfs(sta);
|
||||
ieee80211_sta_debugfs_remove(sta);
|
||||
|
||||
sta_info_put(sta);
|
||||
}
|
||||
|
||||
static void sta_info_remove(struct sta_info *sta)
|
||||
/* Caller must hold local->sta_lock */
|
||||
void sta_info_remove(struct sta_info *sta)
|
||||
{
|
||||
struct ieee80211_local *local = sta->local;
|
||||
struct ieee80211_sub_if_data *sdata;
|
||||
|
||||
sta_info_hash_del(local, sta, 0);
|
||||
/* don't do anything if we've been removed already */
|
||||
if (sta_info_hash_del(local, sta))
|
||||
return;
|
||||
|
||||
list_del(&sta->list);
|
||||
sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
|
||||
if (sta->flags & WLAN_STA_PS) {
|
||||
@ -254,61 +197,44 @@ static void sta_info_remove(struct sta_info *sta)
|
||||
}
|
||||
local->num_sta--;
|
||||
sta_info_remove_aid_ptr(sta);
|
||||
|
||||
}
|
||||
|
||||
void sta_info_free(struct sta_info *sta, int locked)
|
||||
void sta_info_free(struct sta_info *sta)
|
||||
{
|
||||
struct sk_buff *skb;
|
||||
struct ieee80211_local *local = sta->local;
|
||||
|
||||
if (!locked) {
|
||||
spin_lock_bh(&local->sta_lock);
|
||||
sta_info_remove(sta);
|
||||
spin_unlock_bh(&local->sta_lock);
|
||||
} else {
|
||||
sta_info_remove(sta);
|
||||
}
|
||||
if (local->ops->sta_table_notification)
|
||||
local->ops->sta_table_notification(local_to_hw(local),
|
||||
local->num_sta);
|
||||
might_sleep();
|
||||
|
||||
write_lock_bh(&local->sta_lock);
|
||||
sta_info_remove(sta);
|
||||
write_unlock_bh(&local->sta_lock);
|
||||
|
||||
while ((skb = skb_dequeue(&sta->ps_tx_buf)) != NULL) {
|
||||
local->total_ps_buffered--;
|
||||
dev_kfree_skb_any(skb);
|
||||
dev_kfree_skb(skb);
|
||||
}
|
||||
while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) {
|
||||
dev_kfree_skb_any(skb);
|
||||
dev_kfree_skb(skb);
|
||||
}
|
||||
|
||||
if (sta->key) {
|
||||
if (local->ops->set_key) {
|
||||
struct ieee80211_key_conf *key;
|
||||
key = ieee80211_key_data2conf(local, sta->key);
|
||||
if (key) {
|
||||
local->ops->set_key(local_to_hw(local),
|
||||
DISABLE_KEY,
|
||||
sta->addr, key, sta->aid);
|
||||
kfree(key);
|
||||
}
|
||||
}
|
||||
} else if (sta->key_idx_compression != HW_KEY_IDX_INVALID) {
|
||||
struct ieee80211_key_conf conf;
|
||||
memset(&conf, 0, sizeof(conf));
|
||||
conf.hw_key_idx = sta->key_idx_compression;
|
||||
conf.alg = ALG_NULL;
|
||||
conf.flags |= IEEE80211_KEY_FORCE_SW_ENCRYPT;
|
||||
local->ops->set_key(local_to_hw(local), DISABLE_KEY,
|
||||
sta->addr, &conf, sta->aid);
|
||||
sta->key_idx_compression = HW_KEY_IDX_INVALID;
|
||||
}
|
||||
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
|
||||
printk(KERN_DEBUG "%s: Removed STA " MAC_FMT "\n",
|
||||
wiphy_name(local->hw.wiphy), MAC_ARG(sta->addr));
|
||||
#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
|
||||
|
||||
#ifdef CONFIG_MAC80211_DEBUGFS
|
||||
if (in_atomic()) {
|
||||
list_add(&sta->list, &local->deleted_sta_list);
|
||||
queue_work(local->hw.workqueue, &local->sta_debugfs_add);
|
||||
} else
|
||||
#endif
|
||||
finish_sta_info_free(local, sta);
|
||||
ieee80211_key_free(sta->key);
|
||||
sta->key = NULL;
|
||||
|
||||
if (local->ops->sta_notify)
|
||||
local->ops->sta_notify(local_to_hw(local), sta->dev->ifindex,
|
||||
STA_NOTIFY_REMOVE, sta->addr);
|
||||
|
||||
rate_control_remove_sta_debugfs(sta);
|
||||
ieee80211_sta_debugfs_remove(sta);
|
||||
|
||||
sta_info_put(sta);
|
||||
}
|
||||
|
||||
|
||||
@ -369,13 +295,13 @@ static void sta_info_cleanup(unsigned long data)
|
||||
struct ieee80211_local *local = (struct ieee80211_local *) data;
|
||||
struct sta_info *sta;
|
||||
|
||||
spin_lock_bh(&local->sta_lock);
|
||||
read_lock_bh(&local->sta_lock);
|
||||
list_for_each_entry(sta, &local->sta_list, list) {
|
||||
__sta_info_get(sta);
|
||||
sta_info_cleanup_expire_buffered(local, sta);
|
||||
sta_info_put(sta);
|
||||
}
|
||||
spin_unlock_bh(&local->sta_lock);
|
||||
read_unlock_bh(&local->sta_lock);
|
||||
|
||||
local->sta_cleanup.expires = jiffies + STA_INFO_CLEANUP_INTERVAL;
|
||||
add_timer(&local->sta_cleanup);
|
||||
@ -388,36 +314,21 @@ static void sta_info_debugfs_add_task(struct work_struct *work)
|
||||
container_of(work, struct ieee80211_local, sta_debugfs_add);
|
||||
struct sta_info *sta, *tmp;
|
||||
|
||||
while (1) {
|
||||
spin_lock_bh(&local->sta_lock);
|
||||
if (!list_empty(&local->deleted_sta_list)) {
|
||||
sta = list_entry(local->deleted_sta_list.next,
|
||||
struct sta_info, list);
|
||||
list_del(local->deleted_sta_list.next);
|
||||
} else
|
||||
sta = NULL;
|
||||
spin_unlock_bh(&local->sta_lock);
|
||||
if (!sta)
|
||||
break;
|
||||
finish_sta_info_free(local, sta);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
sta = NULL;
|
||||
spin_lock_bh(&local->sta_lock);
|
||||
read_lock_bh(&local->sta_lock);
|
||||
list_for_each_entry(tmp, &local->sta_list, list) {
|
||||
if (!tmp->debugfs_registered) {
|
||||
if (!tmp->debugfs.dir) {
|
||||
sta = tmp;
|
||||
__sta_info_get(sta);
|
||||
break;
|
||||
}
|
||||
}
|
||||
spin_unlock_bh(&local->sta_lock);
|
||||
read_unlock_bh(&local->sta_lock);
|
||||
|
||||
if (!sta)
|
||||
break;
|
||||
|
||||
sta->debugfs_registered = 1;
|
||||
ieee80211_sta_debugfs_add(sta);
|
||||
rate_control_add_sta_debugfs(sta);
|
||||
sta_info_put(sta);
|
||||
@ -427,9 +338,8 @@ static void sta_info_debugfs_add_task(struct work_struct *work)
|
||||
|
||||
void sta_info_init(struct ieee80211_local *local)
|
||||
{
|
||||
spin_lock_init(&local->sta_lock);
|
||||
rwlock_init(&local->sta_lock);
|
||||
INIT_LIST_HEAD(&local->sta_list);
|
||||
INIT_LIST_HEAD(&local->deleted_sta_list);
|
||||
|
||||
init_timer(&local->sta_cleanup);
|
||||
local->sta_cleanup.expires = jiffies + STA_INFO_CLEANUP_INTERVAL;
|
||||
@ -449,17 +359,8 @@ int sta_info_start(struct ieee80211_local *local)
|
||||
|
||||
void sta_info_stop(struct ieee80211_local *local)
|
||||
{
|
||||
struct sta_info *sta, *tmp;
|
||||
|
||||
del_timer(&local->sta_cleanup);
|
||||
|
||||
list_for_each_entry_safe(sta, tmp, &local->sta_list, list) {
|
||||
/* sta_info_free must be called with 0 as the last
|
||||
* parameter to ensure all debugfs sta entries are
|
||||
* unregistered. We don't need locking at this
|
||||
* point. */
|
||||
sta_info_free(sta, 0);
|
||||
}
|
||||
sta_info_flush(local, NULL);
|
||||
}
|
||||
|
||||
void sta_info_remove_aid_ptr(struct sta_info *sta)
|
||||
@ -487,10 +388,19 @@ void sta_info_remove_aid_ptr(struct sta_info *sta)
|
||||
void sta_info_flush(struct ieee80211_local *local, struct net_device *dev)
|
||||
{
|
||||
struct sta_info *sta, *tmp;
|
||||
LIST_HEAD(tmp_list);
|
||||
|
||||
spin_lock_bh(&local->sta_lock);
|
||||
write_lock_bh(&local->sta_lock);
|
||||
list_for_each_entry_safe(sta, tmp, &local->sta_list, list)
|
||||
if (!dev || dev == sta->dev)
|
||||
sta_info_free(sta, 1);
|
||||
spin_unlock_bh(&local->sta_lock);
|
||||
if (!dev || dev == sta->dev) {
|
||||
__sta_info_get(sta);
|
||||
sta_info_remove(sta);
|
||||
list_add_tail(&sta->list, &tmp_list);
|
||||
}
|
||||
write_unlock_bh(&local->sta_lock);
|
||||
|
||||
list_for_each_entry_safe(sta, tmp, &tmp_list, list) {
|
||||
sta_info_free(sta);
|
||||
sta_info_put(sta);
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,9 @@
|
||||
* send and receive non-IEEE 802.1X frames
|
||||
*/
|
||||
#define WLAN_STA_SHORT_PREAMBLE BIT(7)
|
||||
/* whether this is an AP that we are associated with as a client */
|
||||
#define WLAN_STA_ASSOC_AP BIT(8)
|
||||
#define WLAN_STA_WME BIT(9)
|
||||
#define WLAN_STA_HT BIT(10)
|
||||
#define WLAN_STA_WDS BIT(27)
|
||||
|
||||
|
||||
@ -91,37 +92,11 @@ struct sta_info {
|
||||
int channel_use;
|
||||
int channel_use_raw;
|
||||
|
||||
u8 antenna_sel_tx;
|
||||
u8 antenna_sel_rx;
|
||||
|
||||
|
||||
int key_idx_compression; /* key table index for compression and TX
|
||||
* filtering; used only if sta->key is not
|
||||
* set */
|
||||
|
||||
#ifdef CONFIG_MAC80211_DEBUGFS
|
||||
int debugfs_registered;
|
||||
#endif
|
||||
unsigned int assoc_ap:1; /* whether this is an AP that we are
|
||||
* associated with as a client */
|
||||
unsigned int dls_sta:1; /* whether this stations is a DLS peer of us */
|
||||
|
||||
#define DLS_STATUS_OK 0
|
||||
#define DLS_STATUS_NOLINK 1
|
||||
int dls_status;
|
||||
u32 dls_timeout;
|
||||
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
u32 wpa_trigger;
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
|
||||
#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
|
||||
unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
|
||||
unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
|
||||
#endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
|
||||
|
||||
int vlan_id;
|
||||
|
||||
u16 listen_interval;
|
||||
|
||||
#ifdef CONFIG_MAC80211_DEBUGFS
|
||||
@ -160,12 +135,18 @@ struct sta_info {
|
||||
*/
|
||||
#define STA_INFO_CLEANUP_INTERVAL (10 * HZ)
|
||||
|
||||
static inline void __sta_info_get(struct sta_info *sta)
|
||||
{
|
||||
kref_get(&sta->kref);
|
||||
}
|
||||
|
||||
struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr);
|
||||
int sta_info_min_txrate_get(struct ieee80211_local *local);
|
||||
void sta_info_put(struct sta_info *sta);
|
||||
struct sta_info * sta_info_add(struct ieee80211_local *local,
|
||||
struct net_device *dev, u8 *addr, gfp_t gfp);
|
||||
void sta_info_free(struct sta_info *sta, int locked);
|
||||
void sta_info_remove(struct sta_info *sta);
|
||||
void sta_info_free(struct sta_info *sta);
|
||||
void sta_info_init(struct ieee80211_local *local);
|
||||
int sta_info_start(struct ieee80211_local *local);
|
||||
void sta_info_stop(struct ieee80211_local *local);
|
||||
|
@ -182,7 +182,7 @@ u8 * ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key *key,
|
||||
*pos++ = iv0;
|
||||
*pos++ = iv1;
|
||||
*pos++ = iv2;
|
||||
*pos++ = (key->keyidx << 6) | (1 << 5) /* Ext IV */;
|
||||
*pos++ = (key->conf.keyidx << 6) | (1 << 5) /* Ext IV */;
|
||||
*pos++ = key->u.tkip.iv32 & 0xff;
|
||||
*pos++ = (key->u.tkip.iv32 >> 8) & 0xff;
|
||||
*pos++ = (key->u.tkip.iv32 >> 16) & 0xff;
|
||||
@ -194,7 +194,7 @@ u8 * ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key *key,
|
||||
void ieee80211_tkip_gen_phase1key(struct ieee80211_key *key, u8 *ta,
|
||||
u16 *phase1key)
|
||||
{
|
||||
tkip_mixing_phase1(ta, &key->key[ALG_TKIP_TEMP_ENCR_KEY],
|
||||
tkip_mixing_phase1(ta, &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY],
|
||||
key->u.tkip.iv32, phase1key);
|
||||
}
|
||||
|
||||
@ -204,12 +204,13 @@ void ieee80211_tkip_gen_rc4key(struct ieee80211_key *key, u8 *ta,
|
||||
/* Calculate per-packet key */
|
||||
if (key->u.tkip.iv16 == 0 || !key->u.tkip.tx_initialized) {
|
||||
/* IV16 wrapped around - perform TKIP phase 1 */
|
||||
tkip_mixing_phase1(ta, &key->key[ALG_TKIP_TEMP_ENCR_KEY],
|
||||
tkip_mixing_phase1(ta, &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY],
|
||||
key->u.tkip.iv32, key->u.tkip.p1k);
|
||||
key->u.tkip.tx_initialized = 1;
|
||||
}
|
||||
|
||||
tkip_mixing_phase2(key->u.tkip.p1k, &key->key[ALG_TKIP_TEMP_ENCR_KEY],
|
||||
tkip_mixing_phase2(key->u.tkip.p1k,
|
||||
&key->conf.key[ALG_TKIP_TEMP_ENCR_KEY],
|
||||
key->u.tkip.iv16, rc4key);
|
||||
}
|
||||
|
||||
@ -237,7 +238,8 @@ void ieee80211_tkip_encrypt_data(struct crypto_blkcipher *tfm,
|
||||
int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
|
||||
struct ieee80211_key *key,
|
||||
u8 *payload, size_t payload_len, u8 *ta,
|
||||
int only_iv, int queue)
|
||||
int only_iv, int queue,
|
||||
u32 *out_iv32, u16 *out_iv16)
|
||||
{
|
||||
u32 iv32;
|
||||
u32 iv16;
|
||||
@ -266,7 +268,7 @@ int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
|
||||
if (!(keyid & (1 << 5)))
|
||||
return TKIP_DECRYPT_NO_EXT_IV;
|
||||
|
||||
if ((keyid >> 6) != key->keyidx)
|
||||
if ((keyid >> 6) != key->conf.keyidx)
|
||||
return TKIP_DECRYPT_INVALID_KEYIDX;
|
||||
|
||||
if (key->u.tkip.rx_initialized[queue] &&
|
||||
@ -293,7 +295,7 @@ int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
|
||||
key->u.tkip.iv32_rx[queue] != iv32) {
|
||||
key->u.tkip.rx_initialized[queue] = 1;
|
||||
/* IV16 wrapped around - perform TKIP phase 1 */
|
||||
tkip_mixing_phase1(ta, &key->key[ALG_TKIP_TEMP_ENCR_KEY],
|
||||
tkip_mixing_phase1(ta, &key->conf.key[ALG_TKIP_TEMP_ENCR_KEY],
|
||||
iv32, key->u.tkip.p1k_rx[queue]);
|
||||
#ifdef CONFIG_TKIP_DEBUG
|
||||
{
|
||||
@ -302,7 +304,8 @@ int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
|
||||
" TK=", MAC_ARG(ta));
|
||||
for (i = 0; i < 16; i++)
|
||||
printk("%02x ",
|
||||
key->key[ALG_TKIP_TEMP_ENCR_KEY + i]);
|
||||
key->conf.key[
|
||||
ALG_TKIP_TEMP_ENCR_KEY + i]);
|
||||
printk("\n");
|
||||
printk(KERN_DEBUG "TKIP decrypt: P1K=");
|
||||
for (i = 0; i < 5; i++)
|
||||
@ -313,7 +316,7 @@ int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
|
||||
}
|
||||
|
||||
tkip_mixing_phase2(key->u.tkip.p1k_rx[queue],
|
||||
&key->key[ALG_TKIP_TEMP_ENCR_KEY],
|
||||
&key->conf.key[ALG_TKIP_TEMP_ENCR_KEY],
|
||||
iv16, rc4key);
|
||||
#ifdef CONFIG_TKIP_DEBUG
|
||||
{
|
||||
@ -328,11 +331,14 @@ int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
|
||||
res = ieee80211_wep_decrypt_data(tfm, rc4key, 16, pos, payload_len - 12);
|
||||
done:
|
||||
if (res == TKIP_DECRYPT_OK) {
|
||||
/* FIX: these should be updated only after Michael MIC has been
|
||||
* verified */
|
||||
/* Record previously received IV */
|
||||
key->u.tkip.iv32_rx[queue] = iv32;
|
||||
key->u.tkip.iv16_rx[queue] = iv16;
|
||||
/*
|
||||
* Record previously received IV, will be copied into the
|
||||
* key information after MIC verification. It is possible
|
||||
* that we don't catch replays of fragments but that's ok
|
||||
* because the Michael MIC verication will then fail.
|
||||
*/
|
||||
*out_iv32 = iv32;
|
||||
*out_iv16 = iv16;
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -31,6 +31,7 @@ enum {
|
||||
int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
|
||||
struct ieee80211_key *key,
|
||||
u8 *payload, size_t payload_len, u8 *ta,
|
||||
int only_iv, int queue);
|
||||
int only_iv, int queue,
|
||||
u32 *out_iv32, u16 *out_iv16);
|
||||
|
||||
#endif /* TKIP_H */
|
||||
|
1898
package/mac80211/src/mac80211/tx.c
Normal file
1898
package/mac80211/src/mac80211/tx.c
Normal file
File diff suppressed because it is too large
Load Diff
485
package/mac80211/src/mac80211/util.c
Normal file
485
package/mac80211/src/mac80211/util.c
Normal file
@ -0,0 +1,485 @@
|
||||
/*
|
||||
* Copyright 2002-2005, Instant802 Networks, Inc.
|
||||
* Copyright 2005-2006, Devicescape Software, Inc.
|
||||
* Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
|
||||
* Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* utilities for mac80211
|
||||
*/
|
||||
|
||||
#include <net/mac80211.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/if_arp.h>
|
||||
#include <linux/wireless.h>
|
||||
#include <linux/bitmap.h>
|
||||
#include <net/cfg80211.h>
|
||||
|
||||
#include "ieee80211_i.h"
|
||||
#include "ieee80211_rate.h"
|
||||
#include "wme.h"
|
||||
|
||||
/* privid for wiphys to determine whether they belong to us or not */
|
||||
void *mac80211_wiphy_privid = &mac80211_wiphy_privid;
|
||||
|
||||
/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
|
||||
/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
|
||||
const unsigned char rfc1042_header[] =
|
||||
{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
|
||||
|
||||
/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
|
||||
const unsigned char bridge_tunnel_header[] =
|
||||
{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
|
||||
|
||||
/* No encapsulation header if EtherType < 0x600 (=length) */
|
||||
static const unsigned char eapol_header[] =
|
||||
{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x88, 0x8e };
|
||||
|
||||
|
||||
static int rate_list_match(const int *rate_list, int rate)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!rate_list)
|
||||
return 0;
|
||||
|
||||
for (i = 0; rate_list[i] >= 0; i++)
|
||||
if (rate_list[i] == rate)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ieee80211_prepare_rates(struct ieee80211_local *local,
|
||||
struct ieee80211_hw_mode *mode)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < mode->num_rates; i++) {
|
||||
struct ieee80211_rate *rate = &mode->rates[i];
|
||||
|
||||
rate->flags &= ~(IEEE80211_RATE_SUPPORTED |
|
||||
IEEE80211_RATE_BASIC);
|
||||
|
||||
if (local->supp_rates[mode->mode]) {
|
||||
if (!rate_list_match(local->supp_rates[mode->mode],
|
||||
rate->rate))
|
||||
continue;
|
||||
}
|
||||
|
||||
rate->flags |= IEEE80211_RATE_SUPPORTED;
|
||||
|
||||
/* Use configured basic rate set if it is available. If not,
|
||||
* use defaults that are sane for most cases. */
|
||||
if (local->basic_rates[mode->mode]) {
|
||||
if (rate_list_match(local->basic_rates[mode->mode],
|
||||
rate->rate))
|
||||
rate->flags |= IEEE80211_RATE_BASIC;
|
||||
} else switch (mode->mode) {
|
||||
case MODE_IEEE80211A:
|
||||
if (rate->rate == 60 || rate->rate == 120 ||
|
||||
rate->rate == 240)
|
||||
rate->flags |= IEEE80211_RATE_BASIC;
|
||||
break;
|
||||
case MODE_IEEE80211B:
|
||||
if (rate->rate == 10 || rate->rate == 20)
|
||||
rate->flags |= IEEE80211_RATE_BASIC;
|
||||
break;
|
||||
case MODE_IEEE80211G:
|
||||
if (rate->rate == 10 || rate->rate == 20 ||
|
||||
rate->rate == 55 || rate->rate == 110)
|
||||
rate->flags |= IEEE80211_RATE_BASIC;
|
||||
break;
|
||||
case NUM_IEEE80211_MODES:
|
||||
/* not useful */
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set ERP and MANDATORY flags based on phymode */
|
||||
switch (mode->mode) {
|
||||
case MODE_IEEE80211A:
|
||||
if (rate->rate == 60 || rate->rate == 120 ||
|
||||
rate->rate == 240)
|
||||
rate->flags |= IEEE80211_RATE_MANDATORY;
|
||||
break;
|
||||
case MODE_IEEE80211B:
|
||||
if (rate->rate == 10)
|
||||
rate->flags |= IEEE80211_RATE_MANDATORY;
|
||||
break;
|
||||
case MODE_IEEE80211G:
|
||||
if (rate->rate == 10 || rate->rate == 20 ||
|
||||
rate->rate == 55 || rate->rate == 110 ||
|
||||
rate->rate == 60 || rate->rate == 120 ||
|
||||
rate->rate == 240)
|
||||
rate->flags |= IEEE80211_RATE_MANDATORY;
|
||||
break;
|
||||
case NUM_IEEE80211_MODES:
|
||||
/* not useful */
|
||||
break;
|
||||
}
|
||||
if (ieee80211_is_erp_rate(mode->mode, rate->rate))
|
||||
rate->flags |= IEEE80211_RATE_ERP;
|
||||
}
|
||||
}
|
||||
|
||||
u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len)
|
||||
{
|
||||
u16 fc;
|
||||
|
||||
if (len < 24)
|
||||
return NULL;
|
||||
|
||||
fc = le16_to_cpu(hdr->frame_control);
|
||||
|
||||
switch (fc & IEEE80211_FCTL_FTYPE) {
|
||||
case IEEE80211_FTYPE_DATA:
|
||||
switch (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) {
|
||||
case IEEE80211_FCTL_TODS:
|
||||
return hdr->addr1;
|
||||
case (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS):
|
||||
return NULL;
|
||||
case IEEE80211_FCTL_FROMDS:
|
||||
return hdr->addr2;
|
||||
case 0:
|
||||
return hdr->addr3;
|
||||
}
|
||||
break;
|
||||
case IEEE80211_FTYPE_MGMT:
|
||||
return hdr->addr3;
|
||||
case IEEE80211_FTYPE_CTL:
|
||||
if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)
|
||||
return hdr->addr1;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int ieee80211_get_hdrlen(u16 fc)
|
||||
{
|
||||
int hdrlen = 24;
|
||||
|
||||
switch (fc & IEEE80211_FCTL_FTYPE) {
|
||||
case IEEE80211_FTYPE_DATA:
|
||||
if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
|
||||
hdrlen = 30; /* Addr4 */
|
||||
/*
|
||||
* The QoS Control field is two bytes and its presence is
|
||||
* indicated by the IEEE80211_STYPE_QOS_DATA bit. Add 2 to
|
||||
* hdrlen if that bit is set.
|
||||
* This works by masking out the bit and shifting it to
|
||||
* bit position 1 so the result has the value 0 or 2.
|
||||
*/
|
||||
hdrlen += (fc & IEEE80211_STYPE_QOS_DATA)
|
||||
>> (ilog2(IEEE80211_STYPE_QOS_DATA)-1);
|
||||
break;
|
||||
case IEEE80211_FTYPE_CTL:
|
||||
/*
|
||||
* ACK and CTS are 10 bytes, all others 16. To see how
|
||||
* to get this condition consider
|
||||
* subtype mask: 0b0000000011110000 (0x00F0)
|
||||
* ACK subtype: 0b0000000011010000 (0x00D0)
|
||||
* CTS subtype: 0b0000000011000000 (0x00C0)
|
||||
* bits that matter: ^^^ (0x00E0)
|
||||
* value of those: 0b0000000011000000 (0x00C0)
|
||||
*/
|
||||
if ((fc & 0xE0) == 0xC0)
|
||||
hdrlen = 10;
|
||||
else
|
||||
hdrlen = 16;
|
||||
break;
|
||||
}
|
||||
|
||||
return hdrlen;
|
||||
}
|
||||
EXPORT_SYMBOL(ieee80211_get_hdrlen);
|
||||
|
||||
int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb)
|
||||
{
|
||||
const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *) skb->data;
|
||||
int hdrlen;
|
||||
|
||||
if (unlikely(skb->len < 10))
|
||||
return 0;
|
||||
hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control));
|
||||
if (unlikely(hdrlen > skb->len))
|
||||
return 0;
|
||||
return hdrlen;
|
||||
}
|
||||
EXPORT_SYMBOL(ieee80211_get_hdrlen_from_skb);
|
||||
|
||||
int ieee80211_is_eapol(const struct sk_buff *skb)
|
||||
{
|
||||
const struct ieee80211_hdr *hdr;
|
||||
u16 fc;
|
||||
int hdrlen;
|
||||
|
||||
if (unlikely(skb->len < 10))
|
||||
return 0;
|
||||
|
||||
hdr = (const struct ieee80211_hdr *) skb->data;
|
||||
fc = le16_to_cpu(hdr->frame_control);
|
||||
|
||||
if (unlikely(!WLAN_FC_DATA_PRESENT(fc)))
|
||||
return 0;
|
||||
|
||||
hdrlen = ieee80211_get_hdrlen(fc);
|
||||
|
||||
if (unlikely(skb->len >= hdrlen + sizeof(eapol_header) &&
|
||||
memcmp(skb->data + hdrlen, eapol_header,
|
||||
sizeof(eapol_header)) == 0))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx)
|
||||
{
|
||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
|
||||
|
||||
hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
|
||||
if (tx->u.tx.extra_frag) {
|
||||
struct ieee80211_hdr *fhdr;
|
||||
int i;
|
||||
for (i = 0; i < tx->u.tx.num_extra_frag; i++) {
|
||||
fhdr = (struct ieee80211_hdr *)
|
||||
tx->u.tx.extra_frag[i]->data;
|
||||
fhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
|
||||
int rate, int erp, int short_preamble)
|
||||
{
|
||||
int dur;
|
||||
|
||||
/* calculate duration (in microseconds, rounded up to next higher
|
||||
* integer if it includes a fractional microsecond) to send frame of
|
||||
* len bytes (does not include FCS) at the given rate. Duration will
|
||||
* also include SIFS.
|
||||
*
|
||||
* rate is in 100 kbps, so divident is multiplied by 10 in the
|
||||
* DIV_ROUND_UP() operations.
|
||||
*/
|
||||
|
||||
if (local->hw.conf.phymode == MODE_IEEE80211A || erp) {
|
||||
/*
|
||||
* OFDM:
|
||||
*
|
||||
* N_DBPS = DATARATE x 4
|
||||
* N_SYM = Ceiling((16+8xLENGTH+6) / N_DBPS)
|
||||
* (16 = SIGNAL time, 6 = tail bits)
|
||||
* TXTIME = T_PREAMBLE + T_SIGNAL + T_SYM x N_SYM + Signal Ext
|
||||
*
|
||||
* T_SYM = 4 usec
|
||||
* 802.11a - 17.5.2: aSIFSTime = 16 usec
|
||||
* 802.11g - 19.8.4: aSIFSTime = 10 usec +
|
||||
* signal ext = 6 usec
|
||||
*/
|
||||
dur = 16; /* SIFS + signal ext */
|
||||
dur += 16; /* 17.3.2.3: T_PREAMBLE = 16 usec */
|
||||
dur += 4; /* 17.3.2.3: T_SIGNAL = 4 usec */
|
||||
dur += 4 * DIV_ROUND_UP((16 + 8 * (len + 4) + 6) * 10,
|
||||
4 * rate); /* T_SYM x N_SYM */
|
||||
} else {
|
||||
/*
|
||||
* 802.11b or 802.11g with 802.11b compatibility:
|
||||
* 18.3.4: TXTIME = PreambleLength + PLCPHeaderTime +
|
||||
* Ceiling(((LENGTH+PBCC)x8)/DATARATE). PBCC=0.
|
||||
*
|
||||
* 802.11 (DS): 15.3.3, 802.11b: 18.3.4
|
||||
* aSIFSTime = 10 usec
|
||||
* aPreambleLength = 144 usec or 72 usec with short preamble
|
||||
* aPLCPHeaderLength = 48 usec or 24 usec with short preamble
|
||||
*/
|
||||
dur = 10; /* aSIFSTime = 10 usec */
|
||||
dur += short_preamble ? (72 + 24) : (144 + 48);
|
||||
|
||||
dur += DIV_ROUND_UP(8 * (len + 4) * 10, rate);
|
||||
}
|
||||
|
||||
return dur;
|
||||
}
|
||||
|
||||
/* Exported duration function for driver use */
|
||||
__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id,
|
||||
size_t frame_len, int rate)
|
||||
{
|
||||
struct ieee80211_local *local = hw_to_local(hw);
|
||||
struct net_device *bdev = dev_get_by_index(if_id);
|
||||
struct ieee80211_sub_if_data *sdata;
|
||||
u16 dur;
|
||||
int erp;
|
||||
|
||||
if (unlikely(!bdev))
|
||||
return 0;
|
||||
|
||||
sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
|
||||
erp = ieee80211_is_erp_rate(hw->conf.phymode, rate);
|
||||
dur = ieee80211_frame_duration(local, frame_len, rate,
|
||||
erp, sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE);
|
||||
|
||||
dev_put(bdev);
|
||||
return cpu_to_le16(dur);
|
||||
}
|
||||
EXPORT_SYMBOL(ieee80211_generic_frame_duration);
|
||||
|
||||
__le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id,
|
||||
size_t frame_len,
|
||||
const struct ieee80211_tx_control *frame_txctl)
|
||||
{
|
||||
struct ieee80211_local *local = hw_to_local(hw);
|
||||
struct ieee80211_rate *rate;
|
||||
struct net_device *bdev = dev_get_by_index(if_id);
|
||||
struct ieee80211_sub_if_data *sdata;
|
||||
int short_preamble;
|
||||
int erp;
|
||||
u16 dur;
|
||||
|
||||
if (unlikely(!bdev))
|
||||
return 0;
|
||||
|
||||
sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
|
||||
short_preamble = sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE;
|
||||
|
||||
rate = frame_txctl->rts_rate;
|
||||
erp = !!(rate->flags & IEEE80211_RATE_ERP);
|
||||
|
||||
/* CTS duration */
|
||||
dur = ieee80211_frame_duration(local, 10, rate->rate,
|
||||
erp, short_preamble);
|
||||
/* Data frame duration */
|
||||
dur += ieee80211_frame_duration(local, frame_len, rate->rate,
|
||||
erp, short_preamble);
|
||||
/* ACK duration */
|
||||
dur += ieee80211_frame_duration(local, 10, rate->rate,
|
||||
erp, short_preamble);
|
||||
|
||||
dev_put(bdev);
|
||||
return cpu_to_le16(dur);
|
||||
}
|
||||
EXPORT_SYMBOL(ieee80211_rts_duration);
|
||||
|
||||
__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id,
|
||||
size_t frame_len,
|
||||
const struct ieee80211_tx_control *frame_txctl)
|
||||
{
|
||||
struct ieee80211_local *local = hw_to_local(hw);
|
||||
struct ieee80211_rate *rate;
|
||||
struct net_device *bdev = dev_get_by_index(if_id);
|
||||
struct ieee80211_sub_if_data *sdata;
|
||||
int short_preamble;
|
||||
int erp;
|
||||
u16 dur;
|
||||
|
||||
if (unlikely(!bdev))
|
||||
return 0;
|
||||
|
||||
sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
|
||||
short_preamble = sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE;
|
||||
|
||||
rate = frame_txctl->rts_rate;
|
||||
erp = !!(rate->flags & IEEE80211_RATE_ERP);
|
||||
|
||||
/* Data frame duration */
|
||||
dur = ieee80211_frame_duration(local, frame_len, rate->rate,
|
||||
erp, short_preamble);
|
||||
if (!(frame_txctl->flags & IEEE80211_TXCTL_NO_ACK)) {
|
||||
/* ACK duration */
|
||||
dur += ieee80211_frame_duration(local, 10, rate->rate,
|
||||
erp, short_preamble);
|
||||
}
|
||||
|
||||
dev_put(bdev);
|
||||
return cpu_to_le16(dur);
|
||||
}
|
||||
EXPORT_SYMBOL(ieee80211_ctstoself_duration);
|
||||
|
||||
struct ieee80211_rate *
|
||||
ieee80211_get_rate(struct ieee80211_local *local, int phymode, int hw_rate)
|
||||
{
|
||||
struct ieee80211_hw_mode *mode;
|
||||
int r;
|
||||
|
||||
list_for_each_entry(mode, &local->modes_list, list) {
|
||||
if (mode->mode != phymode)
|
||||
continue;
|
||||
for (r = 0; r < mode->num_rates; r++) {
|
||||
struct ieee80211_rate *rate = &mode->rates[r];
|
||||
if (rate->val == hw_rate ||
|
||||
(rate->flags & IEEE80211_RATE_PREAMBLE2 &&
|
||||
rate->val2 == hw_rate))
|
||||
return rate;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue)
|
||||
{
|
||||
struct ieee80211_local *local = hw_to_local(hw);
|
||||
|
||||
if (test_and_clear_bit(IEEE80211_LINK_STATE_XOFF,
|
||||
&local->state[queue])) {
|
||||
if (test_bit(IEEE80211_LINK_STATE_PENDING,
|
||||
&local->state[queue]))
|
||||
tasklet_schedule(&local->tx_pending_tasklet);
|
||||
else
|
||||
if (!ieee80211_qdisc_installed(local->mdev)) {
|
||||
if (queue == 0)
|
||||
netif_wake_queue(local->mdev);
|
||||
} else
|
||||
__netif_schedule(local->mdev);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(ieee80211_wake_queue);
|
||||
|
||||
void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue)
|
||||
{
|
||||
struct ieee80211_local *local = hw_to_local(hw);
|
||||
|
||||
if (!ieee80211_qdisc_installed(local->mdev) && queue == 0)
|
||||
netif_stop_queue(local->mdev);
|
||||
set_bit(IEEE80211_LINK_STATE_XOFF, &local->state[queue]);
|
||||
}
|
||||
EXPORT_SYMBOL(ieee80211_stop_queue);
|
||||
|
||||
void ieee80211_start_queues(struct ieee80211_hw *hw)
|
||||
{
|
||||
struct ieee80211_local *local = hw_to_local(hw);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < local->hw.queues; i++)
|
||||
clear_bit(IEEE80211_LINK_STATE_XOFF, &local->state[i]);
|
||||
if (!ieee80211_qdisc_installed(local->mdev))
|
||||
netif_start_queue(local->mdev);
|
||||
}
|
||||
EXPORT_SYMBOL(ieee80211_start_queues);
|
||||
|
||||
void ieee80211_stop_queues(struct ieee80211_hw *hw)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < hw->queues; i++)
|
||||
ieee80211_stop_queue(hw, i);
|
||||
}
|
||||
EXPORT_SYMBOL(ieee80211_stop_queues);
|
||||
|
||||
void ieee80211_wake_queues(struct ieee80211_hw *hw)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < hw->queues; i++)
|
||||
ieee80211_wake_queue(hw, i);
|
||||
}
|
||||
EXPORT_SYMBOL(ieee80211_wake_queues);
|
@ -63,11 +63,11 @@ static inline int ieee80211_wep_weak_iv(u32 iv, int keylen)
|
||||
}
|
||||
|
||||
|
||||
void ieee80211_wep_get_iv(struct ieee80211_local *local,
|
||||
struct ieee80211_key *key, u8 *iv)
|
||||
static void ieee80211_wep_get_iv(struct ieee80211_local *local,
|
||||
struct ieee80211_key *key, u8 *iv)
|
||||
{
|
||||
local->wep_iv++;
|
||||
if (ieee80211_wep_weak_iv(local->wep_iv, key->keylen))
|
||||
if (ieee80211_wep_weak_iv(local->wep_iv, key->conf.keylen))
|
||||
local->wep_iv += 0x0100;
|
||||
|
||||
if (!iv)
|
||||
@ -76,13 +76,13 @@ void ieee80211_wep_get_iv(struct ieee80211_local *local,
|
||||
*iv++ = (local->wep_iv >> 16) & 0xff;
|
||||
*iv++ = (local->wep_iv >> 8) & 0xff;
|
||||
*iv++ = local->wep_iv & 0xff;
|
||||
*iv++ = key->keyidx << 6;
|
||||
*iv++ = key->conf.keyidx << 6;
|
||||
}
|
||||
|
||||
|
||||
u8 * ieee80211_wep_add_iv(struct ieee80211_local *local,
|
||||
struct sk_buff *skb,
|
||||
struct ieee80211_key *key)
|
||||
static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local,
|
||||
struct sk_buff *skb,
|
||||
struct ieee80211_key *key)
|
||||
{
|
||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
|
||||
u16 fc;
|
||||
@ -109,9 +109,9 @@ u8 * ieee80211_wep_add_iv(struct ieee80211_local *local,
|
||||
}
|
||||
|
||||
|
||||
void ieee80211_wep_remove_iv(struct ieee80211_local *local,
|
||||
struct sk_buff *skb,
|
||||
struct ieee80211_key *key)
|
||||
static void ieee80211_wep_remove_iv(struct ieee80211_local *local,
|
||||
struct sk_buff *skb,
|
||||
struct ieee80211_key *key)
|
||||
{
|
||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
|
||||
u16 fc;
|
||||
@ -159,10 +159,10 @@ int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb,
|
||||
u8 *rc4key, *iv;
|
||||
size_t len;
|
||||
|
||||
if (!key || key->alg != ALG_WEP)
|
||||
if (!key || key->conf.alg != ALG_WEP)
|
||||
return -1;
|
||||
|
||||
klen = 3 + key->keylen;
|
||||
klen = 3 + key->conf.keylen;
|
||||
rc4key = kmalloc(klen, GFP_ATOMIC);
|
||||
if (!rc4key)
|
||||
return -1;
|
||||
@ -179,7 +179,7 @@ int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb,
|
||||
memcpy(rc4key, iv, 3);
|
||||
|
||||
/* Copy rest of the WEP key (the secret part) */
|
||||
memcpy(rc4key + 3, key->key, key->keylen);
|
||||
memcpy(rc4key + 3, key->conf.key, key->conf.keylen);
|
||||
|
||||
/* Add room for ICV */
|
||||
skb_put(skb, WEP_ICV_LEN);
|
||||
@ -251,10 +251,10 @@ int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
|
||||
|
||||
keyidx = skb->data[hdrlen + 3] >> 6;
|
||||
|
||||
if (!key || keyidx != key->keyidx || key->alg != ALG_WEP)
|
||||
if (!key || keyidx != key->conf.keyidx || key->conf.alg != ALG_WEP)
|
||||
return -1;
|
||||
|
||||
klen = 3 + key->keylen;
|
||||
klen = 3 + key->conf.keylen;
|
||||
|
||||
rc4key = kmalloc(klen, GFP_ATOMIC);
|
||||
if (!rc4key)
|
||||
@ -264,7 +264,7 @@ int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
|
||||
memcpy(rc4key, skb->data + hdrlen, 3);
|
||||
|
||||
/* Copy rest of the WEP key (the secret part) */
|
||||
memcpy(rc4key + 3, key->key, key->keylen);
|
||||
memcpy(rc4key + 3, key->conf.key, key->conf.keylen);
|
||||
|
||||
if (ieee80211_wep_decrypt_data(local->wep_rx_tfm, rc4key, klen,
|
||||
skb->data + hdrlen + WEP_IV_LEN,
|
||||
@ -286,25 +286,6 @@ int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
|
||||
}
|
||||
|
||||
|
||||
int ieee80211_wep_get_keyidx(struct sk_buff *skb)
|
||||
{
|
||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
|
||||
u16 fc;
|
||||
int hdrlen;
|
||||
|
||||
fc = le16_to_cpu(hdr->frame_control);
|
||||
if (!(fc & IEEE80211_FCTL_PROTECTED))
|
||||
return -1;
|
||||
|
||||
hdrlen = ieee80211_get_hdrlen(fc);
|
||||
|
||||
if (skb->len < 8 + hdrlen)
|
||||
return -1;
|
||||
|
||||
return skb->data[hdrlen + 3] >> 6;
|
||||
}
|
||||
|
||||
|
||||
u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key)
|
||||
{
|
||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
|
||||
@ -321,8 +302,83 @@ u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key)
|
||||
ivpos = skb->data + hdrlen;
|
||||
iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2];
|
||||
|
||||
if (ieee80211_wep_weak_iv(iv, key->keylen))
|
||||
if (ieee80211_wep_weak_iv(iv, key->conf.keylen))
|
||||
return ivpos;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ieee80211_txrx_result
|
||||
ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx)
|
||||
{
|
||||
if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA &&
|
||||
((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT ||
|
||||
(rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH))
|
||||
return TXRX_CONTINUE;
|
||||
|
||||
if (!(rx->u.rx.status->flag & RX_FLAG_DECRYPTED)) {
|
||||
if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) {
|
||||
if (net_ratelimit())
|
||||
printk(KERN_DEBUG "%s: RX WEP frame, decrypt "
|
||||
"failed\n", rx->dev->name);
|
||||
return TXRX_DROP;
|
||||
}
|
||||
} else if (!(rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED)) {
|
||||
ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key);
|
||||
/* remove ICV */
|
||||
skb_trim(rx->skb, rx->skb->len - 4);
|
||||
}
|
||||
|
||||
return TXRX_CONTINUE;
|
||||
}
|
||||
|
||||
static int wep_encrypt_skb(struct ieee80211_txrx_data *tx, struct sk_buff *skb)
|
||||
{
|
||||
if (!(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) {
|
||||
if (ieee80211_wep_encrypt(tx->local, skb, tx->key))
|
||||
return -1;
|
||||
} else {
|
||||
tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx;
|
||||
if (tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) {
|
||||
if (!ieee80211_wep_add_iv(tx->local, skb, tx->key))
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ieee80211_txrx_result
|
||||
ieee80211_crypto_wep_encrypt(struct ieee80211_txrx_data *tx)
|
||||
{
|
||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
|
||||
u16 fc;
|
||||
|
||||
fc = le16_to_cpu(hdr->frame_control);
|
||||
|
||||
if (((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA &&
|
||||
((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT ||
|
||||
(fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH)))
|
||||
return TXRX_CONTINUE;
|
||||
|
||||
tx->u.tx.control->iv_len = WEP_IV_LEN;
|
||||
tx->u.tx.control->icv_len = WEP_ICV_LEN;
|
||||
ieee80211_tx_set_iswep(tx);
|
||||
|
||||
if (wep_encrypt_skb(tx, tx->skb) < 0) {
|
||||
I802_DEBUG_INC(tx->local->tx_handlers_drop_wep);
|
||||
return TXRX_DROP;
|
||||
}
|
||||
|
||||
if (tx->u.tx.extra_frag) {
|
||||
int i;
|
||||
for (i = 0; i < tx->u.tx.num_extra_frag; i++) {
|
||||
if (wep_encrypt_skb(tx, tx->u.tx.extra_frag[i]) < 0) {
|
||||
I802_DEBUG_INC(tx->local->
|
||||
tx_handlers_drop_wep);
|
||||
return TXRX_DROP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TXRX_CONTINUE;
|
||||
}
|
||||
|
@ -18,14 +18,6 @@
|
||||
|
||||
int ieee80211_wep_init(struct ieee80211_local *local);
|
||||
void ieee80211_wep_free(struct ieee80211_local *local);
|
||||
void ieee80211_wep_get_iv(struct ieee80211_local *local,
|
||||
struct ieee80211_key *key, u8 *iv);
|
||||
u8 * ieee80211_wep_add_iv(struct ieee80211_local *local,
|
||||
struct sk_buff *skb,
|
||||
struct ieee80211_key *key);
|
||||
void ieee80211_wep_remove_iv(struct ieee80211_local *local,
|
||||
struct sk_buff *skb,
|
||||
struct ieee80211_key *key);
|
||||
void ieee80211_wep_encrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
|
||||
size_t klen, u8 *data, size_t data_len);
|
||||
int ieee80211_wep_decrypt_data(struct crypto_blkcipher *tfm, u8 *rc4key,
|
||||
@ -34,7 +26,11 @@ int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb,
|
||||
struct ieee80211_key *key);
|
||||
int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
|
||||
struct ieee80211_key *key);
|
||||
int ieee80211_wep_get_keyidx(struct sk_buff *skb);
|
||||
u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key);
|
||||
|
||||
ieee80211_txrx_result
|
||||
ieee80211_crypto_wep_decrypt(struct ieee80211_txrx_data *rx);
|
||||
ieee80211_txrx_result
|
||||
ieee80211_crypto_wep_encrypt(struct ieee80211_txrx_data *tx);
|
||||
|
||||
#endif /* WEP_H */
|
||||
|
@ -18,78 +18,6 @@
|
||||
#include "ieee80211_i.h"
|
||||
#include "wme.h"
|
||||
|
||||
static inline int WLAN_FC_IS_QOS_DATA(u16 fc)
|
||||
{
|
||||
return (fc & 0x8C) == 0x88;
|
||||
}
|
||||
|
||||
|
||||
ieee80211_txrx_result
|
||||
ieee80211_rx_h_parse_qos(struct ieee80211_txrx_data *rx)
|
||||
{
|
||||
u8 *data = rx->skb->data;
|
||||
int tid;
|
||||
unsigned int is_agg_frame = 0;
|
||||
|
||||
/* does the frame have a qos control field? */
|
||||
if (WLAN_FC_IS_QOS_DATA(rx->fc)) {
|
||||
u8 *qc = data + ieee80211_get_hdrlen(rx->fc) - QOS_CONTROL_LEN;
|
||||
|
||||
/* frame has qos control */
|
||||
rx->u.rx.qos_control = le16_to_cpu(*((__le16*)qc));
|
||||
tid = rx->u.rx.qos_control & QOS_CONTROL_TID_MASK;
|
||||
if (rx->u.rx.qos_control &
|
||||
IEEE80211_QOS_CONTROL_A_MSDU_PRESENT)
|
||||
is_agg_frame = 1;
|
||||
} else {
|
||||
if (unlikely((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT)) {
|
||||
/* Separate TID for management frames */
|
||||
tid = NUM_RX_DATA_QUEUES - 1;
|
||||
} else {
|
||||
/* no qos control present */
|
||||
tid = 0; /* 802.1d - Best Effort */
|
||||
}
|
||||
rx->u.rx.qos_control = 0;
|
||||
}
|
||||
#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
|
||||
I802_DEBUG_INC(rx->local->wme_rx_queue[tid]);
|
||||
if (rx->sta) {
|
||||
I802_DEBUG_INC(rx->sta->wme_rx_queue[tid]);
|
||||
}
|
||||
#endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
|
||||
|
||||
rx->u.rx.queue = tid;
|
||||
rx->u.rx.is_agg_frame = is_agg_frame;
|
||||
/* Set skb->priority to 1d tag if highest order bit of TID is not set.
|
||||
* For now, set skb->priority to 0 for other cases. */
|
||||
rx->skb->priority = (tid > 7) ? 0 : tid;
|
||||
|
||||
return TXRX_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
ieee80211_txrx_result
|
||||
ieee80211_rx_h_remove_qos_control(struct ieee80211_txrx_data *rx)
|
||||
{
|
||||
u16 fc = rx->fc;
|
||||
u8 *data = rx->skb->data;
|
||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) data;
|
||||
|
||||
if (!WLAN_FC_IS_QOS_DATA(fc))
|
||||
return TXRX_CONTINUE;
|
||||
|
||||
/* remove the qos control field, update frame type and meta-data */
|
||||
memmove(data + 2, data, ieee80211_get_hdrlen(fc) - 2);
|
||||
hdr = (struct ieee80211_hdr *) skb_pull(rx->skb, 2);
|
||||
/* change frame type to non QOS */
|
||||
rx->fc = fc &= ~IEEE80211_STYPE_QOS_DATA;
|
||||
hdr->frame_control = cpu_to_le16(fc);
|
||||
|
||||
return TXRX_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_NET_SCHED
|
||||
/* maximum number of hardware queues we support. */
|
||||
#define TC_80211_MAX_QUEUES 8
|
||||
|
||||
@ -166,13 +94,9 @@ static inline int wme_downgrade_ac(struct sk_buff *skb)
|
||||
static inline int classify80211(struct sk_buff *skb, struct Qdisc *qd)
|
||||
{
|
||||
struct ieee80211_local *local = wdev_priv(qd->dev->ieee80211_ptr);
|
||||
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(qd->dev);
|
||||
struct ieee80211_if_sta *ifsta = &sdata->u.sta;
|
||||
struct ieee80211_tx_packet_data *pkt_data =
|
||||
(struct ieee80211_tx_packet_data *) skb->cb;
|
||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
|
||||
unsigned short fc = le16_to_cpu(hdr->frame_control);
|
||||
int qos, tsid, dir;
|
||||
int qos;
|
||||
const int ieee802_1d_to_ac[8] = { 2, 3, 3, 2, 1, 1, 0, 0 };
|
||||
|
||||
/* see if frame is data or non data frame */
|
||||
@ -182,12 +106,8 @@ static inline int classify80211(struct sk_buff *skb, struct Qdisc *qd)
|
||||
return IEEE80211_TX_QUEUE_DATA0;
|
||||
}
|
||||
|
||||
if (unlikely(pkt_data->mgmt_iface)) {
|
||||
/* Data frames from hostapd (mainly, EAPOL) use AC_VO
|
||||
* and they will include QoS control fields if
|
||||
* the target STA is using WME. */
|
||||
skb->priority = 7;
|
||||
return ieee802_1d_to_ac[skb->priority];
|
||||
if (0 /* injected */) {
|
||||
/* use AC from radiotap */
|
||||
}
|
||||
|
||||
/* is this a QoS frame? */
|
||||
@ -201,34 +121,9 @@ static inline int classify80211(struct sk_buff *skb, struct Qdisc *qd)
|
||||
/* use the data classifier to determine what 802.1d tag the
|
||||
* data frame has */
|
||||
skb->priority = classify_1d(skb, qd);
|
||||
tsid = 8 + skb->priority;
|
||||
|
||||
/* FIXME: only uplink needs to be checked for Tx */
|
||||
dir = STA_TS_UPLINK;
|
||||
|
||||
if ((sdata->type == IEEE80211_IF_TYPE_STA) &&
|
||||
(local->wmm_acm & BIT(skb->priority))) {
|
||||
switch (ifsta->ts_data[tsid][dir].status) {
|
||||
case TS_STATUS_ACTIVE:
|
||||
/* if TS Management is enabled, update used_time */
|
||||
ifsta->ts_data[tsid][dir].used_time_usec +=
|
||||
ifsta->MPDUExchangeTime;
|
||||
break;
|
||||
case TS_STATUS_THROTTLING:
|
||||
/* if admitted time is used up, refuse to send more */
|
||||
if (net_ratelimit())
|
||||
printk(KERN_DEBUG "QoS packet throttling\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* in case we are a client verify acm is not set for this ac */
|
||||
while ((local->wmm_acm & BIT(skb->priority)) &&
|
||||
!((sdata->type == IEEE80211_IF_TYPE_STA) &&
|
||||
(ifsta->ts_data[skb->priority + EDCA_TSID_MIN][dir].status
|
||||
== TS_STATUS_ACTIVE))) {
|
||||
while (unlikely(local->wmm_acm & BIT(skb->priority))) {
|
||||
if (wme_downgrade_ac(skb)) {
|
||||
/* No AC with lower priority has acm=0, drop packet. */
|
||||
return -1;
|
||||
@ -251,7 +146,7 @@ static int wme_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd)
|
||||
struct Qdisc *qdisc;
|
||||
int err, queue;
|
||||
|
||||
if (pkt_data->requeue) {
|
||||
if (pkt_data->flags & IEEE80211_TXPD_REQUEUE) {
|
||||
skb_queue_tail(&q->requeued[pkt_data->queue], skb);
|
||||
qd->q.qlen++;
|
||||
return 0;
|
||||
@ -458,7 +353,7 @@ static int wme_qdiscop_init(struct Qdisc *qd, struct rtattr *opt)
|
||||
skb_queue_head_init(&q->requeued[i]);
|
||||
q->queues[i] = qdisc_create_dflt(qd->dev, &pfifo_qdisc_ops,
|
||||
qd->handle);
|
||||
if (q->queues[i] == 0) {
|
||||
if (!q->queues[i]) {
|
||||
q->queues[i] = &noop_qdisc;
|
||||
printk(KERN_ERR "%s child qdisc %i creation failed", dev->name, i);
|
||||
}
|
||||
@ -709,4 +604,3 @@ void ieee80211_wme_unregister(void)
|
||||
{
|
||||
unregister_qdisc(&wme_qdisc_ops);
|
||||
}
|
||||
#endif /* CONFIG_NET_SCHED */
|
||||
|
@ -24,11 +24,10 @@
|
||||
|
||||
#define QOS_CONTROL_TAG1D_MASK 0x07
|
||||
|
||||
ieee80211_txrx_result
|
||||
ieee80211_rx_h_parse_qos(struct ieee80211_txrx_data *rx);
|
||||
|
||||
ieee80211_txrx_result
|
||||
ieee80211_rx_h_remove_qos_control(struct ieee80211_txrx_data *rx);
|
||||
static inline int WLAN_FC_IS_QOS_DATA(u16 fc)
|
||||
{
|
||||
return (fc & 0x8C) == 0x88;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NET_SCHED
|
||||
void ieee80211_install_qdisc(struct net_device *dev);
|
||||
|
@ -11,19 +11,13 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/compiler.h>
|
||||
#include <net/iw_handler.h>
|
||||
|
||||
#include <net/mac80211.h>
|
||||
#include "ieee80211_common.h"
|
||||
|
||||
#include "ieee80211_i.h"
|
||||
#include "michael.h"
|
||||
#include "tkip.h"
|
||||
#include "aes_ccm.h"
|
||||
#include "wpa.h"
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
#include "hostapd_ioctl.h"
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
|
||||
|
||||
static int ieee80211_get_hdr_info(const struct sk_buff *skb, u8 **sa, u8 **da,
|
||||
u8 *qos_tid, u8 **data, size_t *data_len)
|
||||
@ -88,24 +82,16 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx)
|
||||
|
||||
fc = tx->fc;
|
||||
|
||||
if (!tx->key || tx->key->alg != ALG_TKIP || skb->len < 24 ||
|
||||
if (!tx->key || tx->key->conf.alg != ALG_TKIP || skb->len < 24 ||
|
||||
!WLAN_FC_DATA_PRESENT(fc))
|
||||
return TXRX_CONTINUE;
|
||||
|
||||
if (ieee80211_get_hdr_info(skb, &sa, &da, &qos_tid, &data, &data_len))
|
||||
return TXRX_DROP;
|
||||
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
if ((tx->sta && tx->sta->wpa_trigger & WPA_TRIGGER_FAIL_TX_MIC) ||
|
||||
(!tx->u.tx.unicast &&
|
||||
tx->local->wpa_trigger & WPA_TRIGGER_FAIL_TX_MIC)) {
|
||||
wpa_test = 1;
|
||||
}
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
|
||||
if (!tx->key->force_sw_encrypt &&
|
||||
!tx->fragmented &&
|
||||
!(tx->local->hw.flags & IEEE80211_HW_TKIP_INCLUDE_MMIC) &&
|
||||
if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
|
||||
!(tx->flags & IEEE80211_TXRXD_FRAGMENTED) &&
|
||||
!(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) &&
|
||||
!wpa_test) {
|
||||
/* hwaccel - with no need for preallocated room for Michael MIC
|
||||
*/
|
||||
@ -128,31 +114,11 @@ ieee80211_tx_h_michael_mic_add(struct ieee80211_txrx_data *tx)
|
||||
#else
|
||||
authenticator = 1;
|
||||
#endif
|
||||
key = &tx->key->key[authenticator ? ALG_TKIP_TEMP_AUTH_TX_MIC_KEY :
|
||||
ALG_TKIP_TEMP_AUTH_RX_MIC_KEY];
|
||||
key = &tx->key->conf.key[authenticator ? ALG_TKIP_TEMP_AUTH_TX_MIC_KEY :
|
||||
ALG_TKIP_TEMP_AUTH_RX_MIC_KEY];
|
||||
mic = skb_put(skb, MICHAEL_MIC_LEN);
|
||||
michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic);
|
||||
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
if (tx->sta && tx->sta->wpa_trigger & WPA_TRIGGER_FAIL_TX_MIC) {
|
||||
printk(KERN_INFO "%s: WPA testing - corrupting TX Michael MIC "
|
||||
"for STA " MAC_FMT "\n",
|
||||
tx->dev->name, MAC_ARG(tx->sta->addr));
|
||||
tx->u.tx.control->key_idx = HW_KEY_IDX_INVALID;
|
||||
tx->sta->wpa_trigger &= ~WPA_TRIGGER_FAIL_TX_MIC;
|
||||
tx->wpa_test = 1;
|
||||
mic[0]++;
|
||||
} else if (!tx->u.tx.unicast &&
|
||||
tx->local->wpa_trigger & WPA_TRIGGER_FAIL_TX_MIC) {
|
||||
printk(KERN_INFO "%s: WPA testing - corrupting TX Michael MIC "
|
||||
"for Group Key\n", tx->dev->name);
|
||||
tx->u.tx.control->key_idx = HW_KEY_IDX_INVALID;
|
||||
tx->local->wpa_trigger &= ~WPA_TRIGGER_FAIL_TX_MIC;
|
||||
tx->wpa_test = 1;
|
||||
mic[0]++;
|
||||
}
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
|
||||
return TXRX_CONTINUE;
|
||||
}
|
||||
|
||||
@ -169,34 +135,16 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx)
|
||||
|
||||
fc = rx->fc;
|
||||
|
||||
/* If device handles decryption totally, skip this check */
|
||||
if ((rx->local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP) ||
|
||||
(rx->local->hw.flags & IEEE80211_HW_DEVICE_STRIPS_MIC))
|
||||
/*
|
||||
* No way to verify the MIC if the hardware stripped it
|
||||
*/
|
||||
if (rx->u.rx.status->flag & RX_FLAG_MMIC_STRIPPED)
|
||||
return TXRX_CONTINUE;
|
||||
|
||||
if (!rx->key || rx->key->alg != ALG_TKIP ||
|
||||
if (!rx->key || rx->key->conf.alg != ALG_TKIP ||
|
||||
!(rx->fc & IEEE80211_FCTL_PROTECTED) || !WLAN_FC_DATA_PRESENT(fc))
|
||||
return TXRX_CONTINUE;
|
||||
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
if (rx->sta && rx->sta->wpa_trigger & WPA_TRIGGER_FAIL_RX_MIC) {
|
||||
wpa_test = 1;
|
||||
}
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
|
||||
if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) &&
|
||||
!rx->key->force_sw_encrypt) {
|
||||
if (rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) {
|
||||
if (skb->len < MICHAEL_MIC_LEN)
|
||||
return TXRX_DROP;
|
||||
}
|
||||
/* Need to verify Michael MIC sometimes in software even when
|
||||
* hwaccel is used. Atheros ar5212: fragmented frames and QoS
|
||||
* frames. */
|
||||
if (!rx->fragmented && !wpa_test)
|
||||
goto remove_mic;
|
||||
}
|
||||
|
||||
if (ieee80211_get_hdr_info(skb, &sa, &da, &qos_tid, &data, &data_len)
|
||||
|| data_len < MICHAEL_MIC_LEN)
|
||||
return TXRX_DROP;
|
||||
@ -208,76 +156,28 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx)
|
||||
#else
|
||||
authenticator = 1;
|
||||
#endif
|
||||
key = &rx->key->key[authenticator ? ALG_TKIP_TEMP_AUTH_RX_MIC_KEY :
|
||||
ALG_TKIP_TEMP_AUTH_TX_MIC_KEY];
|
||||
key = &rx->key->conf.key[authenticator ? ALG_TKIP_TEMP_AUTH_RX_MIC_KEY :
|
||||
ALG_TKIP_TEMP_AUTH_TX_MIC_KEY];
|
||||
michael_mic(key, da, sa, qos_tid & 0x0f, data, data_len, mic);
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
if (rx->sta && rx->sta->wpa_trigger & WPA_TRIGGER_FAIL_RX_MIC) {
|
||||
printk(KERN_INFO "%s: WPA testing - corrupting RX Michael MIC "
|
||||
"for STA " MAC_FMT "\n",
|
||||
rx->dev->name, MAC_ARG(rx->sta->addr));
|
||||
rx->sta->wpa_trigger &= ~WPA_TRIGGER_FAIL_RX_MIC;
|
||||
mic[0]++;
|
||||
}
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
if (memcmp(mic, data + data_len, MICHAEL_MIC_LEN) != 0 || wpa_test) {
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
int i;
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
|
||||
if (!rx->u.rx.ra_match)
|
||||
if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
|
||||
return TXRX_DROP;
|
||||
|
||||
printk(KERN_DEBUG "%s: invalid Michael MIC in data frame from "
|
||||
MAC_FMT "\n", rx->dev->name, MAC_ARG(sa));
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
printk(KERN_DEBUG " received");
|
||||
for (i = 0; i < MICHAEL_MIC_LEN; i++)
|
||||
printk(" %02x", data[data_len + i]);
|
||||
printk(" expected");
|
||||
for (i = 0; i < MICHAEL_MIC_LEN; i++)
|
||||
printk(" %02x", mic[i]);
|
||||
printk("\n");
|
||||
printk(KERN_DEBUG " SA=" MAC_FMT " DA=" MAC_FMT " key",
|
||||
MAC_ARG(sa), MAC_ARG(da));
|
||||
for (i = 0; i < 8; i++)
|
||||
printk(" %02x", key[i]);
|
||||
printk(" (%d)\n", authenticator);
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
|
||||
do {
|
||||
struct ieee80211_hdr *hdr;
|
||||
union iwreq_data wrqu;
|
||||
char *buf = kmalloc(128, GFP_ATOMIC);
|
||||
if (!buf)
|
||||
break;
|
||||
|
||||
/* TODO: needed parameters: count, key type, TSC */
|
||||
hdr = (struct ieee80211_hdr *) skb->data;
|
||||
sprintf(buf, "MLME-MICHAELMICFAILURE.indication("
|
||||
"keyid=%d %scast addr=" MAC_FMT ")",
|
||||
rx->key->keyidx,
|
||||
hdr->addr1[0] & 0x01 ? "broad" : "uni",
|
||||
MAC_ARG(hdr->addr2));
|
||||
memset(&wrqu, 0, sizeof(wrqu));
|
||||
wrqu.data.length = strlen(buf);
|
||||
wireless_send_event(rx->dev, IWEVCUSTOM, &wrqu, buf);
|
||||
kfree(buf);
|
||||
} while (0);
|
||||
|
||||
if (!rx->local->apdev)
|
||||
return TXRX_DROP;
|
||||
|
||||
ieee80211_rx_mgmt(rx->local, rx->skb, rx->u.rx.status,
|
||||
ieee80211_msg_michael_mic_failure);
|
||||
|
||||
return TXRX_QUEUED;
|
||||
mac80211_ev_michael_mic_failure(rx->dev, rx->key->conf.keyidx,
|
||||
(void *) skb->data);
|
||||
return TXRX_DROP;
|
||||
}
|
||||
|
||||
remove_mic:
|
||||
/* remove Michael MIC from payload */
|
||||
skb_trim(skb, skb->len - MICHAEL_MIC_LEN);
|
||||
|
||||
/* update IV in key information to be able to detect replays */
|
||||
rx->key->u.tkip.iv32_rx[rx->u.rx.queue] = rx->u.rx.tkip_iv32;
|
||||
rx->key->u.tkip.iv16_rx[rx->u.rx.queue] = rx->u.rx.tkip_iv16;
|
||||
|
||||
return TXRX_CONTINUE;
|
||||
}
|
||||
|
||||
@ -295,7 +195,11 @@ static int tkip_encrypt_skb(struct ieee80211_txrx_data *tx,
|
||||
hdrlen = ieee80211_get_hdrlen(fc);
|
||||
len = skb->len - hdrlen;
|
||||
|
||||
tailneed = !tx->key->force_sw_encrypt ? 0 : TKIP_ICV_LEN;
|
||||
if (tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
|
||||
tailneed = 0;
|
||||
else
|
||||
tailneed = TKIP_ICV_LEN;
|
||||
|
||||
if ((skb_headroom(skb) < TKIP_IV_LEN ||
|
||||
skb_tailroom(skb) < tailneed)) {
|
||||
I802_DEBUG_INC(tx->local->tx_expand_skb_head);
|
||||
@ -308,31 +212,12 @@ static int tkip_encrypt_skb(struct ieee80211_txrx_data *tx,
|
||||
memmove(pos, pos + TKIP_IV_LEN, hdrlen);
|
||||
pos += hdrlen;
|
||||
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
if (test & WPA_TRIGGER_TX_REPLAY)
|
||||
goto skip_iv_inc;
|
||||
iv_inc:
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
|
||||
/* Increase IV for the frame */
|
||||
key->u.tkip.iv16++;
|
||||
if (key->u.tkip.iv16 == 0)
|
||||
key->u.tkip.iv32++;
|
||||
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
if (test & WPA_TRIGGER_TX_SKIP_SEQ) {
|
||||
test = 0;
|
||||
goto iv_inc;
|
||||
}
|
||||
skip_iv_inc:
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
|
||||
if (!tx->key->force_sw_encrypt
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
&& !tx->wpa_test
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
) {
|
||||
u32 flags = tx->local->hw.flags;
|
||||
if (tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) {
|
||||
hdr = (struct ieee80211_hdr *)skb->data;
|
||||
|
||||
/* hwaccel - with preallocated room for IV */
|
||||
@ -342,23 +227,7 @@ skip_iv_inc:
|
||||
0x7f),
|
||||
(u8) key->u.tkip.iv16);
|
||||
|
||||
if (flags & IEEE80211_HW_TKIP_REQ_PHASE2_KEY)
|
||||
ieee80211_tkip_gen_rc4key(key, hdr->addr2,
|
||||
tx->u.tx.control->tkip_key);
|
||||
else if (flags & IEEE80211_HW_TKIP_REQ_PHASE1_KEY) {
|
||||
if (key->u.tkip.iv16 == 0 ||
|
||||
!key->u.tkip.tx_initialized) {
|
||||
ieee80211_tkip_gen_phase1key(key, hdr->addr2,
|
||||
(u16 *)tx->u.tx.control->tkip_key);
|
||||
key->u.tkip.tx_initialized = 1;
|
||||
tx->u.tx.control->flags |=
|
||||
IEEE80211_TXCTL_TKIP_NEW_PHASE1_KEY;
|
||||
} else
|
||||
tx->u.tx.control->flags &=
|
||||
~IEEE80211_TXCTL_TKIP_NEW_PHASE1_KEY;
|
||||
}
|
||||
|
||||
tx->u.tx.control->key_idx = tx->key->hw_key_idx;
|
||||
tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -373,59 +242,27 @@ skip_iv_inc:
|
||||
|
||||
|
||||
ieee80211_txrx_result
|
||||
ieee80211_tx_h_tkip_encrypt(struct ieee80211_txrx_data *tx)
|
||||
ieee80211_crypto_tkip_encrypt(struct ieee80211_txrx_data *tx)
|
||||
{
|
||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
|
||||
u16 fc;
|
||||
struct ieee80211_key *key = tx->key;
|
||||
struct sk_buff *skb = tx->skb;
|
||||
int wpa_test = 0, test = 0;
|
||||
|
||||
fc = le16_to_cpu(hdr->frame_control);
|
||||
|
||||
if (!key || key->alg != ALG_TKIP || !WLAN_FC_DATA_PRESENT(fc))
|
||||
if (!WLAN_FC_DATA_PRESENT(fc))
|
||||
return TXRX_CONTINUE;
|
||||
|
||||
tx->u.tx.control->icv_len = TKIP_ICV_LEN;
|
||||
tx->u.tx.control->iv_len = TKIP_IV_LEN;
|
||||
ieee80211_tx_set_iswep(tx);
|
||||
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
if ((tx->sta && tx->sta->wpa_trigger & WPA_TRIGGER_FAIL_TX_ICV) ||
|
||||
(!tx->u.tx.unicast &&
|
||||
tx->local->wpa_trigger & WPA_TRIGGER_FAIL_TX_ICV)) {
|
||||
wpa_test = 1;
|
||||
}
|
||||
|
||||
if (tx->sta) {
|
||||
test = tx->sta->wpa_trigger;
|
||||
tx->sta->wpa_trigger &=
|
||||
~(WPA_TRIGGER_TX_REPLAY | WPA_TRIGGER_TX_REPLAY_FRAG |
|
||||
WPA_TRIGGER_TX_SKIP_SEQ);
|
||||
} else {
|
||||
test = tx->local->wpa_trigger;
|
||||
tx->local->wpa_trigger &=
|
||||
~(WPA_TRIGGER_TX_REPLAY | WPA_TRIGGER_TX_REPLAY_FRAG |
|
||||
WPA_TRIGGER_TX_SKIP_SEQ);
|
||||
}
|
||||
if (test &
|
||||
(WPA_TRIGGER_TX_REPLAY | WPA_TRIGGER_TX_REPLAY_FRAG |
|
||||
WPA_TRIGGER_TX_SKIP_SEQ)) {
|
||||
printk(KERN_INFO "%s: WPA testing - TKIP TX packet number "
|
||||
"%s%s%s%s\n", tx->dev->name,
|
||||
tx->sta ? "[UNICAST]" : "[MULTICAST]",
|
||||
test & WPA_TRIGGER_TX_REPLAY ? "[REPLAY]" : "",
|
||||
test & WPA_TRIGGER_TX_REPLAY_FRAG ?
|
||||
"[REPLAY FRAG]" : "",
|
||||
test & WPA_TRIGGER_TX_SKIP_SEQ ? "[SKIP SEQ]" : "");
|
||||
}
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
|
||||
if (!tx->key->force_sw_encrypt &&
|
||||
!(tx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) &&
|
||||
if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
|
||||
!(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) &&
|
||||
!wpa_test) {
|
||||
/* hwaccel - with no need for preallocated room for IV/ICV */
|
||||
tx->u.tx.control->key_idx = tx->key->hw_key_idx;
|
||||
tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx;
|
||||
return TXRX_CONTINUE;
|
||||
}
|
||||
|
||||
@ -434,10 +271,6 @@ ieee80211_tx_h_tkip_encrypt(struct ieee80211_txrx_data *tx)
|
||||
|
||||
if (tx->u.tx.extra_frag) {
|
||||
int i;
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
if (test & WPA_TRIGGER_TX_REPLAY_FRAG)
|
||||
test |= WPA_TRIGGER_TX_REPLAY;
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
for (i = 0; i < tx->u.tx.num_extra_frag; i++) {
|
||||
if (tkip_encrypt_skb(tx, tx->u.tx.extra_frag[i], test)
|
||||
< 0)
|
||||
@ -445,31 +278,12 @@ ieee80211_tx_h_tkip_encrypt(struct ieee80211_txrx_data *tx)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
if (tx->sta && tx->sta->wpa_trigger & WPA_TRIGGER_FAIL_TX_ICV) {
|
||||
printk(KERN_INFO "%s: WPA testing - corrupting TX TKIP ICV "
|
||||
"for STA " MAC_FMT "\n",
|
||||
tx->dev->name, MAC_ARG(tx->sta->addr));
|
||||
tx->u.tx.control->key_idx = HW_KEY_IDX_INVALID;
|
||||
tx->sta->wpa_trigger &= ~WPA_TRIGGER_FAIL_TX_ICV;
|
||||
skb->data[skb->len - 1]++;
|
||||
} else if (!tx->u.tx.unicast &&
|
||||
tx->local->wpa_trigger & WPA_TRIGGER_FAIL_TX_ICV) {
|
||||
printk(KERN_INFO "%s: WPA testing - corrupting TX TKIP ICV "
|
||||
"for Group Key\n",
|
||||
tx->dev->name);
|
||||
tx->u.tx.control->key_idx = HW_KEY_IDX_INVALID;
|
||||
tx->local->wpa_trigger &= ~WPA_TRIGGER_FAIL_TX_ICV;
|
||||
skb->data[skb->len - 1]++;
|
||||
}
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
|
||||
return TXRX_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
ieee80211_txrx_result
|
||||
ieee80211_rx_h_tkip_decrypt(struct ieee80211_txrx_data *rx)
|
||||
ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx)
|
||||
{
|
||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
|
||||
u16 fc;
|
||||
@ -480,30 +294,19 @@ ieee80211_rx_h_tkip_decrypt(struct ieee80211_txrx_data *rx)
|
||||
fc = le16_to_cpu(hdr->frame_control);
|
||||
hdrlen = ieee80211_get_hdrlen(fc);
|
||||
|
||||
if (!rx->key || rx->key->alg != ALG_TKIP ||
|
||||
!(rx->fc & IEEE80211_FCTL_PROTECTED) ||
|
||||
(rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
|
||||
if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
|
||||
return TXRX_CONTINUE;
|
||||
|
||||
if (!rx->sta || skb->len - hdrlen < 12)
|
||||
return TXRX_DROP;
|
||||
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
if (rx->sta && rx->sta->wpa_trigger & WPA_TRIGGER_FAIL_RX_ICV) {
|
||||
printk(KERN_INFO "%s: WPA testing - corrupting RX TKIP ICV "
|
||||
"for STA " MAC_FMT "\n",
|
||||
rx->dev->name, MAC_ARG(rx->sta->addr));
|
||||
rx->sta->wpa_trigger &= ~WPA_TRIGGER_FAIL_RX_ICV;
|
||||
skb->data[skb->len - 1]++;
|
||||
wpa_test = 1;
|
||||
}
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
|
||||
if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) &&
|
||||
!rx->key->force_sw_encrypt) {
|
||||
if (!(rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV)) {
|
||||
/* Hardware takes care of all processing, including
|
||||
* replay protection, so no need to continue here. */
|
||||
if (rx->u.rx.status->flag & RX_FLAG_DECRYPTED) {
|
||||
if (rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED) {
|
||||
/*
|
||||
* Hardware took care of all processing, including
|
||||
* replay protection, and stripped the ICV/IV so
|
||||
* we cannot do any checks here.
|
||||
*/
|
||||
return TXRX_CONTINUE;
|
||||
}
|
||||
|
||||
@ -514,7 +317,9 @@ ieee80211_rx_h_tkip_decrypt(struct ieee80211_txrx_data *rx)
|
||||
res = ieee80211_tkip_decrypt_data(rx->local->wep_rx_tfm,
|
||||
key, skb->data + hdrlen,
|
||||
skb->len - hdrlen, rx->sta->addr,
|
||||
hwaccel, rx->u.rx.queue);
|
||||
hwaccel, rx->u.rx.queue,
|
||||
&rx->u.rx.tkip_iv32,
|
||||
&rx->u.rx.tkip_iv16);
|
||||
if (res != TKIP_DECRYPT_OK || wpa_test) {
|
||||
printk(KERN_DEBUG "%s: TKIP decrypt failed for RX frame from "
|
||||
MAC_FMT " (res=%d)\n",
|
||||
@ -644,7 +449,10 @@ static int ccmp_encrypt_skb(struct ieee80211_txrx_data *tx,
|
||||
hdrlen = ieee80211_get_hdrlen(fc);
|
||||
len = skb->len - hdrlen;
|
||||
|
||||
tailneed = !key->force_sw_encrypt ? 0 : CCMP_MIC_LEN;
|
||||
if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
|
||||
tailneed = 0;
|
||||
else
|
||||
tailneed = CCMP_MIC_LEN;
|
||||
|
||||
if ((skb_headroom(skb) < CCMP_HDR_LEN ||
|
||||
skb_tailroom(skb) < tailneed)) {
|
||||
@ -662,31 +470,17 @@ static int ccmp_encrypt_skb(struct ieee80211_txrx_data *tx,
|
||||
/* PN = PN + 1 */
|
||||
pn = key->u.ccmp.tx_pn;
|
||||
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
if (test & WPA_TRIGGER_TX_REPLAY)
|
||||
goto skip_pn_inc;
|
||||
pn_inc:
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
|
||||
for (i = CCMP_PN_LEN - 1; i >= 0; i--) {
|
||||
pn[i]++;
|
||||
if (pn[i])
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
if (test & WPA_TRIGGER_TX_SKIP_SEQ) {
|
||||
test = 0;
|
||||
goto pn_inc;
|
||||
}
|
||||
skip_pn_inc:
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
ccmp_pn2hdr(pos, pn, key->conf.keyidx);
|
||||
|
||||
ccmp_pn2hdr(pos, pn, key->keyidx);
|
||||
|
||||
if (!key->force_sw_encrypt) {
|
||||
if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) {
|
||||
/* hwaccel - with preallocated room for CCMP header */
|
||||
tx->u.tx.control->key_idx = key->hw_key_idx;
|
||||
tx->u.tx.control->key_idx = key->conf.hw_key_idx;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -700,49 +494,27 @@ skip_pn_inc:
|
||||
|
||||
|
||||
ieee80211_txrx_result
|
||||
ieee80211_tx_h_ccmp_encrypt(struct ieee80211_txrx_data *tx)
|
||||
ieee80211_crypto_ccmp_encrypt(struct ieee80211_txrx_data *tx)
|
||||
{
|
||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
|
||||
struct ieee80211_key *key = tx->key;
|
||||
u16 fc;
|
||||
struct sk_buff *skb = tx->skb;
|
||||
int test = 0;
|
||||
|
||||
fc = le16_to_cpu(hdr->frame_control);
|
||||
|
||||
if (!key || key->alg != ALG_CCMP || !WLAN_FC_DATA_PRESENT(fc))
|
||||
if (!WLAN_FC_DATA_PRESENT(fc))
|
||||
return TXRX_CONTINUE;
|
||||
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
if (tx->sta) {
|
||||
test = tx->sta->wpa_trigger;
|
||||
tx->sta->wpa_trigger = 0;
|
||||
} else {
|
||||
test = tx->local->wpa_trigger;
|
||||
tx->local->wpa_trigger = 0;
|
||||
}
|
||||
if (test &
|
||||
(WPA_TRIGGER_TX_REPLAY | WPA_TRIGGER_TX_REPLAY_FRAG |
|
||||
WPA_TRIGGER_TX_SKIP_SEQ)) {
|
||||
printk(KERN_INFO "%s: WPA testing - CCMP TX packet number "
|
||||
"%s%s%s%s\n", tx->dev->name,
|
||||
tx->sta ? "[UNICAST]" : "[MULTICAST]",
|
||||
test & WPA_TRIGGER_TX_REPLAY ? "[REPLAY]" : "",
|
||||
test & WPA_TRIGGER_TX_REPLAY_FRAG ?
|
||||
"[REPLAY FRAG]" : "",
|
||||
test & WPA_TRIGGER_TX_SKIP_SEQ ? "[SKIP SEQ]" : "");
|
||||
}
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
|
||||
tx->u.tx.control->icv_len = CCMP_MIC_LEN;
|
||||
tx->u.tx.control->iv_len = CCMP_HDR_LEN;
|
||||
ieee80211_tx_set_iswep(tx);
|
||||
|
||||
if (!tx->key->force_sw_encrypt &&
|
||||
!(tx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV)) {
|
||||
if ((tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) &&
|
||||
!(tx->key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
|
||||
/* hwaccel - with no need for preallocated room for CCMP "
|
||||
* header or MIC fields */
|
||||
tx->u.tx.control->key_idx = tx->key->hw_key_idx;
|
||||
tx->u.tx.control->key_idx = tx->key->conf.hw_key_idx;
|
||||
return TXRX_CONTINUE;
|
||||
}
|
||||
|
||||
@ -751,10 +523,6 @@ ieee80211_tx_h_ccmp_encrypt(struct ieee80211_txrx_data *tx)
|
||||
|
||||
if (tx->u.tx.extra_frag) {
|
||||
int i;
|
||||
#ifdef CONFIG_HOSTAPD_WPA_TESTING
|
||||
if (test & WPA_TRIGGER_TX_REPLAY_FRAG)
|
||||
test |= WPA_TRIGGER_TX_REPLAY;
|
||||
#endif /* CONFIG_HOSTAPD_WPA_TESTING */
|
||||
for (i = 0; i < tx->u.tx.num_extra_frag; i++) {
|
||||
if (ccmp_encrypt_skb(tx, tx->u.tx.extra_frag[i], test)
|
||||
< 0)
|
||||
@ -767,7 +535,7 @@ ieee80211_tx_h_ccmp_encrypt(struct ieee80211_txrx_data *tx)
|
||||
|
||||
|
||||
ieee80211_txrx_result
|
||||
ieee80211_rx_h_ccmp_decrypt(struct ieee80211_txrx_data *rx)
|
||||
ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx)
|
||||
{
|
||||
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
|
||||
u16 fc;
|
||||
@ -780,9 +548,7 @@ ieee80211_rx_h_ccmp_decrypt(struct ieee80211_txrx_data *rx)
|
||||
fc = le16_to_cpu(hdr->frame_control);
|
||||
hdrlen = ieee80211_get_hdrlen(fc);
|
||||
|
||||
if (!key || key->alg != ALG_CCMP ||
|
||||
!(rx->fc & IEEE80211_FCTL_PROTECTED) ||
|
||||
(rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
|
||||
if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
|
||||
return TXRX_CONTINUE;
|
||||
|
||||
data_len = skb->len - hdrlen - CCMP_HDR_LEN - CCMP_MIC_LEN;
|
||||
@ -790,8 +556,7 @@ ieee80211_rx_h_ccmp_decrypt(struct ieee80211_txrx_data *rx)
|
||||
return TXRX_DROP;
|
||||
|
||||
if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) &&
|
||||
!key->force_sw_encrypt &&
|
||||
!(rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV))
|
||||
(rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED))
|
||||
return TXRX_CONTINUE;
|
||||
|
||||
(void) ccmp_hdr2pn(pn, skb->data + hdrlen);
|
||||
@ -810,10 +575,8 @@ ieee80211_rx_h_ccmp_decrypt(struct ieee80211_txrx_data *rx)
|
||||
return TXRX_DROP;
|
||||
}
|
||||
|
||||
if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) &&
|
||||
!key->force_sw_encrypt) {
|
||||
/* hwaccel has already decrypted frame and verified MIC */
|
||||
} else {
|
||||
if (!(rx->u.rx.status->flag & RX_FLAG_DECRYPTED)) {
|
||||
/* hardware didn't decrypt/verify MIC */
|
||||
u8 *scratch, *b_0, *aad;
|
||||
|
||||
scratch = key->u.ccmp.rx_crypto_buf;
|
||||
|
@ -19,13 +19,13 @@ ieee80211_txrx_result
|
||||
ieee80211_rx_h_michael_mic_verify(struct ieee80211_txrx_data *rx);
|
||||
|
||||
ieee80211_txrx_result
|
||||
ieee80211_tx_h_tkip_encrypt(struct ieee80211_txrx_data *tx);
|
||||
ieee80211_crypto_tkip_encrypt(struct ieee80211_txrx_data *tx);
|
||||
ieee80211_txrx_result
|
||||
ieee80211_rx_h_tkip_decrypt(struct ieee80211_txrx_data *rx);
|
||||
ieee80211_crypto_tkip_decrypt(struct ieee80211_txrx_data *rx);
|
||||
|
||||
ieee80211_txrx_result
|
||||
ieee80211_tx_h_ccmp_encrypt(struct ieee80211_txrx_data *tx);
|
||||
ieee80211_crypto_ccmp_encrypt(struct ieee80211_txrx_data *tx);
|
||||
ieee80211_txrx_result
|
||||
ieee80211_rx_h_ccmp_decrypt(struct ieee80211_txrx_data *rx);
|
||||
ieee80211_crypto_ccmp_decrypt(struct ieee80211_txrx_data *rx);
|
||||
|
||||
#endif /* WPA_H */
|
||||
|
@ -1,5 +1,4 @@
|
||||
obj-$(CONFIG_WIRELESS_EXT) += wext.o
|
||||
obj-$(CONFIG_CFG80211) += cfg80211.o
|
||||
|
||||
cfg80211-y += core.o sysfs.o
|
||||
cfg80211-y += core.o sysfs.o radiotap.o
|
||||
cfg80211-$(CONFIG_NL80211) += nl80211.o
|
||||
|
@ -162,10 +162,15 @@ int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,
|
||||
|
||||
/* this will check for collisions */
|
||||
result = device_rename(&rdev->wiphy.dev, newname);
|
||||
if (!result)
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
/* TODO: do debugfs rename! */
|
||||
if (!debugfs_rename(rdev->wiphy.debugfsdir->d_parent,
|
||||
rdev->wiphy.debugfsdir,
|
||||
rdev->wiphy.debugfsdir->d_parent,
|
||||
newname))
|
||||
printk(KERN_ERR "cfg80211: failed to rename debugfs dir to %s!\n",
|
||||
newname);
|
||||
|
||||
nl80211_notify_dev_rename(rdev);
|
||||
|
||||
@ -355,7 +360,7 @@ out_fail_notifier:
|
||||
out_fail_sysfs:
|
||||
return err;
|
||||
}
|
||||
module_init(cfg80211_init);
|
||||
subsys_initcall(cfg80211_init);
|
||||
|
||||
static void cfg80211_exit(void)
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
261
package/mac80211/src/wireless/radiotap.c
Normal file
261
package/mac80211/src/wireless/radiotap.c
Normal file
@ -0,0 +1,261 @@
|
||||
/*
|
||||
* Radiotap parser
|
||||
*
|
||||
* Copyright 2007 Andy Green <andy@warmcat.com>
|
||||
*/
|
||||
|
||||
#include <net/cfg80211.h>
|
||||
#include <net/ieee80211_radiotap.h>
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
/* function prototypes and related defs are in include/net/cfg80211.h */
|
||||
|
||||
/**
|
||||
* ieee80211_radiotap_iterator_init - radiotap parser iterator initialization
|
||||
* @iterator: radiotap_iterator to initialize
|
||||
* @radiotap_header: radiotap header to parse
|
||||
* @max_length: total length we can parse into (eg, whole packet length)
|
||||
*
|
||||
* Returns: 0 or a negative error code if there is a problem.
|
||||
*
|
||||
* This function initializes an opaque iterator struct which can then
|
||||
* be passed to ieee80211_radiotap_iterator_next() to visit every radiotap
|
||||
* argument which is present in the header. It knows about extended
|
||||
* present headers and handles them.
|
||||
*
|
||||
* How to use:
|
||||
* call __ieee80211_radiotap_iterator_init() to init a semi-opaque iterator
|
||||
* struct ieee80211_radiotap_iterator (no need to init the struct beforehand)
|
||||
* checking for a good 0 return code. Then loop calling
|
||||
* __ieee80211_radiotap_iterator_next()... it returns either 0,
|
||||
* -ENOENT if there are no more args to parse, or -EINVAL if there is a problem.
|
||||
* The iterator's @this_arg member points to the start of the argument
|
||||
* associated with the current argument index that is present, which can be
|
||||
* found in the iterator's @this_arg_index member. This arg index corresponds
|
||||
* to the IEEE80211_RADIOTAP_... defines.
|
||||
*
|
||||
* Radiotap header length:
|
||||
* You can find the CPU-endian total radiotap header length in
|
||||
* iterator->max_length after executing ieee80211_radiotap_iterator_init()
|
||||
* successfully.
|
||||
*
|
||||
* Alignment Gotcha:
|
||||
* You must take care when dereferencing iterator.this_arg
|
||||
* for multibyte types... the pointer is not aligned. Use
|
||||
* get_unaligned((type *)iterator.this_arg) to dereference
|
||||
* iterator.this_arg for type "type" safely on all arches.
|
||||
*
|
||||
* Example code:
|
||||
* See Documentation/networking/radiotap-headers.txt
|
||||
*/
|
||||
|
||||
int ieee80211_radiotap_iterator_init(
|
||||
struct ieee80211_radiotap_iterator *iterator,
|
||||
struct ieee80211_radiotap_header *radiotap_header,
|
||||
int max_length)
|
||||
{
|
||||
/* Linux only supports version 0 radiotap format */
|
||||
if (radiotap_header->it_version)
|
||||
return -EINVAL;
|
||||
|
||||
/* sanity check for allowed length and radiotap length field */
|
||||
if (max_length < le16_to_cpu(get_unaligned(&radiotap_header->it_len)))
|
||||
return -EINVAL;
|
||||
|
||||
iterator->rtheader = radiotap_header;
|
||||
iterator->max_length = le16_to_cpu(get_unaligned(
|
||||
&radiotap_header->it_len));
|
||||
iterator->arg_index = 0;
|
||||
iterator->bitmap_shifter = le32_to_cpu(get_unaligned(
|
||||
&radiotap_header->it_present));
|
||||
iterator->arg = (u8 *)radiotap_header + sizeof(*radiotap_header);
|
||||
iterator->this_arg = NULL;
|
||||
|
||||
/* find payload start allowing for extended bitmap(s) */
|
||||
|
||||
if (unlikely(iterator->bitmap_shifter & (1<<IEEE80211_RADIOTAP_EXT))) {
|
||||
while (le32_to_cpu(get_unaligned((__le32 *)iterator->arg)) &
|
||||
(1<<IEEE80211_RADIOTAP_EXT)) {
|
||||
iterator->arg += sizeof(u32);
|
||||
|
||||
/*
|
||||
* check for insanity where the present bitmaps
|
||||
* keep claiming to extend up to or even beyond the
|
||||
* stated radiotap header length
|
||||
*/
|
||||
|
||||
if (((ulong)iterator->arg -
|
||||
(ulong)iterator->rtheader) > iterator->max_length)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
iterator->arg += sizeof(u32);
|
||||
|
||||
/*
|
||||
* no need to check again for blowing past stated radiotap
|
||||
* header length, because ieee80211_radiotap_iterator_next
|
||||
* checks it before it is dereferenced
|
||||
*/
|
||||
}
|
||||
|
||||
/* we are all initialized happily */
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(ieee80211_radiotap_iterator_init);
|
||||
|
||||
|
||||
/**
|
||||
* ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg
|
||||
* @iterator: radiotap_iterator to move to next arg (if any)
|
||||
*
|
||||
* Returns: 0 if there is an argument to handle,
|
||||
* -ENOENT if there are no more args or -EINVAL
|
||||
* if there is something else wrong.
|
||||
*
|
||||
* This function provides the next radiotap arg index (IEEE80211_RADIOTAP_*)
|
||||
* in @this_arg_index and sets @this_arg to point to the
|
||||
* payload for the field. It takes care of alignment handling and extended
|
||||
* present fields. @this_arg can be changed by the caller (eg,
|
||||
* incremented to move inside a compound argument like
|
||||
* IEEE80211_RADIOTAP_CHANNEL). The args pointed to are in
|
||||
* little-endian format whatever the endianess of your CPU.
|
||||
*
|
||||
* Alignment Gotcha:
|
||||
* You must take care when dereferencing iterator.this_arg
|
||||
* for multibyte types... the pointer is not aligned. Use
|
||||
* get_unaligned((type *)iterator.this_arg) to dereference
|
||||
* iterator.this_arg for type "type" safely on all arches.
|
||||
*/
|
||||
|
||||
int ieee80211_radiotap_iterator_next(
|
||||
struct ieee80211_radiotap_iterator *iterator)
|
||||
{
|
||||
|
||||
/*
|
||||
* small length lookup table for all radiotap types we heard of
|
||||
* starting from b0 in the bitmap, so we can walk the payload
|
||||
* area of the radiotap header
|
||||
*
|
||||
* There is a requirement to pad args, so that args
|
||||
* of a given length must begin at a boundary of that length
|
||||
* -- but note that compound args are allowed (eg, 2 x u16
|
||||
* for IEEE80211_RADIOTAP_CHANNEL) so total arg length is not
|
||||
* a reliable indicator of alignment requirement.
|
||||
*
|
||||
* upper nybble: content alignment for arg
|
||||
* lower nybble: content length for arg
|
||||
*/
|
||||
|
||||
static const u8 rt_sizes[] = {
|
||||
[IEEE80211_RADIOTAP_TSFT] = 0x88,
|
||||
[IEEE80211_RADIOTAP_FLAGS] = 0x11,
|
||||
[IEEE80211_RADIOTAP_RATE] = 0x11,
|
||||
[IEEE80211_RADIOTAP_CHANNEL] = 0x24,
|
||||
[IEEE80211_RADIOTAP_FHSS] = 0x22,
|
||||
[IEEE80211_RADIOTAP_DBM_ANTSIGNAL] = 0x11,
|
||||
[IEEE80211_RADIOTAP_DBM_ANTNOISE] = 0x11,
|
||||
[IEEE80211_RADIOTAP_LOCK_QUALITY] = 0x22,
|
||||
[IEEE80211_RADIOTAP_TX_ATTENUATION] = 0x22,
|
||||
[IEEE80211_RADIOTAP_DB_TX_ATTENUATION] = 0x22,
|
||||
[IEEE80211_RADIOTAP_DBM_TX_POWER] = 0x11,
|
||||
[IEEE80211_RADIOTAP_ANTENNA] = 0x11,
|
||||
[IEEE80211_RADIOTAP_DB_ANTSIGNAL] = 0x11,
|
||||
[IEEE80211_RADIOTAP_DB_ANTNOISE] = 0x11,
|
||||
[IEEE80211_RADIOTAP_RX_FLAGS] = 0x22,
|
||||
[IEEE80211_RADIOTAP_TX_FLAGS] = 0x22,
|
||||
[IEEE80211_RADIOTAP_RTS_RETRIES] = 0x11,
|
||||
[IEEE80211_RADIOTAP_DATA_RETRIES] = 0x11,
|
||||
/*
|
||||
* add more here as they are defined in
|
||||
* include/net/ieee80211_radiotap.h
|
||||
*/
|
||||
};
|
||||
|
||||
/*
|
||||
* for every radiotap entry we can at
|
||||
* least skip (by knowing the length)...
|
||||
*/
|
||||
|
||||
while (iterator->arg_index < sizeof(rt_sizes)) {
|
||||
int hit = 0;
|
||||
int pad;
|
||||
|
||||
if (!(iterator->bitmap_shifter & 1))
|
||||
goto next_entry; /* arg not present */
|
||||
|
||||
/*
|
||||
* arg is present, account for alignment padding
|
||||
* 8-bit args can be at any alignment
|
||||
* 16-bit args must start on 16-bit boundary
|
||||
* 32-bit args must start on 32-bit boundary
|
||||
* 64-bit args must start on 64-bit boundary
|
||||
*
|
||||
* note that total arg size can differ from alignment of
|
||||
* elements inside arg, so we use upper nybble of length
|
||||
* table to base alignment on
|
||||
*
|
||||
* also note: these alignments are ** relative to the
|
||||
* start of the radiotap header **. There is no guarantee
|
||||
* that the radiotap header itself is aligned on any
|
||||
* kind of boundary.
|
||||
*
|
||||
* the above is why get_unaligned() is used to dereference
|
||||
* multibyte elements from the radiotap area
|
||||
*/
|
||||
|
||||
pad = (((ulong)iterator->arg) -
|
||||
((ulong)iterator->rtheader)) &
|
||||
((rt_sizes[iterator->arg_index] >> 4) - 1);
|
||||
|
||||
if (pad)
|
||||
iterator->arg +=
|
||||
(rt_sizes[iterator->arg_index] >> 4) - pad;
|
||||
|
||||
/*
|
||||
* this is what we will return to user, but we need to
|
||||
* move on first so next call has something fresh to test
|
||||
*/
|
||||
iterator->this_arg_index = iterator->arg_index;
|
||||
iterator->this_arg = iterator->arg;
|
||||
hit = 1;
|
||||
|
||||
/* internally move on the size of this arg */
|
||||
iterator->arg += rt_sizes[iterator->arg_index] & 0x0f;
|
||||
|
||||
/*
|
||||
* check for insanity where we are given a bitmap that
|
||||
* claims to have more arg content than the length of the
|
||||
* radiotap section. We will normally end up equalling this
|
||||
* max_length on the last arg, never exceeding it.
|
||||
*/
|
||||
|
||||
if (((ulong)iterator->arg - (ulong)iterator->rtheader) >
|
||||
iterator->max_length)
|
||||
return -EINVAL;
|
||||
|
||||
next_entry:
|
||||
iterator->arg_index++;
|
||||
if (unlikely((iterator->arg_index & 31) == 0)) {
|
||||
/* completed current u32 bitmap */
|
||||
if (iterator->bitmap_shifter & 1) {
|
||||
/* b31 was set, there is more */
|
||||
/* move to next u32 bitmap */
|
||||
iterator->bitmap_shifter = le32_to_cpu(
|
||||
get_unaligned(iterator->next_bitmap));
|
||||
iterator->next_bitmap++;
|
||||
} else
|
||||
/* no more bitmaps: end */
|
||||
iterator->arg_index = sizeof(rt_sizes);
|
||||
} else /* just try the next bit */
|
||||
iterator->bitmap_shifter >>= 1;
|
||||
|
||||
/* if we found a valid arg earlier, return it now */
|
||||
if (hit)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* we don't know how to handle any more args, we're done */
|
||||
return -ENOENT;
|
||||
}
|
||||
EXPORT_SYMBOL(ieee80211_radiotap_iterator_next);
|
@ -39,59 +39,9 @@ static ssize_t _show_permaddr(struct device *dev,
|
||||
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
|
||||
}
|
||||
|
||||
static ssize_t _store_add_iface(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
struct cfg80211_registered_device *rdev = dev_to_rdev(dev);
|
||||
int res;
|
||||
|
||||
if (len > IFNAMSIZ)
|
||||
return -EINVAL;
|
||||
|
||||
if (!rdev->ops->add_virtual_intf)
|
||||
return -ENOSYS;
|
||||
|
||||
rtnl_lock();
|
||||
res = rdev->ops->add_virtual_intf(&rdev->wiphy, (char*)buf,
|
||||
NL80211_IFTYPE_UNSPECIFIED);
|
||||
rtnl_unlock();
|
||||
|
||||
return res ? res : len;
|
||||
}
|
||||
|
||||
static ssize_t _store_remove_iface(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t len)
|
||||
{
|
||||
struct cfg80211_registered_device *rdev = dev_to_rdev(dev);
|
||||
int res, ifidx;
|
||||
struct net_device *netdev;
|
||||
|
||||
if (len > IFNAMSIZ)
|
||||
return -EINVAL;
|
||||
|
||||
if (!rdev->ops->del_virtual_intf)
|
||||
return -ENOSYS;
|
||||
|
||||
netdev = dev_get_by_name(buf);
|
||||
if (!netdev)
|
||||
return -ENODEV;
|
||||
ifidx = netdev->ifindex;
|
||||
dev_put(netdev);
|
||||
|
||||
rtnl_lock();
|
||||
res = rdev->ops->del_virtual_intf(&rdev->wiphy, ifidx);
|
||||
rtnl_unlock();
|
||||
|
||||
return res ? res : len;
|
||||
}
|
||||
|
||||
static struct device_attribute ieee80211_dev_attrs[] = {
|
||||
__ATTR(index, S_IRUGO, _show_index, NULL),
|
||||
__ATTR(macaddress, S_IRUGO, _show_permaddr, NULL),
|
||||
__ATTR(add_iface, S_IWUGO, NULL, _store_add_iface),
|
||||
__ATTR(remove_iface, S_IWUGO, NULL, _store_remove_iface),
|
||||
{}
|
||||
};
|
||||
|
||||
@ -102,12 +52,14 @@ static void wiphy_dev_release(struct device *dev)
|
||||
cfg80211_dev_free(rdev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_HOTPLUG
|
||||
static int wiphy_uevent(struct device *dev, char **envp,
|
||||
int num_envp, char *buf, int size)
|
||||
{
|
||||
/* TODO, we probably need stuff here */
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct class ieee80211_class = {
|
||||
.name = "ieee80211",
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user