# Copyright (c) 2004-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header$ # Based on bridge script, which was # Contributed by Roy Marples (uberlord@gentoo.org) # Fix any potential localisation problems # Note that LC_ALL trumps LC_anything_else according to locale(7) madwifi() { LC_ALL=C /sbin/wlanconfig "$@" } # char* madwifi_provides(void) # # Returns a string to change module definition for starting up madwifi_provides() { echo "madwifi" } # void madwifi_depend(void) # # Sets up the dependancies for the module madwifi_depend() { after interface after wireless before dhcp } # bool madwifi_check_installed(void) # # Returns 1 if bridge is installed, otherwise 0 madwifi_check_installed() { [[ -x /sbin/wlanconfig ]] && return 0 ${1:-false} && eerror "For madwifi support, emerge net-wireless/madwifi-tools" return 1 } # bool madwifi_check_depends(void) # # Checks to see if we have the needed functions madwifi_check_depends() { local f for f in interface_variable interface_down interface_del_addresses interface_set_flag; do [[ $( type -t ${f} ) == function ]] && continue eerror "wlanconfig: missing required function ${f}\n" return 1 done return 0 } # char* madwifi_get_vars(char *interface) # # Returns a string spaced with possible user set # configuration variables madwifi_get_vars() { echo "madwifi_${1} wlanconfig_${1}" } # bool madwifi_start(char *iface) # # #set up bridge madwifi_pre_start() { local iface=${1} ports i e x ifvar=$( interface_variable ${1} ) local -a opts eval ports=\"\$\{madwifi_${ifvar}\[@\]\}\" [[ -z ${ports} ]] && return 0 ebegin "Creating madwifi virtual interfaces based on ${iface}" eindent for i in ${ports}; do ebegin "${i}" eval portmode=$( eval echo \$\{mode_${i}\} | tr '[:upper:]' '[:lower:]' ) portmode=${portmode:-managed} ## Ugly but works if [[ ${portmode} == "auto" || ${portmode} == "managed" ]] ; then portmode="sta" fi if [[ ${portmode} == "ad-hoc" ]] ; then portmode="adhoc" fi if [[ ${portmode} == "master" ]] ; then portmode="ap" fi einfo "Creating port ${i} in mode ${portmode}" e=$( wlanconfig ${i} create wlandev ${iface} wlanmode ${portmode} 2>&1 ) if [[ ${e} != ${i} ]]; then eend 1 "${e}" return 1 fi eend 0 done eoutdent return 0 } madwifi_stop() { local iface=${1} ports i e x ifvar=$( interface_variable ${1} ) local -a opts eval ports=\"\$\{madwifi_${ifvar}\[@\]\}\" [[ -z ${ports} ]] && return 0 ebegin "Destroying madwifi virtual interfaces based on ${iface}" for i in ${ports}; do ebegin "${i}" portmode="sta" eval portmode=\"\$\{mode_${i}\[@\]\}\" e=$( wlanconfig ${i} destroy 2>&1 ) if [[ -n ${e} ]]; then eend 1 "${e}" return 1 fi eend 0 done eoutdent eend 0 return 0 }