#!/bin/bash

#  Tool to install/uninstall and patch wireless drivers and 802.11 stacks
#
#  Copyright (c) 2007 Martin Beck
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


USERID=""

#run as root?

if [ x"`which id 2> /dev/null`" != "x" ]
then
	USERID="`id -u 2> /dev/null`"
fi

if [ x$USERID == "x" -a x$UID != "x" ]
then
	USERID=$UID
fi

if [ x$USERID != "x" -a x$USERID != "x0" ]
then
	echo Run it as root ; exit ;
fi

#getting commands
LSPCMCIA=`which lspcmcia 2>/dev/null`
IWCONFIG=`which iwconfig 2>/dev/null`
MODPROBE=`which modprobe 2>/dev/null`
RMMOD=`which rmmod 2>/dev/null`
PATCH=`which patch 2>/dev/null`
LSPCI=`which lspci 2>/dev/null`
LSUSB=`which lsusb 2>/dev/null`
WGET=`which wget 2>/dev/null`
MAKE=`which make 2>/dev/null`
GCC=`which gcc 2>/dev/null`
TAR=`which tar 2>/dev/null`
UNZIP=`which unzip 2>/dev/null`
SVN=`which svn 2>/dev/null`
CVS=`which cvs 2>/dev/null`
GIT=`which git 2>/dev/null`
CARDCTL=`which pccardctl 2>/dev/null`

if [ x"$CARDCTL" == x ]
then
    CARDCTL=`which cardctl 2>/dev/null`
fi

#global variables
if [ x"$KVER" == x ]
then
    KVER=`uname -r`
fi
KMAJOR=`echo $KVER | sed 's/^\([0-9]\)\..*$/\1/'`
KMINOR=`echo $KVER | sed 's/^[0-9]\.\([0-9]\)\..*$/\1/'`
KPATCH=`echo $KVER | sed 's/^[0-9]\.[0-9]\.\([0-9]*\).*$/\1/'`
KSUBPT=`echo $KVER | sed -n 's/^[0-9]\.[0-9]\.[0-9]*\.\([0-9]*\).*$/\1/p'`
KSRC="/lib/modules/$KVER/build"
KMOD="/lib/modules/$KVER"
KUTS=""

VANILLA="$KMAJOR.$KMINOR.$KPATCH"
if [ x"$KSUBPT" != x ]
then
    VANILLA="$VANILLA.$KSUBPT"
fi

if [ -f "$KSRC/include/linux/utsrelease.h" ]
then
    KUTS=`grep UTS_RELEASE $KSRC/include/linux/utsrelease.h 2>/dev/null | head -n 1 | cut -d " " -f3 | sed 's/"//g'`
else
    KUTS=`grep UTS_RELEASE $KSRC/include/linux/version.h 2>/dev/null | head -n 1 | cut -d " " -f3 | sed 's/"//g'`
fi

if [ x"$KUTS" != x ]
then
    if [ x"$KUTS" != x"$KVER" ]
    then
        echo "-------"
        echo "Your linked kernel source doesn't match your current running version."
        echo "\"$KUTS\" vs. \"$KVER\""
        printf "You "
        if [ -d "/lib/modules/$KUTS" ]
        then
            printf "will probably"
        else
            printf "may"
        fi
        printf " run into problems when installing drivers.\n"
        echo "-------"
    fi
fi

OWN_NAME=$0

D_DIR="/usr/src/drivers"
LOGFILE="/var/log/airdriver"

#firmware preparation
#possible paths, ordered by importance
FIRMPATHS="/lib/firmware /usr/lib/firmware /lib/hotplug/firmware /usr/local/lib/firmware /usr/firmware"

for i in $FIRMPATHS
do
    if [ -d "$i" ]
    then
        FIRMPATH="$i"
    fi
done

if [ x"$FIRMPATH" == x ]
then
    FIRMPATH="/lib/firmware"
    mkdir -p "$FIRMPATH"
fi
#done preparing firmware directory

NO_DRIVER_ERROR='You need to specify a driver number obtained from "airdriver-ng installed" or "airdriver-ng loaded"'
NO_STACK_ERROR='You need to specify a stack number obtained from "airdriver-ng supported"'
NO_FIRMWARE_ERROR='You need to specify a driver number obtained from "airdriver-ng supported"'

YES=1
NO=0
ERROR=255

NO_INSTALL=$NO
NO_FIRMWARE=$NO

#distribution definition - for future enhancements - not used right now
i=0
LNAME[$i]="Debian"
LI_UTIL[$i]="apt-get"
LI_ARGUMENT[$i]="install"
LI_KSOURCE[$i]=""
LDETECT[$i]=""

i=$(($i+1))
LNAME[$i]="Fedora"
LI_UTIL[$i]="yum"
LI_ARGUMENT[$i]=""
LI_KSOURCE[$i]=""
LDETECT[$i]="cat /etc/fedora-release 2>/dev/null"

i=$(($i+1))
LNAME[$i]="Gentoo"
LI_UTIL[$i]="emerge"
LI_ARGUMENT[$i]="-a"
LI_KSOURCE[$i]=""
LDETECT[$i]=""

i=$(($i+1))
LNAME[$i]="Mandriva"
LI_UTIL[$i]=""
LI_ARGUMENT[$i]=""
LI_KSOURCE[$i]=""
LDETECT[$i]=""

i=$(($i+1))
LNAME[$i]="Slackware"
LI_UTIL[$i]=""
LI_ARGUMENT[$i]=""
LI_KSOURCE[$i]=""
LDETECT[$i]=""

i=$(($i+1))
LNAME[$i]="openSUSE"
LI_UTIL[$i]="zypper"
LI_ARGUMENT[$i]="install"
LI_KSOURCE[$i]="cat /etc/SuSE-release 2>/dev/null"
LDETECT[$i]=""

i=$(($i+1))
LNAME[$i]="[X|K]Ubuntu"
LI_UTIL[$i]="apt-get"
LI_ARGUMENT[$i]="install"
LI_KSOURCE[$i]="linux-source-$VANILLA"
LDETECT[$i]=""


#END - distribution definition
LCOUNT=$(($i+1))

#stack definition

i=0
SNAME[$i]="IEEE80211"
SCONFIG[$i]="CONFIG_IEEE80211="
SCONFIGS[$i]="CONFIG_IEEE80211=m CONFIG_IEEE80211_CRYPT_WEP=m CONFIG_IEEE80211_CRYPT_CCMP=m CONFIG_IEEE80211_CRYPT_TKIP=m"
SMODULE[$i]="ieee80211"
SMODULES[$i]="ieee80211 ieee80211_crypt ieee80211_crypt_wep ieee80211_crypt_tkip ieee80211_crypt_ccmp"
SI_INIT[$i]="install_ieee80211 $i"
SI_DRIVERGET[$i]="cp"
SI_DRIVERFILE[$i]="ieee80211_tx.c"
SI_DRIVERPATH1[$i]="$KSRC/net/ieee80211"
SI_DRIVERPATH2[$i]="/usr/src/linux/net/ieee80211"
SI_DRIVEREXDIR[$i]=""
SI_DRIVERDIR[$i]="ieee80211"
SI_PREPATCH[$i]=""
SI_PATCHFILE[$i]="ieee80211_inject-2.6.22.patch"
SI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/ieee80211_inject-2.6.22.patch"
SI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/ieee80211_inject-2.6.22.patch"
SI_PATCHARG[$i]="-p3"
SI_PRECOMP[$i]=""
SI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${SI_DRIVERDIR[$i]} modules"
SI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/net/ieee80211/""
SI_INSTALL2[$i]="cp -f *.ko "$KMOD/kernel/net/ieee80211/""
SSITE[$i]="http://ieee80211.sourceforge.net/"

i=$(($i+1))
SNAME[$i]="IEEE80211 Softmac"
SCONFIG[$i]="CONFIG_IEEE80211_SOFTMAC="
SCONFIGS[$i]="CONFIG_IEEE80211_SOFTMAC=m"
SMODULE[$i]="ieee80211softmac"
SMODULES[$i]="ieee80211softmac"
SI_INIT[$i]="install_softmac $i"
SI_DRIVERGET[$i]="cp"
SI_DRIVERFILE[$i]="ieee80211softmac_wx.c"
SI_DRIVERPATH1[$i]="$KSRC/net/ieee80211/softmac"
SI_DRIVERPATH2[$i]="/usr/src/linux/net/ieee80211/softmac"
SI_DRIVEREXDIR[$i]=""
SI_DRIVERDIR[$i]="softmac"
SI_PREPATCH[$i]=""
SI_PATCHFILE[$i]="ieee80211_softmac_adjust_bitrate.patch"
SI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/ieee80211_softmac_adjust_bitrate.patch"
SI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/ieee80211_softmac_adjust_bitrate.patch"
SI_PATCHARG[$i]="-p4"
SI_PRECOMP[$i]=""
SI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${SI_DRIVERDIR[$i]} modules"
SI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/net/ieee80211/softmac/""
SI_INSTALL2[$i]="cp -f *.ko "$KMOD/kernel/net/ieee80211/softmac/""
SSITE[$i]="http://softmac.sipsolutions.net/"

i=$(($i+1))
SNAME[$i]="mac80211"
SCONFIG[$i]="CONFIG_MAC80211="
SCONFIGS[$i]="CONFIG_MAC80211=m"
SMODULE[$i]="mac80211"
SMODULES[$i]="mac80211 rc80211_simple cfg80211 nl80211 rc80211_lowest"
SSITE[$i]="http://intellinuxwireless.org/?p=mac80211"

i=$(($i+1))
SNAME[$i]="custom"
SCONFIG[$i]=""
SMODULE[$i]=""
SMODULES[$i]=""
SSITE[$i]=""

#END of stack definition
SCOUNT=$(($i+1))

#drivers
#DCOUNT = Number of known drivers
#DNAME[x] = Driver name to be displayed
#DMODULE[x] = Main module name to recognise installed/loaded status (complete name without trailing ".ko")
#DCONFIG[x] = Configure variable in kernel config file
#DMODULES[x] = All modules used by the driver (complete name without trailing ".ko")
#DINSTALL[x] = Function to d/l, patch and install the driver
#DSITE[x] = Website with more information about the driver
#DETECT_X[x] = string to grep for while detecting devices: lsusb -v, lspci and lspcmcia -v

i=0
DNAME[$i]="ACX100/111"
DSTACK[$i]="0"
DMODINFO[$i]=""
DMODULE[$i]="acx"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="acx"
DI_INIT[$i]=""
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="acx-20070101.tar.bz2"
DI_DRIVERPATH1[$i]="http://www.cmartin.tk/acx/acx-20070101.tar.bz2"
DI_DRIVERPATH2[$i]="http://www.hauke-m.de/fileadmin/acx/acx-20070101.tar.bz2"
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]="acx-20070101"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]="acx-20070101.patch"
DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/acx-20070101.patch"
DI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/acx-20070101.patch"
DI_PATCHARG[$i]="-p1"
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${DI_DRIVERDIR[$i]} modules"
DI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/drivers/net/wireless/acx/""
DI_INSTALL2[$i]="cp -f acx.ko "$KMOD/kernel/drivers/net/wireless/acx/""
DF_FIRMFILES[$i]="tiacx100 tiacx100r11 tiacx111c17 tiacx100r0D tiacx100r15 tiacx111c16 tiacx111c19"
DF_FIRMFILE[$i]="fw.tar.bz2"
DF_FIRMPATH1[$i]="http://www.hauke-m.de/fileadmin/acx/fw.tar.bz2"
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]="fw"
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=acx"
DETECT_USB[$i]=""
DETECT_PCI[$i]="ACX"
DETECT_CS[$i]="ACX"

i=$(($i+1))
DNAME[$i]="ADMtek 8211"
DSTACK[$i]="0"
DMODINFO[$i]="^depends: *ieee80211"
DMODULE[$i]="adm8211"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="adm8211"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="ADMtek 8211"
DSTACK[$i]="2"
DMODINFO[$i]="^depends: *mac80211"
DMODULE[$i]="adm8211"
DCONFIG[$i]="CONFIG_ADM8211="
DCONFIGS[$i]="CONFIG_ADM8211=m"
DMODULES[$i]="adm8211"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Atmel at76c50x"
DSTACK[$i]="0"
DMODINFO[$i]=""
DMODULE[$i]="atmel"
DCONFIG[$i]="CONFIG_ATMEL="
DCONFIGS[$i]="CONFIG_ATMEL=m CONFIG_PCI_ATMEL=m CONFIG_PCMCIA_ATMEL=m CONFIG_TCG_ATMEL=m"
DMODULES[$i]="atmel atmel_cs atmel_pci at76c505a-rfmd2958 at76c505-rfmd2958 at76c505-rfmd.ko at76c503.ko at76c503-rfmd.ko at76c503-rfmd-acc.ko at76c503-i3863.ko at76c503-i3861.ko at76_usbdfu.ko"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]="atmel_at76c502_3com.bin atmel_at76c503-rfmd.bin atmel_at76c502_3com-wpa.bin atmel_at76c504_2958-wpa.bin atmel_at76c502.bin atmel_at76c504a_2958-wpa.bin atmel_at76c502d.bin atmel_at76c504.bin atmel_at76c502d-wpa.bin atmel_at76c504c-wpa.bin atmel_at76c502e.bin atmel_at76c505a-rfmd2958.bin atmel_at76c502e-wpa.bin atmel_at76c505-rfmd2958.bin atmel_at76c502-wpa.bin atmel_at76c505-rfmd.bin atmel_at76c503-i3861.bin atmel_at76c506.bin atmel_at76c503-i3863.bin atmel_at76c506-wpa.bin atmel_at76c503-rfmd-0.90.2-140.bin atmel_at76c503-rfmd-acc.bin"
DF_FIRMFILE[$i]="at76c503afw-0.1.tar.gz"
DF_FIRMPATH1[$i]="http://downloads.sourceforge.net/at76c503a/at76c503afw-0.1.tar.gz"
DF_FIRMPATH2[$i]="http://downloads.sourceforge.net/at76c503a/at76c503afw-0.1.tar.gz"
DF_FIRMDIR[$i]="at76_usb-firmware-0.1"
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Atmel at76_usb"
DSTACK[$i]="0"
DMODINFO[$i]=""
DMODULE[$i]="at76_usb"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="at76_usb"
DI_INIT[$i]=""
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="at76_usb-0.16.tar.gz"
DI_DRIVERPATH1[$i]="http://download.berlios.de/at76c503a/at76_usb-0.16.tar.gz"
DI_DRIVERPATH2[$i]="http://download2.berlios.de/at76c503a/at76_usb-0.16.tar.gz"
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]="at76_usb-0.16"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="make"
DI_INSTALL1[$i]="make install"
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]="atmel_at76c502_3com.bin atmel_at76c503-rfmd.bin atmel_at76c502_3com-wpa.bin atmel_at76c504_2958-wpa.bin atmel_at76c502.bin atmel_at76c504a_2958-wpa.bin atmel_at76c502d.bin atmel_at76c504.bin atmel_at76c502d-wpa.bin atmel_at76c504c-wpa.bin atmel_at76c502e.bin atmel_at76c505a-rfmd2958.bin atmel_at76c502e-wpa.bin atmel_at76c505-rfmd2958.bin atmel_at76c502-wpa.bin atmel_at76c505-rfmd.bin atmel_at76c503-i3861.bin atmel_at76c506.bin atmel_at76c503-i3863.bin atmel_at76c506-wpa.bin atmel_at76c503-rfmd-0.90.2-140.bin atmel_at76c503-rfmd-acc.bin"
DF_FIRMFILE[$i]="at76c503afw-0.1.tar.gz"
DF_FIRMPATH1[$i]="http://downloads.sourceforge.net/at76c503a/at76c503afw-0.1.tar.gz"
DF_FIRMPATH2[$i]="http://downloads.sourceforge.net/at76c503a/at76c503afw-0.1.tar.gz"
DF_FIRMDIR[$i]="at76_usb-firmware-0.1"
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Broadcom 4300"
DSTACK[$i]="0"
DMODINFO[$i]=""
DMODULE[$i]="bcm43xx"
DCONFIG[$i]="CONFIG_BCM43XX="
DCONFIGS[$i]="CONFIG_BCM43XX=m CONFIG_BCM43XX_DMA=y CONFIG_BCM43XX_PIO=y CONFIG_BCM43XX_DMA_AND_PIO_MODE=y"
DMODULES[$i]="bcm43xx"
DI_INIT[$i]=""
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="linux-$VANILLA.tar.bz2"
DI_DRIVERPATH1[$i]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2"
DI_DRIVERPATH2[$i]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2"
DI_DRIVEREXDIR[$i]="linux-$VANILLA/drivers/net/wireless/bcm43xx"
DI_DRIVERDIR[$i]="bcm43xx"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]="bcm43xx-injection-linux-2.6.20.patch"
DI_PATCHPATH1[$i]="http://trac.aircrack-ng.org/attachment/ticket/183/bcm43xx-injection-linux-2.6.20.patch?format=raw"
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]="-p5"
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${DI_DRIVERDIR[$i]} modules"
DI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/drivers/net/wireless/bcm43xx/""
DI_INSTALL2[$i]="cp -f bcm43xx.ko $KMOD/kernel/drivers/net/wireless/bcm43xx/"
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=broadcom"
DETECT_USB[$i]=""
DETECT_PCI[$i]="BCM43"
DETECT_CS[$i]="BCM43"

