3 # Copyright (C) 2011 OpenWrt.org
6 [ -e /etc/config/network ] && exit 0
8 touch /etc/config/network
10 . /lib/functions/uci-defaults.sh
13 ucidef_set_interface_loopback
15 board=$(ar71xx_board_name)
22 ucidef_set_interface_lan "eth0 eth1"
27 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
28 ucidef_add_switch "switch0" "1" "1"
29 ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
30 ucidef_add_switch_vlan "switch0" "2" "0t 1"
35 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
36 ucidef_add_switch "switch0" "1" "1"
37 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
38 ucidef_add_switch_vlan "switch0" "2" "0t 5"
42 ucidef_set_interfaces_lan_wan "eth0" "eth1"
43 ucidef_add_switch "switch0" "1" "1"
44 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
45 ucidef_add_switch_vlan "switch0" "2" "5 6"
52 ucidef_set_interfaces_lan_wan "eth1" "eth0"
53 ucidef_add_switch "switch0" "1" "1"
54 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
55 ucidef_add_switch_vlan "switch0" "2" "5 6"
61 ucidef_set_interfaces_lan_wan "eth1" "eth0"
62 ucidef_add_switch "switch0" "1" "1"
63 ucidef_add_switch_vlan "switch0" "1" "0 2 3 4 5"
64 ucidef_add_switch_vlan "switch0" "2" "1 6"
68 ucidef_set_interfaces_lan_wan "eth1" "eth0"
69 ucidef_add_switch "switch0" "1" "1"
70 ucidef_add_switch_vlan "switch0" "1" "0 1 3"
71 ucidef_set_interface_wlan
75 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
76 ucidef_add_switch "switch0" "1" "1"
77 ucidef_add_switch_vlan "switch0" "1" "0t 5"
78 ucidef_add_switch_vlan "switch0" "2" "0t 4"
87 ucidef_set_interfaces_lan_wan "eth0.1 eth1" "eth0.2"
88 ucidef_add_switch "switch0" "1" "1"
89 ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
90 ucidef_add_switch_vlan "switch0" "2" "0t 1"
91 ucidef_add_switch "switch1" "1" "1"
92 ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 4 5"
95 rb-2011uas* | rb-2011uias | rb-2011uias-2hnd)
96 ucidef_set_interface_raw "sfp" "eth0.3"
97 ucidef_add_switch_vlan "switch0" "3" "0t 6"
104 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
105 ucidef_add_switch "switch0" "1" "1"
106 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
110 ucidef_set_interfaces_lan_wan "eth1" "eth0"
111 ucidef_add_switch "switch0" "1" "1"
112 ucidef_add_switch_vlan "switch0" "1" "2 3 4 5 6"
113 ucidef_add_switch_vlan "switch0" "2" "0 1"
117 ucidef_set_interfaces_lan_wan "eth0" "eth1"
118 ucidef_add_switch "switch0" "1" "1"
119 ucidef_add_switch_vlan "switch0" "0" "0 1 2 3 5"
123 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
124 ucidef_add_switch "switch0" "1" "1"
125 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
126 ucidef_add_switch_vlan "switch0" "2" "5 6"
131 ucidef_set_interfaces_lan_wan "eth1" "eth0"
132 ucidef_add_switch "switch0" "1" "1"
133 ucidef_add_switch_vlan "switch0" "1" "1 2 5"
137 ucidef_set_interfaces_lan_wan "eth1" "eth0"
138 ucidef_add_switch "switch0" "1" "1"
139 ucidef_add_switch_vlan "switch0" "1" "0 1 2"
143 ucidef_set_interfaces_lan_wan "eth1" "eth0"
144 ucidef_add_switch "switch0" "1" "1"
145 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5"
150 ucidef_set_interfaces_lan_wan "eth1" "eth0"
151 ucidef_add_switch "switch0" "1" "1"
152 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
160 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
161 ucidef_add_switch "switch0" "1" "1"
162 ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
163 ucidef_add_switch_vlan "switch0" "2" "0t 1"
167 ucidef_set_interfaces_lan_wan "eth1" "eth0"
171 ucidef_set_interfaces_lan_wan "eth0 eth1.1" "eth1.2"
172 ucidef_add_switch "switch0" "1" "1"
173 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
174 ucidef_add_switch "switch1" "1" "1"
175 ucidef_add_switch_vlan "switch1" "1" "0t 1 2 3 4"
176 ucidef_add_switch_vlan "switch1" "2" "0t 5"
182 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
183 ucidef_add_switch "switch0" "1" "1"
184 ucidef_add_switch_vlan "switch0" "1" "0t 1 3 4 5"
185 ucidef_add_switch_vlan "switch0" "2" "0t 2"
189 ucidef_set_interfaces_lan_wan "eth1" "eth0"
190 ucidef_add_switch "switch0" "1" "1"
191 ucidef_add_switch_vlan "switch0" "1" "0 1 3"
196 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
197 ucidef_add_switch "switch0" "1" "1"
198 ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
199 ucidef_add_switch_vlan "switch0" "2" "0t 1"
203 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
204 ucidef_add_switch "switch0" "1" "1"
205 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
206 ucidef_add_switch_vlan "switch0" "2" "0 5t"
210 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
211 ucidef_add_switch "switch0" "1" "1"
212 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 9t"
213 ucidef_add_switch_vlan "switch0" "2" "0 9t"
218 ucidef_set_interface_raw "eth" "eth0"
219 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
234 ucidef_set_interfaces_lan_wan "eth1" "eth0"
235 ucidef_add_switch "switch0" "1" "1"
236 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
240 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
241 ucidef_add_switch "switch0" "1" "1"
242 ucidef_add_switch_vlan "switch0" "1" "0t 1"
243 ucidef_add_switch_vlan "switch0" "2" "0t 2"
247 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
248 ucidef_add_switch "switch0" "1" "1"
249 ucidef_add_switch_vlan "switch0" "1" "0t 5"
250 ucidef_add_switch_vlan "switch0" "2" "0t 1"
254 ucidef_set_interfaces_lan_wan "eth0" "eth1"
255 ucidef_add_switch "switch0" "1" "1"
256 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4 5"
260 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
261 ucidef_add_switch "switch0" "1" "1"
262 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
268 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
269 ucidef_add_switch "switch0" "1" "1"
270 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
271 ucidef_add_switch_vlan "switch0" "2" "0t 5"
272 mac=$(mtd_get_mac_ascii nvram "wan_mac")
273 [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
278 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
279 ucidef_add_switch "switch0" "1" "1"
280 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
281 ucidef_add_switch_vlan "switch0" "2" "0t 5"
282 mac=$(mtd_get_mac_ascii devdata "wanmac")
283 [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
287 ucidef_set_interface_lan "wlan0"
294 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
295 ucidef_add_switch "switch0" "1" "1"
296 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
297 ucidef_add_switch_vlan "switch0" "2" "0t 5"
298 mac_lan=$(mtd_get_mac_binary caldata 0)
299 [ -n "$mac_lan" ] && ucidef_set_interface_macaddr "lan" "$mac_lan"
300 mac_wan=$(mtd_get_mac_binary caldata 6)
301 [ -n "$mac_wan" ] && ucidef_set_interface_macaddr "wan" "$mac_wan"
306 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
307 ucidef_add_switch "switch0" "1" "1"
308 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
309 ucidef_add_switch_vlan "switch0" "2" "0t 5"
310 mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
311 [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
315 ucidef_set_interface_lan "eth0 eth1"
319 ucidef_set_interface_lan "eth0"
320 ucidef_add_switch "switch0" "1" "0"
321 ucidef_add_switch_vlan "switch0" "0" "0 2 3 4"
366 ucidef_set_interface_lan "eth0"
372 ucidef_set_interface_lan "eth1"
386 ucidef_set_interfaces_lan_wan "eth1" "eth0"
390 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
391 ucidef_add_switch "switch0" "1" "1"
392 ucidef_add_switch_vlan "switch0" "1" "0t 3"
393 ucidef_add_switch_vlan "switch0" "2" "0t 2"
397 ucidef_set_interfaces_lan_wan "eth0" "eth1"
401 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
402 ucidef_add_switch "switch0" "1" "1"
403 ucidef_add_switch_vlan "switch0" "1" "5 6t"
404 ucidef_add_switch_vlan "switch0" "2" "1 6t"
437 ucidef_set_interfaces_lan_wan "eth0" "eth1"
438 ucidef_add_switch "switch0" "1" "1"
439 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
443 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
444 ucidef_add_switch "switch0" "1" "1"
445 ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
446 ucidef_add_switch_vlan "switch0" "2" "0t 1"
450 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
451 ucidef_add_switch "switch0" "1" "1"
452 ucidef_add_switch_vlan "switch0" "1" "0t 1 2"
453 ucidef_add_switch_vlan "switch0" "2" "0t 3"
457 ucidef_set_interfaces_lan_wan "eth0" "eth1"
458 ucidef_add_switch "switch0" "1" "1"
459 ucidef_add_switch_vlan "switch0" "1" "0 2 3"
463 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
464 ucidef_add_switch "switch0" "1" "1"
465 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
466 # Blinkrate: 0=43ms; 1=84ms; 2=120ms; 3=170ms; 4=340ms; 5=670ms
467 uci set network.@switch[-1].blinkrate='2'
469 ucidef_add_switch_port "switch0" "1"
470 # Port 1 controls the GREEN configuration of LEDs for
471 # the switch and the section does not correspond to a real
474 # 0=LED off; 1=Collision/FDX; 2=Link/activity; 3=1000 Mb/s;
475 # 4=100 Mb/s; 5=10 Mb/s; 6=1000 Mb/s+activity; 7=100 Mb/s+activity;
476 # 8=10 Mb/s+activity; 9=10/100 Mb/s+activity; 10: Fiber;
477 # 11: Fault; 12: Link/activity(tx); 13: Link/activity(rx);
478 # 14: Link (master); 15: separate register
479 uci set network.@switch_port[-1].led='6'
481 ucidef_add_switch_port "switch0" "2"
482 # Port 2 controls the ORANGE configuration of LEDs for
483 # the switch and the section does not correspond to a real
486 # See the key above for switch port 1 for the meaning of the
487 # 'led' setting below.
488 uci set network.@switch_port[-1].led='9'
490 ucidef_add_switch_port "switch0" "5"
491 # Port 5 controls the configuration of the WAN LED and the
492 # section does not correspond to a real switch port.
494 # To toggle the use of green or orange LEDs for the WAN port,
495 # see the LED setting for wndr3700:green:wan in /etc/config/system.
497 # See the key above for switch port 1 for the meaning of the
498 # 'led' setting below.
499 uci set network.@switch_port[-1].led='2'
503 ucidef_set_interfaces_lan_wan "eth0" "eth1"