Index: head/etc/network.subr =================================================================== --- head/etc/network.subr (revision 173354) +++ head/etc/network.subr (revision 173355) @@ -1,972 +1,969 @@ # # Copyright (c) 2003 The FreeBSD Project. 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. # # THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 PROJECT 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. # # $FreeBSD$ # # # Subroutines commonly used from network startup scripts. # Requires that rc.conf be loaded first. # # ifconfig_up if # Evaluate ifconfig(8) arguments for interface $if and # run ifconfig(8) with those arguments. It returns 0 if # arguments were found and executed or 1 if the interface # had no arguments. Pseudo arguments DHCP and WPA are handled # here. # ifconfig_up() { _cfg=1 ifconfig_args=`ifconfig_getargs $1` if [ -n "${ifconfig_args}" ]; then ifconfig $1 up ifconfig $1 ${ifconfig_args} _cfg=0 fi if wpaif $1; then - if [ $_cfg -ne 0 ] ; then - ifconfig $1 up - fi /etc/rc.d/wpa_supplicant start $1 _cfg=0 # XXX: not sure this should count fi if dhcpif $1; then if [ $_cfg -ne 0 ] ; then ifconfig $1 up fi if syncdhcpif $1; then /etc/rc.d/dhclient start $1 fi _cfg=0 fi return $_cfg } # ifconfig_down if # returns 1 if wpa_supplicant or dhclient was stopped or # the interface exists. # ifconfig_down() { [ -z "$1" ] && return 1 _cfg=1 if wpaif $1; then /etc/rc.d/wpa_supplicant stop $1 _cfg=0 fi if dhcpif $1; then /etc/rc.d/dhclient stop $1 _cfg=0 fi if ifexists $1; then ifconfig $1 down _cfg=0 fi return $_cfg } # get_if_var if var [default] # Return the value of the pseudo-hash corresponding to $if where # $var is a string containg the sub-string "IF" which will be # replaced with $if after the characters defined in _punct are # replaced with '_'. If the variable is unset, replace it with # $default if given. get_if_var() { if [ $# -ne 2 -a $# -ne 3 ]; then err 3 'USAGE: get_if_var name var [default]' fi _if=$1 _punct=". - / +" for _punct_c in $_punct; do _if=`ltr ${_if} ${_punct_c} '_'` done _var=$2 _default=$3 prefix=${_var%%IF*} suffix=${_var##*IF} eval echo \${${prefix}${_if}${suffix}-${_default}} } # _ifconfig_getargs if # Echos the arguments for the supplied interface to stdout. # returns 1 if empty. In general, ifconfig_getargs should be used # outside this file. _ifconfig_getargs() { _ifn=$1 if [ -z "$_ifn" ]; then return 1 fi get_if_var $_ifn ifconfig_IF "$ifconfig_DEFAULT" } # ifconfig_getargs if # Takes the result from _ifconfig_getargs and removes pseudo # args such as DHCP and WPA. ifconfig_getargs() { _tmpargs=`_ifconfig_getargs $1` if [ $? -eq 1 ]; then return 1 fi _args= for _arg in $_tmpargs; do case $_arg in [Dd][Hh][Cc][Pp]) ;; [Nn][Oo][Aa][Uu][Tt][Oo]) ;; [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) ;; [Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) ;; [Ww][Pp][Aa]) ;; *) _args="$_args $_arg" ;; esac done echo $_args } # autoif # Returns 0 if the interface should be automaticly configured at # boot time and 1 otherwise. autoif() { _tmpargs=`_ifconfig_getargs $1` for _arg in $_tmpargs; do case $_arg in [Nn][Oo][Aa][Uu][Tt][Oo]) return 1 ;; esac done return 0 } # dhcpif if # Returns 0 if the interface is a DHCP interface and 1 otherwise. dhcpif() { _tmpargs=`_ifconfig_getargs $1` for _arg in $_tmpargs; do case $_arg in [Dd][Hh][Cc][Pp]) return 0 ;; [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) return 0 ;; [Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) return 0 ;; esac done return 1 } # syncdhcpif # Returns 0 if the interface should be configured synchronously and # 1 otherwise. syncdhcpif() { _tmpargs=`_ifconfig_getargs $1` for _arg in $_tmpargs; do case $_arg in [Nn][Oo][Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) return 1 ;; [Ss][Yy][Nn][Cc][Dd][Hh][Cc][Pp]) return 0 ;; esac done if checkyesno synchronous_dhclient; then return 0 else return 1 fi } # wpaif if # Returns 0 if the interface is a WPA interface and 1 otherwise. wpaif() { _tmpargs=`_ifconfig_getargs $1` for _arg in $_tmpargs; do case $_arg in [Ww][Pp][Aa]) return 0 ;; esac done return 1 } # ipv6if if # Returns 0 if the interface should be configured for IPv6 and # 1 otherwise. ipv6if() { if ! checkyesno ipv6_enable; then return 1 fi case "${ipv6_network_interfaces}" in [Aa][Uu][Tt][Oo]) return 0 ;; ''|[Nn][Oo][Nn][Ee]) return 1 ;; esac for v6if in ${ipv6_network_interfaces}; do if [ "${v6if}" = "${1}" ]; then return 0 fi done return 1 } # ifexists if # Returns 0 if the interface exists and 1 otherwise. ifexists() { ifconfig -n $1 > /dev/null 2>&1 } # ipv4_up if # add IPv4 addresses to the interface $if ipv4_up() { _if=$1 ifalias_up ${_if} ipv4_addrs_common ${_if} alias } # ipv4_down if # remove IPv4 addresses from the interface $if ipv4_down() { _if=$1 _ifs="^" _ret=1 ifexists ${_if} || return 1 inetList="`ifconfig ${_if} | grep 'inet ' | tr "\n" "$_ifs"`" oldifs="$IFS" IFS="$_ifs" for _inet in $inetList ; do # get rid of extraneous line [ -z "$_inet" ] && break _inet=`expr "$_inet" : '.*\(inet \([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*'` IFS="$oldifs" ifconfig ${_if} ${_inet} delete IFS="$_ifs" _ret=0 done IFS="$oldifs" ifalias_down ${_if} && _ret=0 ipv4_addrs_common ${_if} -alias && _ret=0 return $_ret } # ipv4_addrs_common if action # Evaluate the ifconfig_if_ipv4 arguments for interface $if # and use $action to add or remove IPv4 addresses from $if. ipv4_addrs_common() { _ret=1 _if=$1 _action=$2 # get ipv4-addresses cidr_addr=`get_if_var $_if ipv4_addrs_IF` for _cidr in ${cidr_addr}; do _ipaddr=${_cidr%%/*} _netmask="/"${_cidr##*/} _range=${_ipaddr##*.} _ipnet=${_ipaddr%.*} _iplow=${_range%-*} _iphigh=${_range#*-} # clear netmask when removing aliases if [ "${_action}" = "-alias" ]; then _netmask="" fi _ipcount=${_iplow} while [ "${_ipcount}" -le "${_iphigh}" ]; do eval "ifconfig ${_if} ${_action} ${_ipnet}.${_ipcount}${_netmask}" _ipcount=$((${_ipcount}+1)) _ret=0 # only the first ipaddr in a subnet need the real netmask if [ "${_action}" != "-alias" ]; then _netmask="/32" fi done done return $_ret } # ifalias_up if # Configure aliases for network interface $if. # It returns 0 if at least one alias was configured or # 1 if there were none. # ifalias_up() { _ret=1 alias=0 while : ; do ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}` if [ -n "${ifconfig_args}" ]; then ifconfig $1 ${ifconfig_args} alias alias=$((${alias} + 1)) _ret=0 else break fi done return $_ret } #ifalias_down if # Remove aliases for network interface $if. # It returns 0 if at least one alias was removed or # 1 if there were none. # ifalias_down() { _ret=1 alias=0 while : ; do ifconfig_args=`get_if_var $1 ifconfig_IF_alias${alias}` if [ -n "${ifconfig_args}" ]; then ifconfig $1 ${ifconfig_args} -alias alias=$((${alias} + 1)) _ret=0 else break fi done return $_ret } # ifscript_up if # Evaluate a startup script for the $if interface. # It returns 0 if a script was found and processed or # 1 if no script was found. # ifscript_up() { if [ -r /etc/start_if.$1 ]; then . /etc/start_if.$1 return 0 fi return 1 } # ifscript_down if # Evaluate a shutdown script for the $if interface. # It returns 0 if a script was found and processed or # 1 if no script was found. # ifscript_down() { if [ -r /etc/stop_if.$1 ]; then . /etc/stop_if.$1 return 0 fi return 1 } # Create cloneable interfaces. # clone_up() { _prefix= _list= for ifn in ${cloned_interfaces}; do ifconfig ${ifn} create if [ $? -eq 0 ]; then _list="${_list}${_prefix}${ifn}" [ -z "$_prefix" ] && _prefix=' ' fi done debug "Cloned: ${_list}" } # Destroy cloned interfaces. Destroyed interfaces are echoed # to standard output. # clone_down() { _prefix= _list= for ifn in ${cloned_interfaces}; do ifconfig ${ifn} destroy if [ $? -eq 0 ]; then _list="${_list}${_prefix}${ifn}" [ -z "$_prefix" ] && _prefix=' ' fi done debug "Destroyed clones: ${_list}" } # Create netgraph nodes. # ng_mkpeer() { ngctl -f - 2> /dev/null </dev/null 2>&1 ifconfig $i tunnel ${peers} ifconfig $i up ;; esac done } # ng_fec_create ifn # Configure Fast EtherChannel for interface $ifn. Returns 0 if FEC # arguments were found and configured; returns !0 otherwise. ng_fec_create() { local req_iface iface bogus req_iface="$1" ngctl shutdown ${req_iface}: > /dev/null 2>&1 bogus="" while true; do iface=`ng_create_one fec dummy fec` if [ -z "${iface}" ]; then exit 2 fi if [ "${iface}" = "${req_iface}" ]; then break fi bogus="${bogus} ${iface}" done for iface in ${bogus}; do ngctl shutdown ${iface}: done } fec_up() { for i in ${fec_interfaces}; do ng_fec_create $i for j in `get_if_var $i fecconfig_IF`; do case ${j} in '') continue ;; *) ngctl msg ${i}: add_iface "\"${j}\"" ;; esac done done } # # ipx_up ifn # Configure any IPX addresses for interface $ifn. Returns 0 if IPX # arguments were found and configured; returns 1 otherwise. # ipx_up() { ifn="$1" ifconfig_args=`get_if_var $ifn ifconfig_IF_ipx` if [ -n "${ifconfig_args}" ]; then ifconfig ${ifn} ${ifconfig_args} return 0 fi return 1 } # ipx_down ifn # Remove IPX addresses for interface $ifn. Returns 0 if IPX # addresses were found and unconfigured. It returns 1, otherwise. # ipx_down() { [ -z "$1" ] && return 1 _ifs="^" _ret=1 ifexists $1 || return 1 ipxList="`ifconfig $1 | grep 'ipx ' | tr "\n" "$_ifs"`" oldifs="$IFS" IFS="$_ifs" for _ipx in $ipxList ; do # get rid of extraneous line [ -z "$_ipx" ] && break _ipx=`expr "$_ipx" : '.*\(ipx [0-9a-h]\{1,8\}H*\.[0-9a-h]\{1,12\}\).*'` IFS="$oldifs" ifconfig $1 ${_ipx} delete IFS="$_ifs" _ret=0 done IFS="$oldifs" return $_ret } # ifnet_rename # Rename all requested interfaces. # ifnet_rename() { _ifn_list="`ifconfig -l`" [ -z "$_ifn_list" ] && return 0 for _if in ${_ifn_list} ; do _ifname=`get_if_var $_if ifconfig_IF_name` if [ ! -z "$_ifname" ]; then ifconfig $_if name $_ifname fi done return 0 } # # list_net_interfaces type # List all network interfaces. The type of interface returned # can be controlled by the type argument. The type # argument can be any of the following: # nodhcp - all interfaces, excluding DHCP configured interfaces # dhcp - list only DHCP configured interfaces # If no argument is specified all network interfaces are output. # Note that the list will include cloned interfaces if applicable. # Cloned interfaces must already exist to have a chance to appear # in the list if ${network_interfaces} is set to `auto'. # list_net_interfaces() { type=$1 # Get a list of ALL the interfaces and make lo0 first if it's there. # case ${network_interfaces} in [Aa][Uu][Tt][Oo]) _prefix='' _autolist="`ifconfig -l`" _lo= for _if in ${_autolist} ; do if autoif $_if; then if [ "$_if" = "lo0" ]; then _lo="lo0 " else _tmplist="${_tmplist}${_prefix}${_if}" [ -z "$_prefix" ] && _prefix=' ' fi fi done _tmplist="${_lo}${_tmplist}" ;; *) _tmplist="${network_interfaces} ${cloned_interfaces}" ;; esac if [ -z "$type" ]; then echo $_tmplist return 0 fi # Separate out dhcp and non-dhcp interfaces # _aprefix= _bprefix= for _if in ${_tmplist} ; do if dhcpif $_if; then _dhcplist="${_dhcplist}${_aprefix}${_if}" [ -z "$_aprefix" ] && _aprefix=' ' elif [ -n "`_ifconfig_getargs $_if`" ]; then _nodhcplist="${_nodhcplist}${_bprefix}${_if}" [ -z "$_bprefix" ] && _bprefix=' ' fi done case "$type" in nodhcp) echo $_nodhcplist ;; dhcp) echo $_dhcplist ;; esac return 0 } hexdigit() { if [ $1 -lt 10 ]; then echo $1 else case $1 in 10) echo a ;; 11) echo b ;; 12) echo c ;; 13) echo d ;; 14) echo e ;; 15) echo f ;; esac fi } hexprint() { val=$1 str='' dig=`hexdigit $((${val} & 15))` str=${dig}${str} val=$((${val} >> 4)) while [ ${val} -gt 0 ]; do dig=`hexdigit $((${val} & 15))` str=${dig}${str} val=$((${val} >> 4)) done echo ${str} } # Setup the interfaces for IPv6 network6_interface_setup() { interfaces=$* rtsol_interfaces='' case ${ipv6_gateway_enable} in [Yy][Ee][Ss]) rtsol_available=no ;; *) rtsol_available=yes ;; esac for i in $interfaces; do rtsol_interface=yes prefix=`get_if_var $i ipv6_prefix_IF` if [ -n "${prefix}" ]; then rtsol_available=no rtsol_interface=no laddr=`network6_getladdr $i` hostid=`expr "${laddr}" : 'fe80::\(.*\)%\(.*\)'` for j in ${prefix}; do address=$j\:${hostid} ifconfig $i inet6 ${address} prefixlen 64 alias case ${ipv6_gateway_enable} in [Yy][Ee][Ss]) # subnet-router anycast address # (rfc2373) ifconfig $i inet6 $j:: prefixlen 64 \ alias anycast ;; esac done fi ipv6_ifconfig=`get_if_var $i ipv6_ifconfig_IF` if [ -n "${ipv6_ifconfig}" ]; then rtsol_available=no rtsol_interface=no ifconfig $i inet6 ${ipv6_ifconfig} alias fi if [ ${rtsol_available} = yes -a ${rtsol_interface} = yes ] then case ${i} in lo0|gif[0-9]*|stf[0-9]*|faith[0-9]*|lp[0-9]*|sl[0-9]*|tun[0-9]*|pflog[0-9]*|pfsync[0-9]*) ;; *) rtsol_interfaces="${rtsol_interfaces} ${i}" ;; esac else ifconfig $i inet6 fi done if [ ${rtsol_available} = yes -a -n "${rtsol_interfaces}" ]; then # Act as endhost - automatically configured. # You can configure only single interface, as # specification assumes that autoconfigured host has # single interface only. sysctl net.inet6.ip6.accept_rtadv=1 set ${rtsol_interfaces} ifconfig $1 up rtsol ${rtsol_flags} $1 fi for i in $interfaces; do alias=0 while : ; do ipv6_ifconfig=`get_if_var $i ipv6_ifconfig_IF_alias${alias}` if [ -z "${ipv6_ifconfig}" ]; then break; fi ifconfig $i inet6 ${ipv6_ifconfig} alias alias=$((${alias} + 1)) done done } # Setup IPv6 to IPv4 mapping network6_stf_setup() { case ${stf_interface_ipv4addr} in [Nn][Oo] | '') ;; *) # assign IPv6 addr and interface route for 6to4 interface stf_prefixlen=$((16+${stf_interface_ipv4plen:-0})) OIFS="$IFS" IFS=".$IFS" set ${stf_interface_ipv4addr} IFS="$OIFS" hexfrag1=`hexprint $(($1*256 + $2))` hexfrag2=`hexprint $(($3*256 + $4))` ipv4_in_hexformat="${hexfrag1}:${hexfrag2}" case ${stf_interface_ipv6_ifid} in [Aa][Uu][Tt][Oo] | '') for i in ${ipv6_network_interfaces}; do laddr=`network6_getladdr ${i}` case ${laddr} in '') ;; *) break ;; esac done stf_interface_ipv6_ifid=`expr "${laddr}" : \ 'fe80::\(.*\)%\(.*\)'` case ${stf_interface_ipv6_ifid} in '') stf_interface_ipv6_ifid=0:0:0:1 ;; esac ;; esac ifconfig stf0 create >/dev/null 2>&1 ifconfig stf0 inet6 2002:${ipv4_in_hexformat}:${stf_interface_ipv6_slaid:-0}:${stf_interface_ipv6_ifid} \ prefixlen ${stf_prefixlen} # disallow packets to malicious 6to4 prefix route add -inet6 2002:e000:: -prefixlen 20 ::1 -reject route add -inet6 2002:7f00:: -prefixlen 24 ::1 -reject route add -inet6 2002:0000:: -prefixlen 24 ::1 -reject route add -inet6 2002:ff00:: -prefixlen 24 ::1 -reject ;; esac } # Setup static routes network6_static_routes_setup() { # Set up any static routes. case ${ipv6_defaultrouter} in [Nn][Oo] | '') ;; *) ipv6_static_routes="default ${ipv6_static_routes}" ipv6_route_default="default ${ipv6_defaultrouter}" ;; esac case ${ipv6_static_routes} in [Nn][Oo] | '') ;; *) for i in ${ipv6_static_routes}; do ipv6_route_args=`get_if_var $i ipv6_route_IF` route add -inet6 ${ipv6_route_args} done ;; esac } # Setup faith network6_faith_setup() { case ${ipv6_faith_prefix} in [Nn][Oo] | '') ;; *) sysctl net.inet6.ip6.keepfaith=1 ifconfig faith0 create >/dev/null 2>&1 ifconfig faith0 up for prefix in ${ipv6_faith_prefix}; do prefixlen=`expr "${prefix}" : ".*/\(.*\)"` case ${prefixlen} in '') prefixlen=96 ;; *) prefix=`expr "${prefix}" : \ "\(.*\)/${prefixlen}"` ;; esac route add -inet6 ${prefix} -prefixlen ${prefixlen} ::1 route change -inet6 ${prefix} -prefixlen ${prefixlen} \ -ifp faith0 done ;; esac } # Install the "default interface" to kernel, which will be used # as the default route when there's no router. network6_default_interface_setup() { # Choose IPv6 default interface if it is not clearly specified. case ${ipv6_default_interface} in '') for i in ${ipv6_network_interfaces}; do case $i in lo0|faith[0-9]*) continue ;; esac laddr=`network6_getladdr $i exclude_tentative` case ${laddr} in '') ;; *) ipv6_default_interface=$i break ;; esac done ;; esac # Disallow unicast packets without outgoing scope identifiers, # or route such packets to a "default" interface, if it is specified. route add -inet6 fe80:: -prefixlen 10 ::1 -reject case ${ipv6_default_interface} in [Nn][Oo] | '') route add -inet6 ff02:: -prefixlen 16 ::1 -reject ;; *) laddr=`network6_getladdr ${ipv6_default_interface}` route add -inet6 ff02:: ${laddr} -prefixlen 16 -interface \ -cloning # Disable installing the default interface with the # case net.inet6.ip6.forwarding=0 and # net.inet6.ip6.accept_rtadv=0, due to avoid conflict # between the default router list and the manual # configured default route. case ${ipv6_gateway_enable} in [Yy][Ee][Ss]) ;; *) if [ `sysctl -n net.inet6.ip6.accept_rtadv` -eq 1 ] then ndp -I ${ipv6_default_interface} fi ;; esac ;; esac } network6_getladdr() { ifconfig $1 2>/dev/null | while read proto addr rest; do case ${proto} in inet6) case ${addr} in fe80::*) if [ -z "$2" ]; then echo ${addr} return fi case ${rest} in *tentative*) continue ;; *) echo ${addr} return esac esac esac done } Index: head/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c =================================================================== --- head/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c (revision 173354) +++ head/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c (revision 173355) @@ -1,793 +1,802 @@ /* * WPA Supplicant - driver interaction with BSD net80211 layer * Copyright (c) 2004, Sam Leffler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Alternatively, this software may be distributed under the terms of BSD * license. * * See README and COPYING for more details. * * $FreeBSD$ */ #include #include #include #include #include #include #include "common.h" #include "driver.h" #include "eloop.h" #include "wpa_supplicant.h" #include "l2_packet.h" #include "wpa.h" /* XXX for RSN_INFO_ELEM */ #include #include #include #include #include #include struct wpa_driver_bsd_data { int sock; /* open socket for 802.11 ioctls */ int route; /* routing socket for events */ char ifname[IFNAMSIZ+1]; /* interface name */ unsigned int ifindex; /* interface index */ void *ctx; int prev_roaming; /* roaming state to restore on deinit */ int prev_privacy; /* privacy state to restore on deinit */ int prev_wpa; /* wpa state to restore on deinit */ }; static int set80211var(struct wpa_driver_bsd_data *drv, int op, const void *arg, int arg_len) { struct ieee80211req ireq; memset(&ireq, 0, sizeof(ireq)); strncpy(ireq.i_name, drv->ifname, IFNAMSIZ); ireq.i_type = op; ireq.i_len = arg_len; ireq.i_data = (void *) arg; if (ioctl(drv->sock, SIOCS80211, &ireq) < 0) { fprintf(stderr, "ioctl[SIOCS80211, op %u, len %u]: %s\n", op, arg_len, strerror(errno)); return -1; } return 0; } static int get80211var(struct wpa_driver_bsd_data *drv, int op, void *arg, int arg_len) { struct ieee80211req ireq; memset(&ireq, 0, sizeof(ireq)); strncpy(ireq.i_name, drv->ifname, IFNAMSIZ); ireq.i_type = op; ireq.i_len = arg_len; ireq.i_data = arg; if (ioctl(drv->sock, SIOCG80211, &ireq) < 0) { fprintf(stderr, "ioctl[SIOCG80211, op %u, len %u]: %s\n", op, arg_len, strerror(errno)); return -1; } return ireq.i_len; } static int set80211param(struct wpa_driver_bsd_data *drv, int op, int arg) { struct ieee80211req ireq; memset(&ireq, 0, sizeof(ireq)); strncpy(ireq.i_name, drv->ifname, IFNAMSIZ); ireq.i_type = op; ireq.i_val = arg; if (ioctl(drv->sock, SIOCS80211, &ireq) < 0) { fprintf(stderr, "ioctl[SIOCS80211, op %u, arg 0x%x]: %s\n", op, arg, strerror(errno)); return -1; } return 0; } static int get80211param(struct wpa_driver_bsd_data *drv, int op) { struct ieee80211req ireq; memset(&ireq, 0, sizeof(ireq)); strncpy(ireq.i_name, drv->ifname, IFNAMSIZ); ireq.i_type = op; if (ioctl(drv->sock, SIOCG80211, &ireq) < 0) { fprintf(stderr, "ioctl[SIOCG80211, op %u]: %s\n", op, strerror(errno)); return -1; } return ireq.i_val; } static int getifflags(struct wpa_driver_bsd_data *drv, int *flags) { struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, drv->ifname, sizeof (ifr.ifr_name)); if (ioctl(drv->sock, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) { perror("SIOCGIFFLAGS"); return errno; } *flags = ifr.ifr_flags & 0xffff; return 0; } static int setifflags(struct wpa_driver_bsd_data *drv, int flags) { struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, drv->ifname, sizeof (ifr.ifr_name)); ifr.ifr_flags = flags & 0xffff; if (ioctl(drv->sock, SIOCSIFFLAGS, (caddr_t)&ifr) < 0) { perror("SIOCSIFFLAGS"); return errno; } return 0; } static int wpa_driver_bsd_get_bssid(void *priv, u8 *bssid) { struct wpa_driver_bsd_data *drv = priv; return get80211var(drv, IEEE80211_IOC_BSSID, bssid, IEEE80211_ADDR_LEN) < 0 ? -1 : 0; } #if 0 static int wpa_driver_bsd_set_bssid(void *priv, const char *bssid) { struct wpa_driver_bsd_data *drv = priv; return set80211var(drv, IEEE80211_IOC_BSSID, bssid, IEEE80211_ADDR_LEN); } #endif static int wpa_driver_bsd_get_ssid(void *priv, u8 *ssid) { struct wpa_driver_bsd_data *drv = priv; return get80211var(drv, IEEE80211_IOC_SSID, ssid, IEEE80211_NWID_LEN); } static int wpa_driver_bsd_set_ssid(void *priv, const char *ssid, size_t ssid_len) { struct wpa_driver_bsd_data *drv = priv; return set80211var(drv, IEEE80211_IOC_SSID, ssid, ssid_len); } static int wpa_driver_bsd_set_wpa_ie(struct wpa_driver_bsd_data *drv, const char *wpa_ie, size_t wpa_ie_len) { return set80211var(drv, IEEE80211_IOC_OPTIE, wpa_ie, wpa_ie_len); } static int wpa_driver_bsd_set_wpa_internal(void *priv, int wpa, int privacy) { struct wpa_driver_bsd_data *drv = priv; int ret = 0; wpa_printf(MSG_DEBUG, "%s: wpa=%d privacy=%d", __FUNCTION__, wpa, privacy); if (!wpa && wpa_driver_bsd_set_wpa_ie(drv, NULL, 0) < 0) ret = -1; if (set80211param(drv, IEEE80211_IOC_PRIVACY, privacy) < 0) ret = -1; if (set80211param(drv, IEEE80211_IOC_WPA, wpa) < 0) ret = -1; return ret; } static int wpa_driver_bsd_set_wpa(void *priv, int enabled) { wpa_printf(MSG_DEBUG, "%s: enabled=%d", __FUNCTION__, enabled); return wpa_driver_bsd_set_wpa_internal(priv, enabled ? 3 : 0, enabled); } static int wpa_driver_bsd_del_key(struct wpa_driver_bsd_data *drv, int key_idx, const unsigned char *addr) { struct ieee80211req_del_key wk; memset(&wk, 0, sizeof(wk)); if (addr != NULL && bcmp(addr, "\xff\xff\xff\xff\xff\xff", IEEE80211_ADDR_LEN) != 0) { struct ether_addr ea; memcpy(&ea, addr, IEEE80211_ADDR_LEN); wpa_printf(MSG_DEBUG, "%s: addr=%s keyidx=%d", __func__, ether_ntoa(&ea), key_idx); memcpy(wk.idk_macaddr, addr, IEEE80211_ADDR_LEN); wk.idk_keyix = (uint8_t) IEEE80211_KEYIX_NONE; } else { wpa_printf(MSG_DEBUG, "%s: keyidx=%d", __func__, key_idx); wk.idk_keyix = key_idx; } return set80211var(drv, IEEE80211_IOC_DELKEY, &wk, sizeof(wk)); } static int wpa_driver_bsd_set_key(void *priv, wpa_alg alg, const unsigned char *addr, int key_idx, int set_tx, const u8 *seq, size_t seq_len, const u8 *key, size_t key_len) { struct wpa_driver_bsd_data *drv = priv; struct ieee80211req_key wk; struct ether_addr ea; char *alg_name; u_int8_t cipher; if (alg == WPA_ALG_NONE) return wpa_driver_bsd_del_key(drv, key_idx, addr); switch (alg) { case WPA_ALG_WEP: alg_name = "WEP"; cipher = IEEE80211_CIPHER_WEP; break; case WPA_ALG_TKIP: alg_name = "TKIP"; cipher = IEEE80211_CIPHER_TKIP; break; case WPA_ALG_CCMP: alg_name = "CCMP"; cipher = IEEE80211_CIPHER_AES_CCM; break; default: wpa_printf(MSG_DEBUG, "%s: unknown/unsupported algorithm %d", __func__, alg); return -1; } memcpy(&ea, addr, IEEE80211_ADDR_LEN); wpa_printf(MSG_DEBUG, "%s: alg=%s addr=%s key_idx=%d set_tx=%d seq_len=%zu key_len=%zu", __func__, alg_name, ether_ntoa(&ea), key_idx, set_tx, seq_len, key_len); if (seq_len > sizeof(u_int64_t)) { wpa_printf(MSG_DEBUG, "%s: seq_len %zu too big", __func__, seq_len); return -2; } if (key_len > sizeof(wk.ik_keydata)) { wpa_printf(MSG_DEBUG, "%s: key length %zu too big", __func__, key_len); return -3; } memset(&wk, 0, sizeof(wk)); wk.ik_type = cipher; wk.ik_flags = IEEE80211_KEY_RECV; if (set_tx) wk.ik_flags |= IEEE80211_KEY_XMIT; memcpy(wk.ik_macaddr, addr, IEEE80211_ADDR_LEN); /* * Deduce whether group/global or unicast key by checking * the address (yech). Note also that we can only mark global * keys default; doing this for a unicast key is an error. */ if (bcmp(addr, "\xff\xff\xff\xff\xff\xff", IEEE80211_ADDR_LEN) == 0) { wk.ik_flags |= IEEE80211_KEY_GROUP; wk.ik_keyix = key_idx; } else { wk.ik_keyix = (key_idx == 0 ? IEEE80211_KEYIX_NONE : key_idx); } if (wk.ik_keyix != IEEE80211_KEYIX_NONE && set_tx) wk.ik_flags |= IEEE80211_KEY_DEFAULT; wk.ik_keylen = key_len; memcpy(&wk.ik_keyrsc, seq, seq_len); wk.ik_keyrsc = le64toh(wk.ik_keyrsc); memcpy(wk.ik_keydata, key, key_len); return set80211var(drv, IEEE80211_IOC_WPAKEY, &wk, sizeof(wk)); } static int wpa_driver_bsd_set_countermeasures(void *priv, int enabled) { struct wpa_driver_bsd_data *drv = priv; wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, enabled); return set80211param(drv, IEEE80211_IOC_COUNTERMEASURES, enabled); } static int wpa_driver_bsd_set_drop_unencrypted(void *priv, int enabled) { struct wpa_driver_bsd_data *drv = priv; wpa_printf(MSG_DEBUG, "%s: enabled=%d", __func__, enabled); return set80211param(drv, IEEE80211_IOC_DROPUNENCRYPTED, enabled); } static int wpa_driver_bsd_deauthenticate(void *priv, const u8 *addr, int reason_code) { struct wpa_driver_bsd_data *drv = priv; struct ieee80211req_mlme mlme; wpa_printf(MSG_DEBUG, "%s", __func__); memset(&mlme, 0, sizeof(mlme)); mlme.im_op = IEEE80211_MLME_DEAUTH; mlme.im_reason = reason_code; memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN); return set80211var(drv, IEEE80211_IOC_MLME, &mlme, sizeof(mlme)); } static int wpa_driver_bsd_disassociate(void *priv, const u8 *addr, int reason_code) { struct wpa_driver_bsd_data *drv = priv; struct ieee80211req_mlme mlme; wpa_printf(MSG_DEBUG, "%s", __func__); memset(&mlme, 0, sizeof(mlme)); mlme.im_op = IEEE80211_MLME_DISASSOC; mlme.im_reason = reason_code; memcpy(mlme.im_macaddr, addr, IEEE80211_ADDR_LEN); return set80211var(drv, IEEE80211_IOC_MLME, &mlme, sizeof(mlme)); } static int wpa_driver_bsd_associate(void *priv, struct wpa_driver_associate_params *params) { struct wpa_driver_bsd_data *drv = priv; struct ieee80211req_mlme mlme; int privacy; wpa_printf(MSG_DEBUG, "%s: ssid '%.*s' wpa ie len %u pairwise %u group %u key mgmt %u" , __func__ , params->ssid_len, params->ssid , params->wpa_ie_len , params->pairwise_suite , params->group_suite , params->key_mgmt_suite ); /* XXX error handling is wrong but unclear what to do... */ if (wpa_driver_bsd_set_wpa_ie(drv, params->wpa_ie, params->wpa_ie_len) < 0) return -1; privacy = !(params->pairwise_suite == CIPHER_NONE && params->group_suite == CIPHER_NONE && params->key_mgmt_suite == KEY_MGMT_NONE && params->wpa_ie_len == 0); wpa_printf(MSG_DEBUG, "%s: set PRIVACY %u", __func__, privacy); if (set80211param(drv, IEEE80211_IOC_PRIVACY, privacy) < 0) return -1; if (params->wpa_ie_len && set80211param(drv, IEEE80211_IOC_WPA, params->wpa_ie[0] == RSN_INFO_ELEM ? 2 : 1) < 0) return -1; memset(&mlme, 0, sizeof(mlme)); mlme.im_op = IEEE80211_MLME_ASSOC; if (params->ssid != NULL) memcpy(mlme.im_ssid, params->ssid, params->ssid_len); mlme.im_ssid_len = params->ssid_len; if (params->bssid != NULL) memcpy(mlme.im_macaddr, params->bssid, IEEE80211_ADDR_LEN); if (set80211var(drv, IEEE80211_IOC_MLME, &mlme, sizeof(mlme)) < 0) return -1; return 0; } static int wpa_driver_bsd_set_auth_alg(void *priv, int auth_alg) { struct wpa_driver_bsd_data *drv = priv; int authmode; if ((auth_alg & AUTH_ALG_OPEN_SYSTEM) && (auth_alg & AUTH_ALG_SHARED_KEY)) authmode = IEEE80211_AUTH_AUTO; else if (auth_alg & AUTH_ALG_SHARED_KEY) authmode = IEEE80211_AUTH_SHARED; else authmode = IEEE80211_AUTH_OPEN; wpa_printf(MSG_DEBUG, "%s alg 0x%x authmode %u", __func__, auth_alg, authmode); return set80211param(drv, IEEE80211_IOC_AUTHMODE, authmode); } static int wpa_driver_bsd_scan(void *priv, const u8 *ssid, size_t ssid_len) { struct wpa_driver_bsd_data *drv = priv; int flags; /* NB: interface must be marked UP to do a scan */ if (getifflags(drv, &flags) != 0 || setifflags(drv, flags | IFF_UP) != 0) return -1; /* set desired ssid before scan */ if (wpa_driver_bsd_set_ssid(drv, ssid, ssid_len) < 0) return -1; /* NB: net80211 delivers a scan complete event so no need to poll */ return set80211param(drv, IEEE80211_IOC_SCAN_REQ, 0); } #include #include static void wpa_driver_bsd_event_receive(int sock, void *ctx, void *sock_ctx) { struct wpa_driver_bsd_data *drv = sock_ctx; char buf[2048]; struct if_announcemsghdr *ifan; struct if_msghdr *ifm; struct rt_msghdr *rtm; union wpa_event_data event; struct ieee80211_michael_event *mic; int n; n = read(sock, buf, sizeof(buf)); if (n < 0) { if (errno != EINTR && errno != EAGAIN) perror("read(PF_ROUTE)"); return; } rtm = (struct rt_msghdr *) buf; if (rtm->rtm_version != RTM_VERSION) { wpa_printf(MSG_DEBUG, "Routing message version %d not " "understood\n", rtm->rtm_version); return; } memset(&event, 0, sizeof(event)); switch (rtm->rtm_type) { case RTM_IFANNOUNCE: ifan = (struct if_announcemsghdr *) rtm; if (ifan->ifan_index != drv->ifindex) break; strlcpy(event.interface_status.ifname, drv->ifname, sizeof(event.interface_status.ifname)); switch (ifan->ifan_what) { case IFAN_DEPARTURE: event.interface_status.ievent = EVENT_INTERFACE_REMOVED; default: return; } wpa_printf(MSG_DEBUG, "RTM_IFANNOUNCE: Interface '%s' %s", event.interface_status.ifname, ifan->ifan_what == IFAN_DEPARTURE ? "removed" : "added"); wpa_supplicant_event(ctx, EVENT_INTERFACE_STATUS, &event); break; case RTM_IEEE80211: ifan = (struct if_announcemsghdr *) rtm; if (ifan->ifan_index != drv->ifindex) break; switch (ifan->ifan_what) { case RTM_IEEE80211_ASSOC: case RTM_IEEE80211_REASSOC: wpa_supplicant_event(ctx, EVENT_ASSOC, NULL); break; case RTM_IEEE80211_DISASSOC: wpa_supplicant_event(ctx, EVENT_DISASSOC, NULL); break; case RTM_IEEE80211_SCAN: wpa_supplicant_event(ctx, EVENT_SCAN_RESULTS, NULL); break; case RTM_IEEE80211_REPLAY: /* ignore */ break; case RTM_IEEE80211_MICHAEL: mic = (struct ieee80211_michael_event *) &ifan[1]; wpa_printf(MSG_DEBUG, "Michael MIC failure wireless event: " "keyix=%u src_addr=" MACSTR, mic->iev_keyix, MAC2STR(mic->iev_src)); memset(&event, 0, sizeof(event)); event.michael_mic_failure.unicast = !IEEE80211_IS_MULTICAST(mic->iev_dst); wpa_supplicant_event(ctx, EVENT_MICHAEL_MIC_FAILURE, &event); break; } break; case RTM_IFINFO: ifm = (struct if_msghdr *) rtm; if (ifm->ifm_index != drv->ifindex) break; if ((rtm->rtm_flags & RTF_UP) == 0) { strlcpy(event.interface_status.ifname, drv->ifname, sizeof(event.interface_status.ifname)); event.interface_status.ievent = EVENT_INTERFACE_REMOVED; wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' DOWN", event.interface_status.ifname); wpa_supplicant_event(ctx, EVENT_INTERFACE_STATUS, &event); } break; } } /* Compare function for sorting scan results. Return >0 if @b is consider * better. */ static int wpa_scan_result_compar(const void *a, const void *b) { const struct wpa_scan_result *wa = a; const struct wpa_scan_result *wb = b; /* WPA/WPA2 support preferred */ if ((wb->wpa_ie_len || wb->rsn_ie_len) && !(wa->wpa_ie_len || wa->rsn_ie_len)) return 1; if (!(wb->wpa_ie_len || wb->rsn_ie_len) && (wa->wpa_ie_len || wa->rsn_ie_len)) return -1; /* privacy support preferred */ if ((wa->caps & IEEE80211_CAPINFO_PRIVACY) && (wb->caps & IEEE80211_CAPINFO_PRIVACY) == 0) return 1; if ((wa->caps & IEEE80211_CAPINFO_PRIVACY) == 0 && (wb->caps & IEEE80211_CAPINFO_PRIVACY)) return -1; /* best/max rate preferred if signal level close enough XXX */ if (wa->maxrate != wb->maxrate && abs(wb->level - wa->level) < 5) return wb->maxrate - wa->maxrate; /* use freq for channel preference */ /* all things being equal, use signal level */ return wb->level - wa->level; } static int getmaxrate(const uint8_t rates[15], uint8_t nrates) { int i, maxrate = -1; for (i = 0; i < nrates; i++) { int rate = rates[i] & IEEE80211_RATE_VAL; if (rate > maxrate) rate = maxrate; } return maxrate; } /* unalligned little endian access */ #define LE_READ_4(p) \ ((u_int32_t) \ ((((const u_int8_t *)(p))[0] ) | \ (((const u_int8_t *)(p))[1] << 8) | \ (((const u_int8_t *)(p))[2] << 16) | \ (((const u_int8_t *)(p))[3] << 24))) static int __inline iswpaoui(const u_int8_t *frm) { return frm[1] > 3 && LE_READ_4(frm+2) == ((WPA_OUI_TYPE<<24)|WPA_OUI); } static int wpa_driver_bsd_get_scan_results(void *priv, struct wpa_scan_result *results, size_t max_size) { #define min(a,b) ((a)>(b)?(b):(a)) struct wpa_driver_bsd_data *drv = priv; uint8_t buf[24*1024]; const uint8_t *cp, *vp; const struct ieee80211req_scan_result *sr; struct wpa_scan_result *wsr; int len, ielen; memset(results, 0, max_size * sizeof(struct wpa_scan_result)); len = get80211var(drv, IEEE80211_IOC_SCAN_RESULTS, buf, sizeof(buf)); if (len < 0) return -1; cp = buf; wsr = results; while (len >= sizeof(struct ieee80211req_scan_result)) { sr = (const struct ieee80211req_scan_result *) cp; memcpy(wsr->bssid, sr->isr_bssid, IEEE80211_ADDR_LEN); wsr->ssid_len = sr->isr_ssid_len; wsr->freq = sr->isr_freq; wsr->noise = sr->isr_noise; wsr->qual = sr->isr_rssi; wsr->level = 0; /* XXX? */ wsr->caps = sr->isr_capinfo; wsr->maxrate = getmaxrate(sr->isr_rates, sr->isr_nrates); vp = ((u_int8_t *)sr) + sr->isr_ie_off; memcpy(wsr->ssid, vp, sr->isr_ssid_len); if (sr->isr_ie_len > 0) { vp += sr->isr_ssid_len; ielen = sr->isr_ie_len; while (ielen > 0) { switch (vp[0]) { case IEEE80211_ELEMID_VENDOR: if (!iswpaoui(vp)) break; wsr->wpa_ie_len = min(2+vp[1], SSID_MAX_WPA_IE_LEN); memcpy(wsr->wpa_ie, vp, wsr->wpa_ie_len); break; case IEEE80211_ELEMID_RSN: wsr->rsn_ie_len = min(2+vp[1], SSID_MAX_WPA_IE_LEN); memcpy(wsr->rsn_ie, vp, wsr->rsn_ie_len); break; } ielen -= 2+vp[1]; vp += 2+vp[1]; } } cp += sr->isr_len, len -= sr->isr_len; wsr++; } qsort(results, wsr - results, sizeof(struct wpa_scan_result), wpa_scan_result_compar); wpa_printf(MSG_DEBUG, "Received %d bytes of scan results (%d BSSes)", len, wsr - results); return wsr - results; #undef min } static void * wpa_driver_bsd_init(void *ctx, const char *ifname) { #define GETPARAM(drv, param, v) \ (((v) = get80211param(drv, param)) != -1) struct wpa_driver_bsd_data *drv; + int flags; drv = malloc(sizeof(*drv)); if (drv == NULL) return NULL; memset(drv, 0, sizeof(*drv)); /* * NB: We require the interface name be mappable to an index. * This implies we do not support having wpa_supplicant * wait for an interface to appear. This seems ok; that * doesn't belong here; it's really the job of devd. */ drv->ifindex = if_nametoindex(ifname); if (drv->ifindex == 0) { wpa_printf(MSG_DEBUG, "%s: interface %s does not exist", __func__, ifname); goto fail1; } drv->sock = socket(PF_INET, SOCK_DGRAM, 0); if (drv->sock < 0) goto fail1; + drv->ctx = ctx; + strncpy(drv->ifname, ifname, sizeof(drv->ifname)); + + /* + * Mark the interface as down to ensure wpa_supplicant has exclusive + * access to the net80211 state machine, do this before opening the + * route socket to avoid a false event that the interface disappeared. + */ + if (getifflags(drv, &flags) == 0) + (void) setifflags(drv, flags &~ IFF_UP); + drv->route = socket(PF_ROUTE, SOCK_RAW, 0); if (drv->route < 0) goto fail; eloop_register_read_sock(drv->route, wpa_driver_bsd_event_receive, ctx, drv); - - drv->ctx = ctx; - strncpy(drv->ifname, ifname, sizeof(drv->ifname)); if (!GETPARAM(drv, IEEE80211_IOC_ROAMING, drv->prev_roaming)) { wpa_printf(MSG_DEBUG, "%s: failed to get roaming state: %s", __func__, strerror(errno)); goto fail; } if (!GETPARAM(drv, IEEE80211_IOC_PRIVACY, drv->prev_privacy)) { wpa_printf(MSG_DEBUG, "%s: failed to get privacy state: %s", __func__, strerror(errno)); goto fail; } if (!GETPARAM(drv, IEEE80211_IOC_WPA, drv->prev_wpa)) { wpa_printf(MSG_DEBUG, "%s: failed to get wpa state: %s", __func__, strerror(errno)); goto fail; } if (set80211param(drv, IEEE80211_IOC_ROAMING, IEEE80211_ROAMING_MANUAL) < 0) { wpa_printf(MSG_DEBUG, "%s: failed to set wpa_supplicant-based " "roaming: %s", __func__, strerror(errno)); goto fail; } if (set80211param(drv, IEEE80211_IOC_WPA, 1+2) < 0) { wpa_printf(MSG_DEBUG, "%s: failed to enable WPA support %s", __func__, strerror(errno)); goto fail; } return drv; fail: close(drv->sock); fail1: free(drv); return NULL; #undef GETPARAM } static void wpa_driver_bsd_deinit(void *priv) { struct wpa_driver_bsd_data *drv = priv; int flags; /* NB: mark interface down */ if (getifflags(drv, &flags) == 0) (void) setifflags(drv, flags &~ IFF_UP); wpa_driver_bsd_set_wpa_internal(drv, drv->prev_wpa, drv->prev_privacy); if (set80211param(drv, IEEE80211_IOC_ROAMING, drv->prev_roaming) < 0) wpa_printf(MSG_DEBUG, "%s: failed to restore roaming state", __func__); (void) close(drv->route); /* ioctl socket */ (void) close(drv->sock); /* event socket */ free(drv); } struct wpa_driver_ops wpa_driver_bsd_ops = { .name = "bsd", .desc = "BSD 802.11 support (Atheros, etc.)", .init = wpa_driver_bsd_init, .deinit = wpa_driver_bsd_deinit, .get_bssid = wpa_driver_bsd_get_bssid, .get_ssid = wpa_driver_bsd_get_ssid, .set_wpa = wpa_driver_bsd_set_wpa, .set_key = wpa_driver_bsd_set_key, .set_countermeasures = wpa_driver_bsd_set_countermeasures, .set_drop_unencrypted = wpa_driver_bsd_set_drop_unencrypted, .scan = wpa_driver_bsd_scan, .get_scan_results = wpa_driver_bsd_get_scan_results, .deauthenticate = wpa_driver_bsd_deauthenticate, .disassociate = wpa_driver_bsd_disassociate, .associate = wpa_driver_bsd_associate, .set_auth_alg = wpa_driver_bsd_set_auth_alg, };