i=$(($i+1))
DNAME[$i]="Broadcom 4300"
DSTACK[$i]="2"
DMODINFO[$i]=""
DMODULE[$i]="bcm43xx-mac80211"
DCONFIG[$i]="CONFIG_BCM43XX_MAC80211="
DCONFIGS[$i]="CONFIG_BCM43XX_MAC80211=m CONFIG_BCM43XX_MAC80211_PCI=y CONFIG_BCM43XX_MAC80211_PCMCIA=y CONFIG_BCM43XX_MAC80211_DMA=y CONFIG_BCM43XX_MAC80211_PIO=y CONFIG_BCM43XX_MAC80211_DMA_AND_PIO_MODE=y"
DMODULES[$i]="bcm43xx-mac80211.ko"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]="BCM43"
DETECT_CS[$i]="BCM43"

i=$(($i+1))
DNAME[$i]="Cisco/Aironet 802.11"
DSTACK[$i]="1"
DMODINFO[$i]=""
DMODULE[$i]="airo"
DCONFIG[$i]="CONFIG_AIRO="
DCONFIGS[$i]="CONFIG_AIRO=m CONFIG_AIRO_CS=m"
DMODULES[$i]="airo airo_cs"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="HostAP"
DSTACK[$i]="0"
DMODINFO[$i]=""
DMODULE[$i]="hostap"
DCONFIG[$i]="CONFIG_HOSTAP="
DCONFIGS[$i]="CONFIG_HOSTAP=m CONFIG_HOSTAP_CS=m CONFIG_HOSTAP_PLX=m CONFIG_HOSTAP_PCI=m CONFIG_HOSTAP_FIRMWARE=y CONFIG_HOSTAP_FIRMWARE_NVRAM=y"
DMODULES[$i]="hostap_pci hostap_plx hostap_cs hostap"
DI_INIT[$i]="install_hostap $i"
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="linux-$VANILLA.tar.bz2"
DI_DRIVERPATH1[$i]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2"
DI_DRIVERPATH2[$i]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2"
DI_DRIVEREXDIR[$i]="linux-$VANILLA/drivers/net/wireless/hostap"
DI_DRIVERDIR[$i]="hostap"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]="hostap-kernel-$VANILLA.patch"
DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/hostap-kernel-$VANILLA.patch"
DI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/hostap-kernel-$VANILLA.patch"
DI_PATCHARG[$i]="-p5"
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${DI_DRIVERDIR[$i]} modules"
DI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/drivers/net/wireless/hostap/""
DI_INSTALL2[$i]="cp -f *.ko $KMOD/kernel/drivers/net/wireless/hostap/"
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=hostap"
DETECT_USB[$i]="prism2"
DETECT_PCI[$i]="Intersil\|Prism"
DETECT_CS[$i]="Wireless LAN"

i=$(($i+1))
DNAME[$i]="Intel Pro Wireless 2100 B"
DSTACK[$i]="0"
DMODINFO[$i]=""
DMODULE[$i]="ipw2100"
DCONFIG[$i]="CONFIG_IPW2100="
DCONFIGS[$i]="CONFIG_IPW2100=m CONFIG_IPW2100_MONITOR=y"
DMODULES[$i]="ipw2100"
DI_INIT[$i]=""
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="linux-$VANILLA.tar.bz2"
DI_DRIVERPATH1[$i]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2"
DI_DRIVERPATH2[$i]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2"
DI_DRIVEREXDIR[$i]="linux-$VANILLA/drivers/net/wireless"
DI_DRIVERDIR[$i]="ipw2100"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]="ipw2100_precomp"
DI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${DI_DRIVERDIR[$i]} modules"
DI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/drivers/net/wireless/ipw2100/""
DI_INSTALL2[$i]="cp -f ipw2100.ko $KMOD/kernel/drivers/net/wireless/ipw2100/"
DF_FIRMFILES[$i]="ipw2100-1.3.fw ipw2100-1.3-i.fw ipw2100-1.3-p.fw"
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]="2100"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Intel Pro Wireless 2200 (B/G)/2915 (A/B/G)"
DSTACK[$i]="0"
DMODINFO[$i]=""
DMODULE[$i]="ipw2200"
DCONFIG[$i]="CONFIG_IPW2200="
DCONFIGS[$i]="CONFIG_IPW2200=m CONFIG_IPW2200_MONITOR=y CONFIG_IPW2200_RADIOTAP=y CONFIG_IPW2200_PROMISCUOUS=y CONFIG_IPW2200_QOS=y"
DMODULES[$i]="ipw2200"
DI_INIT[$i]="install_ipw2200 $i"
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="linux-$VANILLA.tar.bz2"
DI_DRIVERPATH1[$i]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2"
DI_DRIVERPATH2[$i]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2"
DI_DRIVEREXDIR[$i]="linux-$VANILLA/drivers/net/wireless"
DI_DRIVERDIR[$i]="ipw2200"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]="ipw2200-1.1.4-inject.patch"
DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/ipw2200-1.1.4-inject.patch"
DI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/ipw2200-1.1.4-inject.patch"
DI_PATCHARG[$i]="-p1 -f"
DI_PRECOMP[$i]="ipw2200_precomp"
DI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${DI_DRIVERDIR[$i]} modules"
DI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/drivers/net/wireless/ipw2200/""
DI_INSTALL2[$i]="cp -f ipw2200.ko $KMOD/kernel/drivers/net/wireless/ipw2200/"
DF_FIRMFILES[$i]="ipw2200-ibss.fw ipw2200-bss.fw ipw2200-sniffer.fw"
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=ipw2200"
DETECT_USB[$i]=""
DETECT_PCI[$i]="2200BG"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Intel Pro Wireless 3945 A/B/G"
DSTACK[$i]="0"
DMODINFO[$i]=""
DMODULE[$i]="ipw3945"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="ipw3945"
DI_INIT[$i]=""
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]="ipw3945.ucode"
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=ipw3945"
DETECT_USB[$i]=""
DETECT_PCI[$i]="3945"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Intel Pro Wireless 3945 A/B/G - raw mode"
DSTACK[$i]=""
DMODINFO[$i]=""
DMODULE[$i]="ipwraw"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="ipwraw"
DI_INIT[$i]=""
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="ipwraw-ng-2.0.0-10072007.tar.bz2"
DI_DRIVERPATH1[$i]="http://www.tu-darmstadt.de/~p_larbig/wlan/ipwraw-ng-2.0.0-10072007.tar.bz2"
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]="ipwraw-ng"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="make"
DI_INSTALL1[$i]="make install"
DI_INSTALL2[$i]="make install_ucode"
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]="www.tu-darmstadt.de/~p_larbig/wlan/"
DETECT_USB[$i]=""
DETECT_PCI[$i]="3945"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Intel Pro Wireless 3945 A/B/G"
DSTACK[$i]="2"
DMODINFO[$i]="^depends: *mac80211"
DMODULE[$i]="iwl3945"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="iwl3945"
DI_INIT[$i]=""
DI_DRIVERGET[$i]="git"
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=ipw3945"
DETECT_USB[$i]=""
DETECT_PCI[$i]="3945"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Intel Pro Wireless 4965 A/B/G/N"
DSTACK[$i]="2"
DMODINFO[$i]="^depends: *mac80211"
DMODULE[$i]="iwl4965"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="iwl4965"
DI_INIT[$i]=""
DI_DRIVERGET[$i]="git"
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]="4965"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Lucent Hermes and Prism II"
DSTACK[$i]="0"
DMODINFO[$i]=""
DMODULE[$i]="hermes"
DCONFIG[$i]="CONFIG_HERMES="
DCONFIGS[$i]="CONFIG_HERMES=m CONFIG_PLX_HERMES=m CONFIG_TMD_HERMES=m CONFIG_NORTEL_HERMES=m CONFIG_PCI_HERMES=m CONFIG_PCMCIA_HERMES=m"
DMODULES[$i]="hermes orinoco orinoco_nortel orinoco_pci orinoco_plx orinoco_tmd orinoco_cs spectrum_cs"
DI_INIT[$i]="install_hermes $i"
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="orinoco-0.13e-SN-14.tar.bz2"
DI_DRIVERPATH1[$i]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-14.tar.bz2"
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]="orinoco-0.13e-SN-14"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="$MAKE"
DI_INSTALL1[$i]="$MAKE install"
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Madwifi[-ng]"
DSTACK[$i]="0"
DMODINFO[$i]=""
DMODULE[$i]="ath_pci"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="wlan_wep ath_rate_sample ath_rate_onoe ath_pci ath_hal ath_rate_amrr ath_rate_minstrel wlan_xauth wlan_tkip wlan_ccmp wlan_acl wlan wlan_scan_ap wlan_scan_sta"
DI_INIT[$i]=""
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="madwifi-trunk-r4104-20100112.tar.gz"
DI_DRIVERPATH1[$i]="http://snapshots.madwifi-project.org/madwifi-trunk/madwifi-trunk-r4104-20100112.tar.gz"
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]="madwifi-trunk-r4104-20100112"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]="-p1"
DI_PRECOMP[$i]="export KERNELRELEASE=$KVER"
DI_COMPILE[$i]="$MAKE"
DI_INSTALL1[$i]="madwifi_install"
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=madwifi-ng"
DETECT_USB[$i]=""
DETECT_PCI[$i]="Atheros"
DETECT_CS[$i]="atheros\|Atheros"

