###################################################################################
##  apcfg
##
##  Configuration file for Atheros AP.
##  This file will "predefine" default configuration data for the AP.  This
##  will first read all configuration data from flash (cfg -e), then fill in any
##  defaults that are missing.  Thus the defaults will appear on the web pages
##  even if the configuration store has been cleared.
##
###################################################################################
##
## Get the current settings from flash/cache area
##

#cfg -e > /tmp/vars.$$
#. /tmp/vars.$$
#rm /tmp/vars.$$

##
## Set Network configuration
##
## AP_IPADDR  = IP address of the bridge
## WAN_IPADDR = Fixed IP address of the WAN, if it's not bridged
## WAN_MODE   = bridged for attached to bridged, Get address if dhcp, fixed address
##              if static
##
###################################################################################

#cfg -a AP_IPADDR=${AP_IPADDR:="192.168.1.2"}
#cfg -a AP_NETMASK=${AP_NETMASK:="255.255.255.0"}
#cfg -a WAN_MODE=${WAN_MODE:="bridged"}
#cfg -a WAN_IPADDR=${WAN_IPADDR:="192.168.2.1"}
#cfg -a WAN_NETMASK=${WAN_NETMASK:="255.255.255.0"}

#
# Indicate if you want the WLAN to be activated on boot up.
#

if [ "${WLAN_ON_BOOT}" = "" ]; then
    export WLAN_ON_BOOT="n"
fi

#cfg -a WLAN_ON_BOOT=${WLAN_ON_BOOT:="n"}

#
# AP Start Mode
# This can be overridded by environmental variables
# Modes can be
#    standard := standard single AP start mode
#      rootap := WDS root AP for WDS modes
#    reptater := WDS repeater station
#      client := WDS "virtual wire" client
#       multi := Multiple BSSID with all encryption types
#      stafwd := Station mode with address forwarding enabled
#
#

if [ "${AP_STARTMODE}" = "" ]; then
    export AP_STARTMODE="standard"
fi

#cfg -a AP_STARTMODE=${AP_STARTMODE:="standard"}

#################################################################################
## Default Parameters
## If these are not set explictly by exporting environmental variables, the following
## Defaults will be applied
#################################################################################
#
# AP_PRIMARY_CH could be
#                a number or
#                11ng (which means auto-scan in 11ng mode)

if [ "${AP_CHMODE}" = "" ]; then
    export AP_CHMODE="11NGHT20"
fi

if [ "${AP_PRIMARY_CH}" = "" ]; then
    export AP_PRIMARY_CH=6
fi

#cfg -a AP_PRIMARY_CH=${AP_PRIMARY_CH:=6}
#cfg -a AP_CHMODE=${AP_CHMODE:="11NGHT20"}

##
## This is for pure G or pure N operations.  Hmmmm...
##

if [ "${PUREG}" = "" ]; then
    export PUREG=0
fi

if [ "${PUREN}" = "" ]; then
    export PUREN=0
fi

#cfg -a PUREG=${PUREG:=0}
#cfg -a PUREN=${PUREN:=0}

##
## Channel Configuration Section
##
if [ "${TXQUEUELEN}" = "" ]; then
    export TXQUEUELEN=1000
fi

if [ "${SHORTGI}" = "" ]; then
    export SHORTGI=1
fi

#cfg -a TXQUEUELEN=${TXQUEUELEN:=1000}
#cfg -a SHORTGI=${SHORTGI:=1}

#
# Aggregation.  First parameter enables/disables,
# second parameter sets the size limit
#

if [ "${RATECTL}" = "" ]; then
    export RATECTL="auto"
fi

if [ "${CWMMODE}" = "" ]; then
    export CWMMODE=0
fi

if [ "${AMPDUMIN}" = "" ]; then
    export AMPDUMIN=32768
fi

if [ "${AMPDULIMIT}" = "" ]; then
    export AMPDULIMIT=5000
fi

if [ "${AMPDUFRAMES}" = "" ]; then
    export AMPDUFRAMES=32
fi

if [ "${AMPDUENABLE}" = "" ]; then
    export AMPDUENABLE=1
fi

if [ "${MANRATE}" = "" ]; then
    export MANRATE=0x8c8c8c8c
fi

if [ "${MANRETRIES}" = "" ]; then
    export MANRETRIES=0x04040404
fi

if [ "${RX_CHAINMASK}" = "" ]; then
    export RX_CHAINMASK=3
fi

if [ "${TX_CHAINMASK}" = "" ]; then
    export TX_CHAINMASK=3
fi

if [ "${SWAP_LED}" = "" ]; then
    export SWAP_LED=1
fi

if [ "${LED_CUSTOM}" = "" ]; then
    export LED_CUSTOM=3
fi

