📄 shared
字号:
i=`expr $i + 1` done if [ -z "$bssfound" ]; then # No BSSs found, bail. return 1 else # Now find the closest bigsignal=0 for i in $bssfound ; do result=`$WLANCTL $1 dot11req_scan_results bssindex=$i` eval $result if [ $bigsignal -lt $signal ]; then bigsignal=$signal bigbssindex=$i fi done result=`$WLANCTL $1 dot11req_scan_results bssindex=$bigbssindex` eval $result return 0 fi}wlan_wep (){ # $1 == wlandev #=======WEP=========================================== # Setup privacy if [ ${dot11PrivacyInvoked:-"false"} = "false" ] ; then return 0; fi result=`$WLANCTL $1 dot11req_mibget mibattribute=dot11PrivacyOptionImplemented` if [ $? = 0 ] ; then eval $result eval $mibattribute else ${ECHO} "dot11PrivacyOptionImplemented mibget failed." return 1 fi if [ $dot11PrivacyOptionImplemented = "false" ] ; then ${ECHO} "Cannot enable privacy, dot11PrivacyOptionImplemented=false." return 1 fi # Do we want host-based WEP? result=`$WLANCTL $1 lnxreq_hostwep \ decrypt="${lnxreq_hostWEPDecrypt:-false}" \ encrypt="${lnxreq_hostWEPEncrypt:-false}"` # set up the rest of the parametsrs. if [ $dot11PrivacyOptionImplemented = "true" -a \ $dot11PrivacyInvoked = "true" ] ; then result=`$WLANCTL $1 dot11req_mibset \ mibattribute=dot11WEPDefaultKeyID=$dot11WEPDefaultKeyID ` result=`$WLANCTL $1 dot11req_mibset \ mibattribute=dot11ExcludeUnencrypted=$dot11ExcludeUnencrypted ` result=`$WLANCTL $1 dot11req_mibset \ mibattribute=dot11PrivacyInvoked=$dot11PrivacyInvoked` if [ "${PRIV_GENSTR:-empty}" != "empty" ] ; then if [ ${PRIV_KEY128:-"false"} = "false" ]; then keys=`$PRIV_GENERATOR "$PRIV_GENSTR" 5` else keys=`$PRIV_GENERATOR "$PRIV_GENSTR" 13` fi knum=0 for i in $keys ; do result=`$WLANCTL $1 dot11req_mibset \ mibattribute=dot11WEPDefaultKey$knum=$i` knum=`expr $knum + 1` done else result=`$WLANCTL $1 dot11req_mibset \ mibattribute=dot11WEPDefaultKey0=$dot11WEPDefaultKey0 ` result=`$WLANCTL $1 dot11req_mibset \ mibattribute=dot11WEPDefaultKey1=$dot11WEPDefaultKey1 ` result=`$WLANCTL $1 dot11req_mibset \ mibattribute=dot11WEPDefaultKey2=$dot11WEPDefaultKey2 ` result=`$WLANCTL $1 dot11req_mibset \ mibattribute=dot11WEPDefaultKey3=$dot11WEPDefaultKey3 ` fi else # disable wep explicitly. result=`$WLANCTL $1 dot11req_mibset \ mibattribute=dot11PrivacyInvoked=$dot11PrivacyInvoked ` result=`$WLANCTL $1 dot11req_mibset \ mibattribute=dot11ExcludeUnencrypted=false ` fi}wlan_adhoc (){ # $1 == wlandev #=======IBSS STARTUP================================== startcmd="$WLANCTL $1 dot11req_start " startcmd="$startcmd ssid=$DesiredSSID" startcmd="$startcmd bsstype=independent" startcmd="$startcmd beaconperiod=$BCNINT" startcmd="$startcmd dtimperiod=3" startcmd="$startcmd cfpollable=false" startcmd="$startcmd cfpollreq=false" startcmd="$startcmd cfpperiod=3" startcmd="$startcmd cfpmaxduration=100" startcmd="$startcmd probedelay=100" startcmd="$startcmd dschannel=$CHANNEL" j=1 for i in $BASICRATES ; do startcmd="$startcmd basicrate$j=$i" j=`expr $j + 1` done j=1 for i in $OPRATES ; do startcmd="$startcmd operationalrate$j=$i" j=`expr $j + 1` done results=`$startcmd` # Here's where it runs if [ $? = 0 ]; then eval $results if [ $resultcode != "success" ] ; then ${ECHO} "IBSS not started, resultcode=$resultcode" exit 1 else ${ECHO} "IBSS mode started." fi else ${ECHO} FAILED: $startcmd return 1 fi WLAN_SCHEMESSID="$DesiredSSID"}wlan_infra (){ # $1 == wlandev #==== INFRASTRUCURE STARTUP=========================== # XXX TODO: Grok DesiredBSSID sleep 5 results=`$WLANCTL $1 lnxreq_autojoin \ "ssid=$DesiredSSID" \ authtype=${AuthType:="opensystem"} | sed 's/\([^=]*\)=\(.*\)/\1="\2"/'` eval $results if [ ${resultcode:-"failure"} != "success" ] ; then ${ECHO} 'error: Autojoin indicated failure!' return 1; fi WLAN_SCHEMESSID="$DesiredSSID"}wlan_dot11_join (){ # $1 == wlandev joincmd="$WLANCTL $1 dot11req_join bssid=$DesiredBSSID" joincmd="$joincmd joinfailuretimeout=1" j=1 for i in $OPRATES ; do joincmd="$joincmd operationalrate$j=$i" j=`expr $j + 1` done results=`$joincmd` eval $results if [ ${resultcode:-"failure"} != "success" ] ; then ${ECHO} "$1: JOIN Failure" ${ECHO} "joincmd=$joincmd" ${ECHO} "results=$results" return 1; fi}wlan_dot11_auth_assoc (){ # $1 == wlandev if [ $bsstype = "infrastructure" ] ; then results=`$WLANCTL $1 dot11req_authenticate \ peerstaaddress=$DesiredBSSID \ authenticationtype=$AuthType \ authenticationfailuretimeout=2000` eval $results if [ ${resultcode:-"failure"} != "success" ] ; then ${ECHO} "error: dot11req_authenticate failed, "\ "resultcode=$resultcode" return 1; fi results=`$WLANCTL $1 dot11req_associate \ listeninterval=1000 \ associatefailuretimeout=2000 ` if [ ${resultcode:-"failure"} != "success" ] ; then ${ECHO} 'error: dot11req_associate failed!' return 1; fi fi}wlan_set_ssid_schemefile (){ # $1 == SSID # Find the scheme file if [ -r /var/lib/misc/pcmcia-scheme ] ; then # Debian WLAN_SCHEMEFILE="/var/lib/misc/pcmcia-scheme" elif [ -d /var/state/pcmcia ] ; then WLAN_SCHEMEFILE="/var/state/pcmcia/scheme" elif [ -d /var/lib/pcmcia ] ; then WLAN_SCHEMEFILE="/var/lib/pcmcia/scheme" else WLAN_SCHEMEFILE="/var/run/pcmcia-scheme" fi # Collect the current scheme name and save the file if [ -r $WLAN_SCHEMEFILE ] ; then WLAN_SCHEME=`cat $WLAN_SCHEMEFILE` cp $WLAN_SCHEMEFILE /var/run/wlan_scheme_`date +"%T"`.tmp else touch /var/run/wlan_scheme_`date +"%T"`.tmp fi # Set up the <scheme:SSID> string if [ ! "$WLAN_SCHEME" ] ; then WLAN_SCHEME="default" fi WLAN_SCHEME="$WLAN_SCHEME:$1" # Write to schemefile echo $WLAN_SCHEME > $WLAN_SCHEMEFILE}wlan_restore_schemefile (){ # Find the scheme file if [ -r /var/lib/misc/pcmcia-scheme ] ; then # Debian WLAN_SCHEMEFILE="/var/lib/misc/pcmcia-scheme" elif [ -d /var/state/pcmcia ] ; then WLAN_SCHEMEFILE="/var/state/pcmcia/scheme" elif [ -d /var/lib/pcmcia ] ; then WLAN_SCHEMEFILE="/var/lib/pcmcia/scheme" else WLAN_SCHEMEFILE="/var/run/pcmcia-scheme" fi TMPFILE=`ls /var/run/wlan_scheme*.tmp | tail -n 1` if [ -r $TMPFILE ] ; then cat $TMPFILE > $WLAN_SCHEMEFILE rm -f $TMPFILE else ${ECHO} "wlan_restore_schemefile: No wlan_scheme\*.tmp file found." fi}wlan_bring_it_up (){ # $1 == wlandev # $2 == non-null if wext enabled. #=======ENABLE======================================== # Do we want to init the card at all? eval 'WLAN_ENABLE=$ENABLE_'$1 if ! is_true $WLAN_ENABLE ; then return 1 fi if wlan_enable $1 ; then if [ -z "$2" ] ; then wlan_scan_and_join $1 return $? else ${ECHO} "Bypassing configuration due to wireless extensions" fi else return 1; fi return 1}wlan_scan_and_join (){ #=======MAC STARTUP========================================= wlan_supports_scan $1 if [ $? = 0 ] ; then wlan_scan $1 if [ $? = 0 ] ; then wlan_source_config_for_ssid "$ssid" "$bssid" wlan_user_mibs $1 wlan_wep $1 wlan_join $1 else if is_true $IS_ADHOC ; then # start an IBSS; we didn't find one. wlan_adhoc $1 else return 1 fi fi else wlan_source_config $1 wlan_user_mibs $1 wlan_wep $1 if is_true $IS_ADHOC ; then wlan_adhoc $1 else wlan_infra $1 fi fi return $?}wlan_join (){ # $1 == wlandev grep 'autojoin' /proc/net/p80211/$1/wlandev > /dev/null if [ $? = 0 ]; then wlan_infra $1 else wlan_dot11_join $1 wlan_dot11_auth_assoc $1 fi}tmpname (){ # $1 == prefix local i=0 local tname=$TMPDIR/${1}_$$ if [ -f ${tname}.tmp ] ; then for i in 0 1 2 3 4 5 6 7 8 9 ; do if [ ! -f ${tname}_${i}.tmp ] ; then echo ${tname}_${i}.tmp return 0 fi done else echo ${tname}.tmp fi return 0}source_procfile (){ # $1 == procfile to source local fname=`tmpname wlan_procfile` cat "$1" > $fname . $fname rm -f $fname}# This is set by the Configure script as part of 'make install'#FIRMWARE_DIR="/usr/share/linux-wlan"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -