From a6b03f428a48d288dca24f1f567907aba26074ee Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Tue, 30 Mar 2004 22:59:22 +0000 Subject: [PATCH] add support for setting 802.11 rtsthreshold, transmit power, and 11g protection mode Reviewed by: imp (just code) --- sbin/ifconfig/ifconfig.8 | 30 ++++++++++++++++- sbin/ifconfig/ifconfig.c | 3 ++ sbin/ifconfig/ifconfig.h | 3 ++ sbin/ifconfig/ifieee80211.c | 66 +++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 1 deletion(-) diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index fcf11d10923c..487e127bcaab 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -32,7 +32,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd April 28, 2003 +.Dd March 30, 2004 .Dt IFCONFIG 8 .Os .Sh NAME @@ -635,6 +635,34 @@ For IEEE 802.11 wireless interfaces, disable powersave mode. .It Cm powersavesleep Ar sleep For IEEE 802.11 wireless interfaces, set the desired max powersave sleep time in milliseconds. +.It Cm protmode Ar technique +For IEEE 802.11 wireless interfaces operating in 11g, use the specified +technique for protecting OFDM frames in a mixed 11b/11g network. +The set of valid techniques is +.Dq off , +.Dq cts +(CTS to self), +and +.Dq rtscts +(RTS/CTS). +Technique names are case insensitive. +.It Cm rtsthreshold Ar length +For IEEE 802.11 wireless interfaces, set the threshold for which +transmitted frames are preceded by transmission of an +RTS +control frame. +.Ar Length +is the frame size in bytes and must be in the range 1 to 2312. +Not all adaptors support setting the RTS threshold. +.It Cm txpower Ar power +For IEEE 802.11 wireless interfaces, set the power used to transmit frames. +.Ar Power +is a unitless value in the range 0 to 100 that is interpreted +by drivers to derive a device-specific value. +Out of range values are truncated. +Typically only a few discreet power settings are available and +the driver will use the setting closest to the specified value. +Not all adaptors support changing the transmit power. .It Cm wepmode Ar mode For IEEE 802.11 wireless interfaces, set the desired WEP mode. Not all adaptors support all modes. diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 05c06acaf8de..4957bd6ccccc 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -274,6 +274,9 @@ struct cmd { { "wepkey", NEXTARG, set80211wepkey }, { "nwkey", NEXTARG, set80211nwkey }, /* NetBSD */ { "-nwkey", 0, set80211wep }, /* NetBSD */ + { "rtsthreshold",NEXTARG, set80211rtsthreshold }, + { "protmode", NEXTARG, set80211protmode }, + { "txpower", NEXTARG, set80211txpower }, #endif #ifdef USE_MAC { "maclabel", NEXTARG, setifmaclabel }, diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h index 622be5409772..fb340fc1b2c9 100644 --- a/sbin/ifconfig/ifconfig.h +++ b/sbin/ifconfig/ifconfig.h @@ -64,6 +64,9 @@ extern void set80211wep(const char *, int, int, const struct afswtch *rafp); extern void set80211weptxkey(const char *, int, int, const struct afswtch *rafp); extern void set80211wepkey(const char *, int, int, const struct afswtch *rafp); extern void set80211nwkey(const char *, int, int, const struct afswtch *rafp); +extern void set80211rtsthreshold(const char *, int, int, const struct afswtch *rafp); +extern void set80211protmode(const char *, int, int, const struct afswtch *rafp); +extern void set80211txpower(const char *, int, int, const struct afswtch *rafp); extern void ieee80211_status(int s, struct rt_addrinfo *); extern void maclabel_status(int s, struct rt_addrinfo *); extern void setifmaclabel(const char *, int, int, const struct afswtch *rafp); diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c index 031dc8f03b4d..6f83de077407 100644 --- a/sbin/ifconfig/ifieee80211.c +++ b/sbin/ifconfig/ifieee80211.c @@ -285,6 +285,36 @@ set80211nwkey(const char *val, int d, int s, const struct afswtch *rafp) set80211(s, IEEE80211_IOC_WEPTXKEY, txkey, 0, NULL); } +void +set80211rtsthreshold(const char *val, int d, int s, const struct afswtch *rafp) +{ + set80211(s, IEEE80211_IOC_RTSTHRESHOLD, atoi(val), 0, NULL); +} + +void +set80211protmode(const char *val, int d, int s, const struct afswtch *rafp) +{ + int mode; + + if (strcasecmp(val, "off") == 0) { + mode = IEEE80211_PROTMODE_OFF; + } else if (strcasecmp(val, "cts") == 0) { + mode = IEEE80211_PROTMODE_CTS; + } else if (strcasecmp(val, "rtscts") == 0) { + mode = IEEE80211_PROTMODE_RTSCTS; + } else { + err(1, "unknown protection mode"); + } + + set80211(s, IEEE80211_IOC_PROTMODE, mode, 0, NULL); +} + +void +set80211txpower(const char *val, int d, int s, const struct afswtch *rafp) +{ + set80211(s, IEEE80211_IOC_TXPOWER, atoi(val), 0, NULL); +} + void ieee80211_status (int s, struct rt_addrinfo *info __unused) { @@ -380,6 +410,42 @@ ieee80211_status (int s, struct rt_addrinfo *info __unused) printf("\n"); + spacer = '\t'; + ireq.i_type = IEEE80211_IOC_RTSTHRESHOLD; + if (ioctl(s, SIOCG80211, &ireq) != -1) { + printf("%crtsthreshold %d", spacer, ireq.i_val); + spacer = ' '; + } + + ireq.i_type = IEEE80211_IOC_PROTMODE; + if (ioctl(s, SIOCG80211, &ireq) != -1) { + printf("%cprotmode", spacer); + switch (ireq.i_val) { + case IEEE80211_PROTMODE_OFF: + printf(" OFF"); + break; + case IEEE80211_PROTMODE_CTS: + printf(" CTS"); + break; + case IEEE80211_PROTMODE_RTSCTS: + printf(" RTSCTS"); + break; + default: + printf(" UNKNOWN"); + break; + } + spacer = ' '; + } + + ireq.i_type = IEEE80211_IOC_TXPOWER; + if (ioctl(s, SIOCG80211, &ireq) != -1) { + printf("%ctxpower %d", spacer, ireq.i_val); + spacer = ' '; + } + + if (spacer != '\t') + printf("\n"); + ireq.i_type = IEEE80211_IOC_WEP; if (ioctl(s, SIOCG80211, &ireq) != -1 && ireq.i_val != IEEE80211_WEP_NOSUP) {