#cfg -a AMPDUENABLE=${AMPDUENABLE:=1}
#cfg -a AMPDUFRAMES=${AMPDUFRAMES:=32}
#cfg -a AMPDULIMIT=${AMPDULIMIT:=50000}
#cfg -a AMPDUMIN=${AMPDUMIN:=32768}
#cfg -a CWMMODE=${CWMMODE:=1}
#cfg -a RATECTL=${RATECTL:="auto"}
#cfg -a MANRATE=${MANRATE:=0x8c8c8c8c}
#cfg -a MANRETRIES=${MANRETRIES:=0x04040404}
#cfg -a RX_CHAINMASK=${RX_CHAINMASK:=3}
#cfg -a TX_CHAINMASK=${TX_CHAINMASK:=3}
#cfg -a SWAP_LED=${SWAP_LED:=1}
#cfg -a LED_CUSTOM=${LED_CUSTOM:=3}

##
## AP Identification Section
##

#cfg -a AP_SSID="${AP_SSID:=Atheros_XSpan_2G}"

##
## Set the default modes for multi configuration
##

#cfg -a AP_MODE=${AP_MODE:="ap"}
#cfg -a AP_MODE_2=${AP_MODE_2:="ap"}
#cfg -a AP_MODE_3=${AP_MODE_3:="ap"}
#cfg -a AP_MODE_4=${AP_MODE_4:="ap"}
#cfg -a AP_MODE_5=${AP_MODE_5:="ap"}
#cfg -a AP_MODE_6=${AP_MODE_6:="ap"}
#cfg -a AP_MODE_7=${AP_MODE_7:="ap"}
#cfg -a AP_MODE_8=${AP_MODE_8:="ap"}

if [ "${AP_MODE}" = "" ]; then
    export AP_MODE=ap
fi
if [ "${AP_MODE2}" = "" ]; then
    export AP_MODE2=ap
fi
if [ "${AP_MODE3}" = "" ]; then
    export AP_MODE3=ap
fi
if [ "${AP_MODE4}" = "" ]; then
    export AP_MODE4=ap
fi
if [ "${AP_MODE5}" = "" ]; then
    export AP_MODE5=ap
fi
if [ "${AP_MODE6}" = "" ]; then
    export AP_MODE6=ap
fi
if [ "${AP_MODE7}" = "" ]; then
    export AP_MODE7=ap
fi
if [ "${AP_MODE8}" = "" ]; then
    export AP_MODE8=ap
fi

##
## Set default security modes
##

#cfg -a AP_SECMODE=${AP_SECMODE:="None"}
#cfg -a AP_SECMODE_2=${AP_SECMODE_2:="None"}
#cfg -a AP_SECMODE_3=${AP_SECMODE_3:="None"}
#cfg -a AP_SECMODE_4=${AP_SECMODE_4:="None"}
#cfg -a AP_SECMODE_5=${AP_SECMODE_5:="None"}
#cfg -a AP_SECMODE_6=${AP_SECMODE_6:="None"}
#cfg -a AP_SECMODE_7=${AP_SECMODE_7:="None"}
#cfg -a AP_SECMODE_8=${AP_SECMODE_8:="None"}

if [ "${AP_SECMODE}" = "" ]; then
    export AP_SECMODE="None"
fi
if [ "${AP_SECMODE2}" = "" ]; then
    export AP_SECMODE2="None"
fi
if [ "${AP_SECMODE3}" = "" ]; then
    export AP_SECMODE3="None"
fi
if [ "${AP_SECMODE4}" = "" ]; then
    export AP_SECMODE4="None"
fi
if [ "${AP_SECMODE5}" = "" ]; then
    export AP_SECMODE5="None"
fi
if [ "${AP_SECMODE6}" = "" ]; then
    export AP_SECMODE6="None"
fi
if [ "${AP_SECMODE7}" = "" ]; then
    export AP_SECMODE7="None"
fi
if [ "${AP_SECMODE8}" = "" ]; then
    export AP_SECMODE8="None"
fi

##
## Set default secfile to PSK, only valid in WPA mode
##

#cfg -a AP_SECFILE=${AP_SECFILE:="PSK"}
#cfg -a AP_SECFILE_2=${AP_SECFILE_2:="PSK"}
#cfg -a AP_SECFILE_3=${AP_SECFILE_3:="PSK"}
#cfg -a AP_SECFILE_4=${AP_SECFILE_4:="PSK"}
#cfg -a AP_SECFILE_5=${AP_SECFILE_5:="PSK"}
#cfg -a AP_SECFILE_6=${AP_SECFILE_6:="PSK"}
#cfg -a AP_SECFILE_7=${AP_SECFILE_7:="PSK"}
#cfg -a AP_SECFILE_8=${AP_SECFILE_8:="PSK"}

if [ "${AP_SECFILE}" = "" ]; then
    export AP_SECFILE="PSK"
fi
if [ "${AP_SECFILE2}" = "" ]; then
    export AP_SECFILE2="PSK"
fi
if [ "${AP_SECFILE3}" = "" ]; then
    export AP_SECFILE3="PSK"
fi
if [ "${AP_SECFILE4}" = "" ]; then
    export AP_SECFILE4="PSK"
