From 2e79ca976239826b5d0de8c01f1aff7935cc4097 Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Tue, 30 Mar 2004 22:57:57 +0000 Subject: [PATCH] o add support for controlling the power of transmitted frames o add support for controlling the 11g protection mechanism used to protect OFDM frames in a mixed 11b/g network Reviewed by: imp --- sys/net80211/ieee80211_ioctl.c | 32 ++++++++++++++++++++++++++++++++ sys/net80211/ieee80211_ioctl.h | 5 +++++ sys/net80211/ieee80211_node.c | 1 + sys/net80211/ieee80211_proto.c | 1 + sys/net80211/ieee80211_var.h | 15 +++++++++++++++ 5 files changed, 54 insertions(+) diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c index 99779f237ab9..75995910d253 100644 --- a/sys/net80211/ieee80211_ioctl.c +++ b/sys/net80211/ieee80211_ioctl.c @@ -873,6 +873,15 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case IEEE80211_IOC_RTSTHRESHOLD: ireq->i_val = ic->ic_rtsthreshold; break; + case IEEE80211_IOC_PROTMODE: + ireq->i_val = ic->ic_protmode; + break; + case IEEE80211_IOC_TXPOWER: + if ((ic->ic_caps & IEEE80211_C_TXPMGT) == 0) + error = EINVAL; + else + ireq->i_val = ic->ic_txpower; + break; default: error = EINVAL; break; @@ -1015,6 +1024,29 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) ic->ic_rtsthreshold = ireq->i_val; error = ENETRESET; break; + case IEEE80211_IOC_PROTMODE: + if (ireq->i_val > IEEE80211_PROT_RTSCTS) { + error = EINVAL; + break; + } + ic->ic_protmode = ireq->i_val; + /* NB: if not operating in 11g this can wait */ + if (ic->ic_curmode == IEEE80211_MODE_11G) + error = ENETRESET; + break; + case IEEE80211_IOC_TXPOWER: + if ((ic->ic_caps & IEEE80211_C_TXPMGT) == 0) { + error = EINVAL; + break; + } + if (!(IEEE80211_TXPOWER_MIN < ireq->i_val && + ireq->i_val < IEEE80211_TXPOWER_MAX)) { + error = EINVAL; + break; + } + ic->ic_txpower = ireq->i_val; + error = ENETRESET; + break; default: error = EINVAL; break; diff --git a/sys/net80211/ieee80211_ioctl.h b/sys/net80211/ieee80211_ioctl.h index 56d6374cefd4..d8c2b024a249 100644 --- a/sys/net80211/ieee80211_ioctl.h +++ b/sys/net80211/ieee80211_ioctl.h @@ -119,6 +119,11 @@ struct ieee80211req { #define IEEE80211_POWERSAVE_ON IEEE80211_POWERSAVE_CAM #define IEEE80211_IOC_POWERSAVESLEEP 11 #define IEEE80211_IOC_RTSTHRESHOLD 12 +#define IEEE80211_IOC_PROTMODE 13 +#define IEEE80211_PROTMODE_OFF 0 +#define IEEE80211_PROTMODE_CTS 1 +#define IEEE80211_PROTMODE_RTSCTS 2 +#define IEEE80211_IOC_TXPOWER 14 #ifndef IEEE80211_CHAN_ANY #define IEEE80211_CHAN_ANY 0xffff /* token for ``any channel'' */ diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c index 28441b551724..92190bcba3e3 100644 --- a/sys/net80211/ieee80211_node.c +++ b/sys/net80211/ieee80211_node.c @@ -102,6 +102,7 @@ ieee80211_node_lateattach(struct ifnet *ifp) ic->ic_bss = (*ic->ic_node_alloc)(ic); KASSERT(ic->ic_bss != NULL, ("unable to setup inital BSS node")); + ic->ic_txpower = IEEE80211_TXPOWER_MAX; ic->ic_bss->ni_chan = IEEE80211_CHAN_ANYC; } diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c index a2b029521ede..8305029158b3 100644 --- a/sys/net80211/ieee80211_proto.c +++ b/sys/net80211/ieee80211_proto.c @@ -102,6 +102,7 @@ ieee80211_proto_attach(struct ifnet *ifp) #endif ic->ic_fragthreshold = 2346; /* XXX not used yet */ ic->ic_fixed_rate = -1; /* no fixed rate */ + ic->ic_protmode = IEEE80211_PROT_CTSONLY; mtx_init(&ic->ic_mgtq.ifq_mtx, ifp->if_xname, "mgmt send q", MTX_DEF); diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index 86a618fd6eec..3750c6a86c37 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -49,6 +49,9 @@ #define IEEE80211_CHAN_ANYC \ ((struct ieee80211_channel *) IEEE80211_CHAN_ANY) +#define IEEE80211_TXPOWER_MAX 100 /* max power */ +#define IEEE80211_TXPOWER_MIN 0 /* kill radio (if possible) */ + enum ieee80211_phytype { IEEE80211_T_DS, /* direct sequence spread spectrum */ IEEE80211_T_FH, /* frequency hopping */ @@ -76,6 +79,15 @@ enum ieee80211_opmode { IEEE80211_M_MONITOR = 8 /* Monitor mode */ }; +/* + * 802.11g protection mode. + */ +enum ieee80211_protmode { + IEEE80211_PROT_NONE = 0, /* no protection */ + IEEE80211_PROT_CTSONLY = 1, /* CTS to self */ + IEEE80211_PROT_RTSCTS = 2, /* RTS-CTS */ +}; + /* * Channels are specified by frequency and attributes. */ @@ -166,6 +178,7 @@ struct ieee80211com { enum ieee80211_phytype ic_phytype; /* XXX wrong for multi-mode */ enum ieee80211_opmode ic_opmode; /* operation mode */ enum ieee80211_state ic_state; /* 802.11 state */ + enum ieee80211_protmode ic_protmode; /* 802.11g protection mode */ struct ifmedia ic_media; /* interface media config */ struct bpf_if *ic_rawbpf; /* packet filter structure */ struct ieee80211_node *ic_bss; /* information for this node */ @@ -226,6 +239,8 @@ struct ieee80211com { #define IEEE80211_F_TXPOW_AUTO 0x00010000 /* TX Power: undefined */ #define IEEE80211_F_SHSLOT 0x00020000 /* CONF: short slot time */ #define IEEE80211_F_SHPREAMBLE 0x00040000 /* CONF: short preamble */ +#define IEEE80211_F_USEPROT 0x00100000 /* STATUS: protection enabled */ +#define IEEE80211_F_USEBARKER 0x00200000 /* STATUS: use barker preamble*/ /* ic_caps */ #define IEEE80211_C_WEP 0x00000001 /* CAPABILITY: WEP available */