diff options
author | sam <sam@FreeBSD.org> | 2008-05-12 00:15:30 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2008-05-12 00:15:30 +0000 |
commit | f663b621286051ac42452779cf814624994dae88 (patch) | |
tree | 3cf79416d2ad19b6945f31a06a6e43e73f0d5527 /sys/net80211 | |
parent | 544a240c14d88ab9e4515a136add5e80481a9d28 (diff) | |
download | FreeBSD-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
Diffstat (limited to 'sys/net80211')
-rw-r--r-- | sys/net80211/ieee80211.c | 30 | ||||
-rw-r--r-- | sys/net80211/ieee80211_ddb.c | 2 | ||||
-rw-r--r-- | sys/net80211/ieee80211_freebsd.c | 11 | ||||
-rw-r--r-- | sys/net80211/ieee80211_proto.h | 1 | ||||
-rw-r--r-- | sys/net80211/ieee80211_var.h | 7 |
5 files changed, 31 insertions, 20 deletions
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 * |