i=$(($i+1))
DNAME[$i]="Prism54"
DSTACK[$i]="0"
DMODINFO[$i]=""
DMODULE[$i]="prism54"
DCONFIG[$i]="CONFIG_PRISM54="
DCONFIGS[$i]="CONFIG_PRISM54=m"
DMODULES[$i]="prism54"
DI_INIT[$i]=""
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="prism54_r531.tar.gz"
DI_DRIVERPATH1[$i]="http://svnweb.tuxfamily.org/dl.php?repname=prism54/prism54&path=%2Ftrunk%2F&rev=531&isdir=1"
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]="trunk"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]="prism54-svn-20050724.patch"
DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/prism54-svn-20050724.patch"
DI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/prism54-svn-20050724.patch"
DI_PATCHARG[$i]="-p1"
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="$MAKE modules"
DI_INSTALL1[$i]="$MAKE install"
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]="gw3887 isl3886_usb"
DF_FIRMFILE[$i]="p54u_firmwares.tar.bz2"
DF_FIRMPATH1[$i]="http://prism54.org/firmware/p54u_firmwares.tar.bz2"
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]="boot/firmware"
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=prism54"
DETECT_USB[$i]=""
DETECT_PCI[$i]="Prism Javelin\|Prism Xbow\|Prism GT\|Prism Duette"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Prism54"
DSTACK[$i]="2"
DMODINFO[$i]=""
DMODULE[$i]="prism54common"
DCONFIG[$i]="CONFIG_P54_COMMON="
DCONFIGS[$i]="CONFIG_P54_COMMON=m CONFIG_P54_USB=m CONFIG_P54_PCI=m"
DMODULES[$i]="prism54common prism54pci prism54usb"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]="gw3887 isl3886_usb"
DF_FIRMFILE[$i]="p54u_firmwares.tar.bz2"
DF_FIRMPATH1[$i]="http://prism54.org/firmware/p54u_firmwares.tar.bz2"
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]="boot/firmware"
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]="Prism Javelin\|Prism Xbow\|Prism GT\|Prism Duette"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Ralink rt2400 (legacy)"
DSTACK[$i]=""
DMODINFO[$i]=""
DMODULE[$i]="rt2400"
DCONFIG[$i]="CONFIG_RT2400="
DCONFIGS[$i]="CONFIG_RT2400=m"
DMODULES[$i]="rt2400"
DI_INIT[$i]="rm -rf source/"
DI_DRIVERGET[$i]="cvs"
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]="-d:pserver:anonymous@rt2400.cvs.sourceforge.net:/cvsroot/rt2400"
DI_DRIVERPATH2[$i]="source/rt2400"
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]="source/rt2400/Module"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="$MAKE"
DI_INSTALL1[$i]="$MAKE install"
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]="RT2400"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Ralink rt2400 (rt2x00)"
DSTACK[$i]="0"
DMODINFO[$i]="^depends:.*80211"
DMODULE[$i]="rt2400pci"
DCONFIG[$i]="CONFIG_RT2400PCI="
DCONFIGS[$i]="CONFIG_RT2400PCI=m"
DMODULES[$i]="rt2400pci"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]="RT2400"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Ralink rt2400 (rt2x00)"
DSTACK[$i]="2"
DMODINFO[$i]="^depends:.*rt2x00lib"
DMODULE[$i]="rt2400pci"
DCONFIG[$i]="CONFIG_RT2400PCI="
DCONFIGS[$i]="CONFIG_RT2400PCI=m"
DMODULES[$i]="rt2400pci"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]="RT2400"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Ralink rt2500 (legacy)"
DSTACK[$i]=""
DMODINFO[$i]=""
DMODULE[$i]="rt2500"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="rt2500"
DI_INIT[$i]="rm -rf source/"
DI_DRIVERGET[$i]="cvs"
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]="-d:pserver:anonymous@rt2400.cvs.sourceforge.net:/cvsroot/rt2400"
DI_DRIVERPATH2[$i]="source/rt2500"
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]="source/rt2500/Module"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="$MAKE"
DI_INSTALL1[$i]="$MAKE install"
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=rt2500"
DETECT_USB[$i]=""
DETECT_PCI[$i]="RT2500"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Ralink rt2500 (rt2x00)"
DSTACK[$i]="0"
DMODINFO[$i]="^depends:.*80211"
DMODULE[$i]="rt2500pci"
DCONFIG[$i]="CONFIG_RT2500PCI="
DCONFIGS[$i]="CONFIG_RT2500PCI=m"
DMODULES[$i]="rt2500pci"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]="RT2500"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Ralink rt2500 (rt2x00)"
DSTACK[$i]="2"
DMODINFO[$i]="^depends:.*rt2x00lib"
DMODULE[$i]="rt2500pci"
DCONFIG[$i]="CONFIG_RT2500PCI="
DCONFIGS[$i]="CONFIG_RT2500PCI=m"
DMODULES[$i]="rt2500pci"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]="RT2500"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Ralink rt2570 (legacy)"
DSTACK[$i]=""
DMODINFO[$i]=""
DMODULE[$i]="rt2570"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="rt2570"
DI_INIT[$i]="rm -rf rt2570-k2wrlz-1.6.3/"
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="rt2570-k2wrlz-1.6.3.tar.bz2"
DI_DRIVERPATH1[$i]="http://homepages.tu-darmstadt.de/~p_larbig/wlan/rt2570-k2wrlz-1.6.3.tar.bz2"
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]="rt2570-k2wrlz-1.6.3/Module"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="$MAKE"
DI_INSTALL1[$i]="$MAKE install"
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=rt2570"
DETECT_USB[$i]="G122 802.11g rev. B1"
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Ralink rt2570 (rt2x00)"
DSTACK[$i]="0"
DMODINFO[$i]="^depends:.*80211"
DMODULE[$i]="rt2500usb"
DCONFIG[$i]="CONFIG_RT2500USB="
DCONFIGS[$i]="CONFIG_RT2500USB=m"
DMODULES[$i]="rt2500usb"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Ralink rt2570 (rt2x00)"
DSTACK[$i]="2"
DMODINFO[$i]="^depends:.*rt2x00lib"
DMODULE[$i]="rt2500usb"
DCONFIG[$i]="CONFIG_RT2500USB="
DCONFIGS[$i]="CONFIG_RT2500USB=m"
DMODULES[$i]="rt2500usb"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Ralink rt61 (legacy)"
DSTACK[$i]=""
DMODINFO[$i]=""
DMODULE[$i]="rt61"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="rt61"
DI_INIT[$i]="rm -rf source/"
DI_DRIVERGET[$i]="cvs"
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]="-d:pserver:anonymous@rt2400.cvs.sourceforge.net:/cvsroot/rt2400"
DI_DRIVERPATH2[$i]="source/rt61"
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]="source/rt61/Module"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="$MAKE"
DI_INSTALL1[$i]="$MAKE install"
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]="rt2561.bin rt2561s.bin rt2661.bin rt61sta.dat"
DF_FIRMFILE[$i]="rt61-1.1.0-b2.tar.gz"
DF_FIRMPATH1[$i]="http://prdownloads.sourceforge.net/rt2400/rt61-1.1.0-b2.tar.gz"
DF_FIRMPATH2[$i]="http://prdownloads.sourceforge.net/rt2400/rt61-1.1.0-b2.tar.gz"
DF_FIRMDIR[$i]="rt61-1.1.0-b2"
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=rt61"
DETECT_USB[$i]=""
DETECT_PCI[$i]="RT61\|RT2600\|RT2561"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Ralink rt61 (rt2x00)"
DSTACK[$i]="0"
DMODINFO[$i]="^depends:.*80211"
DMODULE[$i]="rt61pci"
DCONFIG[$i]="CONFIG_RT61PCI="
DCONFIGS[$i]="CONFIG_RT61PCI=m"
DMODULES[$i]="rt61pci"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]="rt2561.bin rt2561s.bin rt2661.bin rt61sta.dat"
DF_FIRMFILE[$i]="rt61-1.1.0-b2.tar.gz"
DF_FIRMPATH1[$i]="http://prdownloads.sourceforge.net/rt2400/rt61-1.1.0-b2.tar.gz"
DF_FIRMPATH2[$i]="http://prdownloads.sourceforge.net/rt2400/rt61-1.1.0-b2.tar.gz"
DF_FIRMDIR[$i]="rt61-1.1.0-b2"
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]="RT61\|RT2600\|RT2561"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Ralink rt61 (rt2x00)"
DSTACK[$i]="2"
DMODINFO[$i]="^depends:.*rt2x00lib"
DMODULE[$i]="rt61pci"
DCONFIG[$i]="CONFIG_RT61PCI="
DCONFIGS[$i]="CONFIG_RT61PCI=m"
DMODULES[$i]="rt61pci"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]="rt2561.bin rt2561s.bin rt2661.bin rt61sta.dat"
DF_FIRMFILE[$i]="rt61-1.1.0-b2.tar.gz"
DF_FIRMPATH1[$i]="http://prdownloads.sourceforge.net/rt2400/rt61-1.1.0-b2.tar.gz"
DF_FIRMPATH2[$i]="http://prdownloads.sourceforge.net/rt2400/rt61-1.1.0-b2.tar.gz"
DF_FIRMDIR[$i]="rt61-1.1.0-b2"
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]="RT61\|RT2600\|RT2561"
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Ralink rt73 (legacy)"
DSTACK[$i]=""
DMODINFO[$i]=""
DMODULE[$i]="rt73"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="rt73"
DI_INIT[$i]="rm -rf rt73-k2wrlz-3.0.2/"
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="rt73-k2wrlz-3.0.2.tar.bz2"
DI_DRIVERPATH1[$i]="http://homepages.tu-darmstadt.de/~p_larbig/wlan/rt73-k2wrlz-3.0.2.tar.bz2"
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]="rt73-k2wrlz-3.0.2/Module"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="$MAKE"
DI_INSTALL1[$i]="$MAKE install"
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]="rt73.bin rt73sta.dat"
DF_FIRMFILE[$i]="RT73_Linux_STA_Drv1.0.4.0.tar.gz"
DF_FIRMPATH1[$i]="http://www.ralinktech.com.tw/data/RT73_Linux_STA_Drv1.0.4.0.tar.gz"
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]="RT73_Linux_STA_Drv1.0.4.0"
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=rt73"
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Ralink rt73 (rt2x00)"
DSTACK[$i]="0"
DMODINFO[$i]="^depends:.*80211"
DMODULE[$i]="rt73usb"
DCONFIG[$i]="CONFIG_RT73USB="
DCONFIGS[$i]="CONFIG_RT73USB=m"
DMODULES[$i]="rt73usb"
DI_INIT[$i]=""
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]="rt73.bin rt73sta.dat"
DF_FIRMFILE[$i]="RT73_Linux_STA_Drv1.0.4.0.tar.gz"
DF_FIRMPATH1[$i]="http://www.ralinktech.com.tw/data/RT73_Linux_STA_Drv1.0.4.0.tar.gz"
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]="RT73_Linux_STA_Drv1.0.4.0"
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Ralink rt73 (rt2x00)"
DSTACK[$i]="2"
DMODINFO[$i]="^depends:.*rt2x00lib"
DMODULE[$i]="rt73usb"
DCONFIG[$i]="CONFIG_RT73USB="
DCONFIGS[$i]="CONFIG_RT73USB=m"
DMODULES[$i]="rt73usb"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]="rt73.bin rt73sta.dat"
DF_FIRMFILE[$i]="RT73_Linux_STA_Drv1.0.4.0.tar.gz"
DF_FIRMPATH1[$i]="http://www.ralinktech.com.tw/data/RT73_Linux_STA_Drv1.0.4.0.tar.gz"
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]="RT73_Linux_STA_Drv1.0.4.0"
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Realtek rtl8180"
DSTACK[$i]="3"
DMODINFO[$i]=""
DMODULE[$i]="r818x"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="r818x"
DI_INIT[$i]=""
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="rtl8180-0.21.tar.gz"
DI_DRIVERPATH1[$i]="http://ovh.dl.sourceforge.net/sourceforge/rtl8180-sa2400/rtl8180-0.21.tar.gz"
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]="rtl8180-0.21"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]="rtl8180-0.21v2.patch"
DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/rtl8180-0.21v2.patch"
DI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/rtl8180-0.21v2.patch"
DI_PATCHARG[$i]="-p1"
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="$MAKE"
DI_INSTALL1[$i]="$MAKE install"
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=r8180-sa2400"
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Realtek rtl8187"
DSTACK[$i]="3"
DMODINFO[$i]=""
DMODULE[$i]="r8187"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="r8187 ieee80211-rtl ieee80211_crypt-rtl ieee80211_crypt_wep-rtl ieee80211_crypt_tkip-rtl ieee80211_crypt_ccmp-rtl"
DI_INIT[$i]=""
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="rtl8187_linux_26.1010.zip"
DI_DRIVERPATH1[$i]="http://dl.aircrack-ng.org/drivers/rtl8187_linux_26.1010.zip"
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]="rtl8187_linux_26.1010.0622.2006"
DI_PREPATCH[$i]="rtl8187_prepatch $i"
DI_PATCHFILE[$i]="rtl8187_2.6.27.patch"
DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/rtl8187_2.6.27.patch"
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]="-p1"
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="$MAKE"
DI_INSTALL1[$i]="$MAKE install"
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=r8187"
DETECT_USB[$i]="RTL8187"
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Realtek rtl8187"
DSTACK[$i]="2"
DMODINFO[$i]=""
DMODULE[$i]="rtl8187"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="rtl8187"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]="RTL8187"
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="WLAN-NG"
DSTACK[$i]="0"
DMODINFO[$i]=""
DMODULE[$i]="prism2_pci"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="prism2_pci prism2_usb prism2_plx prism2_cs p80211"
DI_INIT[$i]=""
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="linux-wlan-ng-0.2.8.tar.bz2"
DI_DRIVERPATH1[$i]="ftp://ftp.linux-wlan.org/pub/linux-wlan-ng/linux-wlan-ng-0.2.8.tar.bz2"
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]="linux-wlan-ng-0.2.8"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]="linux-wlan-ng-0.2.8.patch"
DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/linux-wlan-ng-0.2.8.patch"
DI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/linux-wlan-ng-0.2.8.patch"
DI_PATCHARG[$i]="-p1"
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="$MAKE auto_config"
DI_INSTALL1[$i]="$MAKE install"
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=wlan-ng"
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="Xircom Creditcard Netwave"
DSTACK[$i]="0"
DMODINFO[$i]=""
DMODULE[$i]="netwave_cs"
DCONFIG[$i]="CONFIG_PCMCIA_NETWAVE="
DCONFIGS[$i]="CONFIG_PCMCIA_NETWAVE=m"
DMODULES[$i]="netwave_cs"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="ZyDAS 1201"
DSTACK[$i]="1"
DMODINFO[$i]=""
DMODULE[$i]="zd1201"
DCONFIG[$i]="CONFIG_USB_ZD1201="
DCONFIGS[$i]="CONFIG_USB_ZD1201=m"
DMODULES[$i]="zd1201"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]="zd1201.fw zd1201-ap.fw"
DF_FIRMFILE[$i]="zd1201-0.14-fw.tar.gz"
DF_FIRMPATH1[$i]="http://downloads.sourceforge.net/linux-lc100020/zd1201-0.14-fw.tar.gz"
DF_FIRMPATH2[$i]="http://downloads.sourceforge.net/linux-lc100020/zd1201-0.14-fw.tar.gz"
DF_FIRMDIR[$i]="zd1201-0.14-fw"
DF_INSTALLDIR[$i]=""
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="ZyDAS 1211"
DSTACK[$i]="1"
DMODINFO[$i]=""
DMODULE[$i]="zd1211"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="zd1211"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]="zd1211b_ub zd1211b_uphm zd1211b_ur zd1211_uph zd1211_uphr zd1211b_uph zd1211b_uphr zd1211_ub zd1211_uphm zd1211_ur"
DF_FIRMFILE[$i]="zd1211-firmware-1.4.tar.bz2"
DF_FIRMPATH1[$i]="http://downloads.sourceforge.net/zd1211/zd1211-firmware-1.4.tar.bz2"
DF_FIRMPATH2[$i]="http://downloads.sourceforge.net/zd1211/zd1211-firmware-1.4.tar.bz2"
DF_FIRMDIR[$i]="zd1211-firmware"
DF_INSTALLDIR[$i]="zd1211"
DSITE[$i]=""
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="ZyDAS 1211rw"
DSTACK[$i]="1"
DMODINFO[$i]=""
DMODULE[$i]="zd1211rw"
DCONFIG[$i]="CONFIG_ZD1211RW="
DCONFIGS[$i]="CONFIG_ZD1211RW=m"
DMODULES[$i]="zd1211rw"
DI_INIT[$i]="install_zd1211rw $i"
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="linux-$VANILLA.tar.bz2"
DI_DRIVERPATH1[$i]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2"
DI_DRIVERPATH2[$i]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2"
DI_DRIVEREXDIR[$i]="linux-$VANILLA/drivers/net/wireless/zd1211rw"
DI_DRIVERDIR[$i]="zd1211rw"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]="zd1211rw_inject_2.6.23.patch"
DI_PATCHPATH1[$i]="http://patches.aircrack-ng.org/zd1211rw_inject_2.6.23.patch"
DI_PATCHPATH2[$i]="http://patches.aircrack-ng.org/old/zd1211rw_inject_2.6.23.patch"
DI_PATCHARG[$i]="-p5"
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="$MAKE -C $KSRC/ M=$D_DIR/${DI_DRIVERDIR[$i]} modules"
DI_INSTALL1[$i]="mkdir -p "$KMOD/kernel/drivers/net/wireless/zd1211rw/""
DI_INSTALL2[$i]="cp -f zd1211rw.ko $KMOD/kernel/drivers/net/wireless/zd1211rw/"
DF_FIRMFILES[$i]="zd1211b_ub zd1211b_uphm zd1211b_ur zd1211_uph zd1211_uphr zd1211b_uph zd1211b_uphr zd1211_ub zd1211_uphm zd1211_ur"
DF_FIRMFILE[$i]="zd1211-firmware-1.4.tar.bz2"
DF_FIRMPATH1[$i]="http://downloads.sourceforge.net/zd1211/zd1211-firmware-1.4.tar.bz2"
DF_FIRMPATH2[$i]="http://downloads.sourceforge.net/zd1211/zd1211-firmware-1.4.tar.bz2"
DF_FIRMDIR[$i]="zd1211-firmware"
DF_INSTALLDIR[$i]="zd1211"
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=zd1211rw"
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="ZyDAS 1211rw"
DSTACK[$i]="2"
DMODINFO[$i]=""
DMODULE[$i]="zd1211rw_mac80211"
DCONFIG[$i]="CONFIG_ZD1211RW_MAC80211="
DCONFIGS[$i]="CONFIG_ZD1211RW_MAC80211=m"
DMODULES[$i]="zd1211rw_mac80211"
DI_INIT[$i]=""
DI_DRIVERGET[$i]=""
DI_DRIVERFILE[$i]=""
DI_DRIVERPATH1[$i]=""
DI_DRIVERPATH2[$i]=""
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]=""
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]=""
DI_INSTALL1[$i]=""
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://www.aircrack-ng.org/doku.php?id=zd1211rw"
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

