add support for setting 802.11 rtsthreshold, transmit power,

and 11g protection mode

Reviewed by:	imp (just code)
This commit is contained in:
Sam Leffler 2004-03-30 22:59:22 +00:00
parent 2e79ca9762
commit a6b03f428a
4 changed files with 101 additions and 1 deletions

View File

@ -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.

View File

@ -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 },

View File

@ -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);

View File

@ -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) {