5 . /lib/functions/uci-defaults.sh
7 if [ ! -x /usr/sbin/maccalc ]; then
8 echo "$0: maccalc not found!"
12 ramips_setup_rt3x5x_vlans()
14 if [ ! -x /sbin/swconfig ]; then
16 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
21 swconfig dev rt305x set reset 1
22 for port in 5 4 3 2 1 0; do
23 if [ `swconfig dev rt305x port $port get disable` = "1" ]; then
26 if [ `swconfig dev rt305x port $port get lan` = "0" ]; then
27 wanports="$port $wanports"
29 lanports="$port $lanports"
32 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
33 ucidef_add_switch "rt305x" "1" "1"
34 ucidef_add_switch_vlan "rt305x" "1" "$lanports 6t"
35 ucidef_add_switch_vlan "rt305x" "2" "$wanports 6t"
38 ramips_setup_interfaces()
42 ucidef_set_interface_loopback
49 ucidef_set_interface_lan "eth0"
54 ucidef_set_interface_lan "eth0.1"
65 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
69 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
70 ucidef_add_switch "switch0" "1" "1"
71 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
72 ucidef_add_switch_vlan "switch0" "2" "0 6t"
76 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
77 ucidef_add_switch "switch0" "1" "1"
78 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
79 ucidef_add_switch_vlan "switch0" "2" "4 6t"
85 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
90 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
91 ucidef_add_switch "switch0" "1" "1"
92 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
93 ucidef_add_switch_vlan "switch0" "2" "0 5t"
98 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
99 ucidef_add_switch "switch0" "1" "1"
100 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
101 ucidef_add_switch_vlan "switch0" "2" "4 5t"
105 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
106 ucidef_add_switch "switch0" "1" "1"
107 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
108 ucidef_add_switch_vlan "switch0" "2" "4 8t"
113 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
114 ucidef_add_switch "switch0" "1" "1"
115 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
116 ucidef_add_switch_vlan "switch0" "2" "0t 5"
121 ucidef_set_interfaces_lan_wan "eth0.2" "eth0.1"
125 ucidef_set_interface_lan "eth0"
129 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
130 if [ -n "${RT3X5X}" ]; then
131 ramips_setup_rt3x5x_vlans
133 ucidef_set_interfaces_lan_wan "eth0" "eth1"
149 lan_mac=$(ramips_get_mac_binary factory 40)
164 lan_mac=$(ramips_get_mac_binary factory 4)
165 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
169 lan_mac=$(ramips_get_mac_binary factory 4)
170 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 5)
175 lan_mac=$(ramips_get_mac_binary factory 40)
176 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
182 lan_mac=$(ramips_get_mac_binary devdata 16388)
183 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
187 lan_mac=$(ramips_get_mac_binary factory 4)
188 lan_mac=$(maccalc or "$lan_mac" "02:00:00:00:00:00")
189 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
193 lan_mac=$(ramips_get_mac_nvram nvram lanmac)
194 wan_mac=$(ramips_get_mac_nvram nvram wanmac)
199 lan_mac=$(ramips_get_mac_binary devdata 16388)
200 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
205 lan_mac=$(ramips_get_mac_binary factory 4)
206 wan_mac=$(ramips_get_mac_binary factory 40)
210 lan_mac=$(ramips_get_mac_binary "u-boot" 262148)
211 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
215 lan_mac=$(ramips_get_mac_binary factory 4)
216 wan_mac=$(ramips_get_mac_binary factory 32772)
220 lan_mac=$(ramips_get_mac_binary factory 40)
221 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 3)
225 lan_mac=$(ramips_get_mac_binary factory 40)
226 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 4)
232 lan_mac=$(ramips_get_mac_binary factory 40)
233 wan_mac=$(ramips_get_mac_binary factory 46)
237 lan_mac=$(ramips_get_mac_binary board-nvram 65440)
238 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
242 lan_mac=$(ramips_get_mac_binary factory 4)
247 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
248 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
251 [ -e /etc/config/network ] && exit 0
253 touch /etc/config/network
255 board=$(ramips_board_name)
257 ramips_setup_interfaces $board
258 ramips_setup_macs $board