summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2008-05-12 00:15:30 +0000
committersam <sam@FreeBSD.org>2008-05-12 00:15:30 +0000
commitf663b621286051ac42452779cf814624994dae88 (patch)
tree3cf79416d2ad19b6945f31a06a6e43e73f0d5527
parent544a240c14d88ab9e4515a136add5e80481a9d28 (diff)
downloadFreeBSD-src-f663b621286051ac42452779cf814624994dae88.zip
FreeBSD-src-f663b621286051ac42452779cf814624994dae88.tar.gz
Minor cleanup of vap create work:
o add IEEE80211_C_STA capability to indicate sta mode is supported (was previously assumed) and mark drivers as capable o add ieee80211_opcap array to map an opmode to the equivalent capability bit o move IEEE80211_C_OPMODE definition to where capabilities are defined so it's clear it should be kept in sync (on future additions) o check device capabilities in clone create before trying to create a vap; this makes driver checks unneeded o make error codes return on failed clone request unique o temporarily add console printfs on clone request failures to aid in debugging; these will move under DIAGNOSTIC or similar before release
-rw-r--r--sys/dev/ath/if_ath.c3
-rw-r--r--sys/dev/if_ndis/if_ndis.c2
-rw-r--r--sys/dev/ipw/if_ipw.c4
-rw-r--r--sys/dev/iwi/if_iwi.c3
-rw-r--r--sys/dev/iwn/if_iwn.c3
-rw-r--r--sys/dev/malo/if_malo.c3
-rw-r--r--sys/dev/ral/rt2560.c3
-rw-r--r--sys/dev/ral/rt2661.c3
-rw-r--r--sys/dev/usb/if_rum.c3
-rw-r--r--sys/dev/usb/if_ural.c3
-rw-r--r--sys/dev/usb/if_zyd.c3
-rw-r--r--sys/dev/wi/if_wi.c3
-rw-r--r--sys/dev/wpi/if_wpi.c3
-rw-r--r--sys/net80211/ieee80211.c30
-rw-r--r--sys/net80211/ieee80211_ddb.c2
-rw-r--r--sys/net80211/ieee80211_freebsd.c11
-rw-r--r--sys/net80211/ieee80211_proto.h1
-rw-r--r--sys/net80211/ieee80211_var.h7
18 files changed, 57 insertions, 33 deletions
diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c
index 3f08c35..ab21df3 100644
--- a/sys/dev/ath/if_ath.c
+++ b/sys/dev/ath/if_ath.c
@@ -515,7 +515,8 @@ ath_attach(u_int16_t devid, struct ath_softc *sc)
ic->ic_phytype = IEEE80211_T_OFDM;
ic->ic_opmode = IEEE80211_M_STA;
ic->ic_caps =
- IEEE80211_C_IBSS /* ibss, nee adhoc, mode */
+ IEEE80211_C_STA /* station mode */
+ | IEEE80211_C_IBSS /* ibss, nee adhoc, mode */
| IEEE80211_C_HOSTAP /* hostap mode */
| IEEE80211_C_MONITOR /* monitor mode */
| IEEE80211_C_AHDEMO /* adhoc demo mode */
diff --git a/sys/dev/if_ndis/if_ndis.c b/sys/dev/if_ndis/if_ndis.c
index 45930f9..692473f 100644
--- a/sys/dev/if_ndis/if_ndis.c
+++ b/sys/dev/if_ndis/if_ndis.c
@@ -724,7 +724,7 @@ ndis_attach(dev)
ic->ic_ifp = ifp;
ic->ic_opmode = IEEE80211_M_STA;
ic->ic_phytype = IEEE80211_T_DS;
- ic->ic_caps = IEEE80211_C_IBSS;
+ ic->ic_caps = IEEE80211_C_STA | IEEE80211_C_IBSS;
setbit(ic->ic_modecaps, IEEE80211_MODE_AUTO);
len = 0;
r = ndis_get_info(sc, OID_802_11_NETWORK_TYPES_SUPPORTED,
diff --git a/sys/dev/ipw/if_ipw.c b/sys/dev/ipw/if_ipw.c
index 45a418e..f7ef813 100644
--- a/sys/dev/ipw/if_ipw.c
+++ b/sys/dev/ipw/if_ipw.c
@@ -305,7 +305,9 @@ ipw_attach(device_t dev)
ic->ic_phytype = IEEE80211_T_DS;
/* set device capabilities */
- ic->ic_caps = IEEE80211_C_IBSS /* IBSS mode supported */
+ ic->ic_caps =
+ IEEE80211_C_STA /* station mode supported */
+ | IEEE80211_C_IBSS /* IBSS mode supported */
| IEEE80211_C_MONITOR /* monitor mode supported */
| IEEE80211_C_PMGT /* power save supported */
| IEEE80211_C_SHPREAMBLE /* short preamble supported */
diff --git a/sys/dev/iwi/if_iwi.c b/sys/dev/iwi/if_iwi.c
index ed9bcff..4f81c1b 100644
--- a/sys/dev/iwi/if_iwi.c
+++ b/sys/dev/iwi/if_iwi.c
@@ -388,7 +388,8 @@ iwi_attach(device_t dev)
/* set device capabilities */
ic->ic_caps =
- IEEE80211_C_IBSS /* IBSS mode supported */
+ IEEE80211_C_STA /* station mode supported */
+ | IEEE80211_C_IBSS /* IBSS mode supported */
| IEEE80211_C_MONITOR /* monitor mode supported */
| IEEE80211_C_PMGT /* power save supported */
| IEEE80211_C_SHPREAMBLE /* short preamble supported */
diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c
index cca04ec..8a1ed68 100644
--- a/sys/dev/iwn/if_iwn.c
+++ b/sys/dev/iwn/if_iwn.c
@@ -377,7 +377,8 @@ iwn_attach(device_t dev)
/* set device capabilities */
ic->ic_caps =
- IEEE80211_C_MONITOR /* monitor mode supported */
+ IEEE80211_C_STA /* station mode supported */
+ | IEEE80211_C_MONITOR /* monitor mode supported */
| IEEE80211_C_TXPMGT /* tx power management */
| IEEE80211_C_SHSLOT /* short slot time supported */
| IEEE80211_C_WPA
diff --git a/sys/dev/malo/if_malo.c b/sys/dev/malo/if_malo.c
index 8da0229..681c824 100644
--- a/sys/dev/malo/if_malo.c
+++ b/sys/dev/malo/if_malo.c
@@ -301,7 +301,8 @@ malo_attach(uint16_t devid, struct malo_softc *sc)
ic->ic_phytype = IEEE80211_T_OFDM;
ic->ic_opmode = IEEE80211_M_STA;
ic->ic_caps =
- IEEE80211_C_BGSCAN /* capable of bg scanning */
+ IEEE80211_C_STA /* station mode supported */
+ | IEEE80211_C_BGSCAN /* capable of bg scanning */
| IEEE80211_C_MONITOR /* monitor mode */
| IEEE80211_C_SHPREAMBLE /* short preamble supported */
| IEEE80211_C_SHSLOT /* short slot time supported */
diff --git a/sys/dev/ral/rt2560.c b/sys/dev/ral/rt2560.c
index 2f65112..e8823b1 100644
--- a/sys/dev/ral/rt2560.c
+++ b/sys/dev/ral/rt2560.c
@@ -278,7 +278,8 @@ rt2560_attach(device_t dev, int id)
/* set device capabilities */
ic->ic_caps =
- IEEE80211_C_IBSS /* ibss, nee adhoc, mode */
+ IEEE80211_C_STA /* station mode */
+ | IEEE80211_C_IBSS /* ibss, nee adhoc, mode */
| IEEE80211_C_HOSTAP /* hostap mode */
| IEEE80211_C_MONITOR /* monitor mode */
| IEEE80211_C_AHDEMO /* adhoc demo mode */
diff --git a/sys/dev/ral/rt2661.c b/sys/dev/ral/rt2661.c
index 0bf2bc7..7dfb635 100644
--- a/sys/dev/ral/rt2661.c
+++ b/sys/dev/ral/rt2661.c
@@ -280,7 +280,8 @@ rt2661_attach(device_t dev, int id)
/* set device capabilities */
ic->ic_caps =
- IEEE80211_C_IBSS /* ibss, nee adhoc, mode */
+ IEEE80211_C_STA /* station mode */
+ | IEEE80211_C_IBSS /* ibss, nee adhoc, mode */
| IEEE80211_C_HOSTAP /* hostap mode */
| IEEE80211_C_MONITOR /* monitor mode */
| IEEE80211_C_AHDEMO /* adhoc demo mode */
diff --git a/sys/dev/usb/if_rum.c b/sys/dev/usb/if_rum.c
index 87db92a..522b8ce 100644
--- a/sys/dev/usb/if_rum.c
+++ b/sys/dev/usb/if_rum.c
@@ -490,7 +490,8 @@ rum_attach(device_t self)
/* set device capabilities */
ic->ic_caps =
- IEEE80211_C_IBSS /* IBSS mode supported */
+ IEEE80211_C_STA /* station mode supported */
+ | IEEE80211_C_IBSS /* IBSS mode supported */
| IEEE80211_C_MONITOR /* monitor mode supported */
| IEEE80211_C_HOSTAP /* HostAp mode supported */
| IEEE80211_C_TXPMGT /* tx power management */
diff --git a/sys/dev/usb/if_ural.c b/sys/dev/usb/if_ural.c
index 40a225b..d19c93e 100644
--- a/sys/dev/usb/if_ural.c
+++ b/sys/dev/usb/if_ural.c
@@ -479,7 +479,8 @@ ural_attach(device_t self)
/* set device capabilities */
ic->ic_caps =
- IEEE80211_C_IBSS /* IBSS mode supported */
+ IEEE80211_C_STA /* station mode supported */
+ | IEEE80211_C_IBSS /* IBSS mode supported */
| IEEE80211_C_MONITOR /* monitor mode supported */
| IEEE80211_C_HOSTAP /* HostAp mode supported */
| IEEE80211_C_TXPMGT /* tx power management */
diff --git a/sys/dev/usb/if_zyd.c b/sys/dev/usb/if_zyd.c
index 9e7cd72..1e05952 100644
--- a/sys/dev/usb/if_zyd.c
+++ b/sys/dev/usb/if_zyd.c
@@ -390,7 +390,8 @@ zyd_complete_attach(struct zyd_softc *sc)
/* set device capabilities */
ic->ic_caps =
- IEEE80211_C_MONITOR /* monitor mode */
+ IEEE80211_C_STA /* station mode */
+ | IEEE80211_C_MONITOR /* monitor mode */
| IEEE80211_C_SHPREAMBLE /* short preamble supported */
| IEEE80211_C_SHSLOT /* short slot time supported */
| IEEE80211_C_BGSCAN /* capable of bg scanning */
diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c
index b13d4dc..51c672d 100644
--- a/sys/dev/wi/if_wi.c
+++ b/sys/dev/wi/if_wi.c
@@ -331,7 +331,8 @@ wi_attach(device_t dev)
ic->ic_ifp = ifp;
ic->ic_phytype = IEEE80211_T_DS;
ic->ic_opmode = IEEE80211_M_STA;
- ic->ic_caps = IEEE80211_C_PMGT
+ ic->ic_caps = IEEE80211_C_STA
+ | IEEE80211_C_PMGT
| IEEE80211_C_MONITOR
;
diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c
index 5ac37a7..6cbd7cd 100644
--- a/sys/dev/wpi/if_wpi.c
+++ b/sys/dev/wpi/if_wpi.c
@@ -623,7 +623,8 @@ wpi_attach(device_t dev)
/* set device capabilities */
ic->ic_caps =
- IEEE80211_C_MONITOR /* monitor mode supported */
+ IEEE80211_C_STA /* station mode supported */
+ | IEEE80211_C_MONITOR /* monitor mode supported */
| IEEE80211_C_TXPMGT /* tx power management */
| IEEE80211_C_SHSLOT /* short slot time supported */
| IEEE80211_C_SHPREAMBLE /* short preamble supported */
diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c
index ad4d3b1..fbea173 100644
--- a/sys/net80211/ieee80211.c
+++ b/sys/net80211/ieee80211.c
@@ -61,6 +61,16 @@ const char *ieee80211_phymode_name[IEEE80211_MODE_MAX] = {
[IEEE80211_MODE_11NA] = "11na",
[IEEE80211_MODE_11NG] = "11ng",
};
+/* map ieee80211_opmode to the corresponding capability bit */
+const int ieee80211_opcap[IEEE80211_OPMODE_MAX] = {
+ [IEEE80211_M_IBSS] = IEEE80211_C_IBSS,
+ [IEEE80211_M_WDS] = IEEE80211_C_WDS,
+ [IEEE80211_M_STA] = IEEE80211_C_STA,
+ [IEEE80211_M_AHDEMO] = IEEE80211_C_AHDEMO,
+ [IEEE80211_M_HOSTAP] = IEEE80211_C_HOSTAP,
+ [IEEE80211_M_MONITOR] = IEEE80211_C_MONITOR,
+};
+
static const uint8_t ieee80211broadcastaddr[IEEE80211_ADDR_LEN] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
@@ -310,9 +320,6 @@ ieee80211_vap_setup(struct ieee80211com *ic, struct ieee80211vap *vap,
const uint8_t bssid[IEEE80211_ADDR_LEN],
const uint8_t macaddr[IEEE80211_ADDR_LEN])
{
-#define IEEE80211_C_OPMODE \
- (IEEE80211_C_IBSS | IEEE80211_C_HOSTAP | IEEE80211_C_AHDEMO | \
- IEEE80211_C_MONITOR | IEEE80211_C_WDS)
struct ifnet *ifp;
ifp = if_alloc(IFT_ETHER);
@@ -341,26 +348,14 @@ ieee80211_vap_setup(struct ieee80211com *ic, struct ieee80211vap *vap,
vap->iv_caps = ic->ic_caps &~ IEEE80211_C_OPMODE;
vap->iv_htcaps = ic->ic_htcaps;
vap->iv_opmode = opmode;
+ vap->iv_caps |= ieee80211_opcap[opmode];
switch (opmode) {
case IEEE80211_M_STA:
/* auto-enable s/w beacon miss support */
if (flags & IEEE80211_CLONE_NOBEACONS)
vap->iv_flags_ext |= IEEE80211_FEXT_SWBMISS;
break;
- case IEEE80211_M_IBSS:
- vap->iv_caps |= IEEE80211_C_IBSS;
- break;
- case IEEE80211_M_AHDEMO:
- vap->iv_caps |= IEEE80211_C_AHDEMO;
- break;
- case IEEE80211_M_HOSTAP:
- vap->iv_caps |= IEEE80211_C_HOSTAP;
- break;
- case IEEE80211_M_MONITOR:
- vap->iv_caps |= IEEE80211_C_MONITOR;
- break;
case IEEE80211_M_WDS:
- vap->iv_caps |= IEEE80211_C_WDS;
/*
* WDS links must specify the bssid of the far end.
* For legacy operation this is a static relationship.
@@ -391,7 +386,7 @@ ieee80211_vap_setup(struct ieee80211com *ic, struct ieee80211vap *vap,
if (vap->iv_opmode == IEEE80211_M_STA &&
(vap->iv_caps & IEEE80211_C_BGSCAN))
vap->iv_flags |= IEEE80211_F_BGSCAN;
- vap->iv_flags |= IEEE80211_F_DOTH; /* XXX out of caps, just ena */
+ vap->iv_flags |= IEEE80211_F_DOTH; /* XXX no cap, just ena */
/* NB: DFS support only makes sense for ap mode right now */
if (vap->iv_opmode == IEEE80211_M_HOSTAP &&
(vap->iv_caps & IEEE80211_C_DFS))
@@ -418,7 +413,6 @@ ieee80211_vap_setup(struct ieee80211com *ic, struct ieee80211vap *vap,
ieee80211_regdomain_vattach(vap);
return 0;
-#undef IEEE80211_C_OPMODE
}
/*
diff --git a/sys/net80211/ieee80211_ddb.c b/sys/net80211/ieee80211_ddb.c
index fd860c7..92dd460 100644
--- a/sys/net80211/ieee80211_ddb.c
+++ b/sys/net80211/ieee80211_ddb.c
@@ -71,7 +71,7 @@ __FBSDID("$FreeBSD$");
#define IEEE80211_FVEN_BITS "\20"
#define IEEE80211_C_BITS \
- "\20\7FF\10TURBOP\11IBSS\12PMGT" \
+ "\20\1STA\7FF\10TURBOP\11IBSS\12PMGT" \
"\13HOSTAP\14AHDEMO\15SWRETRY\16TXPMGT\17SHSLOT\20SHPREAMBLE" \
"\21MONITOR\22DFS\30WPA1\31WPA2\32BURST\33WME\34WDS\36BGSCAN" \
"\37TXFRAG"
diff --git a/sys/net80211/ieee80211_freebsd.c b/sys/net80211/ieee80211_freebsd.c
index d0b1b69..c0c1474 100644
--- a/sys/net80211/ieee80211_freebsd.c
+++ b/sys/net80211/ieee80211_freebsd.c
@@ -108,11 +108,22 @@ wlan_clone_create(struct if_clone *ifc, int unit, caddr_t params)
ifp = ifunit(cp.icp_parent);
if (ifp == NULL)
return ENXIO;
+ /* XXX move printfs to DIAGNOSTIC before release */
if (ifp->if_type != IFT_IEEE80211) {
if_printf(ifp, "%s: reject, not an 802.11 device\n", __func__);
+ return ENXIO;
+ }
+ if (cp.icp_opmode >= IEEE80211_OPMODE_MAX) {
+ if_printf(ifp, "%s: invalid opmode %d\n",
+ __func__, cp.icp_opmode);
return EINVAL;
}
ic = ifp->if_l2com;
+ if ((ic->ic_caps & ieee80211_opcap[cp.icp_opmode]) == 0) {
+ if_printf(ifp, "%s mode not supported\n",
+ ieee80211_opmode_name[cp.icp_opmode]);
+ return EOPNOTSUPP;
+ }
vap = ic->ic_vap_create(ic, ifc->ifc_name, unit,
cp.icp_opmode, cp.icp_flags, cp.icp_bssid,
cp.icp_flags & IEEE80211_CLONE_MACADDR ?
diff --git a/sys/net80211/ieee80211_proto.h b/sys/net80211/ieee80211_proto.h
index ec7061d..9ec94f7 100644
--- a/sys/net80211/ieee80211_proto.h
+++ b/sys/net80211/ieee80211_proto.h
@@ -49,6 +49,7 @@ enum ieee80211_state {
extern const char *ieee80211_mgt_subtype_name[];
extern const char *ieee80211_phymode_name[];
+extern const int ieee80211_opcap[IEEE80211_OPMODE_MAX];
void ieee80211_proto_attach(struct ieee80211com *);
void ieee80211_proto_detach(struct ieee80211com *);
diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h
index 2cbf3d1..38100ae 100644
--- a/sys/net80211/ieee80211_var.h
+++ b/sys/net80211/ieee80211_var.h
@@ -493,6 +493,7 @@ MALLOC_DECLARE(M_80211_VAP);
/* ic_caps/iv_caps: device driver capabilities */
/* 0x2f available */
+#define IEEE80211_C_STA 0x00000001 /* CAPABILITY: STA available */
#define IEEE80211_C_FF 0x00000040 /* CAPABILITY: ATH FF avail */
#define IEEE80211_C_TURBOP 0x00000080 /* CAPABILITY: ATH Turbo avail*/
#define IEEE80211_C_IBSS 0x00000100 /* CAPABILITY: IBSS available */
@@ -505,7 +506,7 @@ MALLOC_DECLARE(M_80211_VAP);
#define IEEE80211_C_SHPREAMBLE 0x00008000 /* CAPABILITY: short preamble */
#define IEEE80211_C_MONITOR 0x00010000 /* CAPABILITY: monitor mode */
#define IEEE80211_C_DFS 0x00020000 /* CAPABILITY: DFS/radar avail*/
-/* 0x20000 available */
+/* 0x7c0000 available */
#define IEEE80211_C_WPA1 0x00800000 /* CAPABILITY: WPA1 avail */
#define IEEE80211_C_WPA2 0x01000000 /* CAPABILITY: WPA2 avail */
#define IEEE80211_C_WPA 0x01800000 /* CAPABILITY: WPA1+WPA2 avail*/
@@ -517,6 +518,10 @@ MALLOC_DECLARE(M_80211_VAP);
#define IEEE80211_C_TXFRAG 0x40000000 /* CAPABILITY: tx fragments */
/* XXX protection/barker? */
+#define IEEE80211_C_OPMODE \
+ (IEEE80211_C_STA | IEEE80211_C_IBSS | IEEE80211_C_HOSTAP | \
+ IEEE80211_C_AHDEMO | IEEE80211_C_MONITOR | IEEE80211_C_WDS)
+
/*
* ic_htcaps/iv_htcaps: HT-specific device/driver capabilities
*
OpenPOWER on IntegriCloud