###################################################################################
##  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:="0.0.0.0"}
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.
#

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
#
#

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)

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...
##

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

##
## Channel Configuration Section
##

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

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

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:=1}
cfg -a TX_CHAINMASK=${TX_CHAINMASK:=1}
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"}

##
## 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"}

##
## 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 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"}

##
## 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 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"}

##
## 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
