summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2009-02-15 08:34:37 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2009-02-15 08:34:37 +0000
commitc1f22d4e90b417b596eb9b56a562cfa40d477496 (patch)
treee919d21d1931178ac36a18f42253f84cfb6222a0
parent25cc901ec9b4af0e38b2b1ea6b4708a464bc041d (diff)
make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known stations in Host AP mode. remove the [-]wmm command while i'm here. QoS is mandatory with 802.11n so there's not much point into making it an option. fix parsing of the "powersave" command too. discussed with deraadt@ man page hints from jmc@ display hints from sobrado@ "i like it" cnst@, grange@
-rw-r--r--sbin/ifconfig/ifconfig.832
-rw-r--r--sbin/ifconfig/ifconfig.c91
-rw-r--r--sys/net80211/ieee80211_ioctl.c7
-rw-r--r--sys/net80211/ieee80211_ioctl.h30
4 files changed, 99 insertions, 61 deletions
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8
index 1d2af36c305..4c1fd92c062 100644
--- a/sbin/ifconfig/ifconfig.8
+++ b/sbin/ifconfig/ifconfig.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ifconfig.8,v 1.174 2009/02/13 17:24:54 damien Exp $
+.\" $OpenBSD: ifconfig.8,v 1.175 2009/02/15 08:34:36 damien Exp $
.\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $
.\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $
.\"
@@ -31,7 +31,7 @@
.\"
.\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94
.\"
-.Dd $Mdocdate: February 13 2009 $
+.Dd $Mdocdate: February 15 2009 $
.Dt IFCONFIG 8
.Os
.Sh NAME
@@ -571,8 +571,8 @@ will begin advertising as master.
.Op Oo Fl Oc Cm nwid Ar id
.Op Oo Fl Oc Cm nwkey Ar key
.Op Oo Fl Oc Cm powersave Op Ar duration
+.Op Cm scan
.Op Oo Fl Oc Cm txpower Ar dBm
-.Op Oo Fl Oc Cm wmm
.Op Oo Fl Oc Cm wpa
.Op Cm wpaakms Ar akm,akm,...
.Op Cm wpaciphers Ar cipher,cipher,...
@@ -595,8 +595,7 @@ wireless network interfaces to
.Ar n .
.Pp
With no channel specified,
-show the results of an access point scan.
-In Host AP mode, this will dump the list of known nodes without scanning.
+show the list of channels supported by the device.
.It Fl chan
Unset the desired channel to be used for IEEE 802.11-based wireless
network interfaces.
@@ -687,6 +686,9 @@ Enable 802.11 power saving mode.
Optionally set the receiver sleep duration (in milliseconds).
.It Fl powersave
Disable 802.11 power saving mode.
+.It Cm scan
+Show the results of an access point scan.
+In Host AP mode, this will dump the list of known nodes without scanning.
.It Cm txpower Ar dBm
Set the transmit power for IEEE 802.11-based wireless network interfaces.
The driver will disable any auto level and transmit power controls in this
@@ -694,24 +696,6 @@ mode.
.It Fl txpower
Disable manual transmit power mode and enable any auto level and transmit
power controls.
-.It Cm wmm
-Enable Wi-Fi Multimedia (WMM).
-WMM is a Wi-Fi Alliance protocol based on the IEEE 802.11e standard and
-provides basic Quality of Service (QoS) features to Wi-Fi networks.
-For a station, this option enables the use of QoS if the access point
-supports it but it does not prevent the association to an access point
-not supporting QoS.
-In Host AP mode, this option allows QoS stations to negotiate QoS during
-association.
-Notice that not all drivers support QoS.
-Check the driver's manual page to know if this option is supported.
-QoS priorities can be defined using VLANs (see the
-.Cm vlanprio
-option).
-Otherwise, the IEEE 802.11 layer will automatically assign priorities to
-frames based on the Differentiated Services Codepoint field of IP packets.
-.It Fl wmm
-Disable Wi-Fi Multimedia.
.It Cm wpa
Enable Wi-Fi Protected Access.
WPA is a Wi-Fi Alliance protocol based on the IEEE 802.11i standard.
@@ -1223,7 +1207,7 @@ Create the gif1 network interface:
.Pp
Scan for wireless networks using bwi0:
.Pp
-.Dl # ifconfig bwi0 chan
+.Dl # ifconfig bwi0 scan
.Sh DIAGNOSTICS
Messages indicating the specified interface does not exist, the
requested address is unknown, or the user is not privileged and
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 3b96b824382..7b00bc4bfb4 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifconfig.c,v 1.212 2009/02/13 17:24:54 damien Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.213 2009/02/15 08:34:36 damien Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
@@ -130,7 +130,8 @@ int Lflag = 1;
#endif /* INET6 */
int showmediaflag;
-int shownet80211flag;
+int shownet80211chans;
+int shownet80211nodes;
void notealias(const char *, int);
void notrailers(const char *, int);
@@ -150,7 +151,6 @@ void setifmtu(const char *, int);
void setifnwid(const char *, int);
void setifbssid(const char *, int);
void setifnwkey(const char *, int);
-void setifwmm(const char *, int);
void setifwpa(const char *, int);
void setifwpaprotos(const char *, int);
void setifwpaakms(const char *, int);
@@ -158,6 +158,7 @@ void setifwpaciphers(const char *, int);
void setifwpagroupcipher(const char *, int);
void setifwpapsk(const char *, int);
void setifchan(const char *, int);
+void setifscan(const char *, int);
void setiftxpower(const char *, int);
void setifpowersave(const char *, int);
void setifnwflag(const char *, int);
@@ -301,8 +302,6 @@ const struct cmd {
{ "-bssid", -1, 0, setifbssid },
{ "nwkey", NEXTARG, 0, setifnwkey },
{ "-nwkey", -1, 0, setifnwkey },
- { "wmm", 1, 0, setifwmm },
- { "-wmm", 0, 0, setifwmm },
{ "wpa", 1, 0, setifwpa },
{ "-wpa", 0, 0, setifwpa },
{ "wpaakms", NEXTARG, 0, setifwpaakms },
@@ -313,8 +312,9 @@ const struct cmd {
{ "-wpapsk", -1, 0, setifwpapsk },
{ "chan", NEXTARG0, 0, setifchan },
{ "-chan", -1, 0, setifchan },
+ { "scan", NEXTARG0, 0, setifscan },
{ "powersave", NEXTARG0, 0, setifpowersave },
- { "-powersave", 0, 0, setifpowersave },
+ { "-powersave", -1, 0, setifpowersave },
{ "broadcast", NEXTARG, 0, setifbroadaddr },
{ "ipdst", NEXTARG, 0, setifipdst },
{ "prefixlen", NEXTARG, 0, setifprefixlen},
@@ -456,6 +456,7 @@ void in6_getprefix(const char *, int);
void at_status(int);
void at_getaddr(const char *, int);
void ieee80211_status(void);
+void ieee80211_listchans(void);
void ieee80211_listnodes(void);
void ieee80211_printnode(struct ieee80211_nodereq *);
@@ -1448,18 +1449,6 @@ setifnwkey(const char *val, int d)
/* ARGSUSED */
void
-setifwmm(const char *val, int d)
-{
- struct ieee80211_wmmparams wmm;
-
- (void)strlcpy(wmm.i_name, name, sizeof(wmm.i_name));
- wmm.i_enabled = d;
- if (ioctl(s, SIOCS80211WMMPARMS, (caddr_t)&wmm) < 0)
- err(1, "SIOCS80211WMMPARMS");
-}
-
-/* ARGSUSED */
-void
setifwpa(const char *val, int d)
{
struct ieee80211_wpaparams wpa;
@@ -1631,16 +1620,16 @@ setifchan(const char *val, int d)
int chan;
if (val == NULL) {
- if (shownet80211flag)
+ if (shownet80211chans || shownet80211nodes)
usage(1);
- shownet80211flag = 1;
+ shownet80211chans = 1;
return;
}
if (d != 0)
chan = IEEE80211_CHAN_ANY;
else {
chan = atoi(val);
- if (chan < 0 || chan > 0xffff) {
+ if (chan < 1 || chan > 256) {
warnx("invalid channel: %s", val);
return;
}
@@ -1652,6 +1641,15 @@ setifchan(const char *val, int d)
warn("SIOCS80211CHANNEL");
}
+/* ARGSUSED */
+void
+setifscan(const char *val, int d)
+{
+ if (shownet80211chans || shownet80211nodes)
+ usage(1);
+ shownet80211nodes = 1;
+}
+
#ifndef SMALL
void
setiftxpower(const char *val, int d)
@@ -1723,13 +1721,13 @@ setifpowersave(const char *val, int d)
return;
}
- if (val) {
+ if (d != -1 && val != NULL) {
power.i_maxsleep = strtonum(val, 0, INT_MAX, &errmsg);
if (errmsg)
errx(1, "powersave %s: %s", val, errmsg);
}
- power.i_enabled = d;
+ power.i_enabled = d == -1 ? 0 : 1;
if (ioctl(s, SIOCS80211POWER, (caddr_t)&power) == -1)
warn("SIOCS80211POWER");
}
@@ -1756,7 +1754,7 @@ void
ieee80211_status(void)
{
int len, i, nwkey_verbose, inwid, inwkey, ipsk, ichan, ipwr;
- int ibssid, itxpower, iwmm, iwpa;
+ int ibssid, itxpower, iwpa;
struct ieee80211_nwid nwid;
struct ieee80211_nwkey nwkey;
struct ieee80211_wpapsk psk;
@@ -1764,7 +1762,6 @@ ieee80211_status(void)
struct ieee80211chanreq channel;
struct ieee80211_bssid bssid;
struct ieee80211_txpower txpower;
- struct ieee80211_wmmparams wmm;
struct ieee80211_wpaparams wpa;
struct ieee80211_nodereq nr;
u_int8_t zero_bssid[IEEE80211_ADDR_LEN];
@@ -1801,18 +1798,13 @@ ieee80211_status(void)
strlcpy(txpower.i_name, name, sizeof(txpower.i_name));
itxpower = ioctl(s, SIOCG80211TXPOWER, &txpower);
- memset(&wmm, 0, sizeof(wmm));
- strlcpy(wmm.i_name, name, sizeof(wmm.i_name));
- iwmm = ioctl(s, SIOCG80211WMMPARMS, &wmm);
-
memset(&wpa, 0, sizeof(wpa));
strlcpy(wpa.i_name, name, sizeof(wpa.i_name));
iwpa = ioctl(s, SIOCG80211WPAPARMS, &wpa);
/* check if any ieee80211 option is active */
if (inwid == 0 || inwkey == 0 || ipsk == 0 || ipwr == 0 ||
- ichan == 0 || ibssid == 0 || iwmm == 0 || iwpa == 0 ||
- itxpower == 0)
+ ichan == 0 || ibssid == 0 || iwpa == 0 || itxpower == 0)
fputs("\tieee80211:", stdout);
else
return;
@@ -1827,7 +1819,7 @@ ieee80211_status(void)
}
if (ichan == 0 && channel.i_channel != 0 &&
- channel.i_channel != (u_int16_t)-1)
+ channel.i_channel != IEEE80211_CHAN_ANY)
printf(" chan %u", channel.i_channel);
memset(&zero_bssid, 0, sizeof(zero_bssid));
@@ -1937,8 +1929,6 @@ ieee80211_status(void)
fputs(" wpagroupcipher ", stdout);
print_cipherset(wpa.i_groupcipher);
}
- if (iwmm == 0 && wmm.i_enabled)
- fputs(" wmm", stdout);
if (ipwr == 0 && power.i_enabled)
printf(" powersave on (%dms sleep)", power.i_maxsleep);
@@ -1955,11 +1945,42 @@ ieee80211_status(void)
}
putchar('\n');
- if (shownet80211flag)
+ if (shownet80211chans)
+ ieee80211_listchans();
+ else if (shownet80211nodes)
ieee80211_listnodes();
}
void
+ieee80211_listchans(void)
+{
+ static struct ieee80211_channel chans[256+1];
+ struct ieee80211_chanreq_all ca;
+ int i;
+
+ bzero(&ca, sizeof(ca));
+ bzero(chans, sizeof(chans));
+ ca.i_chans = chans;
+ strlcpy(ca.i_name, name, sizeof(ca.i_name));
+
+ if (ioctl(s, SIOCG80211ALLCHANS, &ca) != 0) {
+ warn("SIOCG80211ALLCHANS");
+ return;
+ }
+ printf("\t\t%4s %-8s %s\n", "chan", "freq", "properties");
+ for (i = 1; i <= 256; i++) {
+ if (chans[i].ic_flags == 0)
+ continue;
+ printf("\t\t%4d %4d MHz ", i, chans[i].ic_freq);
+ if (chans[i].ic_flags & IEEE80211_CHAN_PASSIVE)
+ printf("passive scan");
+ else
+ putchar('-');
+ putchar('\n');
+ }
+}
+
+void
ieee80211_listnodes(void)
{
struct ieee80211_nodereq_all na;
diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c
index 37f7c6ae01a..7f2a978f16a 100644
--- a/sys/net80211/ieee80211_ioctl.c
+++ b/sys/net80211/ieee80211_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_ioctl.c,v 1.30 2009/02/13 17:24:54 damien Exp $ */
+/* $OpenBSD: ieee80211_ioctl.c,v 1.31 2009/02/15 08:34:36 damien Exp $ */
/* $NetBSD: ieee80211_ioctl.c,v 1.15 2004/05/06 02:58:16 dyoung Exp $ */
/*-
@@ -574,6 +574,11 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
}
chanreq->i_channel = ieee80211_chan2ieee(ic, chan);
break;
+ case SIOCG80211ALLCHANS:
+ error = copyout(ic->ic_channels,
+ ((struct ieee80211_chanreq_all *)data)->i_chans,
+ sizeof(ic->ic_channels));
+ break;
#if 0
case SIOCG80211ZSTATS:
#endif
diff --git a/sys/net80211/ieee80211_ioctl.h b/sys/net80211/ieee80211_ioctl.h
index e836b3ee832..3ffebcb7575 100644
--- a/sys/net80211/ieee80211_ioctl.h
+++ b/sys/net80211/ieee80211_ioctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_ioctl.h,v 1.16 2009/02/13 17:24:54 damien Exp $ */
+/* $OpenBSD: ieee80211_ioctl.h,v 1.17 2009/02/15 08:34:36 damien Exp $ */
/* $NetBSD: ieee80211_ioctl.h,v 1.7 2004/04/30 22:51:04 dyoung Exp $ */
/*-
@@ -156,12 +156,40 @@ struct ieee80211chanreq {
u_int16_t i_channel;
};
+#ifndef _KERNEL
+/*
+ * Channels are specified by frequency and attributes.
+ */
+struct ieee80211_channel {
+ u_int16_t ic_freq; /* setting in MHz */
+ u_int16_t ic_flags; /* see below */
+};
+
+/*
+ * Channel attributes (XXX must keep in sync with radiotap flags).
+ */
+#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */
+#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */
+#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */
+#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel */
+#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */
+#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */
+#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */
+#define IEEE80211_CHAN_XR 0x1000 /* Extended range OFDM channel */
+#endif /* !_KERNEL */
+
+struct ieee80211_chanreq_all {
+ char i_name[IFNAMSIZ]; /* if_name, e.g. "wi0" */
+ struct ieee80211_channel *i_chans;
+};
+
#ifndef IEEE80211_CHAN_ANY
#define IEEE80211_CHAN_ANY 0xffff
#endif
#define SIOCS80211CHANNEL _IOW('i', 238, struct ieee80211chanreq)
#define SIOCG80211CHANNEL _IOWR('i', 239, struct ieee80211chanreq)
+#define SIOCG80211ALLCHANS _IOWR('i', 215, struct ieee80211_chanreq_all)
/* BSS identifier */
struct ieee80211_bssid {