Date: Fri, 13 Oct 2000 18:02:38 -0700 (PDT) From: brooks@one-eyed-alien.net To: FreeBSD-gnats-submit@freebsd.org Subject: conf/21967: [PATCH] Wireless cards need configuration prior to ifconfig Message-ID: <200010140102.e9E12cv03926@minya.sea.one-eyed-alien.net>
next in thread | raw e-mail | index | archive | help
>Number: 21967 >Category: conf >Synopsis: [PATCH] Wireless cards need configuration prior to ifconfig >Confidential: no >Severity: non-critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Oct 13 18:10:01 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Brooks Davis >Release: FreeBSD 5.0-CURRENT i386 >Organization: The Aerospace Corporation >Environment: FreeBSD minya 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Mon Oct 9 19:07:56 PDT 2000 root@minya:/usr/obj/usr/src/sys/MINYA i386 >Description: Wireless ethernet cards often require a substantial number of settings to be configured before they can attach to a network. FreeBSD provides no automated machanism to do this. Additionaly, these settings may vary from one environment to another such as home, office, and public areas such as airport terminals. >How-To-Repeat: Try using a wireless ethernet card with an access point with security settings enabled. >Fix: Apply the following patch. This patch provides generic hooks for interface configuration prior to ifconfig derived from those submitted by Danny Howard <dannyman@tellme.com> in PR:conf/21489. The config_802.11 script tries configrations until one that works is found. I believe the set of defaults I provide will not break existing setups and will automaticaly enable access to unrestricted access points. Aironet configuration depends on Doug Ambrisko's WEP patches submitted in PR:kern/21864 and the Lucent configuration may require the patches in PR:bin/21803 in certain rare cases. This is a work in progress, but it works well enough that I'd like to see it get wider exposure. Until this or a similar facility is commited, I will perodicaly update a copy of the patch at: http://www.one-eyed-alien.net/~brooks/FreeBSD/config802.diff Index: etc/pccard_ether =================================================================== RCS file: /home/ncvs/src/etc/pccard_ether,v retrieving revision 1.18 diff -u -r1.18 pccard_ether --- etc/pccard_ether 2000/09/07 03:06:06 1.18 +++ etc/pccard_ether 2000/10/14 00:40:33 @@ -19,6 +19,16 @@ interface=$1 shift +eval preifconfig=\$preifconfig_${interface} +if [ -n "${preifconfig}" ]; then + preifconfig_ifconfig="" + preifconfig_interface=${interface} + $preifconfig + if [ -n "${preifconfig_ifconfig}" ]; then + pccard_ifconfig=${preifconfig_ifconfig} + fi +fi + case ${pccard_ifconfig} in [Nn][Oo] | '') ;; Index: etc/rc.network =================================================================== RCS file: /home/ncvs/src/etc/rc.network,v retrieving revision 1.87 diff -u -r1.87 rc.network --- etc/rc.network 2000/10/08 19:18:24 1.87 +++ etc/rc.network 2000/10/14 00:41:38 @@ -142,9 +147,20 @@ eval showstat_$ifn=1 fi + preifconfig_ifconfig="" + eval preifconfig=\$preifconfig_${ifn} + if [ -n "${preifconfig}" ]; then + preifconfig_interface=${ifn} + $preifconfig + fi + # Do the primary ifconfig if specified # - eval ifconfig_args=\$ifconfig_${ifn} + if [ -n "${preifconfig_ifconfig}" ]; then + ifconfig_args=${preifconfig_ifconfig} + else + eval ifconfig_args=\$ifconfig_${ifn} + fi case ${ifconfig_args} in '') Index: etc/Makefile =================================================================== RCS file: /home/ncvs/src/etc/Makefile,v retrieving revision 1.237 diff -u -r1.237 Makefile --- etc/Makefile 2000/09/15 08:06:59 1.237 +++ etc/Makefile 2000/10/14 00:23:24 @@ -31,7 +31,7 @@ .endif # -rwxr-xr-x root.wheel, for the new cron root.wheel -BIN2= netstart pccard_ether rc.suspend rc.resume +BIN2= config_802.11 netstart pccard_ether rc.suspend rc.resume MTREE= BSD.include.dist BSD.local.dist BSD.root.dist BSD.usr.dist \ BSD.var.dist BSD.x11.dist BSD.x11-4.dist Index: etc/defaults/rc.conf =================================================================== RCS file: /home/ncvs/src/etc/defaults/rc.conf,v retrieving revision 1.80 diff -u -r1.80 rc.conf --- etc/defaults/rc.conf 2000/10/06 12:24:45 1.80 +++ etc/defaults/rc.conf 2000/10/14 00:21:15 @@ -100,6 +102,44 @@ ppp_nat="YES" # Use PPP's internal network address translation or NO. ppp_profile="papchap" # Which profile to use from /etc/ppp/ppp.conf. ppp_user="root" # Which user to run ppp as + +### IEEE 802.11 wireless networking configuration ### +ieee802_11_configs="infra adhoc" # List of all configs +ieee802_11_config_default="auto" # Default config or auto +#ieee802_11_config_an0="auto" # Config for an0 +#ieee802_11_config_wi0="auto" # Config for wi0 +ieee802_11_association_timeout="0" # Time to wait to check for association +preifconfig_an0=". /etc/config_802.11" # Config an0 on insert/boot +preifconfig_wi0=". /etc/config_802.11" # Config wi0 on insert/boot +### The ad-hoc mode configuration ### +ieee802_11_adhoc_mode="ad-hoc" # Set interface mode +ieee802_11_adhoc_ssid="" # SSID of the network you want +ieee802_11_adhoc_station_name="" # Identifier for this host +ieee802_11_adhoc_rate="auto" # Rate (1, 2, 5.5, 11, or auto) +ieee802_11_adhoc_powermanagement="NO" # Power management +ieee802_11_adhoc_channel="6" # Channel (1-11 in US) +ieee802_11_adhoc_wep="NO" # Set to YES to enable encryption +ieee802_11_adhoc_wep_mixed_ok="NO" # Connect to mixed networks? +ieee802_11_adhoc_wep_tx_key="1" # Set the key to transmit with +ieee802_11_adhoc_wep_key1="" # Each key can be 0, 5, or 13 +ieee802_11_adhoc_wep_key2="" # bytes in length as either an +ieee802_11_adhoc_wep_key3="" # ASCII string or a hex string. +ieee802_11_adhoc_wep_key4="" +#ieee802_11_adhoc_ifconfig="DHCP" # interface configuration +### The infrastructure mode configuration ### +ieee802_11_infra_mode="infrastructure" # Set interface mode +ieee802_11_infra_ssid="" # SSID of the network you want +ieee802_11_infra_station_name="" # Identifier for this host +ieee802_11_infra_rate="auto" # Rate (1, 2, 5.5, 11, or auto) +ieee802_11_infra_powermanagement="NO" # Power management +ieee802_11_infra_wep="NO" # Set to YES to enable encryption +ieee802_11_infra_wep_mixed_ok="NO" # Connect to mixed networks? +ieee802_11_infra_wep_tx_key="1" # Set the key to transmit with +ieee802_11_infra_wep_key1="" # Each key can be 0, 5, or 13 +ieee802_11_infra_wep_key2="" # bytes in length as either an +ieee802_11_infra_wep_key3="" # ASCII string or a hex string. +ieee802_11_infra_wep_key4="" +#ieee802_11_infra_ifconfig="DHCP" # interface configuration ### Network daemon (miscellaneous) & NFS options: ### syslogd_enable="YES" # Run syslog daemon (or NO). Index: share/man/man5/rc.conf.5 =================================================================== RCS file: /home/ncvs/src/share/man/man5/rc.conf.5,v retrieving revision 1.83 diff -u -r1.83 rc.conf.5 --- share/man/man5/rc.conf.5 2000/10/06 12:24:44 1.83 +++ share/man/man5/rc.conf.5 2000/10/13 23:58:43 @@ -135,6 +135,14 @@ you are not connected to a network. If you are using .Xr dhclient 8 to set your hostname via DHCP, this variable should be set to an empty string. +.It Ar default_hostname +If you are using +.Xr dhclient 8 +to set your hostname via DHCP and will be operating without a network +sometimes, set this to something meaningful to be used in those cases. +You should set +.Ar hostname +to an empty string if this is set. .It Ar nisdomainname (str) The NIS domainname of your host, or .Ar NO @@ -534,6 +542,18 @@ .Bd -literal ifconfig_ed0="DHCP" .Ed +.It Ar preifconfig_<interface> +(str) A command to run before attempting to ifconfig a network +interface. This hook provides the ability to preconfigure interfaces +which can not simply have an IP address attached to them such as +wireless Ethernet interfaces. The name of the interface is passed via +the +.Ev preifconfig_interface +environmental variable and an alternate set of +.Nm ifconfig +arguments may be returned by setting +.Ev preifconfig_ifconfig +before returning if the command is sourced. .It Ar ppp_enable (bool) If set to .Ar YES , @@ -563,6 +583,147 @@ (str) The name of the user under which ppp should be started. By default, ppp is started as .Ar root . +.It Ar ieee802_11_configs +(str) An ordered list of all IEEE 802.11 wireless Ethernet +configurations defined by the system. +.It Ar ieee802_11_config_default +(str) The default configuration to use for an IEEE 802.11 wireless +Ethernet device. It may be one or more of the values in +.Ar ieee802_11_configs +or +.Ar AUTO +which is the equivalent of listing all the values from +.Ar ieee802_11_configs . +If there is more then one value, they are tryed in turn until the last +config is reached or one succeedes in configuring the adaptor to +associate with a local network. +.It Ar ieee802_11_config_<interface> +(str) The configuration to use for the given IEEE 802.11 wireless +interface. Values act the same as in +.Ar ieee802_11_config_default . +.It Ar ieee802_11_association_timeout +(integer) The amount of time to sleep between setting the values of a +configuration and checking to see if the adaptor associated with a +network. +.It Ar ieee802_11_<config>_mode +(str) The interface mode. Valid values are +.Ar ad-hoc +or +.Ar infrastructure . +.It Ar ieee802_11_<config>_ssid<num> +(str) The SSID of the network you wish to join. Values are searched +from starting from <num>=1 until a value is not set. Not all adaptors +support more then one SSID. +.It Ar ieee802_11_<config>_ssid +(str) This is the same as +.Ar ieee802_11_<config>_ssid1 +except that it is assumed that +.Ar ieee802_11_<config>_ssid2 +is not set. This is the more portable interface. +.It Ar ieee802_11_<config>_station_name +(str) An identifier for this host. +.It Ar ieee802_11_<config>_rate +(str) The transmit speed for the interface to use. Valid values are +.Ar 1 , +.Ar 2, +.Ar 5.5 , +.Ar 11 , +and +.Ar AUTO . +.It Ar ieee802_11_<config>_powermanagement +(bool+) Set to +.Ar NO +to disable powermanagement. Some interfaces support other modes: +.Ar CAM , +.Ar PSP , +and +.Ar CAM-PSP . +Modes not understood by a given interface are treated as +.Ar YES . +.It Ar ieee802_11_<config>_channel +(integer) The channel to transmit on. Only really meaningful in ad-hoc +mode. +.It Ar ieee802_11_wep +(bool) Set to +.Ar YES +to enable Wired Equivalent Privacy (WEP). +.It Ar ieee802_11_<config>_wep_mixed_ok +(bool) Some cards need to be configured differently for networks with +allow both encrypted and unencrypted traffic. Set to +.Ar YES +for those networks and +.Ar NO +for others. +.It Ar ieee802_11_<config>_wep_tx_key +(integer) Select the WEP key to encript transmissions with. +.It Ar ieee802_11_<config>_wep_key<num> +(str) Set WEP key <num>. <num> must be a number from 1 to 4. Keys may +be specified in hex or as ASCII strings and must be 0, 5, or 13 bytes in +length. +.It Ar ieee802_11_<config>_ifconfig +(str) If this configuration suceeds when tried the +.Nm ifconfig +argument string that would have been used will be replaced with this +string. +.It Ar ieee802_11_<config>_rts_threshold +(integer|MAX) Sets the RTR/CTS threshold for the given iterface. If set +to +.Ar MAX , +the maximum value for the interface is used. +.It Ar ieee802_11_<config>_wi_create_IBSS +(bool) Set to +.Ar YES +to attempt to act as an access point. See the documentation on the +.Ar -c +option to +.Nm wicontrol +for more information. +.It Ar ieee802_11_<config>_wi_ssid +(str) The SSID of the access point we are trying to create. +.It Ar ieee802_11_<config>_wi_ap_density +(str) The density of access points. Controls some access point +switching behavior. Valid values are: +.Ar LOW , +.Ar MEDIUM , +and +.Ar HIGH . +.It Ar ieee802_11_<config>_wi_max_data_len +(integer) Provides access to the +.Nm wicontrol +command's +.Ar -d +option. +.It Ar ieee802_11_<config>_wi_sleep_interval +(integer) Provides access to the +.Nm wicontrol +command's +.Ar -S +option. +.It Ar ieee802_11_<config>_an_ap<num> +(MAC) Set up to 4 access points to preferentialy associate with. <num> +is in the range from 1 to 4 and the value is the MAC address of the +access point in question. +.It Ar ieee802_11_<config>_an_beacon_period +(integer) The ad-hoc beacon period in milliseconds. +.It Ar ieee802_11_<config>_an_tx_diversity +(str) Set the transmit antenna diversity. Valid values are: +.Ar FACTORY , +.Ar ANTENNA1 , +.Ar ANTENNA2 , +and +.Ar BOTH . +.It Ar ieee802_11_<config>_an_rx_diversity +(str) Set the recieve antenna diversity. Valid values are the save as +for +.Ar ieee802_11_<config>_an_tx_diversity . +.It Ar ieee802_11_<config>_an_net_join_timeout +(integer) Time to try to find an ad-hoc master before giving up and +becoming one in milliseconds. +.It Ar ieee802_11_<config>_an_tx_power +(interger) Set the transmit power. Valid values depend on the intended +market for the card. +.It Ar ieee802_11_<config>_an_frag_threshold +(integer) Set the fragmentation threshold for this interface. .It Ar rc_conf_files (str) This option is used to specify a list of files that will override the settings in @@ -1459,6 +1620,7 @@ .Xr motd 5 , .Xr accton 8 , .Xr amd 8 , +.Xr ancontrl 8 , .Xr apm 8 , .Xr atm 8 , .Xr cron 8 , @@ -1492,6 +1654,7 @@ .Xr timed 8 , .Xr vinum 8 , .Xr vnconfig 8 , +.Xr wicontrol 8 , .Xr xntpd 8 , .Xr xtend 8 , .Xr ypbind 8 , --- etc/config_802.11.orig Fri Oct 13 17:24:53 2000 +++ etc/config_802.11 Fri Oct 13 17:38:13 2000 @@ -0,0 +1,644 @@ +#!/bin/sh +############################################################################# +# Copyright 2000 The Aerospace Corporation. +# 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. The name of The Aerospace Corporation may not be used to endorse or +# promote products derived from this software. +# +# THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "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 AEROSPACE CORPORATION 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$ +# + +# +# config_802.11 +# +# The interface to be configured is passed via the +# preifconfig_interface environmental variable. Upon successful +# configuration of an interface, the preifconfig_ifconfig variable is +# set if the secessful configuration sets its +# ieee802_11_<config>_ifconfig variable. +# +# The current version supports wi and an adaptors. +# + +ieee802_11_set_config() { ( + wicontrol="/usr/sbin/wicontrol -i ${preifconfig_interface}" + ancontrol="/usr/sbin/ancontrol -i ${preifconfig_interface}" +# ancontrol="echo ancontrol -i ${preifconfig_interface}" + + # Convert inputs to cannonical form. All general arguments are + # cleaned here to reduce the code in the interface specific + # portion of the code. + # + eval mode=\$ieee802_11_${config}_mode + case ${mode} in + [Aa][Dd]-[Hh][Oo][Cc]|[Aa][Dd][Hh][Oo][Cc]) + mode="ad-hoc" + ;; + [Ii][Nn][Ff][Rr][Aa]*|[Bb][Ss][Ss]) + mode="infrastructure" + ;; + *) + mode="" + ;; + esac + + eval ssid=\${ieee802_11_${config}_ssid-_unset_} + if [ "${ssid}" != "_unset_" ]; then + ssid1=${ssid} + ssid2="_unset_" + else + ssids=1 + while : ; do + eval ssid=\${ieee802_11_${config}_ssid${ssids}-_unset_} + if [ "${ssid}" != "_unset_" ]; then + eval ssid${ssids}=${ssid} + ssids=`expr ${ssids} + 1` + else + break + fi + done + fi + + eval station_name=\${ieee802_11_${config}_station_name-_unset_} + + eval rate=\$ieee802_11_${config}_rate + case ${rate} in + 1|2|5.5|11) + ;; + 5) + rate="5.5" + ;; + [Aa][Uu][Tt][Oo]) + rate="auto" + ;; + *) + rate="" + ;; + esac + + eval powermanagement=\$ieee802_11_${config}_powermanagement + case ${powermanagement} in + [Nn][Oo]) + powermanagement="no" + ;; + [Yy][Ee][Ss]) + powermanagement="yes" + ;; + [Cc][Aa][Mm]) + powermanagement="cam" + ;; + [Pp][Ss][Pp]) + powermanagement="psp" + ;; + [Cc][Aa][Mm]-[Pp][Ss][Pp]) + powermanagement="cam-psp" + ;; + *) + powermanagement="" + ;; + esac + + eval channel=\$ieee802_11_${config}_channel + case ${channel} in + 1|2|3|4|5|6|7|8|9|10|11|12|13|14) + ;; + *) + channel="" + ;; + esac + + eval wep=\$ieee802_11_${config}_wep + case ${wep} in + [Nn][Oo]) + wep="no" + ;; + [Yy][Ee][Ss]) + wep="yes" + ;; + *) + wep="" + ;; + esac + + eval wep_mixed_ok=\$ieee802_11_${config}_wep_mixed_ok + case ${wep_mixed_ok} in + [Nn][Oo]) + wep_mixed_ok="no" + ;; + [Yy][Ee][Ss]) + wep_mixed_ok="yes" + ;; + *) + wep_mixed_ok="" + ;; + esac + + eval wep_tx_key=\$ieee802_11_${config}_wep_tx_key + case ${wep_tx_key} in + 1|2|3|4) + ;; + *) + wep_tx_key="" + ;; + esac + + eval wep_key1=\${ieee802_11_${config}_wep_key1-_unset_} + eval wep_key2=\${ieee802_11_${config}_wep_key2-_unset_} + eval wep_key3=\${ieee802_11_${config}_wep_key3-_unset_} + eval wep_key4=\${ieee802_11_${config}_wep_key4-_unset_} + + eval mac=\${ieee802_11_${config}_mac-_unset_} + + eval rts_threshold=\$ieee802_11_${config}_rts_threshold + case ${rts_threshold} in + [0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[12][0-9][0-9][0-9]) + if [ ${rts_threshold} -gt 2347 ]; then + rts_threshold="max" + fi + ;; + [Mm][Aa][Xx]*) + rts_threshold="max" + ;; + *) + rts_threshold="" + ;; + esac + + # Each interface type needs to be handled differently due to + # differences in the control programs and custom options. + # + case ${preifconfig_interface} in + wi[0-9]*) + # handle general options + # + if [ -n "${mode}" ]; then + case ${mode} in + ad-hoc) + ${wicontrol} -p 3 + ;; + infrastructure) + ${wicontrol} -p 1 + ;; + esac + fi + + if [ "${ssid1}" != "_unset_" ]; then + ${wicontrol} -n "${ssid1}" + fi + + if [ "${station_name}" != "_unset_" ]; then + ${wicontrol} -s "${station_name}" + fi + + # I think these values are probably correct for modern + # cards. However, my tests indicate that the value you + # select has little to do with the speed at which you + # operate. + # + if [ -n "${rate}" ]; then + case ${rate} in + 1) + ${wicontrol} -t 1 + ;; + 2) + ${wicontrol} -t 2 + ;; + 5.5) + ${wicontrol} -t 4 + ;; + 11) + ${wicontrol} -t 5 + ;; + auto) + ${wicontrol} -t 3 + ;; + esac + fi + + if [ -n "${powermanagement}" ]; then + case ${powermanagement} in + no) + ${wicontrol} -P 0 + ;; + *) + ${wicontrol} -P 1 + ;; + esac + fi + + if [ -n "${channel}" ]; then + ${wicontrol} -f ${channel} + fi + + if [ -n "${wep}" ]; then + case ${wep} in + no) + ${wicontrol} -e 0 + ;; + yes) + ${wicontrol} -e 1 + ;; + esac + fi + + # wep_mixed_ok isn't an option for wi devices + + if [ -n "${wep_tx_key}" ]; then + ${wicontrol} -T ${wep_tx_key} + fi + + if [ "${wep_key1}" != "_unset_" ]; then + ${wicontrol} -k "${wep_key1}" -v 1 + fi + if [ "${wep_key2}" != "_unset_" ]; then + ${wicontrol} -k "${wep_key2}" -v 2 + fi + if [ "${wep_key3}" != "_unset_" ]; then + ${wicontrol} -k "${wep_key3}" -v 3 + fi + if [ "${wep_key4}" != "_unset_" ]; then + ${wicontrol} -k "${wep_key4}" -v 4 + fi + + if [ -n "${rts_threshold}" ]; then + case ${rts_threshold} in + max) + ${wicontrol} -r 2347 + ;; + *) + ${wicontrol} -r ${rts_threshold} + ;; + esac + fi + + # Handle wi specific options + # + eval wi_create_IBSS=\$ieee802_11_${config}_wi_create_IBSS + case ${wi_create_IBSS} in + [Nn][Oo]) + ${wicontrol} -c 0 + ;; + [Yy][Ee][Ss]) + ${wicontrol} -c 1 + ;; + *) + ;; + esac + + eval wi_ssid=\${ieee802_11_${config}_wi_ssid-_unset_} + if [ "${wi_ssid}" != "_unset_" ]; then + ${wicontrol} -q "${wi_ssid}" + fi + + eval wi_ap_density=\$ieee802_11_${config}_wi_ap_density + case ${wi_ap_density} in + [Ll][Oo][Ww]|1) + ${wicontrol} -a 1 + ;; + [Mm][Ee][Dd][Ii][Uu][Mm]|2) + ${wicontrol} -a 2 + ;; + [Hh][Ii][Gg][Hh]|3) + ${wicontrol} -a 3 + ;; + *) + ;; + esac + + eval wi_max_data_len=\$ieee802_11_${config}_wi_max_data_len + if [ -n "${wi_max_data_length}" ]; then + ${wicontrol} -d ${wi_max_data_length} + fi + + eval wi_sleep_interval=\$ieee802_11_${config}_wi_sleep_interval + if [ -n "${wi_sleep_interval}" ]; then + ${wicontrol} -S ${wi_sleep_interval} + fi + + ;; + an[0-9]*) + # handle general options + # + if [ -n "${mode}" ]; then + case ${mode} in + ad-hoc) + ${ancontrol} -o 0 + ;; + infrastructure) + ${ancontrol} -o 1 + ;; + esac + fi + + if [ "${ssid1}" != "_unset_" ]; then + ${ancontrol} -v 1 -n "${ssid1}" + if [ "${ssid2}" != "_unset_" ]; then + ${ancontrol} -v 2 -n "${ssid2}" + if [ "${ssid3}" != "_unset_" ]; then + ${ancontrol} -v 3 -n "${ssid3}" + fi + fi + fi + + if [ "${station_name}" != "_unset_" ]; then + ${ancontrol} -l "${station_name}" + fi + + if [ -n "${rate}" ]; then + case ${rate} in + 1) + ${ancontrol} -t 1 + ;; + 2) + ${ancontrol} -t 2 + ;; + 5.5) + ${ancontrol} -t 3 + ;; + 11) + ${ancontrol} -t 4 + ;; + auto) + ${ancontrol} -t 0 + ;; + esac + fi + + if [ -n "${powermanagement}" ]; then + case ${powermanagement} in + no) + ${ancontrol} -s 0 + ;; + # XXX: I think CAM is the right choice for YES, + # but I'm not actually sure. Maybe what I need + # is the 802.11b spec. + yes) + ${ancontrol} -s 1 + ;; + cam) + ${ancontrol} -s 1 + ;; + psp) + ${ancontrol} -s 2 + ;; + cam-psp) + ${ancontrol} -s 3 + ;; + esac + fi + + if [ -n "${channel}" ]; then + ${ancontrol} -c ${channel} + fi + + # Hmm, not sure how this works + if [ -n "${wep_mixed_ok}" ]; then + case ${wep_mixed_ok} in + no) + # Turn off + ;; + yes) + # Turn on + ;; + esac + fi + + if [ "${wep_key1}" != "_unset_" ]; then + ${ancontrol} -v 1 -k "${wep_key1}" + fi + if [ "${wep_key2}" != "_unset_" ]; then + ${ancontrol} -v 3 -k "${wep_key2}" + fi + if [ "${wep_key3}" != "_unset_" ]; then + ${ancontrol} -v 5 -k "${wep_key3}" + fi + if [ "${wep_key4}" != "_unset_" ]; then + ${ancontrol} -v 7 -k "${wep_key4}" + fi + + # XXX Hack around missing feature in ancontrol + if [ -n "${wep_tx_key}" ]; then + case ${wep_tx_key} in + 1) + ${ancontrol} -v 1 -k "${wep_key1}" + ;; + 2) + ${ancontrol} -v 3 -k "${wep_key2}" + ;; + 3) + ${ancontrol} -v 5 -k "${wep_key3}" + ;; + 4) + ${ancontrol} -v 7 -k "${wep_key4}" + ;; + esac + fi + + # Needs to be after key setting for some reason + if [ -n "${wep}" ]; then + case ${wep} in + no) + ${ancontrol} -W 0 + ;; + yes) + ${ancontrol} -W 1 + ;; + esac + fi + + if [ -n "${rts_threshold}" ]; then + case ${rts_threshold} in + max) + ${ancontrol} -r 2312 + ;; + *) + ${ancontrol} -r ${rts_threshold} + ;; + esac + fi + + + # Handle an specific options + # + eval an_ap1=\${ieee802_11_${config}_an_ap1-_unset_} + eval an_ap2=\${ieee802_11_${config}_an_ap2-_unset_} + eval an_ap3=\${ieee802_11_${config}_an_ap3-_unset_} + eval an_ap4=\${ieee802_11_${config}_an_ap4-_unset_} + if [ "${an_ap1}" != "_unset_" ]; then + ${ancontrol} -v 1 -a "${an_ap1}" + fi + if [ "${an_ap2}" != "_unset_" ]; then + ${ancontrol} -v 2 -a "${an_ap2}" + fi + if [ "${an_ap3}" != "_unset_" ]; then + ${ancontrol} -v 3 -a "${an_ap3}" + fi + if [ "${an_ap4}" != "_unset_" ]; then + ${ancontrol} -v 4 -a "${an_ap4}" + fi + + eval an_beacon_period=\$ieee802_11_${config}_an_beacon_period + if [ -n "${an_beacon_period}" ]; then + ${ancontrol} -b ${an_beacon_period} + fi + + eval an_tx_diversity=\$ieee802_11_${config}_an_diversity + eval an_rx_diversity=\$ieee802_11_${config}_an_diversity + case "${an_tx_diversity}" in + '') + ;; + [Ff][Aa][Cc][Tt][Oo][Rr][Yy]|0) + ${ancontrol} -v 1 -d 0 + ;; + [Aa][Nn][Tt][Ee][Nn][Nn][Aa]1|1) + ${ancontrol} -v 1 -d 1 + ;; + [Aa][Nn][Tt][Ee][Nn][Nn][Aa]2|2) + ${ancontrol} -v 1 -d 2 + ;; + [Bb][Oo][Tt][Hh]|3) + ${ancontrol} -v 1 -d 3 + ;; + esac + case "${an_rx_diversity}" in + '') + ;; + [Ff][Aa][Cc][Tt][Oo][Rr][Yy]|0) + ${ancontrol} -v 0 -d 0 + ;; + [Aa][Nn][Tt][Ee][Nn][Nn][Aa]1|1) + ${ancontrol} -v 0 -d 1 + ;; + [Aa][Nn][Tt][Ee][Nn][Nn][Aa]2|2) + ${ancontrol} -v 0 -d 2 + ;; + [Bb][Oo][Tt][Hh]|3) + ${ancontrol} -v 0 -d 3 + ;; + esac + + eval an_net_join_timeout=\$ieee802_11_${config}_an_net_join_timeout + if [ -n "${an_net_join_timeout}" ]; then + ${ancontrol} -j ${an_net_join_timeout} + fi + + eval an_tx_power=\$ieee802_11_${config}_an_tx_power + if [ -n "${an_tx_power}" ]; then + ${ancontrol} -p ${an_net_tx_power} + fi + + eval an_frag_threshold=\$ieee802_11_${config}_an_frag_threshold + if [ -n "${an_frag_threshold}" ]; then + ${ancontrol} -f ${an_frag_threshold} + fi + + ;; + *) + ;; + esac +) } + +ieee802_11_check_status() { + eval ieee802_11_mode=\$ieee802_11_${config}_mode + case ${ieee802_11_mode} in + [Aa][Dd]-[Hh][Oo][Cc]|[Aa][Dd][Hh][Oo][Cc]) + ieee802_11_mode="ad-hoc" + ;; + [Ii][Nn][Ff][Rr][Aa]*|[Bb][Ss][Ss]) + ieee802_11_mode="infrastructure" + ;; + *) + ieee802_11_mode="" + ;; + esac + + case ${preifconfig_interface} in + wi[0-9]*) + if [ `wicontrol -i ${preifconfig_interface} | sed -e '/^Comms.*/!d' -e 's/.*\[ \([0-9]*\) .*/\1/` -gt 0 ]; then + ieee802_11_is_synced="yes" + else + ieee802_11_is_synced="no" + fi + ;; + an[0-9]*) + case ${ieee802_11_mode} in + ad-hoc) + if [ -n "`ancontrol -i ${preifconfig_interface} -S | sed -e '/^Operating.*/!d' -e '/.*synced.*/!d'`" ]; then + ieee802_11_is_synced="yes" + else + ieee802_11_is_synced="no" + fi + ;; + infrastructure) + if [ -n "`ancontrol -i ${preifconfig_interface} -S | sed -e '/^Current AP name.*/!d' -e 's/.*\[ *\([a-zA-Z0-9-]*\) *\].*/\1/'`" ]; then + ieee802_11_is_synced="yes" + else + ieee802_11_is_synced="no" + fi + ;; + esac + ;; + *) + ieee802_11_is_synced="no" + esac +} + +# Select the specific config(s) for this interface or else take the default +# +eval ieee802_11_config=\$ieee802_11_config_${preifconfig_interface} +if [ -z "${ieee802_11_config}" ]; then + ieee802_11_config=${ieee802_11_config_default} +fi + +# If the config is auto then try all the configs +# +case ${ieee802_11_config} in +[Aa][Uu][Tt][Oo]) + ieee802_11_config=${ieee802_11_configs} + ;; +esac + +sleep 1 + +# Try each config in turn until we get one that works or we give up and +# use the last one. +# +for config in ${ieee802_11_config}; do + echo -n "Trying IEEE 802.11 config '$config' on ${preifconfig_interface}..." + ieee802_11_set_config + ifconfig ${preifconfig_interface} up + if [ ${ieee802_11_association_timeout} -gt 0 ]; then + echo -n "sleeping ${ieee802_11_association_timeout}sec..." + sleep ${ieee802_11_association_timeout} + fi + ieee802_11_check_status + ifconfig ${preifconfig_interface} down + if [ "$ieee802_11_is_synced" = "yes" ]; then + echo succeded + eval preifconfig_ifconfig=\${ieee802_11_${config}_ifconfig} + break + else + echo failed + fi +done >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200010140102.e9E12cv03926>