From owner-svn-src-projects@FreeBSD.ORG Fri Jan 9 21:05:37 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 420B3106566B; Fri, 9 Jan 2009 21:05:37 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2DAD48FC1A; Fri, 9 Jan 2009 21:05:37 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n09L5bYc068943; Fri, 9 Jan 2009 21:05:37 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n09L5ak0068932; Fri, 9 Jan 2009 21:05:36 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200901092105.n09L5ak0068932@svn.freebsd.org> From: Sam Leffler Date: Fri, 9 Jan 2009 21:05:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186978 - in projects/vap7: etc etc/defaults etc/rc.d sbin/ifconfig tools/tools/ath tools/tools/ath/athdebug tools/tools/ath/athkey tools/tools/ath/athpow tools/tools/ath/athprom tools/... X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jan 2009 21:05:37 -0000 Author: sam Date: Fri Jan 9 21:05:36 2009 New Revision: 186978 URL: http://svn.freebsd.org/changeset/base/186978 Log: first cut at merging vap/wireless-related support from HEAD: o ifconfig o tools (net80211, atH) o wpa_supplicant o hostapd o rc support Added: projects/vap7/etc/regdomain.xml - copied, changed from r178355, head/etc/regdomain.xml projects/vap7/sbin/ifconfig/regdomain.c - copied, changed from r178354, head/sbin/ifconfig/regdomain.c projects/vap7/sbin/ifconfig/regdomain.h - copied, changed from r178354, head/sbin/ifconfig/regdomain.h projects/vap7/tools/tools/ath/Makefile.inc - copied unchanged from r186961, head/tools/tools/ath/Makefile.inc projects/vap7/tools/tools/ath/athkey/ - copied from r186961, head/tools/tools/ath/athkey/ projects/vap7/tools/tools/ath/athpow/ - copied from r186961, head/tools/tools/ath/athpow/ projects/vap7/tools/tools/ath/athprom/ - copied from r186961, head/tools/tools/ath/athprom/ projects/vap7/tools/tools/ath/athregs/ - copied from r186961, head/tools/tools/ath/athregs/ projects/vap7/tools/tools/ath/common/ - copied from r186961, head/tools/tools/ath/common/ projects/vap7/tools/tools/net80211/scripts/ - copied from r186961, head/tools/tools/net80211/scripts/ projects/vap7/tools/tools/net80211/wlanwds/ - copied from r186961, head/tools/tools/net80211/wlanwds/ projects/vap7/usr.sbin/wpa/wpa_supplicant/driver_wired.c - copied unchanged from r178358, head/usr.sbin/wpa/wpa_supplicant/driver_wired.c Modified: projects/vap7/etc/ (props changed) projects/vap7/etc/Makefile projects/vap7/etc/defaults/rc.conf projects/vap7/etc/network.subr projects/vap7/etc/pccard_ether projects/vap7/etc/rc.d/hostapd projects/vap7/etc/rc.d/netif projects/vap7/etc/rc.d/wpa_supplicant projects/vap7/sbin/ifconfig/ (props changed) projects/vap7/sbin/ifconfig/Makefile projects/vap7/sbin/ifconfig/ifconfig.8 projects/vap7/sbin/ifconfig/ifconfig.c projects/vap7/sbin/ifconfig/ifieee80211.c projects/vap7/sbin/ifconfig/ifmedia.c projects/vap7/sbin/ifconfig/ifvlan.c projects/vap7/tools/tools/ath/ (props changed) projects/vap7/tools/tools/ath/Makefile projects/vap7/tools/tools/ath/athdebug/Makefile projects/vap7/tools/tools/ath/athdebug/athdebug.c projects/vap7/tools/tools/ath/athstats/Makefile projects/vap7/tools/tools/ath/athstats/athstats.c projects/vap7/tools/tools/ath/athstats/athstats.h projects/vap7/tools/tools/ath/athstats/main.c projects/vap7/tools/tools/ath/athstats/statfoo.c projects/vap7/tools/tools/ath/athstats/statfoo.h projects/vap7/tools/tools/net80211/ (props changed) projects/vap7/tools/tools/net80211/Makefile projects/vap7/tools/tools/net80211/README projects/vap7/tools/tools/net80211/wlanstats/main.c projects/vap7/tools/tools/net80211/wlanstats/statfoo.c projects/vap7/tools/tools/net80211/wlanstats/statfoo.h projects/vap7/tools/tools/net80211/wlanstats/wlanstats.c projects/vap7/tools/tools/net80211/wlanstats/wlanstats.h projects/vap7/tools/tools/net80211/wlanwatch/wlanwatch.c projects/vap7/usr.sbin/wlandebug/ (props changed) projects/vap7/usr.sbin/wlandebug/wlandebug.8 projects/vap7/usr.sbin/wlandebug/wlandebug.c projects/vap7/usr.sbin/wpa/ (props changed) projects/vap7/usr.sbin/wpa/hostapd/Makefile projects/vap7/usr.sbin/wpa/hostapd/driver_freebsd.c projects/vap7/usr.sbin/wpa/wpa_supplicant/ (props changed) projects/vap7/usr.sbin/wpa/wpa_supplicant/Packet32.c projects/vap7/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c Modified: projects/vap7/etc/Makefile ============================================================================== --- projects/vap7/etc/Makefile Fri Jan 9 21:04:09 2009 (r186977) +++ projects/vap7/etc/Makefile Fri Jan 9 21:05:36 2009 (r186978) @@ -17,7 +17,7 @@ BIN1= amd.map apmd.conf auth.conf \ portsnap.conf pf.os phones profile protocols \ rc rc.bsdextended rc.firewall rc.firewall6 rc.initdiskless \ rc.sendmail rc.shutdown \ - rc.subr remote rpc services shells \ + rc.subr regdomain.xml remote rpc services shells \ snmpd.config sysctl.conf syslog.conf \ etc.${MACHINE_ARCH}/ttys \ ${.CURDIR}/../gnu/usr.bin/man/manpath/manpath.config \ @@ -49,6 +49,10 @@ SSH= ${.CURDIR}/../crypto/openssh/ssh_co SSL= ${.CURDIR}/../crypto/openssl/apps/openssl.cnf .endif +.if ${MK_WIRELESS} != "no" +BIN1+= regdomain.xml +.endif + # -rwxr-xr-x root:wheel, for the new cron root:wheel BIN2= netstart pccard_ether rc.suspend rc.resume Modified: projects/vap7/etc/defaults/rc.conf ============================================================================== --- projects/vap7/etc/defaults/rc.conf Fri Jan 9 21:04:09 2009 (r186977) +++ projects/vap7/etc/defaults/rc.conf Fri Jan 9 21:05:36 2009 (r186978) @@ -103,7 +103,7 @@ dhclient_flags="" # Extra flags to pass #dhclient_flags_fxp0="" # Extra dhclient flags for fxp0 only background_dhclient="NO" # Start dhcp client in the background. #background_dhclient_fxp0="YES" # Start dhcp client on fxp0 in the background. -synchronous_dhclient="YES" # Start dhclient directly on configured +synchronous_dhclient="NO" # Start dhclient directly on configured # interfaces during startup. firewall_enable="NO" # Set to YES to enable firewall functionality firewall_script="/etc/rc.firewall" # Which script to run to set up the firewall @@ -185,12 +185,14 @@ tcp_drop_synfin="NO" # Set to YES to dr icmp_drop_redirect="NO" # Set to YES to ignore ICMP REDIRECT packets icmp_log_redirect="NO" # Set to YES to log ICMP REDIRECT packets network_interfaces="auto" # List of network interfaces (or "auto"). +if_up_delay="30" # Time to wait for interfaces to come up. cloned_interfaces="" # List of cloned network interfaces to create. #cloned_interfaces="gif0 gif1 gif2 gif3" # Pre-cloning GENERIC config. ifconfig_lo0="inet 127.0.0.1" # default loopback device configuration. #ifconfig_lo0_alias0="inet 127.0.0.254 netmask 0xffffffff" # Sample alias entry. #ifconfig_ed0_ipx="ipx 0x00010010" # Sample IPX address family entry. #ifconfig_fxp0_name="net0" # Change interface name from fxp0 to net0. +#vaps_ath0="wlan0" # VAP interfaces for ath0 device #ipv4_addrs_fxp0="192.168.0.1/24 192.168.1.1-5/28" # example IPv4 address entry. # #autobridge_interfaces="bridge0" # List of bridges to check Modified: projects/vap7/etc/network.subr ============================================================================== --- projects/vap7/etc/network.subr Fri Jan 9 21:04:09 2009 (r186977) +++ projects/vap7/etc/network.subr Fri Jan 9 21:05:36 2009 (r186978) @@ -30,6 +30,48 @@ # Requires that rc.conf be loaded first. # +# ifn_start ifn +# Bring up and configure an interface. If some configuration is applied +# print the interface configuration. +# +ifn_start() +{ + local ifn cfg + ifn="$1" + cfg=1 + + [ -z "$ifn" ] && err 1 "ifn_start called without an interface" + + ifscript_up ${ifn} && cfg=0 + ifconfig_up ${ifn} && cfg=0 + ipv4_up ${ifn} && cfg=0 + ipx_up ${ifn} && cfg=0 + childif_create ${ifn} + + return $cfg +} + +# ifn_start ifn +# Shutdown and de-configure an interface. If action is taken print the +# interface name. +# +ifn_stop() +{ + local ifn cfg + ifn="$1" + cfg=1 + + [ -z "$ifn" ] && return 1 + + ipx_down ${ifn} && cfg=0 + ipv4_down ${ifn} && cfg=0 + ifconfig_down ${ifn} && cfg=0 + ifscript_down ${ifn} && cfg=0 + childif_destroy ${ifn} + + return $cfg +} + # ifconfig_up if # Evaluate ifconfig(8) arguments for interface $if and # run ifconfig(8) with those arguments. It returns 0 if @@ -43,8 +85,8 @@ ifconfig_up() ifconfig_args=`ifconfig_getargs $1` if [ -n "${ifconfig_args}" ]; then - ifconfig $1 up ifconfig $1 ${ifconfig_args} + ifconfig $1 up _cfg=0 fi @@ -426,7 +468,7 @@ clone_up() _prefix= _list= for ifn in ${cloned_interfaces}; do - ifconfig ${ifn} create + ifconfig ${ifn} create `get_if_var ${ifn} create_args_IF` if [ $? -eq 0 ]; then _list="${_list}${_prefix}${ifn}" [ -z "$_prefix" ] && _prefix=' ' @@ -452,6 +494,45 @@ clone_down() debug "Destroyed clones: ${_list}" } +# Create and configure child interfaces. +# Return 0 if child interfaces are created. +# +childif_create() +{ + local cfg child child_wlans create_args ifn i + cfg=1 + + ifn=$1 + + # Create wireless interfaces + child_wlans=`get_if_var $ifn wlans_IF` + + for child in ${child_wlans}; do + create_args="wlandev $ifn `get_if_var $child create_args_IF`" + if expr $child : 'wlan[0-9][0-9]*$' >/dev/null 2>&1; then + ifconfig $child create ${create_args} && cfg=0 + else + i=`ifconfig wlan create ${create_args}` + ifconfig $i name $child && cfg=0 + fi + ifn_start $child + done + + return ${cfg} +} + +# Destroy child interfaces. +# +childif_destroy() +{ + local cfg child child_wlans ifn + + child_wlans="`get_if_var $ifn wlans_IF` `get_if_var $ifn vaps_IF`" + for child in ${child_wlans}; do + ifconfig $child destroy && cfg=0 + done +} + # Create netgraph nodes. # ng_mkpeer() { @@ -676,6 +757,29 @@ list_net_interfaces() return 0 } +# get_default_if -address_family +# Get the interface of the default route for the given address family. +# The -address_family argument must be suitable passing to route(8). +# +get_default_if() +{ + routeget="`route -n get $1 default 2>/dev/null`" + oldifs="$IFS" + IFS=" +" + defif= + for line in $routeget ; do + case $line in + *interface:*) + defif=${line##*: } + ;; + esac + done + IFS=${oldifs} + + echo $defif +} + hexdigit() { if [ $1 -lt 10 ]; then Modified: projects/vap7/etc/pccard_ether ============================================================================== --- projects/vap7/etc/pccard_ether Fri Jan 9 21:04:09 2009 (r186977) +++ projects/vap7/etc/pccard_ether Fri Jan 9 21:05:36 2009 (r186978) @@ -78,7 +78,7 @@ pccard_ether_start() done fi - /etc/rc.d/netif start $ifn + /etc/rc.d/netif quietstart $ifn # Do route configuration if needed. # XXX: should probably do this by calling rc.d/routing. @@ -99,7 +99,7 @@ pccard_ether_stop() fi fi - /etc/rc.d/netif stop $ifn + /etc/rc.d/netif quietstop $ifn # clean ARP table ifexists $ifn && arp -d -i $ifn -a Modified: projects/vap7/etc/rc.d/hostapd ============================================================================== --- projects/vap7/etc/rc.d/hostapd Fri Jan 9 21:04:09 2009 (r186977) +++ projects/vap7/etc/rc.d/hostapd Fri Jan 9 21:05:36 2009 (r186978) @@ -18,6 +18,7 @@ pidfile="/var/run/${name}.pid" command_args="-P ${pidfile} -B ${conf_file}" required_files="${conf_file}" +required_modules="wlan_xauth wlan_wep wlan_tkip wlan_ccmp" extra_commands="reload" load_rc_config ${name} Modified: projects/vap7/etc/rc.d/netif ============================================================================== --- projects/vap7/etc/rc.d/netif Fri Jan 9 21:04:09 2009 (r186977) +++ projects/vap7/etc/rc.d/netif Fri Jan 9 21:05:36 2009 (r186978) @@ -68,7 +68,30 @@ network_start() fi # Configure the interface(s). - network_common ifn_start verbose + network_common ifn_start + + if [ -z "$cmdifn" ]; then + dhcp_interfaces=`list_net_interfaces dhcp` + if [ -n "${dhcp_interfaces}" ]; then + delay=${if_up_delay} + while [ ${delay} -gt 0 ]; do + defif=`get_default_if -inet` + if [ -n "${defif}" ]; then + if [ ${delay} -ne ${if_up_delay} ]; then + echo "($defif)" + fi + break + fi + if [ ${delay} -eq ${if_up_delay} ]; then + echo -n "Waiting for an interface to come up: " + else + echo -n . + fi + sleep 1 + delay=`expr $delay - 1` + done + fi + fi if [ -f /etc/rc.d/ipfilter ] ; then # Resync ipfilter @@ -85,100 +108,67 @@ network_stop() # cmdifn=$* - echo -n "Stopping network:" - # Deconfigure the interface(s) network_common ifn_stop - echo '.' } -# network_common routine verbose +# network_common routine # Common configuration subroutine for network interfaces. This # routine takes all the preparatory steps needed for configuriing -# an interface and then calls $routine. If $verbose is specified, -# it will call ifconfig(8) to show, in long format, the configured -# interfaces. If $verbose is not given, it will simply output the -# configured interface(s). +# an interface and then calls $routine. network_common() { - local _cooked_list _fail _func _verbose + local _cooked_list _fail _func _ok _str _func= - _verbose= if [ -z "$1" ]; then err 1 "network_common(): No function name specified." else _func="$1" fi - [ -n "$2" ] && _verbose=yes # Set the scope of the command (all interfaces or just one). # _cooked_list= if [ -n "$cmdifn" ]; then - # Don't check that the interfaces exist. We need to run + # Don't check that the interface(s) exist. We need to run # the down code even when the interface doesn't exist to # kill off wpa_supplicant. + # XXXBED: is this really true or does wpa_supplicant die? + # if so, we should get rid of the devd entry _cooked_list="$cmdifn" else _cooked_list="`list_net_interfaces`" fi _fail= + _ok= for ifn in ${_cooked_list}; do - if ${_func} ${ifn} ; then - eval showstat_$ifn=1 + if ${_func} ${ifn} $2; then + _ok="${_ok} ${ifn}" else - _fail="$_fail $ifn" + _fail="${_fail} ${ifn}" fi done - # Display interfaces configured by this script - # - for ifn in ${_cooked_list}; do - eval showstat=\$showstat_${ifn} - if [ ! -z ${showstat} ]; then - if [ -n "$_verbose" ]; then - ifconfig ${ifn} - else - echo -n " ${ifn}" - fi + _str= + if [ -n "${_ok}" ]; then + case ${_func} in + ifn_start) + _str='Starting' + ;; + ifn_stop) + _str='Stopping' + ;; + esac + echo "${_str} Network:${_ok}." + if [ -z "${rc_quiet}" ]; then + /sbin/ifconfig ${_ok} fi - done - debug "The following interfaces were not configured: $_fail" -} - -ifn_start() -{ - local ifn cfg - ifn="$1" - cfg=1 - - [ -z "$ifn" ] && return 1 - - ifscript_up ${ifn} && cfg=0 - ifconfig_up ${ifn} && cfg=0 - ipv4_up ${ifn} && cfg=0 - ipx_up ${ifn} && cfg=0 - - return $cfg -} - -ifn_stop() -{ - local ifn cfg - ifn="$1" - cfg=1 - - [ -z "$ifn" ] && return 1 - - ipx_down ${ifn} && cfg=0 - ipv4_down ${ifn} && cfg=0 - ifconfig_down ${ifn} && cfg=0 - ifscript_down ${ifn} && cfg=0 + fi - return $cfg + debug "The following interfaces were not configured: $_fail" } load_rc_config $name Modified: projects/vap7/etc/rc.d/wpa_supplicant ============================================================================== --- projects/vap7/etc/rc.d/wpa_supplicant Fri Jan 9 21:04:09 2009 (r186977) +++ projects/vap7/etc/rc.d/wpa_supplicant Fri Jan 9 21:05:36 2009 (r186978) @@ -20,12 +20,25 @@ if [ -z "$ifn" ]; then return 1 fi -case ${ifn} in -ndis*) +is_ndis_interface() +{ + case `sysctl -n net.wlan.${1#wlan}.%parent 2>/dev/null` in + ndis*) true ;; + *) false ;; + esac +} + +if is_wired_interface ${ifn} ; then + driver="wired" +elif is_ndis_interface ${ifn} ; then driver="ndis" ;; *) - driver="bsd" + if is_wired_interface ${ifn} ; then + driver="wired" + else + driver="bsd" + fi ;; esac @@ -34,5 +47,6 @@ load_rc_config $name pidfile="/var/run/${name}/${ifn}.pid" command_args="-B -q -i $ifn -c $conf_file -D $driver -P $pidfile" required_files=$conf_file +required_modules="wlan_wep wlan_tkip wlan_ccmp" run_rc_command "$1" Copied and modified: projects/vap7/etc/regdomain.xml (from r178355, head/etc/regdomain.xml) ============================================================================== --- head/etc/regdomain.xml Sun Apr 20 20:37:02 2008 (r178355, copy source) +++ projects/vap7/etc/regdomain.xml Fri Jan 9 21:05:36 2009 (r186978) @@ -39,7 +39,7 @@ --> DEBUG - 0 + 0x1ff @@ -1080,6 +1080,75 @@ + + + SR9 + 0x0298 + + + + + 30 + IEEE80211_CHAN_G + + + + 30 + IEEE80211_CHAN_G + + + + 30 + IEEE80211_CHAN_G + + + + + + XR9 + 0x299 + + + + + 30 + IEEE80211_CHAN_G + + + + 30 + IEEE80211_CHAN_G + + + + 30 + IEEE80211_CHAN_G + + + + + + GZ901 + 0x29a + + + + + 30 + IEEE80211_CHAN_G + + + + 30 + IEEE80211_CHAN_G + + + + 30 + IEEE80211_CHAN_G + + + @@ -1201,6 +1270,9 @@ 320 Guatemala + + 5002 ZComax GZ-901 + 340 Honduras @@ -1396,6 +1468,12 @@ 792 Turkey + + 5000 Ubiquiti SR9 + + + 5001 Ubiquiti XR9 + 804 Ukraine @@ -1426,6 +1504,10 @@ 716 Zimbabwe + + + 0 Debug +