i=$(($i+1))
DNAME[$i]="NDIS Wrapper"
DSTACK[$i]=""
DMODINFO[$i]=""
DMODULE[$i]="ndiswrapper"
DCONFIG[$i]=""
DCONFIGS[$i]=""
DMODULES[$i]="ndiswrapper"
DI_INIT[$i]=""
DI_DRIVERGET[$i]="wget"
DI_DRIVERFILE[$i]="ndiswrapper-1.49.tar.gz"
DI_DRIVERPATH1[$i]="http://heanet.dl.sourceforge.net/sourceforge/ndiswrapper/ndiswrapper-1.49.tar.gz"
DI_DRIVERPATH2[$i]="http://internap.dl.sourceforge.net/sourceforge/ndiswrapper/ndiswrapper-1.49.tar.gz"
DI_DRIVEREXDIR[$i]=""
DI_DRIVERDIR[$i]="ndiswrapper-1.49"
DI_PREPATCH[$i]=""
DI_PATCHFILE[$i]=""
DI_PATCHPATH1[$i]=""
DI_PATCHPATH2[$i]=""
DI_PATCHARG[$i]=""
DI_PRECOMP[$i]=""
DI_COMPILE[$i]="make"
DI_INSTALL1[$i]="make install"
DI_INSTALL2[$i]=""
DF_FIRMFILES[$i]=""
DF_FIRMFILE[$i]=""
DF_FIRMPATH1[$i]=""
DF_FIRMPATH2[$i]=""
DF_FIRMDIR[$i]=""
DF_INSTALLDIR[$i]=""
DSITE[$i]="http://ndiswrapper.sourceforge.net"
DETECT_USB[$i]=""
DETECT_PCI[$i]=""
DETECT_CS[$i]=""

#END drivers
DCOUNT=$(($i+1))

#init install scripts
install_hostap() {
    if [ $KMINOR -eq 6 -a $KPATCH -lt 16 ]
    then
        #use external driver 0.4.7
        DI_DRIVERFILE[$1]="hostap-driver-0.4.9.tar.gz"
        DI_DRIVERPATH1[$1]="http://hostap.epitest.fi/releases/hostap-driver-0.4.9.tar.gz"
        DI_DRIVERPATH2[$1]=""
        DI_DRIVEREXDIR[$1]=""
        DI_DRIVERDIR[$1]="hostap-driver-0.4.9"
        DI_PATCHFILE[$1]="hostap-driver-0.4.9.patch"
        DI_PATCHPATH1[$1]="http://patches.aircrack-ng.org/hostap-driver-0.4.9.patch"
        DI_PATCHPATH2[$1]="http://patches.aircrack-ng.org/old/hostap-driver-0.4.9.patch"
        DI_PATCHARG[$1]="-p1"
        DI_COMPILE[$1]="$MAKE"
        DI_INSTALL1[$1]="$MAKE install"
    fi

    if [ $KMINOR -eq 6 -a $KPATCH -gt 18 ]
    then
        DI_PATCHFILE[$1]="hostap-kernel-2.6.18.patch"
        DI_PATCHPATH1[$1]="http://patches.aircrack-ng.org/hostap-kernel-2.6.18.patch"
        DI_PATCHPATH2[$1]="http://patches.aircrack-ng.org/old/hostap-kernel-2.6.18.patch"
    fi
}

install_hermes() {
    if [ $KMINOR -eq 4 ]
    then
        DI_DRIVERFILE[$1]="orinoco-0.13e-SN-3.tar.bz2"
        DI_DRIVERPATH1[$1]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-3.tar.bz2"
        DI_DRIVERPATH2[$1]=""
        DI_DRIVERDIR[$1]="orinoco-0.13e-SN-3"
    fi

    if [ $KMINOR -eq 6 -a $KPATCH -le 7 ]
    then
        DI_DRIVERFILE[$1]="orinoco-0.13e-SN-5.tar.bz2"
        DI_DRIVERPATH1[$1]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-5.tar.bz2"
        DI_DRIVERPATH2[$1]=""
        DI_DRIVERDIR[$1]="orinoco-0.13e-SN-5"
    fi

    if [ $KMINOR -eq 6 -a $KPATCH -ge 8 -a $KPATCH -le 10 ]
    then
        DI_DRIVERFILE[$1]="orinoco-0.13e-SN-7.tar.bz2"
        DI_DRIVERPATH1[$1]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-7.tar.bz2"
        DI_DRIVERPATH2[$1]=""
        DI_DRIVERDIR[$1]="orinoco-0.13e-SN-7"
    fi

    if [ $KMINOR -eq 6 -a $KPATCH -ge 11 -a $KPATCH -le 12 ]
    then
        DI_DRIVERFILE[$1]="orinoco-0.13e-SN-8.tar.bz2"
        DI_DRIVERPATH1[$1]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-8.tar.bz2"
        DI_DRIVERPATH2[$1]=""
        DI_DRIVERDIR[$1]="orinoco-0.13e-SN-8"
    fi

    if [ $KMINOR -eq 6 -a $KPATCH -ge 13 -a $KPATCH -le 14 ]
    then
        DI_DRIVERFILE[$1]="orinoco-0.13e-SN-9.tar.bz2"
        DI_DRIVERPATH1[$1]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-9.tar.bz2"
        DI_DRIVERPATH2[$1]=""
        DI_DRIVERDIR[$1]="orinoco-0.13e-SN-9"
    fi

    if [ $KMINOR -eq 6 -a $KPATCH -ge 18 -a $KPATCH -le 19 ]
    then
        DI_DRIVERFILE[$1]="orinoco-0.13e-SN-15.tar.bz2"
        DI_DRIVERPATH1[$1]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-15.tar.bz2"
        DI_DRIVERPATH2[$1]=""
        DI_DRIVERDIR[$1]="orinoco-0.13e-SN-15"
    fi

    if [ $KMINOR -eq 6 -a $KPATCH -ge 20 -a $KPATCH -le 25 ]
    then
        DI_DRIVERFILE[$1]="orinoco-0.13e-SN-16.tar.bz2"
        DI_DRIVERPATH1[$1]="http://www.projectiwear.org/~plasmahh/orinoco-0.13e-SN-16.tar.bz2"
        DI_DRIVERPATH2[$1]=""
        DI_DRIVERDIR[$1]="orinoco-0.13e-SN-16"
    fi
}

install_ipw2200() {
    if [ $KMINOR -eq 6 -a $KPATCH -lt 15 ]
    then
        DI_DRIVERFILE[$1]="ipw2200-1.1.4.tgz"
        DI_DRIVERPATH1[$1]="http://prdownloads.sourceforge.net/ipw2200/ipw2200-1.1.4.tgz?download"
        DI_DRIVERPATH2[$1]="http://prdownloads.sourceforge.net/ipw2200/ipw2200-1.1.4.tgz?download"
        DI_DRIVEREXDIR[$1]=""
        DI_DRIVERDIR[$1]="ipw2200-1.1.4"
        DI_PRECOMP[$1]=""
        DI_COMPILE[$1]="$MAKE -C $KSRC/ M=$D_DIR/${DI_DRIVERDIR[2]} modules"
        DI_INSTALL1[$1]="mkdir -p "$KMOD/kernel/drivers/net/wireless/ipw2200/""
        DI_INSTALL2[$1]="cp -f ipw2200.ko $KMOD/kernel/drivers/net/wireless/ipw2200/"
    fi
}

install_zd1211rw() {
    if [ $KMINOR -eq 6 -a $KPATCH -lt 18 ]
    then
        DI_DRIVERFILE[$1]="linux-2.6.18.tar.bz2"
        DI_DRIVERPATH1[$1]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.bz2"
        DI_DRIVERPATH2[$1]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.bz2"
        DI_DRIVEREXDIR[$1]="linux-2.6.18/drivers/net/wireless/zd1211rw"
    fi

    if [ $KMINOR -eq 6 -a $KPATCH -eq 20 ]
    then
        DI_PATCHFILE[$1]="zd1211rw_inject_2.6.20.patch"
        DI_PATCHPATH1[$1]="http://patches.aircrack-ng.org/zd1211rw_inject_2.6.20.patch"
        DI_PATCHPATH2[$1]="http://patches.aircrack-ng.org/old/zd1211rw_inject_2.6.20.patch"
    fi

    if [ $KMINOR -eq 6 -a $KPATCH -eq 21 ]
    then
        DI_PATCHFILE[$1]="zd1211rw_inject_2.6.21-gentoo.patch"
        DI_PATCHPATH1[$1]="http://patches.aircrack-ng.org/zd1211rw_inject_2.6.21-gentoo.patch"
        DI_PATCHPATH2[$1]="http://patches.aircrack-ng.org/old/zd1211rw_inject_2.6.21-gentoo.patch"
    fi

    if [ $KMINOR -eq 6 -a $KPATCH -ge 22 ]
    then
        DI_PATCHFILE[$1]="zd1211rw_inject_2.6.22.patch"
        DI_PATCHPATH1[$1]="http://patches.aircrack-ng.org/zd1211rw_inject_2.6.22.patch"
        DI_PATCHPATH2[$1]="http://patches.aircrack-ng.org/old/zd1211rw_inject_2.6.22.patch"
    fi
}

madwifi_install() {
    echo i | $MAKE install
}

ipw2100_precomp() {
    echo 'obj-$(CONFIG_IPW2100) += ipw2100.o' > Makefile
}

ipw2200_precomp() {
    echo 'obj-$(CONFIG_IPW2200) += ipw2200.o' > Makefile
}

rtl8187_prepatch() {
    $TAR xzf stack.tar.gz
    $TAR xzf drv.tar.gz
}

install_ieee80211() {
    #use old patch for kernel < 2.6.22
    if [ $KMINOR -eq 6 -a $KPATCH -lt 22 ]
    then
        SI_PATCHFILE[$1]="ieee80211_inject.patch"
        SI_PATCHPATH1[$1]="http://patches.aircrack-ng.org/ieee80211_inject.patch"
        SI_PATCHPATH2[$1]="http://patches.aircrack-ng.org/old/ieee80211_inject.patch"
    fi

    if [ $2 -eq 1 ]
    then
        #check if kernel source is in /usr/src/linux instead
        missing=0
        #check for default files README COPYING CREDITS (i hope every kernel source includes them all)
        if [ ! -f "/usr/src/linux/README" -o ! -f "/usr/src/linux/COPYING" -o ! -f "/usr/src/linux/CREDITS" ]
        then
            missing=1
        #   echo "Kernel source missing!"
#            return $ERROR
        fi

        #2nd check (in case README COPYING and CREDITS is included in kernel headers)
        #searches for .c files in "net" subdir
        if [ $missing = 0 -a x"`find "/usr/src/linux/net/" -name "*\.c" | head -n 1`" = x ]
        then
            missing=1
        #   echo "Kernel source missing!"
#            return $ERROR
        fi

        if [ $missing = 0 ]
        then
            SI_DRIVERPATH1[$1]=$SI_DRIVERPATH2[$1]
        else
            echo
            echo "Your kernel source is neither in \"$KSRC\" nor in \"/usr/src/linux\"."
            echo "Trying with vanilla source. (May fail on heavily patched distributions.)"
            echo "If it fails install your proper kernel source and rerun this script."
            echo
            sleep 3

            SI_DRIVERGET[$1]="wget"
            SI_DRIVERFILE[$1]="linux-$VANILLA.tar.bz2"
            SI_DRIVERPATH1[$1]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2"
            SI_DRIVERPATH2[$1]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2"
            SI_DRIVEREXDIR[$1]="linux-$VANILLA/net/ieee80211"
            SI_DRIVERDIR[$1]="ieee80211"
        fi
    fi
}

install_softmac() {
    #use no patch for kernel < 2.6.19
    if [ $KMINOR -eq 6 -a $KPATCH -lt 19 ]
    then
        SI_PATCHFILE[$1]=""
        SI_PATCHPATH1[$1]=""
        SI_PATCHPATH2[$1]=""
        SI_PATCHARG[$1]=""
    fi

    if [ $2 -eq 1 ]
    then
        #check if kernel source is in /usr/src/linux instead
        missing=0
        #check for default files README COPYING CREDITS (i hope every kernel source includes them all)
        if [ ! -f "/usr/src/linux/README" -o ! -f "/usr/src/linux/COPYING" -o ! -f "/usr/src/linux/CREDITS" ]
        then
            missing=1
        #   echo "Kernel source missing!"
#            return $ERROR
        fi

        #2nd check (in case README COPYING and CREDITS is included in kernel headers)
        #searches for .c files in "net" subdir
        if [ $missing = 0 -a x"`find "/usr/src/linux/net/" -name "*\.c" | head -n 1`" = x ]
        then
            missing=1
        #   echo "Kernel source missing!"
#            return $ERROR
        fi

        if [ $missing = 0 ]
        then
            SI_DRIVERPATH1[$1]=$SI_DRIVERPATH2[$1]
        else
            echo
            echo "Your kernel source is neither in \"$KSRC\" nor in \"/usr/src/linux\"."
            echo "Trying with vanilla source. (May fail on heavily patched distributions.)"
            echo "If it fails install your proper kernel source and rerun this script."
            echo
            sleep 3

            SI_DRIVERGET[$1]="wget"
            SI_DRIVERFILE[$1]="linux-$VANILLA.tar.bz2"
            SI_DRIVERPATH1[$1]="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2"
            SI_DRIVERPATH2[$1]="ftp://ftp.de.kernel.org/pub/linux/kernel/v2.6/linux-$VANILLA.tar.bz2"
            SI_DRIVEREXDIR[$1]="linux-$VANILLA/net/ieee80211/softmac"
            SI_DRIVERDIR[$1]="softmac"
        fi
    fi
}
#end

