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
47 ucidef_set_interface_lan "eth0"
52 ucidef_set_interface_lan "eth0.1"
63 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
67 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
68 ucidef_add_switch "switch0" "1" "1"
69 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
70 ucidef_add_switch_vlan "switch0" "2" "0 6t"
76 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
80 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
81 ucidef_add_switch "switch0" "1" "1"
82 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
83 ucidef_add_switch_vlan "switch0" "2" "0 5t"
88 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
89 ucidef_add_switch "switch0" "1" "1"
90 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
91 ucidef_add_switch_vlan "switch0" "2" "4 5t"
95 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
96 ucidef_add_switch "switch0" "1" "1"
97 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
98 ucidef_add_switch_vlan "switch0" "2" "4 8t"
103 ucidef_set_interfaces_lan_wan "eth0.2" "eth0.1"
107 ucidef_set_interface_lan "eth0"
111 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
112 if [ -n "${RT3X5X}" ]; then
113 ramips_setup_rt3x5x_vlans
115 ucidef_set_interfaces_lan_wan "eth0" "eth1"
131 lan_mac=$(ramips_get_mac_binary factory 40)
142 lan_mac=$(ramips_get_mac_binary factory 4)
143 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
147 lan_mac=$(ramips_get_mac_binary factory 4)
148 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 5)
152 lan_mac=$(ramips_get_mac_binary factory 40)
153 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
159 lan_mac=$(ramips_get_mac_binary devdata 16388)
160 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
164 lan_mac=$(ramips_get_mac_binary factory 4)
165 lan_mac=$(maccalc or "$lan_mac" "02:00:00:00:00:00")
166 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
170 lan_mac=$(ramips_get_mac_nvram nvram lanmac)
171 wan_mac=$(ramips_get_mac_nvram nvram wanmac)
176 lan_mac=$(ramips_get_mac_binary devdata 16388)
177 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
182 lan_mac=$(ramips_get_mac_binary factory 4)
183 wan_mac=$(ramips_get_mac_binary factory 40)
187 lan_mac=$(ramips_get_mac_binary "u-boot" 262148)
188 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
192 lan_mac=$(ramips_get_mac_binary factory 4)
193 wan_mac=$(ramips_get_mac_binary factory 32772)
199 lan_mac=$(ramips_get_mac_binary factory 40)
200 wan_mac=$(ramips_get_mac_binary factory 46)
204 lan_mac=$(ramips_get_mac_binary board-nvram 65440)
205 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
209 lan_mac=$(ramips_get_mac_binary factory 4)
214 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
215 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
218 [ -e /etc/config/network ] && exit 0
220 touch /etc/config/network
222 board=$(ramips_board_name)
224 ramips_setup_interfaces $board
225 ramips_setup_macs $board