summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2005-02-21 13:33:30 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2005-02-21 13:33:30 +0000
commit112694de422eccd0d7ca5271f10b58dc37931244 (patch)
treed003305655fc75ce8c08efb0992e8a54725846dc /sbin
parent7ba16a3768bef73dc9f8aa18ddfa30b7b0ba1fea (diff)
ipwcontrol and iwicontrol removal.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/Makefile4
-rw-r--r--sbin/ipwcontrol/Makefile14
-rw-r--r--sbin/ipwcontrol/ipwcontrol.865
-rw-r--r--sbin/ipwcontrol/ipwcontrol.c354
-rw-r--r--sbin/iwicontrol/Makefile14
-rw-r--r--sbin/iwicontrol/iwicontrol.865
-rw-r--r--sbin/iwicontrol/iwicontrol.c214
7 files changed, 2 insertions, 728 deletions
diff --git a/sbin/Makefile b/sbin/Makefile
index c7d89e2092b..42cc61fafe8 100644
--- a/sbin/Makefile
+++ b/sbin/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.69 2004/10/20 12:50:48 deraadt Exp $
+# $OpenBSD: Makefile,v 1.70 2005/02/21 13:33:09 damien Exp $
# Not ported: XNSrouted enpload scsiformat startslip
# Missing: icheck
@@ -32,6 +32,6 @@ SUBDIR+= mount_xfs
SUBDIR+= ping6 rtsol
# Man pages (and manpages to do)
-SUBDIR+= fdisk pdisk ancontrol wicontrol wsconsctl iwicontrol ipwcontrol
+SUBDIR+= fdisk pdisk ancontrol wicontrol wsconsctl
.include <bsd.subdir.mk>
diff --git a/sbin/ipwcontrol/Makefile b/sbin/ipwcontrol/Makefile
deleted file mode 100644
index d214c222829..00000000000
--- a/sbin/ipwcontrol/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $Id: Makefile,v 1.2 2004/10/22 16:20:51 deraadt Exp $
-
-.if (${MACHINE} == "i386") || (${MACHINE} == "amd64") || \
- (${MACHINE} == "alpha") || (${MACHINE} == "sgi") || \
- (${MACHINE} == "sparc64") || (${MACHINE_ARCH} == "powerpc") || \
- (${MACHINE} == "cats") || (${MACHINE} == "hppa")
-PROG= ipwcontrol
-.else
-NOPROG=
-.endif
-
-MAN= ipwcontrol.8
-
-.include <bsd.prog.mk>
diff --git a/sbin/ipwcontrol/ipwcontrol.8 b/sbin/ipwcontrol/ipwcontrol.8
deleted file mode 100644
index cccf87524de..00000000000
--- a/sbin/ipwcontrol/ipwcontrol.8
+++ /dev/null
@@ -1,65 +0,0 @@
-.\" $OpenBSD: ipwcontrol.8,v 1.4 2004/11/21 23:52:56 jmc Exp $
-.\"
-.\" Copyright (c) 2004
-.\" Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice unmodified, this list of conditions, and the following
-.\" disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.Dd September 4, 2004
-.Os
-.Dt IPWCONTROL 8
-.Sh NAME
-.Nm ipwcontrol
-.Nd configure Intel PRO/Wireless 2100 network adapter
-.Sh SYNOPSIS
-.Nm
-.Op Fl r
-.Op Fl i Ar interface
-.Sh DESCRIPTION
-The
-.Nm
-utility controls the operation of Intel PRO/Wireless 2100 networking
-devices via the
-.Xr ipw 4
-driver.
-.Pp
-You should not use this program to configure IEEE 802.11 parameters.
-Use
-.Xr ifconfig 8
-instead.
-.Pp
-The options are as follows:
-.Bl -tag -width "-i interfaceXX"
-.It Fl i Ar interface
-Display the adapter's internal statistics.
-.It Fl r
-Display the radio switch state (on or off).
-.El
-.Sh SEE ALSO
-.Xr ipw 4 ,
-.Xr ifconfig 8
-.Sh AUTHORS
-The
-.Nm
-utility and this man page were written by
-.An Damien Bergamini Aq damien.bergamini@free.fr .
diff --git a/sbin/ipwcontrol/ipwcontrol.c b/sbin/ipwcontrol/ipwcontrol.c
deleted file mode 100644
index acb1ff6fece..00000000000
--- a/sbin/ipwcontrol/ipwcontrol.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/* $Id: ipwcontrol.c,v 1.7 2004/11/18 21:02:32 damien Exp $ */
-
-/*-
- * Copyright (c) 2004
- * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice unmodified, this list of conditions, and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char rcsid[] = "$Id: ipwcontrol.c,v 1.7 2004/11/18 21:02:32 damien Exp $";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-#include <unistd.h>
-
-#define SIOCGRADIO _IOWR('i', 139, struct ifreq)
-#define SIOCGTABLE1 _IOWR('i', 140, struct ifreq)
-
-extern char *optarg;
-extern int optind;
-
-static void usage(void);
-static int do_req(char *, unsigned long, void *);
-static void get_radio_state(char *);
-static void get_statistics(char *);
-
-int
-main(int argc, char **argv)
-{
- int ch, ifspecified = 0;
- char *iface;
-
- iface = "ipw0";
- if (argc > 1 && argv[1][0] != '-') {
- iface = argv[1];
- ifspecified = 1;
- optind = 2;
- }
-
- while ((ch = getopt(argc, argv, "hi:r")) != -1) {
- switch (ch) {
- case 'i':
- if (!ifspecified)
- iface = optarg;
- break;
-
- case 'r':
- get_radio_state(iface);
- return EX_OK;
-
- case 'h':
- default:
- usage();
- }
- }
-
- get_statistics(iface);
-
- return EX_OK;
-}
-
-static void
-usage(void)
-{
- extern char *__progname;
-
- fprintf(stderr, "usage: %s [interface] [-r]\n", __progname);
-
- exit(EX_USAGE);
-}
-
-static int
-do_req(char *iface, unsigned long req, void *data)
-{
- int s;
- struct ifreq ifr;
- int error;
-
- if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
- err(EX_OSERR, "Can't create socket");
-
- memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
- ifr.ifr_data = data;
- error = ioctl(s, req, &ifr);
-
- (void)close(s);
-
- return error;
-}
-
-static void
-get_radio_state(char *iface)
-{
- int radio;
-
- if (do_req(iface, SIOCGRADIO, &radio) == -1)
- err(EX_OSERR, "Can't retrieve radio transmitter state");
-
- (void)printf("Radio is %s\n", radio ? "ON" : "OFF");
-}
-
-struct statistic {
- int index;
- const char *desc;
- int unit;
-#define INT 1
-#define HEX 2
-#define MASK HEX
-#define PERCENTAGE 3
-#define BOOL 4
-};
-
-/*-
- * TIM = Traffic Information Message
- * DTIM = Delivery TIM
- * ATIM = Announcement TIM
- * PSP = Power Save Poll
- * RTS = Request To Send
- * CTS = Clear To Send
- * RSSI = Received Signal Strength Indicator
- */
-
-static const struct statistic tbl[] = {
- { 1, "Number of frames submitted for transfer", INT },
- { 2, "Number of frames transmitted", INT },
- { 3, "Number of unicast frames transmitted", INT },
- { 4, "Number of unicast frames transmitted at 1Mb/s", INT },
- { 5, "Number of unicast frames transmitted at 2Mb/s", INT },
- { 6, "Number of unicast frames transmitted at 5.5Mb/s", INT },
- { 7, "Number of unicast frames transmitted at 11Mb/s", INT },
-
- { 13, "Number of multicast frames transmitted at 1Mb/s", INT },
- { 14, "Number of multicast frames transmitted at 2Mb/s", INT },
- { 15, "Number of multicast frames transmitted at 5.5Mb/s", INT },
- { 16, "Number of multicast frames transmitted at 11Mb/s", INT },
-
- { 21, "Number of null frames transmitted", INT },
- { 22, "Number of RTS frames transmitted", INT },
- { 23, "Number of CTS frames transmitted", INT },
- { 24, "Number of ACK frames transmitted", INT },
- { 25, "Number of association requests transmitted", INT },
- { 26, "Number of association responses transmitted", INT },
- { 27, "Number of reassociation requests transmitted", INT },
- { 28, "Number of reassociation responses transmitted", INT },
- { 29, "Number of probe requests transmitted", INT },
- { 30, "Number of probe reponses transmitted", INT },
- { 31, "Number of beacons transmitted", INT },
- { 32, "Number of ATIM frames transmitted", INT },
- { 33, "Number of disassociation requests transmitted", INT },
- { 34, "Number of authentication requests transmitted", INT },
- { 35, "Number of deauthentication requests transmitted", INT },
-
- { 41, "Number of bytes transmitted", INT },
- { 42, "Number of transmission retries", INT },
- { 43, "Number of transmission retries at 1Mb/s", INT },
- { 44, "Number of transmission retries at 2Mb/s", INT },
- { 45, "Number of transmission retries at 5.5Mb/s", INT },
- { 46, "Number of transmission retries at 11Mb/s", INT },
-
- { 51, "Number of transmission failures", INT },
-
- { 54, "Number of transmission aborted due to DMA", INT },
-
- { 56, "Number of disassociation failures", INT },
-
- { 58, "Number of spanning tree frames transmitted", INT },
- { 59, "Number of transmission errors due to missing ACK", INT },
-
- { 61, "Number of frames received", INT },
- { 62, "Number of unicast frames received", INT },
- { 63, "Number of unicast frames received at 1Mb/s", INT },
- { 64, "Number of unicast frames received at 2Mb/s", INT },
- { 65, "Number of unicast frames received at 5.5Mb/s", INT },
- { 66, "Number of unicast frames received at 11Mb/s", INT },
-
- { 71, "Number of multicast frames received", INT },
- { 72, "Number of multicast frames received at 1Mb/s", INT },
- { 73, "Number of multicast frames received at 2Mb/s", INT },
- { 74, "Number of multicast frames received at 5.5Mb/s", INT },
- { 75, "Number of multicast frames received at 11Mb/s", INT },
-
- { 80, "Number of null frames received", INT },
- { 81, "Number of poll frames received", INT },
- { 82, "Number of RTS frames received", INT },
- { 83, "Number of CTS frames received", INT },
- { 84, "Number of ACK frames received", INT },
- { 85, "Number of CF-End frames received", INT },
- { 86, "Number of CF-End + CF-Ack frames received", INT },
- { 87, "Number of association requests received", INT },
- { 88, "Number of association responses received", INT },
- { 89, "Number of reassociation requests received", INT },
- { 90, "Number of reassociation responses received", INT },
- { 91, "Number of probe requests received", INT },
- { 92, "Number of probe reponses received", INT },
- { 93, "Number of beacons received", INT },
- { 94, "Number of ATIM frames received", INT },
- { 95, "Number of disassociation requests received", INT },
- { 96, "Number of authentication requests received", INT },
- { 97, "Number of deauthentication requests received", INT },
-
- { 101, "Number of bytes received", INT },
- { 102, "Number of frames with a bad CRC received", INT },
- { 103, "Number of frames with a bad CRC received at 1Mb/s", INT },
- { 104, "Number of frames with a bad CRC received at 2Mb/s", INT },
- { 105, "Number of frames with a bad CRC received at 5.5Mb/s", INT },
- { 106, "Number of frames with a bad CRC received at 11Mb/s", INT },
-
- { 112, "Number of duplicated frames received at 1Mb/s", INT },
- { 113, "Number of duplicated frames received at 2Mb/s", INT },
- { 114, "Number of duplicated frames received at 5.5Mb/s", INT },
- { 115, "Number of duplicated frames received at 11Mb/s", INT },
-
- { 119, "Number of duplicated frames received", INT },
-
- { 123, "Number of frames with a bad protocol received", INT },
- { 124, "Boot time", INT },
- { 125, "Number of frames dropped due to missing buffer", INT },
- { 126, "Number of frames dropped due to DMA", INT },
-
- { 128, "Number of frames dropped due to missing fragment", INT },
- { 129, "Number of frames dropped due to non-seq fragment", INT },
- { 130, "Number of frames dropped due to missing first frame", INT },
- { 131, "Number of frames dropped due to uncompleted frame", INT },
-
- { 137, "Number of times adapter suspended", INT },
- { 138, "Beacon timeout", INT },
- { 139, "Number of poll response timeouts", INT },
-
- { 141, "Number of PSP DTIM frames received", INT },
- { 142, "Number of PSP TIM frames received", INT },
- { 143, "PSP station Id", INT },
-
- { 147, "RTC time of last association", INT },
- { 148, "Percentage of missed beacons", PERCENTAGE },
- { 149, "Percentage of missed transmission retries", PERCENTAGE },
-
- { 151, "Number of access points in access points table", INT },
-
- { 153, "Number of associations", INT },
- { 154, "Number of association failures", INT },
- { 156, "Number of full scans", INT },
- { 157, "Card disabled", BOOL },
-
- { 160, "RSSI at time of association", INT },
- { 161, "Number of reassociations due to no probe response", INT },
- { 162, "Number of reassociations due to poor line quality", INT },
- { 163, "Number of reassociations due to load", INT },
- { 164, "Number of reassociations due to access point RSSI level", INT },
- { 165, "Number of reassociations due to load leveling", INT },
-
- { 170, "Number of times authentication failed", INT },
- { 171, "Number of times authentication response failed", INT },
- { 172, "Number of entries in association table", INT },
- { 173, "Average RSSI", INT },
-
- { 176, "Self test status", INT },
- { 177, "Power mode", INT },
- { 178, "Power index", INT },
- { 179, "IEEE country code", HEX },
- { 180, "Channels supported for this country", MASK },
- { 181, "Number of adapter warm resets", INT },
- { 182, "Beacon interval", INT },
-
- { 184, "Princeton version", INT },
- { 185, "Antenna diversity disabled", BOOL },
- { 186, "CCA RSSI", INT },
- { 187, "Number of times EEPROM updated", INT },
- { 188, "Beacon intervals between DTIM", INT },
- { 189, "Current channel", INT },
- { 190, "RTC time", INT },
- { 191, "Operating mode", INT },
- { 192, "Transmission rate", HEX },
- { 193, "Supported transmission rates", MASK },
- { 194, "ATIM window", INT },
- { 195, "Supported basic transmission rates", MASK },
- { 196, "Adapter highest rate", HEX },
- { 197, "Access point highest rate", HEX },
- { 198, "Management frame capability", BOOL },
- { 199, "Type of authentication", INT },
- { 200, "Adapter card platform type", INT },
- { 201, "RTS threshold", INT },
- { 202, "International mode", BOOL },
- { 203, "Fragmentation threshold", INT },
-
- { 213, "Microcode version", INT },
-
- { 0, NULL, 0 }
-};
-
-static void
-get_statistics(char *iface)
-{
- static unsigned long stats[256]; /* XXX */
- const struct statistic *stat;
-
- if (do_req(iface, SIOCGTABLE1, stats) == -1)
- err(EX_OSERR, "Can't retrieve statistics");
-
- for (stat = tbl; stat->index != 0; stat++) {
- (void)printf("%-60s[", stat->desc);
- switch (stat->unit) {
- case INT:
- (void)printf("%lu", stats[stat->index]);
- break;
-
- case BOOL:
- (void)printf(stats[stat->index] ? "true" : "false");
- break;
-
- case PERCENTAGE:
- (void)printf("%lu%%", stats[stat->index]);
- break;
-
- case HEX:
- default:
- (void)printf("0x%08lX", stats[stat->index]);
- }
- (void)printf("]\n");
- }
-}
diff --git a/sbin/iwicontrol/Makefile b/sbin/iwicontrol/Makefile
deleted file mode 100644
index 8723958cfe2..00000000000
--- a/sbin/iwicontrol/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $Id: Makefile,v 1.2 2004/10/22 16:20:51 deraadt Exp $
-
-.if (${MACHINE} == "i386") || (${MACHINE} == "amd64") || \
- (${MACHINE} == "alpha") || (${MACHINE} == "sgi") || \
- (${MACHINE} == "sparc64") || (${MACHINE_ARCH} == "powerpc") || \
- (${MACHINE} == "cats") || (${MACHINE} == "hppa")
-PROG= iwicontrol
-.else
-NOPROG=
-.endif
-
-MAN= iwicontrol.8
-
-.include <bsd.prog.mk>
diff --git a/sbin/iwicontrol/iwicontrol.8 b/sbin/iwicontrol/iwicontrol.8
deleted file mode 100644
index 6ed87e52a2d..00000000000
--- a/sbin/iwicontrol/iwicontrol.8
+++ /dev/null
@@ -1,65 +0,0 @@
-.\" $OpenBSD: iwicontrol.8,v 1.5 2004/11/23 21:33:24 jmc Exp $
-.\"
-.\" Copyright (c) 2004
-.\" Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice unmodified, this list of conditions, and the following
-.\" disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.Dd September 26, 2004
-.Os
-.Dt IWICONTROL 8
-.Sh NAME
-.Nm iwicontrol
-.Nd configure Intel(R) PRO/Wireless 2200BG/2915ABG network adapters
-.Sh SYNOPSIS
-.Nm
-.Op Fl i Ar interface
-.Op Fl r
-.Sh DESCRIPTION
-The
-.Nm
-utility controls the operation of Intel(R) PRO/Wireless 2200BG/2915ABG
-networking devices via the
-.Xr iwi 4
-driver.
-.Pp
-You should not use this program to configure IEEE 802.11 parameters.
-Use
-.Xr ifconfig 8
-instead.
-.Pp
-The options are as follows:
-.Bl -tag -width "-i interfaceXX"
-.It Fl i Ar interface
-Displays adapter's internal statistics.
-.It Fl r
-Displays the radio transmitter state (on or off).
-.El
-.Sh SEE ALSO
-.Xr iwi 4 ,
-.Xr ifconfig 8
-.Sh AUTHORS
-The
-.Nm
-utility and this man page were written by
-.An Damien Bergamini Aq damien.bergamini@free.fr .
diff --git a/sbin/iwicontrol/iwicontrol.c b/sbin/iwicontrol/iwicontrol.c
deleted file mode 100644
index d4e1fb59621..00000000000
--- a/sbin/iwicontrol/iwicontrol.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/* $Id: iwicontrol.c,v 1.7 2004/11/23 21:33:24 jmc Exp $ */
-
-/*-
- * Copyright (c) 2004
- * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice unmodified, this list of conditions, and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-#include <unistd.h>
-
-#define SIOCGRADIO _IOWR('i', 139, struct ifreq)
-#define SIOCGTABLE0 _IOWR('i', 140, struct ifreq)
-
-extern char *optarg;
-extern int optind;
-
-static void usage(void);
-static int do_req(char *, unsigned long, void *);
-static void get_radio_state(char *);
-static void get_statistics(char *);
-
-int
-main(int argc, char **argv)
-{
- char *iface = NULL;
- int noflag = 1, rflag = 0, ifspecified = 0;
- int ch;
-
- iface = "iwi0";
- if (argc > 1 && argv[1][0] != '-') {
- iface = argv[1];
- ifspecified = 1;
- optind = 2;
- }
-
- while ((ch = getopt(argc, argv, "hi:r")) != -1) {
- noflag = 0;
- switch (ch) {
- case 'i':
- if (!ifspecified)
- iface = optarg;
- break;
-
- case 'r':
- rflag = 1;
- break;
-
- case 'h':
- default:
- usage();
- }
- }
-
- if (iface == NULL)
- usage();
-
- if (rflag)
- get_radio_state(iface);
-
- if (noflag)
- get_statistics(iface);
-
- return EX_OK;
-}
-
-static void
-usage(void)
-{
- extern char *__progname;
-
- fprintf(stderr, "usage: %s [-i interface] [-r]\n", __progname);
-
- exit(EX_USAGE);
-}
-
-static int
-do_req(char *iface, unsigned long req, void *data)
-{
- int s;
- struct ifreq ifr;
- int error;
-
- if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
- err(EX_OSERR, "Can't create socket");
-
- (void)memset(&ifr, 0, sizeof ifr);
- (void)strncpy(ifr.ifr_name, iface, sizeof ifr.ifr_name);
- ifr.ifr_data = data;
- error = ioctl(s, req, &ifr);
-
- (void)close(s);
-
- return error;
-}
-
-static void
-get_radio_state(char *iface)
-{
- int radio;
-
- if (do_req(iface, SIOCGRADIO, &radio) == -1)
- err(EX_OSERR, "Can't read radio");
-
- (void)printf("Radio is %s\n", radio ? "ON" : "OFF");
-}
-
-struct statistic {
- int index;
- const char *desc;
-};
-
-static const struct statistic tbl[] = {
- { 1, "Current transmission rate" },
- { 2, "Fragmentation threshold" },
- { 3, "RTS threshold" },
- { 4, "Number of frames submitted for transfer" },
- { 5, "Number of frames transmitted" },
- { 6, "Number of unicast frames transmitted" },
- { 7, "Number of unicast 802.11b frames transmitted at 1Mb/s" },
- { 8, "Number of unicast 802.11b frames transmitted at 2Mb/s" },
- { 9, "Number of unicast 802.11b frames transmitted at 5.5Mb/s" },
- { 10, "Number of unicast 802.11b frames transmitted at 11Mb/s" },
-
- { 19, "Number of unicast 802.11g frames transmitted at 1Mb/s" },
- { 20, "Number of unicast 802.11g frames transmitted at 2Mb/s" },
- { 21, "Number of unicast 802.11g frames transmitted at 5.5Mb/s" },
- { 22, "Number of unicast 802.11g frames transmitted at 6Mb/s" },
- { 23, "Number of unicast 802.11g frames transmitted at 9Mb/s" },
- { 24, "Number of unicast 802.11g frames transmitted at 11Mb/s" },
- { 25, "Number of unicast 802.11g frames transmitted at 12Mb/s" },
- { 26, "Number of unicast 802.11g frames transmitted at 18Mb/s" },
- { 27, "Number of unicast 802.11g frames transmitted at 24Mb/s" },
- { 28, "Number of unicast 802.11g frames transmitted at 36Mb/s" },
- { 29, "Number of unicast 802.11g frames transmitted at 48Mb/s" },
- { 30, "Number of unicast 802.11g frames transmitted at 54Mb/s" },
- { 31, "Number of multicast frames transmitted" },
- { 32, "Number of multicast 802.11b frames transmitted at 1Mb/s" },
- { 33, "Number of multicast 802.11b frames transmitted at 2Mb/s" },
- { 34, "Number of multicast 802.11b frames transmitted at 5.5Mb/s" },
- { 35, "Number of multicast 802.11b frames transmitted at 11Mb/s" },
-
- { 44, "Number of multicast 802.11g frames transmitted at 1Mb/s" },
- { 45, "Number of multicast 802.11g frames transmitted at 2Mb/s" },
- { 46, "Number of multicast 802.11g frames transmitted at 5.5Mb/s" },
- { 47, "Number of multicast 802.11g frames transmitted at 6Mb/s" },
- { 48, "Number of multicast 802.11g frames transmitted at 9Mb/s" },
- { 49, "Number of multicast 802.11g frames transmitted at 11Mb/s" },
- { 50, "Number of multicast 802.11g frames transmitted at 12Mb/s" },
- { 51, "Number of multicast 802.11g frames transmitted at 18Mb/s" },
- { 52, "Number of multicast 802.11g frames transmitted at 24Mb/s" },
- { 53, "Number of multicast 802.11g frames transmitted at 36Mb/s" },
- { 54, "Number of multicast 802.11g frames transmitted at 48Mb/s" },
- { 55, "Number of multicast 802.11g frames transmitted at 54Mb/s" },
- { 56, "Number of transmission retries" },
- { 57, "Number of transmission failures" },
- { 58, "Number of frames with a bad CRC received" },
-
- { 61, "Number of full scans" },
- { 62, "Number of partial scans" },
-
- { 64, "Number of bytes transmitted" },
- { 65, "Current RSSI" },
- { 66, "Number of beacons received" },
- { 67, "Number of beacons missed" },
-
- { 0, NULL }
-};
-
-static void
-get_statistics(char *iface)
-{
- static unsigned long stats[256]; /* XXX */
- const struct statistic *stat;
-
- if (do_req(iface, SIOCGTABLE0, stats) == -1)
- err(EX_OSERR, "Can't read statistics");
-
- for (stat = tbl; stat->index != 0; stat++)
- (void)printf("%-60s[%lu]\n", stat->desc, stats[stat->index]);
-}