#install script doing the dirty work
#you're already in the correct dir
#old modules are unloaded
# 5 steps: get the source, get the patch, patch, compile, install
install_action() {
#write some info into log file
    echo "`date`" >> "$LOGFILE" 2>&1
    echo "Installing \"${DNAME[$1]}\" on $KVER." >> "$LOGFILE" 2>&1
#0 - check if all needed variables are set
    if [ x"${DI_DRIVERFILE[$1]}" == x -a x"${DI_DRIVERGET[$1]}" == "wget" ]
    then
        echo "DI_DRIVERFILE[$1] isn't set!"
        return $ERROR
    fi

    if [ x"${DI_DRIVERPATH1[$1]}" == x ]
    then
        echo "DI_DRIVERPATH1[$1] isn't set, you need at least one driver source!"
        return $ERROR
    fi

    if [ x"${DI_DRIVERDIR[$1]}" == x ]
    then
        echo "DI_DRIVERDIR[$1] isn't set!"
        return $ERROR
    fi

    if [ x"${DI_COMPILE[$1]}" == x ]
    then
        echo "DI_COMPILE[$1] isn't set!"
        return $ERROR
    fi

    if [ x"${DI_INSTALL1[$1]}" == x ]
    then
        echo "DI_INSTALL1[$1] isn't set!"
        return $ERROR
    fi

    if [ x"${DI_DRIVERGET[$1]}" == x ]
    then
        echo "DI_DRIVERGET[$1] isn't set!"
        return $ERROR
    fi

    if [ "${DI_DRIVERGET[$1]}" == "wget" -a x"$WGET" == x ]
    then
        echo "You need to install \"wget\" prior to installing ${DNAME[$1]}"
    fi

    if [ "${DI_DRIVERGET[$1]}" == "svn" -a x"$SVN" == x ]
    then
        echo "You need to install \"subversion\" prior to installing ${DNAME[$1]}"
    fi

    if [ "${DI_DRIVERGET[$1]}" == "cvs" -a x"$CVS" == x ]
    then
        echo "You need to install \"cvs\" prior to installing ${DNAME[$1]}"
    fi

    if [ "${DI_DRIVERGET[$1]}" == "git" -a x"$GIT" == x ]
    then
        echo "You need to install \"git\" prior to installing ${DNAME[$1]}"
    fi
#1 - get then correct source
    printf "1. Getting the source..."

    #get it with wget
    if [ "${DI_DRIVERGET[$1]}" == "wget"  ]
    then
        #is compressed source available? no - wget it
        if [ ! -f "${DI_DRIVERFILE[$1]}" ]
        then
            $WGET --progress=dot:mega -O "${DI_DRIVERFILE[$1]}" "${DI_DRIVERPATH1[$1]}" >> "$LOGFILE" 2>&1
            if [ "$?" != "0" ]
            then
                rm "${DI_DRIVERFILE[$1]}" 2>/dev/null
            fi
        fi

        #is compressed source available? no - wget it from mirror
        if [ ! -f "${DI_DRIVERFILE[$1]}" -a x"${DI_DRIVERPATH2[$1]}" != x ]
        then
            $WGET --progress=dot:mega -O "${DI_DRIVERFILE[$1]}" "${DI_DRIVERPATH2[$1]}" >> "$LOGFILE" 2>&1
            if [ "$?" != "0" ]
            then
                rm "${DI_DRIVERFILE[$1]}" 2>/dev/null
            fi
        fi

        #is compressed source available? no - try to locate it
        if [ ! -f "${DI_DRIVERFILE[$1]}" ]
        then
            cp "`locate "${DI_DRIVERFILE[$1]}" | grep "${DI_DRIVERFILE[$1]}$" | head -n 1`" ./ >> "$LOGFILE" 2>&1
            if [ "$?" != "0" ]
            then
                rm "${DI_DRIVERFILE[$1]}" 2>/dev/null
            fi
        fi

        #is compressed source available? no - abort install
        if [ ! -f "${DI_DRIVERFILE[$1]}" ]
        then
            echo "Couldn't find the correct driver file: ${DI_DRIVERFILE[$1]}"
            echo "The specified source seems to be down:"
            echo "${DI_DRIVERPATH1[$1]}"
            if [ x"${DI_DRIVERPATH2[$1]}" != x ]
            then
                echo "${DI_DRIVERPATH2[$1]}"
            fi
            echo "Get the file by hand, put it in \"$D_DIR/\""
            echo "and restart this installation."
            return $NO
        else
            printf "OK\n";
        fi

        printf "2. Extracting the source..."
        if [ -d "${DI_DRIVERDIR[$1]}" ]
        then
            #be carefull!! (deleting old source)
            rm -rf "${DI_DRIVERDIR[$1]}" >> "$LOGFILE" 2>&1
        fi

        if [ x"${DI_DRIVEREXDIR[$1]}" != x ]
        then
            #is tar gzip?
            if [ x"`echo "${DI_DRIVERFILE[$1]}" | grep ".tar.gz$"`" != x -o x"`echo "${DI_DRIVERFILE[$1]}" | grep ".tgz$"`" != x ]
            then
                $TAR xzf "${DI_DRIVERFILE[$1]}" "${DI_DRIVEREXDIR[$1]}" >> "$LOGFILE" 2>&1
            fi

            #is tar bzip2?
            if [ x"`echo "${DI_DRIVERFILE[$1]}" | grep ".tar.bz2$"`" != x ]
            then
                $TAR xjf "${DI_DRIVERFILE[$1]}" "${DI_DRIVEREXDIR[$1]}" >> "$LOGFILE" 2>&1
            fi
        else
            #is tar gzip?
            if [ x"`echo "${DI_DRIVERFILE[$1]}" | grep ".tar.gz$"`" != x -o x"`echo "${DI_DRIVERFILE[$1]}" | grep ".tgz$"`" != x ]
            then
                $TAR xzf "${DI_DRIVERFILE[$1]}" >> "$LOGFILE" 2>&1
            fi

            #is tar bzip2?
            if [ x"`echo "${DI_DRIVERFILE[$1]}" | grep ".tar.bz2$"`" != x ]
            then
                $TAR xjf "${DI_DRIVERFILE[$1]}" >> "$LOGFILE" 2>&1
            fi
        fi

        #is zip?
        if [ x"`echo "${DI_DRIVERFILE[$1]}" | grep ".zip$"`" != x ]
        then
            $UNZIP "${DI_DRIVERFILE[$1]}" >> "$LOGFILE" 2>&1
        fi

        #error? abort...
        if [ $? != "0" ]
        then
            echo "Unable to \"extract ${DI_DRIVERFILE[$1]}\""
            return $NO
        else
            printf "OK\n";
        fi
    fi

    #use svn
    if [ "${DI_DRIVERGET[$1]}" == "svn"  ]
    then
        if [ -d "${DI_DRIVERDIR[$1]}" ]
        then
            #be carefull!! (deleting old source)
            rm -rf "${DI_DRIVERDIR[$1]}" >> "$LOGFILE" 2>&1
        fi

        #if dir is missing (it should be) - check it out
        if [ ! -d "${DI_DRIVERDIR[$1]}" ]
        then
            $SVN co "${DI_DRIVERPATH1[$1]}" "${DI_DRIVERDIR[$1]}" >> "$LOGFILE" 2>&1
        fi

        #still missing? - use mirror/second source in case there is one
        if [ ! -d "${DI_DRIVERDIR[$1]}" -a x"${DI_DRIVERPATH2[$1]}" != x ]
        then
            $SVN co "${DI_DRIVERPATH2[$1]}" "${DI_DRIVERDIR[$1]}" >> "$LOGFILE" 2>&1
        fi

        printf "OK\n";

        echo "2. No extraction needed."
    fi

    #use cvs
    if [ "${DI_DRIVERGET[$1]}" == "cvs"  ]
    then
        if [ -d "${DI_DRIVERDIR[$1]}" ]
        then
            #be carefull!! (deleting old source)
            rm -rf "${DI_DRIVERDIR[$1]}" >> "$LOGFILE" 2>&1
        fi

        #if dir is missing (it should be) - check it out
        if [ ! -d "${DI_DRIVERDIR[$1]}" ]
        then
            $CVS -z3 "${DI_DRIVERPATH1[$1]}"  co -P "${DI_DRIVERPATH2[$1]}" >> "$LOGFILE" 2>&1
        fi
        printf "OK\n";
        echo "2. No extraction needed."
    fi

    #use git
    if [ "${DI_DRIVERGET[$1]}" == "git"  ]
    then
        if [ -d "${DI_DRIVERDIR[$1]}" ]
        then
            #be carefull!! (deleting old source)
            rm -rf "${DI_DRIVERDIR[$1]}" >> "$LOGFILE" 2>&1
        fi

        #if dir is missing (it should be) - check it out
        if [ ! -d "${DI_DRIVERDIR[$1]}" ]
        then
            $GIT clone "${DI_DRIVERPATH1[$1]}" >> "$LOGFILE" 2>&1
        fi

        #still missing? - use mirror/second source in case there is one
        if [ ! -d "${DI_DRIVERDIR[$1]}" -a x"${DI_DRIVERPATH2[$1]}" != x ]
        then
            $GIT clone "${DI_DRIVERPATH2[$1]}" >> "$LOGFILE" 2>&1
        fi
        printf "OK\n";
        echo "2. No extraction needed."
    fi

    #use cp
    if [ "${DI_DRIVERGET[$1]}" == "cp"  ]
    then
        if [ -d "${DI_DRIVERDIR[$1]}" ]
        then
            #be carefull!! (deleting old source)
            rm -rf "${DI_DRIVERDIR[$1]}" >> "$LOGFILE" 2>&1
        fi

        #if dir is missing (it should be) - check it out
        if [ ! -d "${DI_DRIVERDIR[$1]}" -a -d "${DI_DRIVERPATH1[$1]}" ]
        then
            cp -rf "${DI_DRIVERPATH1[$1]}" ./ >> "$LOGFILE" 2>&1
        fi

        #still missing? - use mirror/second source in case there is one
        if [ ! -d "${DI_DRIVERDIR[$1]}" -a -d "${DI_DRIVERPATH2[$1]}" ]
        then
            cp -rf "${DI_DRIVERPATH2[$1]}" ./ >> "$LOGFILE" 2>&1
        fi
        printf "OK\n";
        echo "2. No extraction needed."
    fi

    #extracted dir differs from expected one? rename it
    if [ x"${DI_DRIVEREXDIR[$1]}" != x -a x"${DI_DRIVEREXDIR[$1]}" != x"${DI_DRIVERDIR[$1]}" ]
    then
        mv "${DI_DRIVEREXDIR[$1]}" "${DI_DRIVERDIR[$1]}"
    fi

    #driver dir not available? abort...
    if [ ! -d "${DI_DRIVERDIR[$1]}" ]
    then
        echo "Directory \"${DI_DRIVERDIR[$1]}\" doesn't exist."
        return $NO
    fi

#2 - get the correct patch
    if [ x"${DI_PATCHFILE[$1]}" != x ]
    then
        printf "3. Getting the patch..."
        if [ ! -f "${DI_PATCHFILE[$1]}" ]
        then
            $WGET --progress=dot:mega -O "${DI_PATCHFILE[$1]}" "${DI_PATCHPATH1[$1]}" >> "$LOGFILE" 2>&1
            if [ "$?" != "0" ]
            then
                rm "${DI_PATCHFILE[$1]}" 2>/dev/null
            fi
        fi

        if [ ! -f "${DI_PATCHFILE[$1]}" -a x"${DI_PATCHPATH2[$1]}" != x ]
        then
            $WGET --progress=dot:mega -O "${DI_PATCHFILE[$1]}" "${DI_PATCHPATH2[$1]}" >> "$LOGFILE" 2>&1
            if [ "$?" != "0" ]
            then
                rm "${DI_PATCHFILE[$1]}" 2>/dev/null
            fi
        fi

        if [ ! -f "${DI_PATCHFILE[$1]}" ]
        then
            cp "`locate "${DI_PATCHFILE[$1]}" | grep "${DI_PATCHFILE[$1]}$" | head -n 1`" ./ >> "$LOGFILE" 2>&1
            if [ "$?" != "0" ]
            then
                rm "${DI_PATCHFILE[$1]}" 2>/dev/null
            fi
        fi

        if [ ! -f "${DI_PATCHFILE[$1]}" ]
        then
            echo "Couldn't find the correct patch: ${DI_PATCHFILE[$1]}"
            return $NO
        else
            printf "OK\n";
        fi

        cp "${DI_PATCHFILE[$1]}" "${DI_DRIVERDIR[$1]}"  >> "$LOGFILE" 2>&1

        cd "${DI_DRIVERDIR[$1]}"

    #prepatching
        if [ x"${DI_PREPATCH[$1]}" != x ]
        then
            ${DI_PREPATCH[$1]} >> "$LOGFILE" 2>&1
        fi

    #3 - patch it
        confused=0
        printf "4. Patching the source..."

        if [ x"`$PATCH --dry-run -f -s -N ${DI_PATCHARG[$1]} -i "${DI_PATCHFILE[$1]}" | grep "^No file"`" != x ]
        then
            $PATCH --dry-run -f -s -N ${DI_PATCHARG[$1]} -i "${DI_PATCHFILE[$1]}" >> "$LOGFILE" 2>&1
            echo "Patching failed for files (Couldn't be found)."
            confused=1
        fi

        if [ x"`$PATCH --dry-run -f -s -N ${DI_PATCHARG[$1]} -i "${DI_PATCHFILE[$1]}" | grep "FAILED"`" != x ]
        then
            $PATCH --dry-run -f -s -N ${DI_PATCHARG[$1]} -i "${DI_PATCHFILE[$1]}" >> "$LOGFILE" 2>&1
            echo "Patching failed for some hunks."
            confused=1
        fi

        if [ x"`$PATCH --dry-run -f -s -N ${DI_PATCHARG[$1]} -i "${DI_PATCHFILE[$1]}" | grep "Reversed"`" != x ]
        then
            $PATCH --dry-run -f -s -N ${DI_PATCHARG[$1]} -i "${DI_PATCHFILE[$1]}" >> "$LOGFILE" 2>&1
            echo "Already patched?"
            confused=1
        fi

        $PATCH -N -f ${DI_PATCHARG[$1]} -i "${DI_PATCHFILE[$1]}" >> "$LOGFILE" 2>&1
        if [ x"$confused" == "x0" ]
        then
            printf "OK\n";
        fi
    else
        cd "${DI_DRIVERDIR[$1]}"
        echo "3./4. Not patching."
    fi

#4 - compile it
    if [ x"${DI_PRECOMP[$1]}" != x ]
    then
        ${DI_PRECOMP[$1]} >> "$LOGFILE" 2>&1
    fi

    #set all the needed variables
    if [ x"${DCONFIGS[$1]}" != x ]
    then
        for v in ${DCONFIGS[$1]}
        do
            export $v
        done
    fi

    printf "5. Compiling the source..."
    PWD=`pwd`

    ${DI_COMPILE[$1]} >> "$LOGFILE" 2>&1
    if [ $? != "0" ]
    then
        return $NO
    else
        printf "OK\n"
    fi

    if [ $NO_INSTALL = $YES ]
    then
        return $YES
    fi

#5 - install it
    printf "6. Installing the modules..."
    ${DI_INSTALL1[$1]} >> "$LOGFILE" 2>&1
    if [ x"${DI_INSTALL2[$1]}" != x ]
    then
        ${DI_INSTALL2[$1]}
    fi

    if [ $? != "0" ]
    then
        return $NO
    else
        printf "OK\n"
    fi

    if [ $NO_FIRMWARE = $YES ]
    then
        return $YES
    fi

#6 - check/install firmware
    printf "7. Checking firmware..."
    if [ x"${DF_FIRMFILES[$1]}" != x -a x"${DF_FIRMPATH1[$1]}" != x ]
    then
        firmware_action $1
        if [ $? == "$NO" ]
        then
            return $NO
        else
            printf "OK\n"
        fi
    else
        printf "OK\n"
    fi

    return $YES
}
#END install scripts

