4 # This file handles the NVRAM quirks of various hardware.
6 .
/etc
/network.overrides
7 alias debug
=${DEBUG:-:}
10 for type in lan wifi wan pppoe
14 eval nvram
set ${type}_ifname
$s=\"$
(nvram get
${type}_ifname
$s|
sed s
/$1/$2/g
)\"
20 [ -z "$(nvram get $1)" ] && nvram
set "$1=$2"
23 nvram_set
() { # for the linksys fixup part
24 [ "$(nvram get "$1")" = "$2" ] ||
{
30 # work around braindead CFE defaults in linksys routers
31 boardtype
=$
(nvram get boardtype
)
32 boardflags
=$
(($
(nvram get boardflags
)))
33 [ "$boardtype" = "bcm4710dev" ] && boardtype
="0xdeadbeef"
34 adm_switch
="$(( ($boardflags & 0x80) >> 7 ))"
35 case "$(( $boardtype ))" in
37 if [ "$adm_switch" = 0 ]; then
38 nvram_set sdram_init
"$(printf 0x%04x $(( $(nvram get sdram_init) | 0x0100 )))"
39 [ "$COMMIT" = 1 ] && {
40 nvram_set sdram_config
0x0062
42 nvram_set sdram_ncdl
0x0
43 nvram_set pa0itssit
62
44 nvram_set pa0b0
0x15eb
45 nvram_set pa0b1
0xfa82
46 nvram_set pa0b2
0xfe66
47 nvram_set pa0maxpwr
0x4e
52 nvram_set sdram_init
"$(printf 0x%04x $(( $(nvram get sdram_init) | 0x0100 )))"
53 [ "$COMMIT" = 1 ] && {
54 nvram_set sdram_config
0x0062
55 nvram_set sdram_ncdl
0x0
56 nvram_set pa0itssit
62
57 nvram_set pa0b0
0x168b
58 nvram_set pa0b1
0xfabf
59 nvram_set pa0b2
0xfeaf
60 nvram_set pa0maxpwr
0x4e
64 [ "$COMMIT" = "1" ] && nvram commit
67 # linksys bug; remove when not using static configuration for lan
68 nvram
set lan_proto
="static"
70 # hacks for wrt54g 1.x hardware
71 [ "$(nvram get boardnum)" = "42" \
72 -a "$(nvram get boardtype)" = "bcm94710dev" ] && {
73 debug
"### wrt54g 1.x hack ###"
74 nvram
set vlan1hwname
="et0"
75 nvram
set vlan2hwname
="et0"
80 # hacks for asus wl-500g deluxe
81 [ "$(nvram get boardtype)" = "bcm95365r" \
82 -a "$(nvram get boardnum)" = "45" ] && {
83 debug
"### wl-500g deluxe hacks ###"
84 nvram
set vlan0hwname
="et0"
85 nvram
set vlan1hwname
="et0"
89 # set up the vlan*ports variables for the asus wl-500g deluxe
90 # if they don't already exist
91 nvram_default vlan0ports
"1 2 3 4 5*"
92 nvram_default vlan1ports
"0 5"
96 case "$(nvram get productid)" in
98 debug
"### wl-300g hacks ###"
99 nvram
set lan_ifnames
="eth0 eth2"
100 nvram
set wan_ifname
="none"
103 debug
"### wl-hdd hacks ###"
104 nvram
set lan_ifnames
="eth1 eth2"
105 nvram
set wan_ifname
="none"
109 # hacks for wap54g hardware
110 [ "$(nvram get boardnum)" = "2" \
111 -o "$(nvram get boardnum)" = "1024" ] && {
112 debug
"### wap54g hack ###"
113 nvram
set wan_ifname
="none"
116 # hacks for buffalo wla2-g54l
117 [ "$(nvram get boardnum)" = "00" \
118 -a "$(nvram get product_name)" = "Product_name" \
119 -o "$(nvram get product_name)" = "WLA2-G54L" ] && {
120 debug
"### wla2-g54l hacks ###"
121 nvram
set wan_ifname
="none"
122 nvram
set lan_ifnames
="vlan0"
125 # needed at least for wrt54gs v1.1 and wrt54g v2.0, v2.2
126 [ \
! -z "$(nvram get boardrev)" ] && {
127 nvram_default wl0id
0x4320
130 WAN_PROTO
="$(nvram get wan_proto)"
131 [ "$WAN_PROTO" = "pptp" \
132 -o "$WAN_PROTO" = "pppoe" ] && {
133 WAN_IFNAME
="$(nvram get wan_ifname)"
134 [ "${WAN_IFNAME%%[0-9]*}" = "ppp" ] ||
{
135 nvram
set wan_ifname
=ppp0
136 nvram
set ${WAN_PROTO}_ifname
="$WAN_IFNAME"
141 nvram_default lan_ifname
"br0"
142 nvram_default lan_ifnames
"$FAILSAFE_ifnames"
144 nvram_default wan_ifname
"vlan1"
145 nvram_default wan_proto
"dhcp"
147 nvram_default wl0_ssid OpenWrt
148 nvram_default wl0_mode ap
149 nvram_default wl0_infra
1
150 nvram_default wl0_radio
1
152 [ "$(nvram get il0macaddr)" = "00:90:4c:5f:00:2a" ] && {
153 # if default wifi mac, set two higher than the lan mac
154 nvram
set il0macaddr
=$
(nvram get et0macaddr|
155 awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}')