From 5ebe67629a203c230d9d82f54aca4243b5093bb4 Mon Sep 17 00:00:00 2001 From: Hasso Tepper Date: Fri, 1 Feb 2008 08:18:36 +0000 Subject: [PATCH] Nuke wicontrol(8). Approved-by: sephe@ --- share/man/man4/ath.4 | 6 +- share/man/man4/ieee80211.4 | 3 +- share/man/man4/iwi.4 | 13 +- share/man/man4/wi.4 | 14 +- usr.sbin/Makefile | 3 +- usr.sbin/wicontrol/Makefile | 9 - usr.sbin/wicontrol/wicontrol.8 | 459 -------------- usr.sbin/wicontrol/wicontrol.c | 1086 -------------------------------- 8 files changed, 5 insertions(+), 1588 deletions(-) delete mode 100644 usr.sbin/wicontrol/Makefile delete mode 100644 usr.sbin/wicontrol/wicontrol.8 delete mode 100644 usr.sbin/wicontrol/wicontrol.c diff --git a/share/man/man4/ath.4 b/share/man/man4/ath.4 index 5e7f667b8b..dc5a09d260 100644 --- a/share/man/man4/ath.4 +++ b/share/man/man4/ath.4 @@ -30,7 +30,7 @@ .\" THE POSSIBILITY OF SUCH DAMAGES. .\" .\" $FreeBSD: /repoman/r/ncvs/src/share/man/man4/ath.4,v 1.40 2006/05/12 17:58:11 keramida Exp $ -.\" $DragonFly: src/share/man/man4/ath.4,v 1.7 2007/09/16 19:06:26 swildner Exp $ +.\" $DragonFly: src/share/man/man4/ath.4,v 1.8 2008/02/01 08:18:36 hasso Exp $ .\" .Dd July 13, 2006 .Dt ATH 4 @@ -253,7 +253,6 @@ This should not happen. .Xr wlan 4 , .Xr hostapd 8 , .Xr ifconfig 8 , -.Xr wicontrol 8 , .Xr wpa_supplicant 8 .Sh HISTORY The @@ -268,9 +267,6 @@ mode. See .Xr ifconfig 8 for information on how to change the channel. -See -.Xr wicontrol 8 -for information on different regulatory domains. Different regulatory domains may not be able to communicate with each other with 802.11a as different regulatory domains do not necessarily have overlapping channels. diff --git a/share/man/man4/ieee80211.4 b/share/man/man4/ieee80211.4 index 50e32e75e7..c4487f617a 100644 --- a/share/man/man4/ieee80211.4 +++ b/share/man/man4/ieee80211.4 @@ -26,7 +26,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD: src/share/man/man4/ieee80211.4,v 1.1.2.3 2001/07/13 09:56:16 ru Exp $ -.\" $DragonFly: src/share/man/man4/ieee80211.4,v 1.4 2006/05/26 19:39:39 swildner Exp $ +.\" $DragonFly: src/share/man/man4/ieee80211.4,v 1.5 2008/02/01 08:18:36 hasso Exp $ .\" .Dd February 23, 2001 .Dt IEEE80211 4 @@ -237,7 +237,6 @@ Set the powersave sleep time in msec to the value in .Xr ancontrol 8 , .Xr ifconfig 8 , .Xr raycontrol 8 , -.Xr wicontrol 8 .Sh HISTORY The .Nm diff --git a/share/man/man4/iwi.4 b/share/man/man4/iwi.4 index 1fd48d76bd..9670dd220b 100644 --- a/share/man/man4/iwi.4 +++ b/share/man/man4/iwi.4 @@ -28,7 +28,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $DragonFly: src/share/man/man4/iwi.4,v 1.10 2007/09/16 19:06:26 swildner Exp $ +.\" $DragonFly: src/share/man/man4/iwi.4,v 1.11 2008/02/01 08:18:36 hasso Exp $ .\" .Dd March 1, 2005 .Os @@ -99,16 +99,6 @@ ifconfig iwi0 down -debug up It's worth noting that in BSS mode if you haven't specified an ssid, the driver will auto-assign an ssid, joining the best network available. -.Pp -In IBSS mode you must specify an ssid for the driver to join a network. -If no network exists with the ssid name you have chosen the driver will -auto-create a standalone IBSS network that others may later join. This -behaviour is on by default, and may be controlled by - -.Bd -literal -offset indent -wicontrol iwi0 -c 0 Disables network auto-create behaviour. -.Ed -.Bd -literal -offset indent -wicontrol iwi0 -c 1 Enables network auto-create behaviour. .Ed .Sh DIAGNOSTICS .Bl -diag @@ -125,7 +115,6 @@ The driver will reset the hardware. This should not happen. .Xr wlan 4 , .Xr ifconfig 8 , .Xr iwicontrol 8 , -.Xr wicontrol 8 , .Xr wpa_supplicant 8 .Sh AUTHORS .An -nosplit diff --git a/share/man/man4/wi.4 b/share/man/man4/wi.4 index 6f089d33d8..f7ef1bb995 100644 --- a/share/man/man4/wi.4 +++ b/share/man/man4/wi.4 @@ -29,7 +29,7 @@ .\" THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD: src/share/man/man4/wi.4,v 1.9.4.12 2003/03/03 18:59:15 trhodes Exp $ -.\" $DragonFly: src/share/man/man4/wi.4,v 1.8 2007/09/29 08:33:47 swildner Exp $ +.\" $DragonFly: src/share/man/man4/wi.4,v 1.9 2008/02/01 08:18:36 hasso Exp $ .\" $OpenBSD: wi.4tbl,v 1.14 2002/04/29 19:53:50 jsyn Exp $ .\" .Dd May 2, 2002 @@ -72,8 +72,6 @@ The WaveLAN Gold as well as newer Intersil and Symbol cards support 104bit keys, the others only accept 40bit keys. The Lucent WaveLAN/IEEE Bronze cards do not support WEP at all. To enable encryption, use the -.Xr wicontrol 8 -utility to set your keys, or use .Xr ifconfig 8 as shown below. .Pp @@ -222,12 +220,6 @@ The following such adapters are supported or expected to work: .It US Robotics 2415 (rebadged WL11000P) .El .Sh EXAMPLES -The following examples utilize -.Xr ifconfig 8 -for simplicity, however, -.Xr wicontrol 8 -can also be used to set wireless parameters. -.Pp Join an existing BSS network (ie: connect to an access point): .Pp .Dl "ifconfig wi0 inet 192.168.0.20 netmask 0xffffff00" @@ -317,7 +309,6 @@ command. .Xr polling 4 , .Xr hostapd 8 , .Xr ifconfig 8 , -.Xr wicontrol 8 , .Xr wpa_supplicant 8 .Rs .%T HCF Light programming specification @@ -341,9 +332,6 @@ mode. See .Xr ifconfig 8 for information on how to change the channel. -See -.Xr wicontrol 8 -for information on different regulatory domains. .Pp The Intersil Prism family of chips' host-based access point mode has bugs for station firmware versions prior to 0.8.3. diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index 7f58ee69dd..b757eeabc3 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -1,6 +1,6 @@ # From: @(#)Makefile 5.20 (Berkeley) 6/12/93 # $FreeBSD: src/usr.sbin/Makefile,v 1.183.2.14 2003/04/16 11:01:51 ru Exp $ -# $DragonFly: src/usr.sbin/Makefile,v 1.39 2008/01/30 14:25:35 hasso Exp $ +# $DragonFly: src/usr.sbin/Makefile,v 1.40 2008/02/01 08:18:36 hasso Exp $ .include "../sys/platform/${MACHINE_PLATFORM}/Makefile.inc" @@ -192,7 +192,6 @@ SUBDIR+=apm \ sicontrol \ spkrtest \ stallion \ - wicontrol \ wlconfig .if !defined(NO_I4B) SUBDIR+=i4b diff --git a/usr.sbin/wicontrol/Makefile b/usr.sbin/wicontrol/Makefile deleted file mode 100644 index b3c8ebd69d..0000000000 --- a/usr.sbin/wicontrol/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $FreeBSD: src/usr.sbin/wicontrol/Makefile,v 1.3.2.1 2001/04/25 12:11:11 ru Exp $ -# $DragonFly: src/usr.sbin/wicontrol/Attic/Makefile,v 1.3 2004/07/28 08:38:33 joerg Exp $ - -PROG= wicontrol -MAN= wicontrol.8 - -WARNS?= 6 - -.include diff --git a/usr.sbin/wicontrol/wicontrol.8 b/usr.sbin/wicontrol/wicontrol.8 deleted file mode 100644 index 7c9efac338..0000000000 --- a/usr.sbin/wicontrol/wicontrol.8 +++ /dev/null @@ -1,459 +0,0 @@ -.\" Copyright (c) 1997, 1998, 1999 -.\" Bill Paul 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, 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by Bill Paul. -.\" 4. Neither the name of the author nor the names of any co-contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD -.\" 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. -.\" -.\" $FreeBSD: src/usr.sbin/wicontrol/wicontrol.8,v 1.14.2.12 2003/01/31 11:16:16 dwmalone Exp $ -.\" $DragonFly: src/usr.sbin/wicontrol/Attic/wicontrol.8,v 1.5 2007/09/29 08:33:47 swildner Exp $ -.\" -.Dd April 21, 1999 -.Dt WICONTROL 8 -.Os -.Sh NAME -.Nm wicontrol -.Nd configure WaveLAN/IEEE devices -.Sh SYNOPSIS -.Nm -.Op Fl i -.Ar iface Op Fl o -.Nm -.Op Fl i -.Ar iface Fl t Ar tx_rate -.Nm -.Op Fl i -.Ar iface Fl n Ar network_name -.Nm -.Op Fl i -.Ar iface Fl s Ar station_name -.Nm -.Op Fl i -.Ar iface Fl c Cm 0 | 1 -.Nm -.Op Fl i -.Ar iface Fl q Ar SSID -.Nm -.Op Fl i -.Ar iface Fl p Ar port_type -.Nm -.Op Fl i -.Ar iface Fl a Ar access_point_density -.Nm -.Op Fl i -.Ar iface Fl m Ar mac_address -.Nm -.Op Fl i -.Ar iface Fl d Ar max_data_length -.Nm -.Op Fl i -.Ar iface Fl e Cm 0 | 1 -.Nm -.Op Fl i -.Ar iface Fl k Ar key -.Op Fl v Cm 1 | 2 | 3 | 4 -.Nm -.Op Fl i -.Ar iface Fl T Cm 1 | 2 | 3 | 4 -.Nm -.Op Fl i -.Ar iface Fl r Ar RTS_threshold -.Nm -.Op Fl i -.Ar iface Fl f Ar frequency -.Nm -.Op Fl i -.Ar iface Fl P Cm 0 | 1 -.Nm -.Op Fl i -.Ar iface Fl S Ar max_sleep_duration -.Nm -.Op Fl i -.Ar iface Fl C -(display signal cache) -.Nm -.Op Fl i -.Ar iface Fl L -(list avail access points) -.Nm -.Op Fl i -.Ar iface Fl l -(dump associated stations) -.Sh DESCRIPTION -The -.Nm -utility controls the operation of WaveLAN/IEEE wireless networking -devices via the -.Xr wi 4 -driver. -Most of the parameters that can be changed relate to the -IEEE 802.11 protocol which the WaveLAN implements. -This includes -the station name, whether the station is operating in ad-hoc (point -to point) or BSS (service set) mode, and the network name of a service -set to join (IBSS) if BSS mode is enabled. -The -.Nm -utility can also be used to view the current settings of these parameters -and to dump out the values of the card's statistics counters. -.Pp -The -.Ar iface -argument given to -.Nm -should be the logical interface name associated with the WaveLAN/IEEE -device -.Li ( wi0 , wi1 , -etc.). -If none is specified then -.Dq Li wi0 -is used as default. -.Sh OPTIONS -The options are as follows: -.Bl -tag -width indent -.It Oo Fl i Oc Ar iface Op Fl o -Display the current settings of the specified WaveLAN/IEEE interface. -This retrieves the current card settings from the driver and prints them -out. -Using the additional -.Fl o -flag will cause -.Nm -to print out the statistics counters instead of the card settings. -Encryption keys are only displayed if -.Nm -is run as root. -.It Oo Fl i Oc Ar iface Fl t Ar tx_rate -Set the transmit rate of the specified interface. -The legal values -for the transmit rate vary depending on whether the interface is a -standard WaveLAN/IEEE or a WaveLAN/IEEE Turbo adapter. -The standard -NICs support a maximum transmit rate of 2Mbps while the turbo NICs -support a maximum speed of 6Mbps. -The following table shows the -legal transmit rate settings and the corresponding transmit speeds: -.Bl -column ".Em TX\ rate" ".Em NIC\ speed" -offset indent -.Em "TX rate NIC speed" -.It Cm 1 Ta "Fixed Low (1Mbps)" -.It Cm 2 Ta "Fixed Standard (2Mbps)" -.It Cm 3 Ta "Auto Rate Select (High)" -.It Cm 4 Ta "Fixed Medium (4Mbps)" -.It Cm 5 Ta "Fixed High (6Mbps)" -.It Cm 6 Ta "Auto Rate Select (Standard)" -.It Cm 7 Ta "Auto Rate Select (Medium)" -.El -.Pp -The standard NICs support only settings -.Cm 1 -through -.Cm 3 . -Turbo NICs support all the above listed speed settings. -The default driver setting is -.Cm 3 -(auto rate select). -.It Oo Fl i Oc Ar iface Fl n Ar network_name -Set the name of the service set (IBSS) that this station wishes to -join. -The -.Ar network_name -can be any text string up to 30 characters in length. -The default name -is the string -.Dq Li ANY -which should allow the station to connect to the first -available access point. -The interface should be set for BSS mode using -the -.Fl p -flag in order for this to work. -.Pp -Note: the WaveLAN manual indicates that an empty string will allow the -host to connect to any access point, however I have also seen a reference -in another driver which indicates that the -.Dq Li ANY -string works as well. -.It Oo Fl i Oc Ar iface Fl s Ar station_name -Sets the -station name -for the specified interface. -The -.Ar station_name -is used for diagnostic purposes. -The -.Tn "Lucent WaveMANAGER" -software can -poll the names of remote hosts. -.It Oo Fl i Oc Ar iface Fl c Cm 0 | 1 -Allow the station to create a service set (IBSS). -Permitted values are -.Cm 0 -(don't create IBSS) and -.Cm 1 -(enable creation of IBSS). -The default is -.Cm 0 . -.Pp -Note: this option is provided for experimental purposes only: enabling -the creation of an IBSS on a host system doesn't appear to actually work. -.It Oo Fl i Oc Ar iface Fl q Ar SSID -Specify the name of an IBSS (SSID) to create on a given interface. -The -.Ar SSID -can be any text string up to 30 characters long. -.Pp -Note: this option is provided for experimental purposes only: enabling -the creation of an IBSS on a host system doesn't appear to actually work. -.It Oo Fl i Oc Ar iface Fl p Ar port_type -Set the -port type -for a specified interface. -The legal values for -.Ar port_type -are -.Cm 1 -(BSS mode) and -.Cm 3 -(ad-hoc) mode. -In ad-hoc mode, the station can -communicate directly with any other stations within direct radio range -(provided that they are also operating in ad-hoc mode). -In BSS mode, -hosts must associate with a service set controlled by an access point, -which relays traffic between end stations. -The default setting is -.Cm 3 -(ad-hoc mode). -.It Oo Fl i Oc Ar iface Fl a Ar access_point_density -Specify the -access point density -for a given interface. -Legal values are -.Cm 1 -(low), -.Cm 2 -(medium) and -.Cm 3 -(high). -This setting influences some of the radio modem threshold settings. -.It Oo Fl i Oc Ar iface Fl m Ar mac_address -Set the station address for the specified interface. -The -.Ar mac_address -is specified as a series of six hexadecimal values separated by colons, -e.g., -.Dq Li 00:60:1d:12:34:56 . -This programs the new address into the card -and updates the interface as well. -.It Oo Fl i Oc Ar iface Fl d Ar max_data_length -Set the maximum receive and transmit frame size for a specified interface. -The -.Ar max_data_length -can be any number from 350 to 2304. -The default is 2304. -.It Oo Fl i Oc Ar iface Fl e Cm 0 | 1 -Enable or disable WEP encryption. -Permitted values are -.Cm 0 -(encryption disabled) or -.Cm 1 -(encryption enabled). -Encryption is off by default. -.Pp -Both 128-bit and 64-bit WEP have been broken. -See the -.Sx BUGS -section for details. -.It Oo Fl i Oc Ar iface Fl k Ar key Op Fl v Cm 1 | 2 | 3 | 4 -Set WEP encryption keys. -There are four default encryption keys -that can be programmed. -A specific key can be set using -the -.Fl v -flag. -If the -.Fl v -flag is not specified, the first key will be set. -Encryption keys -can either be normal text (i.e.\& -.Dq Li hello ) -or a series of hexadecimal digits (i.e.\& -.Dq Li 0x1234512345 ) . -For -WaveLAN Turbo Silver cards, the key is restricted to 40 bits, hence -the key can be either a 5 character text string or 10 hex digits. -For WaveLAN Turbo Gold cards, the key can also be 104 bits, -which means the key can be specified as either a 13 character text -string or 26 hex digits in addition to the formats supported by the -Silver cards. -.Pp -Note: Both 128-bit and 64-bit WEP have been broken. -See the -.Sx BUGS -section for details. -.It Oo Fl i Oc Ar iface Fl T Cm 1 | 2 | 3 | 4 -Specify which of the four WEP encryption keys will be used to -encrypt transmitted packets. -.Pp -Note: Both 128-bit and 64-bit WEP have been broken. -See the -.Sx BUGS -section for details. -.It Oo Fl i Oc Ar iface Fl r Ar RTS_threshold -Set the RTS/CTS threshold for a given interface. -This controls the -number of bytes used for the RTS/CTS handshake boundary. -The -.Ar RTS_threshold -can be any value between 0 and 2347. -The default is 2347. -.It Oo Fl i Oc Ar iface Fl f Ar frequency -Set the radio frequency of a given interface. -The -.Ar frequency -should be specified as a channel ID as shown in the table below. -The -list of available frequencies is dependent on radio regulations specified -by regional authorities. -Recognized regulatory authorities include -the FCC (United States), ETSI (Europe), France and Japan. -Frequencies -in the table are specified in MHz. -.Bl -column ".Em Channel\ ID" ".Em FCC" ".Em ETSI" ".Em France" ".Em Japan" -offset indent -.Em "Channel ID FCC ETSI France Japan" -.It Cm 1 Ta "2412 2412 - 2412" -.It Cm 2 Ta "2417 2417 - 2417" -.It Cm 3 Ta "2422 2422 - 2422" -.It Cm 4 Ta "2427 2427 - 2427" -.It Cm 5 Ta "2432 2432 - 2432" -.It Cm 6 Ta "2437 2437 - 2437" -.It Cm 7 Ta "2442 2442 - 2442" -.It Cm 8 Ta "2447 2447 - 2447" -.It Cm 9 Ta "2452 2452 - 2452" -.It Cm 10 Ta "2457 2457 2457 2457" -.It Cm 11 Ta "2462 2462 2462 2462" -.It Cm 12 Ta "- 2467 2467 2467" -.It Cm 13 Ta "- 2472 2472 2472" -.It Cm 14 Ta "- - - 2484" -.El -.Pp -If an illegal channel is specified, the -NIC will revert to its default channel. -For NICs sold in the United States -and Europe, the default channel is -.Cm 3 . -For NICs sold in France, the default channel is -.Cm 11 . -For NICs sold in Japan, the default channel is -.Cm 14 , -and it is the only available channel for pre-11Mbps NICs. -Note that two stations must be set to the same channel in order to -communicate. -.It Oo Fl i Oc Ar iface Fl P Cm 0 | 1 -Enable or disable power management on a given interface. -Enabling -power management uses an alternating sleep/wake protocol to help -conserve power on mobile stations, at the cost of some increased -receive latency. -Power management is off by default. -Note that power -management requires the cooperation of an access point in order to -function; it is not functional in ad-hoc mode. -Also, power management -is only implemented in Lucent WavePOINT firmware version 2.03 or -later, and in WaveLAN PCMCIA adapter firmware 2.00 or later. -Older -revisions will silently ignore the power management setting. -Legal -values for this parameter are -.Cm 0 -(off) and -.Cm 1 -(on). -.It Oo Fl i Oc Ar iface Fl S Ar max_sleep_interval -Specify the sleep interval to use when power management is enabled. -The -.Ar max_sleep_interval -is specified in milliseconds. -The default is 100. -.It Oo Fl i Oc Ar iface Fl C -Display the cached signal strength information maintained by the -.Xr wi 4 -driver. -The driver retains information about signal strength and -noise level for packets received from different hosts. -The signal -strength and noise level values are displayed in units of dBms. -The signal quality values is produced by subtracting the noise level -from the signal strength (i.e. less noise and better signal yields -better signal quality). -.El -.Sh SEE ALSO -.Xr ipsec 4 , -.Xr wi 4 , -.Xr ifconfig 8 -.Sh HISTORY -The -.Nm -utility first appeared in -.Fx 3.0 . -.Sh AUTHORS -The -.Nm -utility was written by -.An Bill Paul Aq wpaul@ctr.columbia.edu . -.Sh BUGS -The WEP encryption method has been broken so that third parties -can recover the keys in use relatively quickly at distances that are -surprising to most people. -Do not rely on WEP for anything but the most basic, remedial security. -IPSEC will give you a higher level of security and should be used -whenever possible. -Do not trust access points or wireless machines that connect through -them as they can provide no assurance that the traffic is legitimate. -MAC addresses can easily be forged and should therefore not be used as -the only access control. -.Pp -The attack on WEP is a passive attack, requiring only the ability to -sniff packets on the network. -The passive attack can be launched at a distance larger, up to many -miles, than one might otherwise expect given a specialized antenna -used in point to point applications. -The attacker can recover the keys from a 128-bit WEP network with only -5,000,000 to 6,000,000 packets. -While this may sound like a large number of packets, empirical -evidence suggests that this amount of traffic is generated in a few -hours on a partially loaded network. -Once a key has been compromised, the only remedial action is to -discontinue it and use a new key. -.Pp -See -.Pa http://www.isoc.org/isoc/conferences/ndss/02/proceedings/papers/stubbl.pdf -for details of the attack. -.Pp -If you must use WEP, you are strongly encouraged to pick keys whose -bytes are random and not confined to ASCII characters. diff --git a/usr.sbin/wicontrol/wicontrol.c b/usr.sbin/wicontrol/wicontrol.c deleted file mode 100644 index e864a99aea..0000000000 --- a/usr.sbin/wicontrol/wicontrol.c +++ /dev/null @@ -1,1086 +0,0 @@ -/* - * Copyright (c) 1997, 1998, 1999 - * Bill Paul . 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, 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Bill Paul. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD - * 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. - * - * $FreeBSD: src/usr.sbin/wicontrol/wicontrol.c,v 1.37 2003/09/29 06:32:11 imp Exp $ - * $DragonFly: src/usr.sbin/wicontrol/Attic/wicontrol.c,v 1.6 2004/07/28 08:38:33 joerg Exp $ - */ - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -static int wi_getval(const char *, struct wi_req *); -static int wi_getvalmaybe(const char *, struct wi_req *); -static void wi_setval(const char *, struct wi_req *); -static void wi_printstr(struct wi_req *); -static void wi_setstr(const char *, int, char *); -static void wi_setbytes(const char *, int, char *, int); -static void wi_setword(const char *, int, int); -static void wi_sethex(const char *, int, char *); -static void wi_printwords(struct wi_req *); -static void wi_printbool(struct wi_req *); -static void wi_printhex(struct wi_req *); -static void wi_printaps(struct wi_req *); -static void wi_dumpinfo(const char *); -static void wi_dumpstats(const char *); -static void wi_setkeys(const char *, char *, int); -static void wi_printkeys(struct wi_req *); -static void wi_printaplist(const char *); -static int wi_hex2int(char); -static void wi_str2key(char *, struct wi_key *); -static void wi_readcache(const char *); -static void usage(const char *); -static int listaps; -static int quiet; - -static int -_wi_getval(const char *iface, struct wi_req *wreq) -{ - struct ifreq ifr; - int s; - int retval; - - bzero((char *)&ifr, sizeof(ifr)); - - strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)); - ifr.ifr_data = (caddr_t)wreq; - - s = socket(AF_INET, SOCK_DGRAM, 0); - if (s == -1) - err(1, "socket"); - retval = ioctl(s, SIOCGWAVELAN, &ifr); - close(s); - - return (retval); -} - -static int -wi_getval(const char *iface, struct wi_req *wreq) -{ - if (_wi_getval(iface, wreq) == -1) { - if (errno != EINPROGRESS) - err(1, "SIOCGWAVELAN"); - return (-1); - } - return (0); -} - -static int -wi_getvalmaybe(const char *iface, struct wi_req *wreq) -{ - if (_wi_getval(iface, wreq) == -1) { - if (errno != EINPROGRESS && errno != EINVAL) - err(1, "SIOCGWAVELAN"); - return (-1); - } - return (0); -} - -static void -wi_setval(const char *iface, struct wi_req *wreq) -{ - struct ifreq ifr; - int s; - - bzero((char *)&ifr, sizeof(ifr)); - - strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)); - ifr.ifr_data = (caddr_t)wreq; - - s = socket(AF_INET, SOCK_DGRAM, 0); - - if (s == -1) - err(1, "socket"); - - if (ioctl(s, SIOCSWAVELAN, &ifr) == -1) - err(1, "SIOCSWAVELAN"); - - close(s); - - return; -} - -void -wi_printstr(struct wi_req *wreq) -{ - char *ptr; - int i; - - if (wreq->wi_type == WI_RID_SERIALNO) { - ptr = (char *)&wreq->wi_val; - for (i = 0; i < (wreq->wi_len - 1) * 2; i++) { - if (ptr[i] == '\0') - ptr[i] = ' '; - } - } else { - ptr = (char *)&wreq->wi_val[1]; - for (i = 0; i < wreq->wi_val[0]; i++) { - if (ptr[i] == '\0') - ptr[i] = ' '; - } - } - - ptr[i] = '\0'; - printf("[ %s ]", ptr); - - return; -} - -void -wi_setstr(const char *iface, int code, char *str) -{ - struct wi_req wreq; - - if (iface == NULL) - errx(1, "must specify interface name"); - - if (str == NULL) - errx(1, "must specify string"); - - bzero((char *)&wreq, sizeof(wreq)); - - if (strlen(str) > 30) - errx(1, "string too long"); - - wreq.wi_type = code; - wreq.wi_len = 18; - wreq.wi_val[0] = strlen(str); - bcopy(str, (char *)&wreq.wi_val[1], strlen(str)); - - wi_setval(iface, &wreq); - - return; -} - -void -wi_setbytes(const char *iface, int code, char *bytes, int len) -{ - struct wi_req wreq; - - if (iface == NULL) - errx(1, "must specify interface name"); - - bzero((char *)&wreq, sizeof(wreq)); - - wreq.wi_type = code; - wreq.wi_len = (len / 2) + 1; - bcopy(bytes, (char *)&wreq.wi_val[0], len); - - wi_setval(iface, &wreq); - - return; -} - -void -wi_setword(const char *iface, int code, int word) -{ - struct wi_req wreq; - - bzero((char *)&wreq, sizeof(wreq)); - - wreq.wi_type = code; - wreq.wi_len = 2; - wreq.wi_val[0] = word; - - wi_setval(iface, &wreq); - - return; -} - -void -wi_sethex(const char *iface, int code, char *str) -{ - struct ether_addr *addr; - - if (str == NULL) - errx(1, "must specify address"); - - addr = ether_aton(str); - - if (addr == NULL) - errx(1, "badly formatted address"); - - wi_setbytes(iface, code, (char *)addr, ETHER_ADDR_LEN); - - return; -} - -static int -wi_hex2int(char c) -{ - if (c >= '0' && c <= '9') - return (c - '0'); - if (c >= 'A' && c <= 'F') - return (c - 'A' + 10); - if (c >= 'a' && c <= 'f') - return (c - 'a' + 10); - - return (0); -} - -static void -wi_str2key(char *s, struct wi_key *k) -{ - int n, i; - char *p; - - /* Is this a hex string? */ - if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) { - /* Yes, convert to int. */ - n = 0; - p = (char *)&k->wi_keydat[0]; - for (i = 2; s[i] != '\0' && s[i + 1] != '\0'; i+= 2) { - *p++ = (wi_hex2int(s[i]) << 4) + wi_hex2int(s[i + 1]); - n++; - } - if (s[i] != '\0') - errx(1, "hex strings must be of even length"); - k->wi_keylen = n; - } else { - /* No, just copy it in. */ - bcopy(s, k->wi_keydat, strlen(s)); - k->wi_keylen = strlen(s); - } - - return; -} - -static void -wi_setkeys(const char *iface, char *key, int idx) -{ - int keylen; - struct wi_req wreq; - struct wi_ltv_keys *keys; - struct wi_key *k; - int has_wep; - - bzero((char *)&wreq, sizeof(wreq)); - wreq.wi_len = WI_MAX_DATALEN; - wreq.wi_type = WI_RID_WEP_AVAIL; - - if (wi_getval(iface, &wreq) == 0) - has_wep = wreq.wi_val[0]; - else - has_wep = 0; - if (!has_wep) - errx(1, "no WEP option available on this card"); - - bzero((char *)&wreq, sizeof(wreq)); - wreq.wi_len = WI_MAX_DATALEN; - wreq.wi_type = WI_RID_DEFLT_CRYPT_KEYS; - - if (wi_getval(iface, &wreq) == -1) - errx(1, "Cannot get default key index"); - keys = (struct wi_ltv_keys *)&wreq; - - keylen = strlen(key); - if (key[0] == '0' && (key[1] == 'x' || key[1] == 'X')) { - if (keylen != 2 && keylen != 12 && keylen != 28) { - errx(1, "encryption key must be 0, 10, or 26 " - "hex digits long"); - } - } else { - if (keylen != 0 && keylen != 5 && keylen != 13) { - errx(1, "encryption key must be 0, 5, or 13 " - "bytes long"); - } - } - - if (idx > 3) - errx(1, "only 4 encryption keys available"); - - k = &keys->wi_keys[idx]; - wi_str2key(key, k); - - wreq.wi_len = (sizeof(struct wi_ltv_keys) / 2) + 1; - wreq.wi_type = WI_RID_DEFLT_CRYPT_KEYS; - wi_setval(iface, &wreq); - - return; -} - -static void -wi_printkeys(struct wi_req *wreq) -{ - int i, j; - int isprintable; - struct wi_key *k; - struct wi_ltv_keys *keys; - char *ptr; - - keys = (struct wi_ltv_keys *)wreq; - - for (i = 0; i < 4; i++) { - k = &keys->wi_keys[i]; - ptr = (char *)k->wi_keydat; - isprintable = 1; - for (j = 0; j < k->wi_keylen; j++) { - if (!isprint(ptr[j])) { - isprintable = 0; - break; - } - } - if (isprintable) { - ptr[j] = '\0'; - printf("[ %s ]", ptr); - } else { - printf("[ 0x"); - for (j = 0; j < k->wi_keylen; j++) { - printf("%02x", ptr[j] & 0xFF); - } - printf(" ]"); - - } - } - - return; -}; - -void -wi_printwords(struct wi_req *wreq) -{ - int i; - - printf("[ "); - for (i = 0; i < wreq->wi_len - 1; i++) - printf("%d ", wreq->wi_val[i]); - printf("]"); - - return; -} - -static void -wi_printswords(struct wi_req *wreq) -{ - int i; - - printf("[ "); - for (i = 0; i < wreq->wi_len - 1; i++) - printf("%d ", ((int16_t *) wreq->wi_val)[i]); - printf("]"); - - return; -} - -static void -wi_printhexwords(struct wi_req *wreq) -{ - int i; - - printf("[ "); - for (i = 0; i < wreq->wi_len - 1; i++) - printf("%x ", wreq->wi_val[i]); - printf("]"); - - return; -} - -void -wi_printbool(struct wi_req *wreq) -{ - if (wreq->wi_val[0]) - printf("[ On ]"); - else - printf("[ Off ]"); - - return; -} - -void -wi_printhex(struct wi_req *wreq) -{ - int i; - unsigned char *c; - - c = (unsigned char *)&wreq->wi_val; - - printf("[ "); - for (i = 0; i < (wreq->wi_len - 1) * 2; i++) { - printf("%02x", c[i]); - if (i < ((wreq->wi_len - 1) * 2) - 1) - printf(":"); - } - - printf(" ]"); - return; -} - -void -wi_printaplist(const char *iface) -{ - int prism2, len, i = 0, j, r; - struct wi_req wreq; - struct wi_scan_p2_hdr *wi_p2_h; - struct wi_scan_res *res; - - if (!quiet) - printf("Available APs:\n"); - - /* first determine if this is a prism2 card or not */ - wreq.wi_len = WI_MAX_DATALEN; - wreq.wi_type = WI_RID_PRISM2; - - if (wi_getval(iface, &wreq) == 0) - prism2 = wreq.wi_val[0]; - else - prism2 = 0; - - /* send out a scan request */ - wreq.wi_len = prism2 ? 3 : 1; - wreq.wi_type = WI_RID_SCAN_REQ; - - if (prism2) { - wreq.wi_val[0] = 0x3FFF; - wreq.wi_val[1] = 0x000F; - } - - wi_setval(iface, &wreq); - - do { - /* - * sleep for 100 milliseconds so there's enough time for the card to - * respond... prism2's take a little longer. - */ - usleep(prism2 ? 500000 : 100000); - - /* get the scan results */ - wreq.wi_len = WI_MAX_DATALEN; - wreq.wi_type = WI_RID_SCAN_RES; - } while (wi_getval(iface, &wreq) == -1 && errno == EINPROGRESS); - - if (prism2) { - wi_p2_h = (struct wi_scan_p2_hdr *)wreq.wi_val; - - /* if the reason is 0, this info is invalid */ - if (wi_p2_h->wi_reason == 0) - return; - - i = 4; - } - - len = prism2 ? WI_PRISM2_RES_SIZE : WI_WAVELAN_RES_SIZE; - - if (!quiet) { - int nstations = ((wreq.wi_len * 2) - i) / len; - if (nstations == 0) { - printf("No stations\n"); - return; - } - printf("%d station%s:\n", nstations, nstations == 1 ? "" : "s"); - printf("%-16.16s BSSID Chan SN S N Intrvl Capinfo\n", "SSID"); - } - for (; i < (wreq.wi_len * 2) - len; i += len) { - res = (struct wi_scan_res *)((char *)wreq.wi_val + i); - - res->wi_ssid[res->wi_ssid_len] = '\0'; - - printf("%-16.16s [ %02x:%02x:%02x:%02x:%02x:%02x ] [ %-2d ] " - "[ %2d %2d %2d ] %3d ", res->wi_ssid, - res->wi_bssid[0], res->wi_bssid[1], res->wi_bssid[2], - res->wi_bssid[3], res->wi_bssid[4], res->wi_bssid[5], - res->wi_chan, res->wi_signal - res->wi_noise, - res->wi_signal, res->wi_noise, res->wi_interval); - - if (!quiet && res->wi_capinfo) { - printf("[ "); - if (res->wi_capinfo & WI_CAPINFO_ESS) - printf("ess "); - if (res->wi_capinfo & WI_CAPINFO_IBSS) - printf("ibss "); - if (res->wi_capinfo & IEEE80211_CAPINFO_CF_POLLABLE) - printf("cfp "); - if (res->wi_capinfo & IEEE80211_CAPINFO_CF_POLLREQ) - printf("cfpr "); - if (res->wi_capinfo & WI_CAPINFO_PRIV) - printf("priv "); - if (res->wi_capinfo & IEEE80211_CAPINFO_SHORT_PREAMBLE) - printf("shpr "); - if (res->wi_capinfo & IEEE80211_CAPINFO_PBCC) - printf("pbcc "); - if (res->wi_capinfo & IEEE80211_CAPINFO_CHNL_AGILITY) - printf("chna "); - if (res->wi_capinfo & IEEE80211_CAPINFO_SHORT_SLOTTIME) - printf("shst "); - if (res->wi_capinfo & IEEE80211_CAPINFO_DSSSOFDM) - printf("ofdm "); - printf("] "); - } - - if (prism2 && res->wi_srates[0] != 0) { - printf("\n%16s [ ", ""); - for (j = 0; j < 10 && res->wi_srates[j] != 0; j++) { - r = res->wi_srates[j] & IEEE80211_RATE_VAL; - if (r & 1) - printf("%d.%d", r / 2, (r % 2) * 5); - else - printf("%d", r / 2); - printf("%s ", res->wi_srates[j] & IEEE80211_RATE_BASIC ? "b" : ""); - } - printf("]"); - } - putchar('\n'); - } -} - -#define WI_STRING 0x01 -#define WI_BOOL 0x02 -#define WI_WORDS 0x03 -#define WI_HEXBYTES 0x04 -#define WI_KEYSTRUCT 0x05 -#define WI_SWORDS 0x06 -#define WI_HEXWORDS 0x07 -#define WI_REGDOMS 0x08 - -struct wi_table { - int wi_code; - int wi_type; - const char *wi_str; -}; - -static struct wi_table wi_table[] = { - { WI_RID_SERIALNO, WI_STRING, "NIC serial number:\t\t\t" }, - { WI_RID_NODENAME, WI_STRING, "Station name:\t\t\t\t" }, - { WI_RID_OWN_SSID, WI_STRING, "SSID for IBSS creation:\t\t\t" }, - { WI_RID_CURRENT_SSID, WI_STRING, "Current netname (SSID):\t\t\t" }, - { WI_RID_DESIRED_SSID, WI_STRING, "Desired netname (SSID):\t\t\t" }, - { WI_RID_CURRENT_BSSID, WI_HEXBYTES, "Current BSSID:\t\t\t\t" }, - { WI_RID_CHANNEL_LIST, WI_HEXWORDS, "Channel list:\t\t\t\t" }, - { WI_RID_OWN_CHNL, WI_WORDS, "IBSS channel:\t\t\t\t" }, - { WI_RID_CURRENT_CHAN, WI_WORDS, "Current channel:\t\t\t" }, - { WI_RID_COMMS_QUALITY, WI_WORDS, "Comms quality/signal/noise:\t\t" }, - { WI_RID_DBM_COMMS_QUAL, WI_SWORDS, "dBm Coms Quality:\t\t\t" }, - { WI_RID_PROMISC, WI_BOOL, "Promiscuous mode:\t\t\t" }, - { WI_RID_PROCFRAME, WI_BOOL, "Process 802.11b Frame:\t\t\t" }, - { WI_RID_PRISM2, WI_WORDS, "Intersil-Prism2 based card:\t\t" }, - { WI_RID_PORTTYPE, WI_WORDS, "Port type (1=BSS, 3=ad-hoc):\t\t"}, - { WI_RID_MAC_NODE, WI_HEXBYTES, "MAC address:\t\t\t\t"}, - { WI_RID_TX_RATE, WI_WORDS, "TX rate (selection):\t\t\t"}, - { WI_RID_CUR_TX_RATE, WI_WORDS, "TX rate (actual speed):\t\t\t"}, - { WI_RID_RTS_THRESH, WI_WORDS, "RTS/CTS handshake threshold:\t\t"}, - { WI_RID_CREATE_IBSS, WI_BOOL, "Create IBSS:\t\t\t\t" }, - { WI_RID_SYSTEM_SCALE, WI_WORDS, "Access point density:\t\t\t" }, - { WI_RID_PM_ENABLED, WI_WORDS, "Power Mgmt (1=on, 0=off):\t\t" }, - { WI_RID_MAX_SLEEP, WI_WORDS, "Max sleep time:\t\t\t\t" }, - { WI_RID_PRI_IDENTITY, WI_WORDS, "PRI Identity:\t\t\t\t" }, - { WI_RID_STA_IDENTITY, WI_WORDS, "STA Identity:\t\t\t\t" } , - { WI_RID_CARD_ID, WI_HEXWORDS, "Card ID register:\t\t\t" }, - { WI_RID_TEMP_TYPE, WI_WORDS, "Temperature Range:\t\t\t" }, -#ifdef WI_EXTRA_INFO - { WI_RID_PRI_SUP_RANGE, WI_WORDS, "PRI Sup Range:\t\t\t\t" }, - { WI_RID_CIF_ACT_RANGE, WI_WORDS, "CFI Act Sup Range:\t\t\t" }, - { WI_RID_STA_SUP_RANGE, WI_WORDS, "STA Sup Range:\t\t\t\t" } , - { WI_RID_MFI_ACT_RANGE, WI_WORDS, "MFI Act Sup Range:\t\t\t" } , -#endif - { 0, 0, NULL } -}; - -static struct wi_table wi_crypt_table[] = { - { WI_RID_ENCRYPTION, WI_BOOL, "WEP encryption:\t\t\t\t" }, - { WI_RID_TX_CRYPT_KEY, WI_WORDS, "TX encryption key:\t\t\t" }, - { WI_RID_DEFLT_CRYPT_KEYS, WI_KEYSTRUCT, "Encryption keys:\t\t\t" }, - { 0, 0, NULL } -}; - -static void -wi_dumpinfo(const char *iface) -{ - struct wi_req wreq; - int i, has_wep; - struct wi_table *w; - - bzero((char *)&wreq, sizeof(wreq)); - - wreq.wi_len = WI_MAX_DATALEN; - wreq.wi_type = WI_RID_WEP_AVAIL; - - if (wi_getval(iface, &wreq) == 0) - has_wep = wreq.wi_val[0]; - else - has_wep = 0; - - w = wi_table; - - for (i = 0; w[i].wi_type; i++) { - bzero((char *)&wreq, sizeof(wreq)); - - wreq.wi_len = WI_MAX_DATALEN; - wreq.wi_type = w[i].wi_code; - - if (wi_getvalmaybe(iface, &wreq) == -1) - continue; - printf("%s", w[i].wi_str); - switch(w[i].wi_type) { - case WI_STRING: - wi_printstr(&wreq); - break; - case WI_WORDS: - wi_printwords(&wreq); - break; - case WI_SWORDS: - wi_printswords(&wreq); - break; - case WI_HEXWORDS: - wi_printhexwords(&wreq); - break; - case WI_BOOL: - wi_printbool(&wreq); - break; - case WI_HEXBYTES: - wi_printhex(&wreq); - break; - default: - break; - } - printf("\n"); - } - - if (has_wep) { - w = wi_crypt_table; - for (i = 0; w[i].wi_type; i++) { - bzero((char *)&wreq, sizeof(wreq)); - - wreq.wi_len = WI_MAX_DATALEN; - wreq.wi_type = w[i].wi_code; - - if (wi_getval(iface, &wreq) == -1) - continue; - printf("%s", w[i].wi_str); - switch(w[i].wi_type) { - case WI_STRING: - wi_printstr(&wreq); - break; - case WI_WORDS: - if (wreq.wi_type == WI_RID_TX_CRYPT_KEY) - wreq.wi_val[0]++; - wi_printwords(&wreq); - break; - case WI_BOOL: - wi_printbool(&wreq); - break; - case WI_HEXBYTES: - wi_printhex(&wreq); - break; - case WI_KEYSTRUCT: - wi_printkeys(&wreq); - break; - default: - break; - } - printf("\n"); - } - } - - if (listaps) - wi_printaplist(iface); - - return; -} - -static void -wi_dumpstats(const char *iface) -{ - struct wi_req wreq; - struct wi_counters *c; - - if (iface == NULL) - errx(1, "must specify interface name"); - - bzero((char *)&wreq, sizeof(wreq)); - wreq.wi_len = WI_MAX_DATALEN; - wreq.wi_type = WI_RID_IFACE_STATS; - - if (wi_getval(iface, &wreq) == -1) - errx(1, "Cannot get interface stats"); - - c = (struct wi_counters *)&wreq.wi_val; - - printf("Transmitted unicast frames:\t\t%d\n", - c->wi_tx_unicast_frames); - printf("Transmitted multicast frames:\t\t%d\n", - c->wi_tx_multicast_frames); - printf("Transmitted fragments:\t\t\t%d\n", - c->wi_tx_fragments); - printf("Transmitted unicast octets:\t\t%d\n", - c->wi_tx_unicast_octets); - printf("Transmitted multicast octets:\t\t%d\n", - c->wi_tx_multicast_octets); - printf("Single transmit retries:\t\t%d\n", - c->wi_tx_single_retries); - printf("Multiple transmit retries:\t\t%d\n", - c->wi_tx_multi_retries); - printf("Transmit retry limit exceeded:\t\t%d\n", - c->wi_tx_retry_limit); - printf("Transmit discards:\t\t\t%d\n", - c->wi_tx_discards); - printf("Transmit discards due to wrong SA:\t%d\n", - c->wi_tx_discards_wrong_sa); - printf("Received unicast frames:\t\t%d\n", - c->wi_rx_unicast_frames); - printf("Received multicast frames:\t\t%d\n", - c->wi_rx_multicast_frames); - printf("Received fragments:\t\t\t%d\n", - c->wi_rx_fragments); - printf("Received unicast octets:\t\t%d\n", - c->wi_rx_unicast_octets); - printf("Received multicast octets:\t\t%d\n", - c->wi_rx_multicast_octets); - printf("Receive FCS errors:\t\t\t%d\n", - c->wi_rx_fcs_errors); - printf("Receive discards due to no buffer:\t%d\n", - c->wi_rx_discards_nobuf); - printf("Can't decrypt WEP frame:\t\t%d\n", - c->wi_rx_WEP_cant_decrypt); - printf("Received message fragments:\t\t%d\n", - c->wi_rx_msg_in_msg_frags); - printf("Received message bad fragments:\t\t%d\n", - c->wi_rx_msg_in_bad_msg_frags); - - return; -} - -static void -usage(const char *p) -{ - fprintf(stderr, "usage: %s -i iface\n", p); - fprintf(stderr, "\t%s -i iface -o\n", p); - fprintf(stderr, "\t%s -i iface -l\n", p); - fprintf(stderr, "\t%s -i iface -L\n", p); - fprintf(stderr, "\t%s -i iface -t tx rate\n", p); - fprintf(stderr, "\t%s -i iface -n network name\n", p); - fprintf(stderr, "\t%s -i iface -s station name\n", p); - fprintf(stderr, "\t%s -i iface -c 0|1\n", p); - fprintf(stderr, "\t%s -i iface -q SSID\n", p); - fprintf(stderr, "\t%s -i iface -p port type\n", p); - fprintf(stderr, "\t%s -i iface -a access point density\n", p); - fprintf(stderr, "\t%s -i iface -m mac address\n", p); - fprintf(stderr, "\t%s -i iface -d max data length\n", p); - fprintf(stderr, "\t%s -i iface -e 0|1\n", p); - fprintf(stderr, "\t%s -i iface -k encryption key [-v 1|2|3|4]\n", p); - fprintf(stderr, "\t%s -i iface -r RTS threshold\n", p); - fprintf(stderr, "\t%s -i iface -f frequency\n", p); - fprintf(stderr, "\t%s -i iface -F 0|1\n", p); - fprintf(stderr, "\t%s -i iface -P 0|1\n", p); - fprintf(stderr, "\t%s -i iface -S max sleep duration\n", p); - fprintf(stderr, "\t%s -i iface -T 1|2|3|4\n", p); -#ifdef WICACHE - fprintf(stderr, "\t%s -i iface -Z zero out signal cache\n", p); - fprintf(stderr, "\t%s -i iface -C print signal cache\n", p); -#endif - - exit(1); -} - -static void -wi_printaps(struct wi_req *wreq) -{ - struct wi_apinfo *w; - int i, j, nstations; - - nstations = *(int *)wreq->wi_val; - printf("%d station%s:\n", nstations, nstations == 1 ? "" : "s"); - w = (struct wi_apinfo *)(((char *)&wreq->wi_val) + sizeof(int)); - for ( i = 0; i < nstations; i++, w++) { - printf("ap[%d]:\n", i); - if (w->scanreason) { - static const char *scanm[] = { - "Host initiated", - "Firmware initiated", - "Inquiry request from host" - }; - printf("\tScanReason:\t\t\t[ %s ]\n", - scanm[w->scanreason - 1]); - } - printf("\tnetname (SSID):\t\t\t[ "); - for (j = 0; j < w->namelen; j++) { - printf("%c", w->name[j]); - } - printf(" ]\n"); - printf("\tBSSID:\t\t\t\t[ %02x:%02x:%02x:%02x:%02x:%02x ]\n", - w->bssid[0]&0xff, w->bssid[1]&0xff, - w->bssid[2]&0xff, w->bssid[3]&0xff, - w->bssid[4]&0xff, w->bssid[5]&0xff); - printf("\tChannel:\t\t\t[ %d ]\n", w->channel); - printf("\tQuality/Signal/Noise [signal]:\t[ %d / %d / %d ]\n" - "\t [dBm]:\t[ %d / %d / %d ]\n", - w->quality, w->signal, w->noise, - w->quality, w->signal - 149, w->noise - 149); - printf("\tBSS Beacon Interval [msec]:\t[ %d ]\n", w->interval); - printf("\tCapinfo:\t\t\t[ "); - if (w->capinfo & IEEE80211_CAPINFO_ESS) - printf("ESS "); - if (w->capinfo & IEEE80211_CAPINFO_PRIVACY) - printf("WEP "); - printf("]\n"); - } -} - -static void -wi_dumpstations(const char *iface) -{ - struct wi_req wreq; - - if (iface == NULL) - errx(1, "must specify interface name"); - - bzero((char *)&wreq, sizeof(wreq)); - wreq.wi_len = WI_MAX_DATALEN; - wreq.wi_type = WI_RID_READ_APS; - - if (wi_getval(iface, &wreq) == -1) - errx(1, "Cannot get stations"); - wi_printaps(&wreq); -} - -static void -wi_readcache(const char *iface) -{ - struct wi_req wreq; - int *wi_sigitems; - struct wi_sigcache *sc; - char * pt; - int i; - - if (iface == NULL) - errx(1, "must specify interface name"); - - bzero((char *)&wreq, sizeof(wreq)); - wreq.wi_len = WI_MAX_DATALEN; - wreq.wi_type = WI_RID_READ_CACHE; - if (wi_getval(iface, &wreq) == -1) - errx(1, "Cannot read signal cache"); - - wi_sigitems = (int *) &wreq.wi_val; - pt = ((char *) &wreq.wi_val); - pt += sizeof(int); - sc = (struct wi_sigcache *) pt; - - for (i = 0; i < *wi_sigitems; i++) { - printf("[%d/%d]:", i+1, *wi_sigitems); - printf(" %02x:%02x:%02x:%02x:%02x:%02x,", - sc->macsrc[0]&0xff, - sc->macsrc[1]&0xff, - sc->macsrc[2]&0xff, - sc->macsrc[3]&0xff, - sc->macsrc[4]&0xff, - sc->macsrc[5]&0xff); - printf(" %d.%d.%d.%d,",((sc->ipsrc >> 0) & 0xff), - ((sc->ipsrc >> 8) & 0xff), - ((sc->ipsrc >> 16) & 0xff), - ((sc->ipsrc >> 24) & 0xff)); - printf(" sig: %d, noise: %d, qual: %d\n", - sc->signal, - sc->noise, - sc->quality); - sc++; - } - - return; -} - -static void -dep(const char *flag, const char *opt) -{ - warnx("warning: flag %s deprecated, migrate to ifconfig %s", flag, - opt); -} - -int -main(int argc, char *argv[]) -{ - int ch; - const char *iface = NULL; - char *p = argv[0]; - char *key = NULL; - int modifier = 0; - - /* Get the interface name */ - opterr = 0; - ch = getopt(argc, argv, "i:"); - if (ch == 'i') { - iface = optarg; - } else { - if (argc > 1 && *argv[1] != '-') { - iface = argv[1]; - optind = 2; - } else { - iface = "wi0"; - optind = 1; - } - optreset = 1; - } - opterr = 1; - - while((ch = getopt(argc, argv, - "a:c:d:e:f:hi:k:lm:n:op:q:r:s:t:v:CF:LP:QS:T")) != -1) { - switch(ch) { - case 'C': - wi_readcache(iface); - exit(0); - break; - case 'o': - wi_dumpstats(iface); - exit(0); - break; - case 'c': - dep("c", "mediaopt"); - wi_setword(iface, WI_RID_CREATE_IBSS, atoi(optarg)); - exit(0); - break; - case 'd': - wi_setword(iface, WI_RID_MAX_DATALEN, atoi(optarg)); - exit(0); - break; - case 'e': - dep("e", "wepmode"); - wi_setword(iface, WI_RID_ENCRYPTION, atoi(optarg)); - exit(0); - break; - case 'f': - dep("f", "channel"); - wi_setword(iface, WI_RID_OWN_CHNL, atoi(optarg)); - exit(0); - break; - case 'F': - wi_setword(iface, WI_RID_PROCFRAME, atoi(optarg)); - exit(0); - break; - case 'k': - dep("k", "wepkey"); - key = optarg; - break; - case 'L': - listaps++; - break; - case 'l': - wi_dumpstations(iface); - exit(0); - break; - case 'p': - dep("p", "mediaopt"); - wi_setword(iface, WI_RID_PORTTYPE, atoi(optarg)); - exit(0); - break; - case 'r': - wi_setword(iface, WI_RID_RTS_THRESH, atoi(optarg)); - exit(0); - break; - case 't': - dep("t", "mediaopt"); - wi_setword(iface, WI_RID_TX_RATE, atoi(optarg)); - exit(0); - break; - case 'n': - dep("n", "ssid"); - wi_setstr(iface, WI_RID_DESIRED_SSID, optarg); - exit(0); - break; - case 's': - dep("s", "stationname"); - wi_setstr(iface, WI_RID_NODENAME, optarg); - exit(0); - break; - case 'm': - wi_sethex(iface, WI_RID_MAC_NODE, optarg); - exit(0); - break; - case 'Q': - quiet = 1; - break; - case 'q': - dep("q", "ssid"); - wi_setstr(iface, WI_RID_OWN_SSID, optarg); - exit(0); - break; - case 'S': - dep("S", "powersleep"); - wi_setword(iface, WI_RID_MAX_SLEEP, atoi(optarg)); - exit(0); - break; - case 'T': - dep("T", "weptxkey"); - wi_setword(iface, - WI_RID_TX_CRYPT_KEY, atoi(optarg) - 1); - exit(0); - break; - case 'P': - dep("P", "powersave"); - wi_setword(iface, WI_RID_PM_ENABLED, atoi(optarg)); - exit(0); - break; - case 'a': - wi_setword(iface, WI_RID_SYSTEM_SCALE, atoi(optarg)); - exit(0); - break; - case 'v': - modifier = atoi(optarg); - modifier--; - break; - case 'h': - default: - usage(p); - break; - } - } - - if (iface == NULL) - usage(p); - - if (key != NULL) { - wi_setkeys(iface, key, modifier); - exit(0); - } - - if (listaps > 1) { - wi_printaplist(iface); - exit(0); - } - - wi_dumpinfo(iface); - - exit(0); -} -- 2.41.0