firmware_action() {
    needs_install=0

    #change back to driver directory
    cd "$D_DIR"

    if [ x"${DF_FIRMFILES[$1]}" != x -a x"${DF_FIRMPATH1[$1]}" != x ]
    then
        for ffp in ${DF_FIRMFILES[$1]}
        do
            if [ x"`find "$FIRMPATH" -name "$ffp"`" == x ]
            then
                needs_install=1
            fi
        done
        if [ x"$needs_install" == "x0" ]
        then
            return $YES
        fi
        #firmware appears to be missing, install it into $FIRMPATH

        #download it if its not available
        #is compressed firmware available? no - wget it
        if [ ! -f "${DF_FIRMFILE[$1]}" ]
        then
            $WGET --progress=dot:mega -O "${DF_FIRMFILE[$1]}" "${DF_FIRMPATH1[$1]}" >> "$LOGFILE" 2>&1
            if [ "$?" != "0" ]
            then
                rm "${DF_FIRMFILE[$1]}" 2>/dev/null
            fi
        fi

        #is compressed firmware available? no - wget it from mirror
        if [ ! -f "${DF_FIRMFILE[$1]}" -a x"${DF_FIRMPATH2[$1]}" != x ]
        then
            $WGET --progress=dot:mega -O "${DF_FIRMFILE[$1]}" "${DF_FIRMPATH2[$1]}" >> "$LOGFILE" 2>&1
            if [ "$?" != "0" ]
            then
                rm "${DF_FIRMFILE[$1]}" 2>/dev/null
            fi
        fi

        #is compressed firmware available? no - try to locate it
        if [ ! -f "${DF_FIRMFILE[$1]}" ]
        then
            cp "`locate "${DF_FIRMFILE[$1]}" | grep "${DF_FIRMFILE[$1]}$" | head -n 1`" ./ >> "$LOGFILE" 2>&1
            if [ "$?" != "0" ]
            then
                rm "${DF_FIRMFILE[$1]}" 2>/dev/null
            fi
        fi

        #is compressed firmware available? no - abort install
        if [ ! -f "${DF_FIRMFILE[$1]}" ]
        then
            echo "Couldn't find the correct firmware file: ${DF_FIRMFILE[$1]}"
            echo "The specified source seems to be down:"
            echo "${DF_FIRMPATH1[$1]}"
            if [ x"${DF_FIRMPATH2[$1]}" != x ]
            then
                echo "${DF_FIRMPATH2[$1]}"
            fi
            echo "Get the file by hand, put it in \"$D_DIR/\""
            echo "and restart this installation."
            return $NO
        fi

        if [ -d "${DF_FIRMDIR[$1]}" ]
        then
            #be carefull!! (deleting old firmware)
            rm -rf "${DF_FIRMDIR[$1]}" >> "$LOGFILE" 2>&1
        fi

        #is tar gzip?
        if [ x"`echo "${DF_FIRMFILE[$1]}" | grep ".tar.gz$"`" != x -o x"`echo "${DF_FIRMFILE[$1]}" | grep ".tgz$"`" != x ]
        then
            $TAR xzf "${DF_FIRMFILE[$1]}" >> "$LOGFILE" 2>&1
        fi

        #is tar bzip2?
        if [ x"`echo "${DF_FIRMFILE[$1]}" | grep ".tar.bz2$"`" != x ]
        then
            $TAR xjf "${DF_FIRMFILE[$1]}" >> "$LOGFILE" 2>&1
        fi

        #is zip?
        if [ x"`echo "${DF_FIRMFILE[$1]}" | grep ".zip$"`" != x ]
        then
            $UNZIP "${DF_FIRMFILE[$1]}" >> "$LOGFILE" 2>&1
        fi

        #error? abort...
        if [ $? != "0" ]
        then
            echo "Unable to extract \"${DF_FIRMFILE[$1]}\"" >> "$LOGFILE"
            return $NO
        fi

        #extracted firmware, change dir
        cd "${DF_FIRMDIR[$1]}"

        if [ ! -d "$FIRMPATH/${DF_INSTALLDIR[$1]}" ]
        then
            mkdir -p "$FIRMPATH/${DF_INSTALLDIR[$1]}" >> "$LOGFILE" 2>&1
        fi

        #check if there are files available
        if [ x"`ls 2>/dev/null`" == x ]
        then
            echo "No firmware found in downloaded archive."
            return $NO
        fi

        for iffp in ${DF_FIRMFILES[$1]}
        do
            firmfilepath="`find -name "$iffp" | tail -n 1`"
            if [ x"$firmfilepath" != x ]
            then
                cp "$firmfilepath" "$FIRMPATH/${DF_INSTALLDIR[$1]}" >> "$LOGFILE" 2>&1
            fi
        done

        #error? abort...
        if [ $? != "0" ]
        then
            echo "Unable to install firmware."
            return $NO
        fi
    else
        echo "No firmware information available."
        return $ERROR
    fi

    return $YES
}

isInstalled() {
    #_D_river or _S_tack? neither? abort
    if [ x"$2" != "xD" -a x"$2" != "xS" ]
    then
        echo "Invalid subset [D/S]!"
        return $ERROR
    fi

    if [ x"$2" == "xD" ]
    then
        if [ $1 -lt 0 -o $1 -ge ${DCOUNT} ]
        then
            echo "Invalid driver number!"
            return $ERROR
        fi

        #no module specified, thus return $NO
        if [ x"${DMODULE[$1]}" == x ]
        then
            return $NO
        fi

        if [ x"`$MODPROBE -l | grep "\/"${DMODULE[$1]}"\.ko"`" != x ]
        then
            if [ x"${DMODINFO[$1]}" != x ]
            then
                modfile="`$MODPROBE -l | grep "\/"${DMODULE[$1]}"\.ko"`"
                if [ x"`modinfo "$modfile" | grep "${DMODINFO[$1]}"`" != x ]
                then
                    return $YES
                else
                    return $NO
                fi
            else
                return $YES
            fi
        else
            return $NO
        fi
    fi

    if [ x"$2" == "xS" ]
    then
        if [ $1 -lt 0 -o $1 -ge ${SCOUNT} ]
        then
            echo "Invalid stack number!"
            return $ERROR
        fi

        #no module specified, thus return $NO
        if [ x"${SMODULE[$1]}" == x ]
        then
            return $NO
        fi

        if [ x"`$MODPROBE -l | grep "\/"${SMODULE[$1]}"\.ko"`" != x ]
        then
            return $YES
        else
            return $NO
        fi
    fi

    return $ERROR
}

isInstalledFirmware() {
    isInstalled=1
    if [ $1 -lt 0 -o $1 -ge ${DCOUNT} ]
    then
        echo "Invalid driver number!"
        return $ERROR
    fi

    #no module specified, thus return $NO
    if [ x"${DF_FIRMFILES[$1]}" == x ]
    then
        return $ERROR
    fi

    for iiffp in ${DF_FIRMFILES[$1]}
    do
        if [ x"`find "$FIRMPATH" -name "$iiffp"`" == x ]
        then
            isInstalled=0
        fi
    done

    if [ x"$isInstalled" == "x1" ]
    then
        return $YES
    else
        return $NO
    fi

    return $ERROR
}

isCompiled() {
    #_D_river or _S_tack? neither? abort
    if [ x"$2" != "xD" -a x"$2" != "xS" ]
    then
        echo "Invalid subset [D/S]!"
        return $ERROR
    fi

    if [ x"$2" == "xD" ]
    then
        if [ $1 -lt 0 -o $1 -ge ${DCOUNT} ]
        then
            echo "Invalid driver number!"
            return $ERROR
        fi

        #no module specified, thus return $NO
        if [ x"${DMODULE[$1]}" == x ]
        then
            return $NO
        fi

        if [ ! -d "$D_DIR/" ]
        then
            return $ERROR
        fi

        cd "$D_DIR/"

        if [ ! -d "${DI_DRIVERDIR[$1]}" ]
        then
            return $ERROR
        fi

        cd "${DI_DRIVERDIR[$1]}/"

        if [ x"`find -name ${DMODULE[$1]}".ko"`" != x ]
        then
            if [ x"${DMODINFO[$1]}" != x ]
            then
                modfile="`find -name ${DMODULE[$1]}".ko"`"
                if [ x"`modinfo "$modfile" | grep "${DMODINFO[$1]}"`" != x ]
                then
                    return $YES
                else
                    return $NO
                fi
            else
                return $YES
            fi
        else
            return $NO
        fi
    fi

    if [ x"$2" == "xS" ]
    then
        if [ $1 -lt 0 -o $1 -ge ${SCOUNT} ]
        then
            echo "Invalid stack number!"
            return $ERROR
        fi

        #no module specified, thus return $NO
        if [ x"${SMODULE[$1]}" == x ]
        then
            return $NO
        fi

        if [ ! -d "$D_DIR/" ]
        then
            return $ERROR
        fi

        cd "$D_DIR/"

        if [ ! -d "${SI_DRIVERDIR[$1]}" ]
        then
            return $ERROR
        fi

        cd "${SI_DRIVERDIR[$1]}/"

        if [ x"`find -name ${SMODULE[$1]}".ko"`" != x ]
        then
            return $YES
        else
            return $NO
        fi
    fi

    return $ERROR
}

isLoaded() {
    #_D_river or _S_tack? neither? abort
    if [ x"$2" != "xD" -a x"$2" != "xS" ]
    then
        echo "Invalid subset [D/S]!"
        return $ERROR
    fi

    if [ x"$2" == "xD" ]
    then
        if [ $1 -lt 0 -o $1 -ge $DCOUNT ]
        then
            echo "Invalid driver number!"
            return $ERROR
        fi

        #no module specified, thus return $NO
        if [ x"${DMODULE[$1]}" == x ]
        then
            return $NO
        fi

        if [ x"`lsmod | grep ${DMODULE[$1]}" "`" != x ]
        then
            if [ x"${DMODINFO[$1]}" != x ]
            then
                if [ x"`modinfo "${DMODULE[$1]}" | grep "${DMODINFO[$1]}"`" != x ]
                then
                    return $YES
                else
                    return $NO
                fi
            else
                return $YES
            fi
        else
            return $NO
        fi
    fi

    if [ x"$2" == "xS" ]
    then
        if [ $1 -lt 0 -o $1 -ge $SCOUNT ]
        then
            echo "Invalid stack number!"
            return $ERROR
        fi

        #no module specified, thus return $NO
        if [ x"${SMODULE[$1]}" == x ]
        then
            return $NO
        fi

        if [ x"`lsmod | grep ${SMODULE[$1]}" "`" != x ]
        then
            return $YES
        else
            return $NO
        fi
    fi

    return $ERROR
}

isInKernel() {
    #_D_river or _S_tack? neither? abort
    if [ x"$2" != "xD" -a x"$2" != "xS" ]
    then
        echo "Invalid subset [D/S]!"
        return $ERROR
    fi

    if [ x"$2" == "xD" ]
    then
        if [ $1 -lt 0 -o $1 -ge $DCOUNT ]
        then
            echo "Invalid driver number!"
            return $ERROR
        fi

        if [ "x${DCONFIG[$1]}" != x ]
        then
            if [ x"`grep ${DCONFIG[$1]}"y" "/lib/modules/"$KVER"/build/.config"`" != x ]
            then
                return $YES
            else
                return $NO
            fi
        else
            return $NO
        fi
    fi

    if [ x"$2" == "xS" ]
    then
        if [ $1 -lt 0 -o $1 -ge $SCOUNT ]
        then
            echo "Invalid stack number!"
            return $ERROR
        fi

        if [ x${SCONFIG[$1]} != x ]
        then
            if [ x"`grep ${SCONFIG[$1]}"y" "/lib/modules/"$KVER"/build/.config"`" != x ]
            then
                return $YES
            else
                return $NO
            fi
        else
            return $NO
        fi
    fi

    return $ERROR
}

listInstalledStacks() {
    echo "Found following stacks installed:"
    i=0
    while [ $i -lt $SCOUNT ]
    do
        isInstalled $i "S"
        if [ $? -eq $YES ]
        then
            printf "$i. ${SNAME[$i]}\n"
        fi
        i=$(($i+1))
    done
}

listInstalledDrivers() {
    echo "Found following drivers installed:"
    i=0
    while [ $i -lt $DCOUNT ]
    do
        isInstalled $i "D"
        if [ $? -eq $YES ]
        then
            if [ x"${DSTACK[$i]}" != x ]
            then
                printf "$i. ${DNAME[$i]} - ${SNAME[${DSTACK[$i]}]}\n"
            else
                printf "$i. ${DNAME[$i]}\n"
            fi
        fi
        i=$(($i+1))
    done
}

listInstalledFirmware() {
    echo "Found following firmwares installed:"
    i=0
    while [ $i -lt $DCOUNT ]
    do
        isInstalledFirmware $i
        ret=$?
        if [ $ret -eq $YES ]
        then
            if [ x"${DSTACK[$i]}" != x ]
            then
                printf "$i. ${DNAME[$i]} - ${SNAME[${DSTACK[$i]}]}\n"
            else
                printf "$i. ${DNAME[$i]}\n"
            fi
        fi
        i=$(($i+1))
    done
}

listLoadedStacks() {
    echo "Found following stacks loaded (as module):"
    i=0
    while [ $i -lt $SCOUNT ]
    do
        isLoaded $i "S"
        if [ $? -eq $YES ]
        then
            printf "$i. ${SNAME[$i]}\n"
        fi
        i=$(($i+1))
    done
}

listLoadedDrivers() {
    echo "Found following drivers loaded (as module):"
    i=0
    while [ $i -lt $DCOUNT ]
    do
        isLoaded $i "D"
        if [ $? -eq $YES ]
        then
            if [ x"${DSTACK[$i]}" != x ]
            then
                printf "$i. ${DNAME[$i]} - ${SNAME[${DSTACK[$i]}]}\n"
            else
                printf "$i. ${DNAME[$i]}\n"
            fi
        fi
        i=$(($i+1))
    done
}

listKernelStacks() {
    echo "Found following stacks in the Kernel:"
    i=0
    while [ $i -lt $SCOUNT ]
    do
        isInKernel $i "S"
        if [ $? -eq $YES ]
        then
            printf "$i. ${SNAME[$i]}\n"
        fi
        i=$(($i+1))
    done
}

listKernelDrivers() {
    echo "Found following drivers in the Kernel:"
    i=0
    while [ $i -lt $DCOUNT ]
    do
        isInKernel $i "D"
        if [ $? -eq $YES ]
        then
            if [ x"${DSTACK[$i]}" != x ]
            then
                printf "$i. ${DNAME[$i]} - ${SNAME[${DSTACK[$i]}]}\n"
            else
                printf "$i. ${DNAME[$i]}\n"
            fi
        fi
        i=$(($i+1))
    done
}

listSupportedStacks() {
    echo "Following stacks are supported:"
    i=0
    while [ $i -lt $SCOUNT ]
    do
        if [ x"${SMODULE[$i]}" != x ]
        then
            printf "$i. ${SNAME[$i]}\n"
        fi
        i=$(($i+1))
    done
}

listSupportedDrivers() {
    echo "Following drivers are supported:"
    i=0
    while [ $i -lt $DCOUNT ]
    do
        if [ x"${DMODULE[$i]}" != x ]
        then
            if [ x"${DSTACK[$i]}" != x ]
            then
                printf "$i. ${DNAME[$i]} - ${SNAME[${DSTACK[$i]}]}\n"
            else
                printf "$i. ${DNAME[$i]}\n"
            fi
        fi
        i=$(($i+1))
    done
}

unloadDriver() {
    if [ $1 -lt 0 -o $1 -ge $DCOUNT ]
    then
        echo "Invalid driver number!"
        return $ERROR
    fi

    isLoaded $1 "D"
    if [ $? -eq $NO ]
    then
        echo "Driver isn't loaded."
        return $NO
    fi

    last=200
    current=0

    for i in ${DMODULES[$1]}
    do
        i="`echo "$i" | sed 's/-/_/'`"
        if [ x"`lsmod | grep $i" "`" != x ]
        then
            current=$(($current+1))
        fi
    done

    while [ $current -lt $last -a $current -gt 0 ]
    do
        last=$current
        current=0
        for i in ${DMODULES[$1]}
        do
            i="`echo "$i" | sed 's/-/_/'`"
            rmmod $i 2>/dev/null
            if [ x"`lsmod | grep $i" "`" != x ]
            then
                current=$(($current+1))
            fi
        done
    done

    if [ $current -eq 0 ]
    then
        return $YES
    else
        return $NO
    fi
}

