#
# This file handles the NVRAM quirks of various hardware.
-. /etc/nvram.overrides
alias debug=${DEBUG:-:}
remap () {
}
}
+fixup_lan() { # fix for wrong lan_ifnames default
+ lan_ifnames="$(nvram get lan_ifnames)"
+ [ "${lan_ifnames%% *}" = "$1" ] || \
+ nvram set lan_ifnames="$2"
+}
+
# work around braindead CFE defaults in linksys routers
boardtype=$(nvram get boardtype)
boardnum=$(nvram get boardnum)
-product_name=$(nvram get product_name)
-
boardflags=$(($(nvram get boardflags)))
adm_switch="$(( ($boardflags & 0x80) >> 7 ))"
[ "$boardnum" = "42" \
-a "$boardtype" = "bcm94710dev" ] && {
debug "### wrt54g 1.x hack ###"
- nvram set vlan1hwname="et0"
- nvram set vlan2hwname="et0"
remap eth0 vlan2
remap eth1 vlan1
+ nvram_default vlan1hwname "et0"
+ nvram_default vlan2hwname "et0"
+ nvram_default lan_ifnames "vlan2 eth2"
}
# hacks for asus wl-500g deluxe
[ "$boardnum" = "45" \
-a "$boardtype" = "bcm95365r" ] && {
debug "### wl-500g deluxe hacks ###"
- nvram set vlan0hwname="et0"
- nvram set vlan1hwname="et0"
remap eth0.1 vlan0
remap eth0 vlan1
+ nvram_default vlan0hwname "et0"
+ nvram_default vlan1hwname "et0"
+ nvram_default lan_ifnames "vlan0 eth1"
# set up the vlan*ports variables for the asus wl-500g deluxe
# if they don't already exist
}
# hacks for asus
-case "$(nvram get productid)" in
- WL300g)
- debug "### wl-300g hacks ###"
- nvram set lan_ifnames="eth0 eth2"
- nvram set wan_ifname="none"
- ;;
- WLHDD)
- debug "### wl-hdd hacks ###"
- nvram set lan_ifnames="eth1 eth2"
- nvram set wan_ifname="none"
- ;;
- *)
- # wl-500g defaults. these are placed here, because WL-HDD and WL-300g
- # might have the same nvram settings.
- [ "$boardnum" = "asusX" \
- -a "$boardtype" = "bcm94710dev" ] && {
- nvram_default wan_device "eth1"
- }
- ;;
-esac
+[ "$boardnum" = "asusX" ] && {
+ debug "### asus hacks ###"
+ case "$(($(nvram get et1phyaddr)))" in
+ 1) # WL-HDD
+ lan=eth1
+ wan=none
+ ;;
+ *)
+ lan=eth0
+ [ "$boardtype" = "bcm94710dev" ] && wan=eth1 || wan=none
+ ;;
+ esac
+
+ fixup_lan "$lan" "$lan eth2"
+ nvram_default wan_ifname "$wan"
+}
# hacks for wap54g hardware
[ "$boardnum" = "2" \
-o "$boardnum" = "1024" ] && {
debug "### wap54g hack ###"
- nvram set wan_ifname="none"
+ nvram_default wan_ifname "none"
+ nvram_default lan_ifnames "eth0 eth1"
}
# hacks for buffalo wla2-g54l
-a "$product_name" = "Product_name" \
-o "$product_name" = "WLA2-G54L" ] && {
debug "### wla2-g54l hacks ###"
- nvram set wan_ifname="none"
- nvram set lan_ifnames="vlan0"
+ nvram_default wan_ifname "none"
+ fixup_lan "vlan0" "vlan0 eth1"
}
# wrtsl54gs vlan defaults
nvram_default wl0id 0x4320
}
-# defaults
+# defaults, can be overridden by hardware-specific nvram_default commands
nvram_default lan_ifname "br0"
-nvram_default lan_ifnames "$FAILSAFE_ifnames"
+nvram_default lan_ifnames "vlan0 eth1 eth2"
nvram_default wan_ifname "vlan1"
nvram_default wan_device "vlan1"