fi
if [ "${AP_SECFILE5}" = "" ]; then
    export AP_SECFILE5="PSK"
fi
if [ "${AP_SECFILE6}" = "" ]; then
    export AP_SECFILE6="PSK"
fi
if [ "${AP_SECFILE7}" = "" ]; then
    export AP_SECFILE7="PSK"
fi
if [ "${AP_SECFILE}" = "" ]; then
    export AP_SECFILE="PSK"
fi

#cfg -a WPS_ENABLE=${WPS_ENABLE:="0"}
#cfg -a WPS_ENABLE_2=${WPS_ENABLE_2:="0"}
#cfg -a WPS_ENABLE_3=${WPS_ENABLE_3:="0"}
#cfg -a WPS_ENABLE_4=${WPS_ENABLE_4:="0"}
#cfg -a WPS_ENABLE_5=${WPS_ENABLE_5:="0"}
#cfg -a WPS_ENABLE_6=${WPS_ENABLE_6:="0"}
#cfg -a WPS_ENABLE_7=${WPS_ENABLE_7:="0"}
#cfg -a WPS_ENABLE_8=${WPS_ENABLE_8:="0"}

##
## Default keys are Decimal (NOT hex)
##

#cfg -a WEP_IS_HEX1=${WEP_IS_HEX1:="0"}
#cfg -a WEP_IS_HEX2=${WEP_IS_HEX2:="0"}
#cfg -a WEP_IS_HEX3=${WEP_IS_HEX3:="0"}
#cfg -a WEP_IS_HEX4=${WEP_IS_HEX4:="0"}
#cfg -a WEP_IS_HEX5=${WEP_IS_HEX5:="0"}
#cfg -a WEP_IS_HEX6=${WEP_IS_HEX6:="0"}
#cfg -a WEP_IS_HEX7=${WEP_IS_HEX7:="0"}
#cfg -a WEP_IS_HEX8=${WEP_IS_HEX8:="0"}
#
#cfg -a WPA_IS_HEX=${WPA_IS_HEX:="0"}
#cfg -a WPA_IS_HEX_2=${WPA_IS_HEX_2:="0"}
#cfg -a WPA_IS_HEX_3=${WPA_IS_HEX_3:="0"}
#cfg -a WPA_IS_HEX_4=${WPA_IS_HEX_4:="0"}
#cfg -a WPA_IS_HEX_5=${WPA_IS_HEX_5:="0"}
#cfg -a WPA_IS_HEX_6=${WPA_IS_HEX_6:="0"}
#cfg -a WPA_IS_HEX_7=${WPA_IS_HEX_7:="0"}
#cfg -a WPA_IS_HEX_8=${WPA_IS_HEX_8:="0"}

if [ "${WPA_IS_HEX}" = "" ]; then
    export WPA_IS_HEX="0"
fi
if [ "${WPA_IS_HEX2}" = "" ]; then
    export WPA_IS_HEX2="0"
fi
if [ "${WPA_IS_HEX3}" = "" ]; then
    export WPA_IS_HEX3="0"
fi
if [ "${WPA_IS_HEX4}" = "" ]; then
    export WPA_IS_HEX4="0"
fi
if [ "${WPA_IS_HEX5}" = "" ]; then
    export WPA_IS_HEX5="0"
fi
if [ "${WPA_IS_HEX6}" = "" ]; then
    export WPA_IS_HEX6="0"
fi
if [ "${WPA_IS_HEX7}" = "" ]; then
    export WPA_IS_HEX7="0"
fi
if [ "${WPA_IS_HEX8}" = "" ]; then
    export WPA_IS_HEX8="0"
fi

if [ "${WEP_IS_HEX1}" = "" ]; then
    export WEP_IS_HEX1="0"
fi
if [ "${WEP_IS_HEX2}" = "" ]; then
    export WEP_IS_HEX2="0"
fi
if [ "${WEP_IS_HEX3}" = "" ]; then
    export WEP_IS_HEX3="0"
fi
if [ "${WEP_IS_HEX4}" = "" ]; then
    export WEP_IS_HEX4="0"
fi
if [ "${WEP_IS_HEX5}" = "" ]; then
    export WEP_IS_HEX5="0"
fi
if [ "${WEP_IS_HEX6}" = "" ]; then
    export WEP_IS_HEX6="0"
fi
if [ "${WEP_IS_HEX7}" = "" ]; then
    export WEP_IS_HEX7="0"
fi
if [ "${WEP_IS_HEX8}" = "" ]; then
    export WEP_IS_HEX8="0"
fi


##
## Export the variables again to catch the defaults
##

#cfg -e > /tmp/vars.$$
#. /tmp/vars.$$
#rm /tmp/vars.$$

#####################################################################################
## The following parameters are board specific, and should not be modified
#####################################################################################

export ATH_use_eeprom=0
# SET it to 1 if no "A" band support 
export AP_NO_A_BAND=1