insertDriver() {
    if [ $1 -lt 0 -o $1 -ge $DCOUNT ]
    then
        echo "Invalid driver number!"
        return $ERROR
    fi

    isInKernel $1 "D"
    if [ $? -eq $YES ]
    then
        echo "Cannot insert an in-kernel driver."
        return $NO
    fi

    isCompiled $1 "D"
    if [ $? -eq $NO ]
    then
        echo "Driver isn't compiled."
        return $NO
    fi

    isLoaded $1 "D"
    if [ $? -eq $YES ]
    then
        unloadDriver $1
        if [ $? -ne $YES ]
        then
            echo "Can't unload current driver."
            echo "You need to remove it from memory."
            echo
            return $NO
        fi
    fi

    last=-1
    current=0
    modnum=0

    cd "$D_DIR/${DI_DRIVERDIR[$1]}/"

    for i in ${DMODULES[$1]}
    do
        if [ x"`find -name $i".ko"`" != x ]
        then
            INSMOD[$modnum]="`find -name $i".ko"`"
            CHECKMOD[$modnum]="$i"
            modnum=$(($modnum+1))
        fi
    done

    if [ $modnum -eq 0 ]
    then
        echo "Driver isn't compiled."
        return $NO
    fi

    while [ $current -gt $last ]
    do
        last=$current
        current=0
        i=0
        while [ $i -lt $modnum ]
        do
            insmod ${INSMOD[$i]} 2>/dev/null
            j="`echo ${CHECKMOD[$i]} | sed 's/-/_/'`"
            if [ x"`lsmod | grep "$j"`" != x ]
            then
                current=$(($current+1))
            fi
            i=$(($i+1))
        done
    done

    if [ $current -eq $modnum ]
    then
        return $YES
    else
        return $NO
    fi
}

loadDriver() {
    if [ $1 -lt 0 -o $1 -ge $DCOUNT ]
    then
        echo "Invalid driver number!"
        return $ERROR
    fi

    isInKernel $1 "D"
    if [ $? -eq $YES ]
    then
        echo "Cannot load an in-kernel driver."
        return $NO
    fi

    isInstalled $1 "D"
    if [ $? -eq $NO ]
    then
        echo "Driver is not installed."
        return $NO
    fi

    isLoaded $1 "D"
    if [ $? -eq $YES ]
    then
        echo "Driver is already loaded."
        return $NO
    fi

    for i in ${DMODULES[$1]}
    do
        i="`echo "$i" | sed 's/-/_/'`"
        $MODPROBE $i 2>/dev/null
    done

    isLoaded $1 "D"
    if [ $? -eq $NO ]
    then
        return $NO
    fi

    return $YES
}

installDriver() {
#check if argument is out of range
    if [ $1 -lt 0 -o $1 -ge $DCOUNT ]
    then
        echo "Invalid driver number!"
        return $ERROR
    fi

#check if atleast kernel headers are installed
    if [ ! -f "$KSRC/.config" ]
    then
        echo "Kernel headers missing!"
        return $ERROR
    fi

#check if GCC is in path
    if [ x"$GCC" == x ]
    then
        echo "GCC not installed!"
        return $ERROR
    fi

#check if gcc version matches the kernel gcc version
    gccvers="`$GCC --version | head -n 1 | sed 's/^[^ ]* [^ ]* \([2-4]..*\)$/\1/'`"
    ret="`cat /proc/version | grep "$gccvers"`"

    if [ x"$ret" == x ]
    then
        echo "Your current GCC version doesn't match the version your kernel was compiled with."
        echo "The build modules will probably not load into the running kernel."
    fi

#cd into driver build directory
    mkdir -p "$D_DIR/"
    if [ ! -d "$D_DIR/" ]
    then
        echo "Directory \"$D_DIR/\" not available."
        return $ERROR
    fi

    cd "$D_DIR/"

#run the custom installscript
    if [ x"${DI_INIT[$1]}" != x ]
    then
        ${DI_INIT[$1]} $1
    fi

    install_action $1

    ret=$?

    echo "Running \"depmod -ae\"..."
    depmod -ae

    return $ret
}

installFirmware() {
#check if argument is out of range
    if [ $1 -lt 0 -o $1 -ge $DCOUNT ]
    then
        echo "Invalid driver number!"
        return $ERROR
    fi

#cd into driver build directory
    mkdir -p "$D_DIR/"
    if [ ! -d "$D_DIR/" ]
    then
        echo "Directory \"$D_DIR/\" not available."
        return $ERROR
    fi

    firmware_action $1

    ret=$?
    return $ret
}

installStack() {
#check if argument is out of range
    if [ $1 -lt 0 -o $1 -ge $SCOUNT ]
    then
        echo "Invalid stack number!"
        return $ERROR
    fi

#check if atleast kernel headers are installed
    if [ ! -f "$KSRC/.config" ]
    then
        echo "Kernel headers missing!"
        return $ERROR
    fi

#check if kernel source is installed
    missing=0
    #check for default files README COPYING CREDITS (i hope every kernel source includes them all)
    if [ ! -f "$KSRC/README" -o ! -f "$KSRC/COPYING" -o ! -f "$KSRC/CREDITS" ]
    then
        missing=1
#        echo "Kernel source missing!"
#        return $ERROR
    fi

    #2nd check (in case README COPYING and CREDITS is included in kernel headers)
    #searches for .c files in "net" subdir

    if [ $missing = 0 -a x"`find "$KSRC/net/" -name "*\.c" | head -n 1`" = x ]
    then
        missing=1
#        echo "Kernel source missing!"
#        return $ERROR
    fi

#check if GCC is in path
    if [ x"$GCC" == x ]
    then
        echo "GCC not installed!"
        return $ERROR
    fi

#check if gcc version matches the kernel gcc version
    gccvers="`$GCC --version | head -n 1 | sed 's/^[^ ]* [^ ]* \([2-4]..*\)$/\1/'`"
    ret="`cat /proc/version | grep "$gccvers"`"

    if [ x"$ret" == x ]
    then
        echo "Your current GCC version doesn't match the version your kernel was compiled with."
        echo "The build modules will probably not load into the running kernel."
    fi

#cd into driver build directory
    mkdir -p "$D_DIR/"
    if [ ! -d "$D_DIR/" ]
    then
        echo "Directory \"$D_DIR/\" not available."
        return $ERROR
    fi

    cd "$D_DIR/"

#run the custom installscript
    if [ x"${SI_INIT[$1]}" != x ]
    then
        ${SI_INIT[$1]} $missing
    fi

#map stack install to driver install, so we can use the install_action functionality
    DCONFIGS[999]=${SCONFIGS[$1]}
#    DI_INIT[999]=${SI_INIT[$1]}
    DI_DRIVERGET[999]=${SI_DRIVERGET[$1]}
    DI_DRIVERFILE[999]=${SI_DRIVERFILE[$1]}
    DI_DRIVERPATH1[999]=${SI_DRIVERPATH1[$1]}
    DI_DRIVERPATH2[999]=${SI_DRIVERPATH2[$1]}
    DI_DRIVEREXDIR[999]=${SI_DRIVEREXDIR[$1]}
    DI_DRIVERDIR[999]=${SI_DRIVERDIR[$1]}
    DI_PREPATCH[999]=${SI_PREPATCH[$1]}
    DI_PATCHFILE[999]=${SI_PATCHFILE[$1]}
    DI_PATCHPATH1[999]=${SI_PATCHPATH1[$1]}
    DI_PATCHPATH2[999]=${SI_PATCHPATH2[$1]}
    DI_PATCHARG[999]=${SI_PATCHARG[$1]}
    DI_PRECOMP[999]=${SI_PRECOMP[$1]}
    DI_COMPILE[999]=${SI_COMPILE[$1]}
    DI_INSTALL1[999]=${SI_INSTALL1[$1]}
    DI_INSTALL2[999]=${SI_INSTALL2[$1]}

    install_action "999"

    ret=$?

    echo "Running \"depmod -ae\"..."
    depmod -ae

    return $ret
}

removeDriver() {
#check if argument is out of range
    if [ "$1" -lt 0 -o "$1" -ge "$DCOUNT" ]
    then
        echo "Invalid driver number!"
        return $ERROR
    fi

#check if its in-kernel
    isInKernel $1 "D"
    if [ $? -eq $YES ]
    then
        echo "Cannot remove drivers build into the kernel!"
        exit
    fi

#check if its installed
    isInstalled $1 "D"
    if [ $? -eq $NO ]
    then
        echo "This driver isn't installed and thus cannot be removed."
        exit
    fi

    echo "Starting to remove \"${DNAME[$1]}\" driver"

#check if its loaded and unload befor trying to remove
    isLoaded $1 "D"
    if [ $? -eq $YES ]
    then
        unloadDriver $1
        if [ $? -eq $NO -o $? -eq $ERROR ]
        then
            echo "Couldn't unload the driver."
        fi
    fi

#loop through the modules, find and rm them
    for i in ${DMODULES[$1]}
    do
        if [ -f "`$MODPROBE -l | grep \/$i\.ko`" ]
        then
            rm -i "`$MODPROBE -l | grep \/$i\.ko`"
        fi
    done

    echo "Running \"depmod -ae\"..."
    depmod -ae

    return $YES
}

removeFirmware() {
#check if argument is out of range
    if [ "$1" -lt 0 -o "$1" -ge "$DCOUNT" ]
    then
        echo "Invalid driver number!"
        return $ERROR
    fi

#check if its installed
    isInstalledFirmware $1
    if [ $? -eq $NO ]
    then
        echo "This firmware isn't installed and thus cannot be removed."
        exit
    fi

    echo "Starting to remove \"${DNAME[$1]}\" firmware"

#loop through the modules, find and rm them
    for i in ${DF_FIRMFILES[$1]}
    do
        oldnumfiles=999
        numfiles="`find "$FIRMPATH" -name "$i" 2>/dev/null | wc -l`"
        while [ "$numfiles" -gt 0 -a "$numfiles" -lt "$oldnumfiles" ]
        do
            fileone="`find "$FIRMPATH" -name "$i" 2>/dev/null | head -n 1`"
            rm -i "$fileone"

            oldnumfiles=$numfiles
            if [ ! -f "$fileone" ]
            then
                numfiles="`find "$FIRMPATH" -name "$i" 2>/dev/null | wc -l`"
            fi
        done
    done

    return $YES
}

removeStack() {
#check if argument is out of range
    if [ "$1" -lt 0 -o "$1" -ge "$SCOUNT" ]
    then
        echo "Invalid stack number!"
        return $ERROR
    fi

    echo "Starting to remove \"${SNAME[$1]}\" driver"

#loop through the modules, find and rm them
    for i in ${SMODULES[$1]}
    do
        if [ -f "`$MODPROBE -l | grep \/$i\.ko`" ]
        then
            rm -i "`$MODPROBE -l | grep \/$i\.ko`"
        fi
    done

    echo "Running \"depmod -ae\"..."
    depmod -ae

    return $YES
}

checkusb() {
    if [ x"$LSUSB" != x ]
    then
        usbnum=`$LSUSB | wc -l`
        j=1
        if [ x"`$LSUSB -vvv | grep -i "$1"`" != x ]
        then
            while [ $j -le $usbnum ]
            do
                bus=`$LSUSB | head -n $j | tail -n 1 | awk '{print $2}' | sed 's/^0*//'`
                dev=`$LSUSB | head -n $j | tail -n 1 | awk '{print $4}' | sed 's/^0*//' | sed 's/:$//'`

                if [ x"$bus" == x ]
                then
                    bus=0
                fi
                if [ x"$dev" == x ]
                then
                    dev=0
                fi

                if [ x"`$LSUSB -s "$bus:$dev" -v | grep -i "$1"`" != x ]
                then
                    echo `$LSUSB -s "$bus:$dev"`
                fi
                j=$(($j+1))
            done
        fi
    fi
}

checkpci() {
    if [ x"$LSPCI" != x ]
    then
        pcinum=`$LSPCI | wc -l`
        j=1
        if [ x"`$LSPCI | grep -i "$1"`" != x ]
        then
            while [ $j -le $pcinum ]
            do
                if [ x"`$LSPCI | head -n $j | tail -n 1 | grep -i "$1"`" != x ]
                then
                    echo `$LSPCI | head -n $j | tail -n 1`
                fi
                j=$(($j+1))
            done
        fi
    fi
}

checkpcmcia() {
    if [ x"$LSPCMCIA" != x -a x"$CARDCTL" != x ]
    then
        pcmcianum=10
        j=0
        if [ x"`$LSPCMCIA -v | grep -i "$1"`" != x ]
        then
            while [ $j -le $pcmcianum ]
            do
                manfid=`$CARDCTL ident $j | grep "manfid" | sed 's/^.*: //'`

                if [ x"$manfid" == x ]
                then
                    manfid="0x0000, 0x0000"
                fi

                if [ x"`$CARDCTL ident $j | grep -i "$1"`" != x ]
                then
                    echo "ID:"$manfid "`$CARDCTL ident $j | head -n 1 | sed 's/^.*: //'`"
                fi
                j=$(($j+1))
            done
        fi
    fi
}

detectAdapters() {
    echo
#usb
    if [ x"$LSUSB" != x ]
    then
        i=0
        while [ $i -lt $DCOUNT ]
        do
            if [ x"${DETECT_USB[$i]}" != x ]
            then
                if [ x"`$LSUSB -vvv | grep "${DETECT_USB[$i]}"`" != x ]
                then
                    echo "Found \"${DNAME[$i]}\" device: (${DMODULE[$i]})"
                    checkusb "${DETECT_USB[$i]}"
                    echo
                fi
            fi
            i=$(($i+1))
        done
    fi

#pci
    if [ x"$LSPCI" != x ]
    then
        i=0
        while [ $i -lt $DCOUNT ]
        do
            if [ x"${DETECT_PCI[$i]}" != x ]
            then
                if [ x"`$LSPCI | grep "${DETECT_PCI[$i]}"`" != x ]
                then
                    echo "Found \"${DNAME[$i]}\" device: (${DMODULE[$i]})"
                    checkpci "${DETECT_PCI[$i]}"
                    echo
                fi
            fi
            i=$(($i+1))
        done
    fi

#pcmcia
    if [ x"$LSPCMCIA" != x ]
    then
        i=0
        while [ $i -lt $DCOUNT ]
        do
            if [ x"${DETECT_CS[$i]}" != x ]
            then
                if [ x"`$LSPCMCIA -vvv | grep "${DETECT_CS[$i]}"`" != x ]
                then
                    echo "Found \"${DNAME[$i]}\" device: (${DMODULE[$i]})"
                    checkpcmcia "${DETECT_CS[$i]}"
                    echo
                fi
            fi
            i=$(($i+1))
        done
    fi

#generic
    GENERIC="wireless\|80211\|80211\.11\|wifi\|wlan"

    #usb
    if [ x"$LSUSB" != x ]
    then
        if [ x"`$LSUSB -vvv | grep -i "$GENERIC"`" != x ]
        then
            echo && echo "USB devices (generic detection):"
            checkusb "$GENERIC"
        fi
    fi

    #pci
    if [ x"$LSPCI" != x ]
    then
        if [ x"`$LSPCI | grep -i "$GENERIC"`" != x ]
        then
            echo && echo "PCI devices (generic detection):"
            checkpci "$GENERIC"
        fi
    fi

    #pcmcia
    if [ x"$LSPCMCIA" != x -a x"$CARDCTL" != x ]
    then
        if [ x"`$LSPCMCIA -v | grep -i "$GENERIC"`" != x ]
        then
            echo && echo "PCMCIA devices (generic detection):"
            checkpcmcia "$GENERIC"
        fi
    fi

    echo
    return $YES
}

name2num() {
    if [ x"$1" == x ]
    then
        return $ERROR
    fi

    i=0
    while [ $i -lt "$DCOUNT" ]
    do
        for j in ${DMODULES[$i]}
        do
            if [ x"`echo "$1 " | grep -i "$j "`" != x ]
            then
                return $i
            fi
        done
        i=$(($i+1))
    done

    return $ERROR
}

name2num_stack() {
    if [ x"$1" == x ]
    then
        return $ERROR
    fi

    i=0
    while [ $i -lt "$SCOUNT" ]
    do
        for j in ${SMODULES[$i]}
        do
            if [ x"`echo "$1 " | grep -i "$j "`" != x ]
            then
                return $i
            fi
        done
        i=$(($i+1))
    done

    return $ERROR
}

usage() {
    printf "Found kernel: $VANILLA\n"
    printf "usage: `basename $0` <command> [drivernumber]\n"
    printf "\tvalid commands:\n"
    printf "\t\tsupported\t\t- lists all supported drivers\n"
    printf "\t\tkernel\t\t\t- lists all in-kernel drivers\n"
    printf "\t\tinstalled\t\t- lists all installed drivers\n"
    printf "\t\tloaded\t\t\t- lists all loaded drivers\n"
    printf "\t\t-----------------------------------------------------\n"
    printf "\t\tinsert <drivernum>\t- inserts a driver\n"
    printf "\t\tload <drivernum>\t- loads a driver\n"
    printf "\t\tunload <drivernum>\t- unloads a driver\n"
    printf "\t\treload <drivernum>\t- reloads a driver\n"
    printf "\t\t-----------------------------------------------------\n"
    printf "\t\tcompile <drivernum>\t- compiles a driver\n"
    printf "\t\tinstall <drivernum>\t- installs a driver\n"
    printf "\t\tremove <drivernum>\t- removes a driver\n"
    printf "\t\t-----------------------------------------------------\n"
    printf "\t\tcompile_stack <stacknum>\t- compiles a stack \n"
    printf "\t\tinstall_stack <stacknum>\t- installs a stack \n"
    printf "\t\tremove_stack <stacknum>\t- removes a stack \n"
    printf "\t\t-----------------------------------------------------\n"
    printf "\t\tinstall_firmware <drivernum>\t- installs the firmware \n"
    printf "\t\tremove_firmware <drivernum>\t- removes the firmware \n"
    printf "\t\t-----------------------------------------------------\n"
    printf "\t\tdetails <drivernum>\t- prints driver details\n"
    printf "\t\tdetect\t\t\t- detects wireless cards\n"
    echo
    exit
}

#checking main argument(s)
if [ x"$1" == x ]
then
    usage
fi

if [ x"$1" == "xsupported" ]
then
    listSupportedStacks
    echo ""
    listSupportedDrivers
    exit
fi

if [ x"$1" == "xinstalled" ]
then
    listInstalledStacks
    echo ""
    listInstalledDrivers
    echo ""
    listInstalledFirmware
    exit
fi

if [ x"$1" == "xloaded" ]
then
    listLoadedStacks
    echo ""
    listLoadedDrivers
    exit
fi

if [ x"$1" == "xkernel" ]
then
    listKernelStacks
    echo ""
    listKernelDrivers
    exit
fi

if [ x"$1" == "xdetect" ]
then
    detectAdapters
    exit
fi

if [ x"$1" == "xremove" ]
then
    if [ x$2 == "x" ]
    then
        echo "$NO_DRIVER_ERROR"
        exit
    fi

    name2num $2
    num=$?

    if [ $num -eq $ERROR ]
    then
        if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null
        then
            num=$2
        else
            echo "Invalid driver!"
            exit
        fi
    fi

    echo "Driver \"${DNAME[$num]}\" specified for removing."

    removeDriver $num
    if [ $? -eq $YES ]
    then
        echo "Removed driver \"${DNAME[$num]}\" successfully"
    else
        echo "Failed to remove the driver."
    fi
    exit
fi

if [ x"$1" == "xremove_stack" ]
then
    if [ x$2 == "x" ]
    then
        echo "$NO_STACK_ERROR"
        exit
    fi

    name2num_stack $2
    num=$?

    if [ $num -eq $ERROR ]
    then
        if [ $2 -ge 0 -a $2 -lt $SCOUNT ] 2>/dev/null
        then
            num=$2
        else
            echo "Invalid stack!"
            exit
        fi
    fi

    echo "Stack \"${SNAME[$num]}\" specified for removing."

    removeStack $num
    if [ $? -eq $YES ]
    then
        echo "Removed stack \"${SNAME[$num]}\" successfully"
    else
        echo "Failed to remove the stack."
    fi
    exit
fi

if [ x"$1" == "xremove_firmware" ]
then
    if [ x$2 == "x" ]
    then
        echo "$NO_FIRMWARE_ERROR"
        exit
    fi

    name2num $2
    num=$?

    if [ $num -eq $ERROR ]
    then
        if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null
        then
            num=$2
        else
            echo "Invalid driver!"
            exit
        fi
    fi

    echo "Firmware \"${DNAME[$num]}\" specified for removing."

    removeFirmware $num
    if [ $? -eq $YES ]
    then
        echo "Removed firmware \"${DNAME[$num]}\" successfully"
    else
        echo "Failed to remove the firmware."
    fi
    exit
fi

if [ x"$1" == "xinstall" ]
then
    if [ x$2 == "x" ]
    then
        echo "$NO_DRIVER_ERROR"
        exit
    fi

    name2num $2
    num=$?

    if [ $num -eq $ERROR ]
    then
        if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null
        then
            num=$2
        else
            echo "Invalid driver!"
            exit
        fi
    fi

    echo "Driver \"${DNAME[$num]}\" specified for installation."

    NO_INSTALL=$NO
    NO_FIRMWARE=$NO
    installDriver $num

    ret=$?

    if [ $ret -eq $YES ]
    then
        echo "Installed driver \"${DNAME[$num]}\" successfully"
    else
        echo "Failed to install the driver."
        echo "Look through \"$LOGFILE\" for errors."
    fi

    if [ $ret == $YES ]
    then
        unloadDriver $num >/dev/null 2>/dev/null
        loadDriver $num
        if [ $? -eq $YES ]
        then
            echo "Loaded driver \"${DNAME[$num]}\" successfully"
        else
            echo "Failed to load the driver."
        fi
    fi

    exit
fi

if [ x"$1" == "xcompile" ]
then
    if [ x$2 == "x" ]
    then
        echo "$NO_DRIVER_ERROR"
        exit
    fi

    name2num $2
    num=$?

    if [ $num -eq $ERROR ]
    then
        if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null
        then
            num=$2
        else
            echo "Invalid driver!"
            exit
        fi
    fi

    echo "Driver \"${DNAME[$num]}\" specified for compilation."

    NO_INSTALL=$YES
    NO_FIRMWARE=$NO
    installDriver $num

    ret=$?

    if [ $ret -eq $YES ]
    then
        echo "Compiled driver \"${DNAME[$num]}\" successfully"
    else
        echo "Failed to compile the driver."
        echo "Look through \"$LOGFILE\" for errors."
    fi

    if [ $ret == $YES ]
    then
        unloadDriver $num >/dev/null 2>/dev/null
        insertDriver $num
        if [ $? -eq $YES ]
        then
            echo "Inserted driver \"${DNAME[$num]}\" successfully"
        else
            echo "Failed to insert the driver."
        fi
    fi

    exit
fi

if [ x"$1" == "xinstall_stack" ]
then
    if [ x$2 == "x" ]
    then
        echo "$NO_STACK_ERROR"
        exit
    fi

    name2num_stack $2
    num=$?

    if [ $num -eq $ERROR ]
    then
        if [ $2 -ge 0 -a $2 -lt $SCOUNT ] 2>/dev/null
        then
            num=$2
        else
            echo "Invalid stack!"
            exit
        fi
    fi

    echo "Stack \"${SNAME[$num]}\" specified for installation."

    NO_INSTALL=$NO
    NO_FIRMWARE=$YES
    installStack $num

    ret=$?

    if [ $ret -eq $YES ]
    then
        echo "Installed stack \"${SNAME[$num]}\" successfully"
        echo "You need to reload the complete stack, or just reboot."
    else
        echo "Failed to install the stack."
        echo "Look through \"$LOGFILE\" for errors."
    fi

    exit
fi

if [ x"$1" == "xinstall_firmware" ]
then
    if [ x$2 == "x" ]
    then
        echo "$NO_FIRMWARE_ERROR"
        exit
    fi

    name2num $2
    num=$?

    if [ $num -eq $ERROR ]
    then
        if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null
        then
            num=$2
        else
            echo "Invalid driver!"
            exit
        fi
    fi

    echo "Firmware \"${DNAME[$num]}\" specified for installation."

    installFirmware $num
    if [ $? -eq $YES ]
    then
        echo "Installed firmware \"${DNAME[$num]}\" successfully"
    else
        echo "Failed to install the firmware."
        echo "Look through \"$LOGFILE\" for errors."
    fi

    exit
fi

if [ x"$1" == "xcompile_stack" ]
then
    if [ x$2 == "x" ]
    then
        echo "$NO_STACK_ERROR"
        exit
    fi

    name2num_stack $2
    num=$?

    if [ $num -eq $ERROR ]
    then
        if [ $2 -ge 0 -a $2 -lt $SCOUNT ] 2>/dev/null
        then
            num=$2
        else
            echo "Invalid stack!"
            exit
        fi
    fi

    echo "Stack \"${SNAME[$num]}\" specified for compilation."

    NO_INSTALL=$YES
    NO_FIRMWARE=$YES
    installStack $num

    ret=$?

    if [ $ret -eq $YES ]
    then
        echo "Compiled stack \"${SNAME[$num]}\" successfully"
        echo "You need to insert the Stack manually"
    else
        echo "Failed to compile the stack."
        echo "Look through \"$LOGFILE\" for errors."
    fi

    exit
fi

if [ x"$1" == "xload" ]
then
    if [ x$2 == "x" ]
    then
        echo "$NO_DRIVER_ERROR"
        exit
    fi

    name2num $2
    num=$?

    if [ $num -eq $ERROR ]
    then
        if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null
        then
            num=$2
        else
            echo "Invalid driver!"
            exit
        fi
    fi

    echo "Driver \"${DNAME[$num]}\" specified for loading."

    loadDriver $num
    if [ $? -eq $YES ]
    then
        echo "Loaded driver \"${DNAME[$num]}\" successfully"
    else
        echo "Failed to load the driver."
    fi
    exit
fi

if [ x"$1" == "xinsert" ]
then
    if [ x$2 == "x" ]
    then
        echo "$NO_DRIVER_ERROR"
        exit
    fi

    name2num $2
    num=$?

    if [ $num -eq $ERROR ]
    then
        if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null
        then
            num=$2
        else
            echo "Invalid driver!"
            exit
        fi
    fi

    echo "Driver \"${DNAME[$num]}\" specified for inserting."

    insertDriver $num
    if [ $? -eq $YES ]
    then
        echo "Inserted driver \"${DNAME[$num]}\" successfully"
    else
        echo "Failed to insert the driver."
    fi
    exit
fi

if [ x"$1" == "xunload" ]
then
    if [ x$2 == "x" ]
    then
        echo "$NO_DRIVER_ERROR"
        exit
    fi

    name2num $2
    num=$?

    if [ $num -eq $ERROR ]
    then
        if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null
        then
            num=$2
        else
            echo "Invalid driver!"
            exit
        fi
    fi

    echo "Driver \"${DNAME[$num]}\" specified for unloading."

    unloadDriver $num
    if [ $? -eq $YES ]
    then
        echo "Unloaded driver \"${DNAME[$num]}\" successfully"
    else
        echo "Failed to unload the driver."
    fi
    exit
fi

if [ x"$1" == "xreload" ]
then
    if [ x$2 == "x" ]
    then
        echo "$NO_DRIVER_ERROR"
        exit
    fi

    name2num $2
    num=$?

    if [ $num -eq $ERROR ]
    then
        if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null
        then
            num=$2
        else
            echo "Invalid driver!"
            exit
        fi
    fi

    echo "Driver \"${DNAME[$num]}\" specified for reloading."

    unloadDriver $num
    if [ $? -ne $YES ]
    then
        echo "Failed to unload the driver."
        exit
    fi

    isLoaded $num "D"
    if [ $? -eq $YES ]
    then
        echo "Failed to unload the driver."
        exit
    fi

    loadDriver $num
    if [ $? -ne $YES ]
    then
        echo "Failed to reload the driver."
        exit
    else
        echo "Reloaded driver \"${DNAME[$num]}\" successfully"
    fi

    exit
fi

if [ x"$1" == "xdetails" ]
then
    if [ x$2 == "x" ]
    then
        echo "$NO_DRIVER_ERROR"
        exit
    fi

    name2num $2
    num=$?

    if [ $num -eq $ERROR ]
    then
        if [ $2 -ge 0 -a $2 -lt $DCOUNT ] 2>/dev/null
        then
            num=$2
        else
            echo "Invalid driver!"
            exit
        fi
    fi

    echo "Driver details for: \"${DNAME[$num]}\""
    echo

    printf "Compiled into kernel:\t"
    isInKernel $num "D"
    if [ $? -eq $YES ]
    then
        echo "YES"
    else
        echo "No"
    fi

    printf "Installed:\t\t"
    isInstalled $num "D"
    if [ $? -eq $YES ]
    then
        echo "YES"
    else
        echo "No"
    fi

    printf "Loaded:\t\t\t"
    isLoaded $num "D"
    if [ $? -eq $YES ]
    then
        echo "YES"
    else
        echo "No"
    fi

    printf "Firmware installed:\t"
    isInstalledFirmware $num
    ret=$?
    if [ $ret -eq $YES ]
    then
        echo "YES"
    else
        if [ $ret -eq $NO ]
        then
            echo "No"
        else
            echo "N/A"
        fi
    fi

    echo
    echo "Modules:"

    echo
    echo "Modules:"
    for i in ${DMODULES[$num]}
    do
        i="`echo "$i" | sed 's/-/_/'`"
        echo -n "$i "
    done
    echo
    echo

    echo "Files:"
    for i in ${DMODULES[$num]}
    do
        mfile="`$MODPROBE -l | grep \/$i\.ko`"
        if [ x"$mfile" != x ]
        then
            mtime="`ls -l $mfile | awk '{print $6" "$7}'`"
            echo $mfile $mtime
        fi
    done
    echo

    modinfo ${DMODULE[$num]} 2>/dev/null | grep "^ver\|^depends"

    echo
    if [ x${DSITE[$num]} != x ]
    then
        echo "For more information see:"
        echo ${DSITE[$num]}
    fi
    exit
fi

usage
