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
)
23 ucidef_set_interface_lan
"eth0 eth1"
28 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
29 ucidef_add_switch
"switch0" "1" "1"
30 ucidef_add_switch_vlan
"switch0" "1" "0t 2 3 4 5"
31 ucidef_add_switch_vlan
"switch0" "2" "0t 1"
36 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
37 ucidef_add_switch
"switch0" "1" "1"
38 ucidef_add_switch_vlan
"switch0" "1" "0t 1 2 3 4"
39 ucidef_add_switch_vlan
"switch0" "2" "0t 5"
43 ucidef_set_interfaces_lan_wan
"eth0" "eth1"
44 ucidef_add_switch
"switch0" "1" "1"
45 ucidef_add_switch_vlan
"switch0" "1" "0 1 2 3 4"
46 ucidef_add_switch_vlan
"switch0" "2" "5 6"
50 ucidef_set_interfaces_lan_wan
"eth0" "eth1"
51 ucidef_add_switch
"switch0" "1" "1"
52 ucidef_add_switch_vlan
"switch0" "1" "0 1 2 3 4"
53 ucidef_add_switch_vlan
"switch0" "2" "5 6"
60 ucidef_set_interfaces_lan_wan
"eth1" "eth0"
61 ucidef_add_switch
"switch0" "1" "1"
62 ucidef_add_switch_vlan
"switch0" "1" "0 1 2 3 4"
63 ucidef_add_switch_vlan
"switch0" "2" "5 6"
69 ucidef_set_interfaces_lan_wan
"eth1" "eth0"
70 ucidef_add_switch
"switch0" "1" "1"
71 ucidef_add_switch_vlan
"switch0" "1" "0 2 3 4 5"
72 ucidef_add_switch_vlan
"switch0" "2" "1 6"
76 ucidef_set_interfaces_lan_wan
"eth1" "eth0"
77 ucidef_add_switch
"switch0" "1" "1"
78 ucidef_add_switch_vlan
"switch0" "1" "0 1 3"
79 ucidef_set_interface_wlan
83 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
84 ucidef_add_switch
"switch0" "1" "1"
85 ucidef_add_switch_vlan
"switch0" "1" "0t 5"
86 ucidef_add_switch_vlan
"switch0" "2" "0t 4"
90 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
91 ucidef_add_switch
"switch0" "1" "1"
92 ucidef_add_switch_vlan
"switch0" "1" "0t 4"
93 ucidef_add_switch_vlan
"switch0" "2" "0t 5"
102 ucidef_set_interfaces_lan_wan
"eth0.1 eth1" "eth0.2"
103 ucidef_add_switch
"switch0" "1" "1"
104 ucidef_add_switch_vlan
"switch0" "1" "0t 2 3 4 5"
105 ucidef_add_switch_vlan
"switch0" "2" "0t 1"
106 ucidef_add_switch
"switch1" "1" "1"
107 ucidef_add_switch_vlan
"switch1" "1" "0 1 2 3 4 5"
110 rb-2011uas
* | rb-2011uias | rb-2011uias-2hnd
)
111 ucidef_set_interface_raw
"sfp" "eth0.3"
112 ucidef_add_switch_vlan
"switch0" "3" "0t 6"
119 ucidef_set_interfaces_lan_wan
"eth0.1" "eth1"
120 ucidef_add_switch
"switch0" "1" "1"
121 ucidef_add_switch_vlan
"switch0" "1" "0 1 2 3 5t"
125 ucidef_set_interfaces_lan_wan
"eth1" "eth0"
126 ucidef_add_switch
"switch0" "1" "1"
127 ucidef_add_switch_vlan
"switch0" "1" "2 3 4 5 6"
128 ucidef_add_switch_vlan
"switch0" "2" "0 1"
132 ucidef_set_interfaces_lan_wan
"eth0" "eth1"
133 ucidef_add_switch
"switch0" "1" "1"
134 ucidef_add_switch_vlan
"switch0" "0" "0 1 2 3 5"
139 ucidef_set_interfaces_lan_wan
"eth0.1" "eth1"
140 ucidef_add_switch
"switch0" "1" "1"
141 ucidef_add_switch_vlan
"switch0" "1" "0t 1 2 3 4"
142 ucidef_add_switch_vlan
"switch0" "2" "5 6"
148 ucidef_set_interfaces_lan_wan
"eth1" "eth0"
149 ucidef_add_switch
"switch0" "1" "1"
150 ucidef_add_switch_vlan
"switch0" "1" "1 2 5"
154 ucidef_set_interfaces_lan_wan
"eth1" "eth0"
155 ucidef_add_switch
"switch0" "1" "1"
156 ucidef_add_switch_vlan
"switch0" "1" "0 1 2"
160 ucidef_set_interfaces_lan_wan
"eth1" "eth0"
161 ucidef_add_switch
"switch0" "1" "1"
162 ucidef_add_switch_vlan
"switch0" "1" "0 1 2 3 5"
167 ucidef_set_interfaces_lan_wan
"eth1" "eth0"
168 ucidef_add_switch
"switch0" "1" "1"
169 ucidef_add_switch_vlan
"switch0" "1" "0 1 2 3 4"
177 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
178 ucidef_add_switch
"switch0" "1" "1"
179 ucidef_add_switch_vlan
"switch0" "1" "0t 2 3 4 5"
180 ucidef_add_switch_vlan
"switch0" "2" "0t 1"
184 ucidef_set_interfaces_lan_wan
"eth1" "eth0"
188 ucidef_set_interfaces_lan_wan
"eth0 eth1.1" "eth1.2"
189 ucidef_add_switch
"switch0" "1" "1"
190 ucidef_add_switch_vlan
"switch0" "1" "0 1 2 3 4"
191 ucidef_add_switch
"switch1" "1" "1"
192 ucidef_add_switch_vlan
"switch1" "1" "0t 1 2 3 4"
193 ucidef_add_switch_vlan
"switch1" "2" "0t 5"
199 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
200 ucidef_add_switch
"switch0" "1" "1"
201 ucidef_add_switch_vlan
"switch0" "1" "0t 1 3 4 5"
202 ucidef_add_switch_vlan
"switch0" "2" "0t 2"
206 ucidef_set_interfaces_lan_wan
"eth1" "eth0"
207 ucidef_add_switch
"switch0" "1" "1"
208 ucidef_add_switch_vlan
"switch0" "1" "0 1 3"
213 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
214 ucidef_add_switch
"switch0" "1" "1"
215 ucidef_add_switch_vlan
"switch0" "1" "0t 2 3 4 5"
216 ucidef_add_switch_vlan
"switch0" "2" "0t 1"
220 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
221 ucidef_add_switch
"switch0" "1" "1"
222 ucidef_add_switch_vlan
"switch0" "1" "1 2 3 4 5t"
223 ucidef_add_switch_vlan
"switch0" "2" "0 5t"
227 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
228 ucidef_add_switch
"switch0" "1" "1"
229 ucidef_add_switch_vlan
"switch0" "1" "1 2 3 4 9t"
230 ucidef_add_switch_vlan
"switch0" "2" "0 9t"
235 ucidef_set_interface_raw
"eth" "eth0"
236 ucidef_set_interfaces_lan_wan
"lan1 lan2 lan3 lan4" "wan"
253 ucidef_set_interfaces_lan_wan
"eth1" "eth0"
254 ucidef_add_switch
"switch0" "1" "1"
255 ucidef_add_switch_vlan
"switch0" "1" "0 1 2 3 4"
259 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
260 ucidef_add_switch
"switch0" "1" "1"
261 ucidef_add_switch_vlan
"switch0" "1" "0t 1"
262 ucidef_add_switch_vlan
"switch0" "2" "0t 2"
266 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
267 ucidef_add_switch
"switch0" "1" "1"
268 ucidef_add_switch_vlan
"switch0" "1" "0t 5"
269 ucidef_add_switch_vlan
"switch0" "2" "0t 1"
273 ucidef_set_interfaces_lan_wan
"eth0" "eth1"
274 ucidef_add_switch
"switch0" "1" "1"
275 ucidef_add_switch_vlan
"switch0" "1" "0 1 2 3 4 5"
279 ucidef_set_interfaces_lan_wan
"eth0.1" "eth1"
280 ucidef_add_switch
"switch0" "1" "1"
281 ucidef_add_switch_vlan
"switch0" "1" "0 1 2 3 5t"
287 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
288 ucidef_add_switch
"switch0" "1" "1"
289 ucidef_add_switch_vlan
"switch0" "1" "0t 1 2 3 4"
290 ucidef_add_switch_vlan
"switch0" "2" "0t 5"
291 mac
=$
(mtd_get_mac_ascii nvram
"wan_mac")
292 [ -n "$mac" ] && ucidef_set_interface_macaddr
"wan" "$mac"
297 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
298 ucidef_add_switch
"switch0" "1" "1"
299 ucidef_add_switch_vlan
"switch0" "1" "0t 1 2 3 4"
300 ucidef_add_switch_vlan
"switch0" "2" "0t 5"
301 mac
=$
(mtd_get_mac_ascii devdata
"wanmac")
302 [ -n "$mac" ] && ucidef_set_interface_macaddr
"wan" "$mac"
306 ucidef_set_interface_lan
"wlan0"
313 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
314 ucidef_add_switch
"switch0" "1" "1"
315 ucidef_add_switch_vlan
"switch0" "1" "0t 1 2 3 4"
316 ucidef_add_switch_vlan
"switch0" "2" "0t 5"
317 mac_lan
=$
(mtd_get_mac_binary caldata
0)
318 [ -n "$mac_lan" ] && ucidef_set_interface_macaddr
"lan" "$mac_lan"
319 mac_wan
=$
(mtd_get_mac_binary caldata
6)
320 [ -n "$mac_wan" ] && ucidef_set_interface_macaddr
"wan" "$mac_wan"
325 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
326 ucidef_add_switch
"switch0" "1" "1"
327 ucidef_add_switch_vlan
"switch0" "1" "0t 1 2 3 4"
328 ucidef_add_switch_vlan
"switch0" "2" "0t 5"
329 mac
=$
(mtd_get_mac_ascii u-boot-env
"wanaddr")
330 [ -n "$mac" ] && ucidef_set_interface_macaddr
"wan" "$mac"
334 ucidef_set_interface_lan
"eth0 eth1"
338 ucidef_set_interface_lan
"eth0"
339 ucidef_add_switch
"switch0" "1" "0"
340 ucidef_add_switch_vlan
"switch0" "0" "0 2 3 4"
388 ucidef_set_interface_lan
"eth0"
393 ucidef_set_interface_lan
"eth1"
407 ucidef_set_interfaces_lan_wan
"eth1" "eth0"
411 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
412 ucidef_add_switch
"switch0" "1" "1"
413 ucidef_add_switch_vlan
"switch0" "1" "0t 3"
414 ucidef_add_switch_vlan
"switch0" "2" "0t 2"
418 ucidef_set_interfaces_lan_wan
"eth0" "eth1"
422 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
423 ucidef_add_switch
"switch0" "1" "1"
424 ucidef_add_switch_vlan
"switch0" "1" "5 6t"
425 ucidef_add_switch_vlan
"switch0" "2" "1 6t"
460 ucidef_set_interfaces_lan_wan
"eth0" "eth1"
461 ucidef_add_switch
"switch0" "1" "1"
462 ucidef_add_switch_vlan
"switch0" "1" "0 1 2 3 4"
466 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
467 ucidef_add_switch
"switch0" "1" "1"
468 ucidef_add_switch_vlan
"switch0" "1" "0t 2 3 4 5"
469 ucidef_add_switch_vlan
"switch0" "2" "0t 1"
473 ucidef_set_interfaces_lan_wan
"eth0.1" "eth0.2"
474 ucidef_add_switch
"switch0" "1" "1"
475 ucidef_add_switch_vlan
"switch0" "1" "0t 1 2"
476 ucidef_add_switch_vlan
"switch0" "2" "0t 3"
480 ucidef_set_interfaces_lan_wan
"eth0" "eth1"
481 ucidef_add_switch
"switch0" "1" "1"
482 ucidef_add_switch_vlan
"switch0" "1" "0 2 3"
486 ucidef_set_interfaces_lan_wan
"eth0.1" "eth1"
487 ucidef_add_switch
"switch0" "1" "1"
488 ucidef_add_switch_vlan
"switch0" "1" "0 1 2 3 5t"
489 # Blinkrate: 0=43ms; 1=84ms; 2=120ms; 3=170ms; 4=340ms; 5=670ms
490 uci
set network.@switch
[-1].blinkrate
='2'
492 ucidef_add_switch_port
"switch0" "1"
493 # Port 1 controls the GREEN configuration of LEDs for
494 # the switch and the section does not correspond to a real
497 # 0=LED off; 1=Collision/FDX; 2=Link/activity; 3=1000 Mb/s;
498 # 4=100 Mb/s; 5=10 Mb/s; 6=1000 Mb/s+activity; 7=100 Mb/s+activity;
499 # 8=10 Mb/s+activity; 9=10/100 Mb/s+activity; 10: Fiber;
500 # 11: Fault; 12: Link/activity(tx); 13: Link/activity(rx);
501 # 14: Link (master); 15: separate register
502 uci
set network.@switch_port
[-1].led
='6'
504 ucidef_add_switch_port
"switch0" "2"
505 # Port 2 controls the ORANGE configuration of LEDs for
506 # the switch and the section does not correspond to a real
509 # See the key above for switch port 1 for the meaning of the
510 # 'led' setting below.
511 uci
set network.@switch_port
[-1].led
='9'
513 ucidef_add_switch_port
"switch0" "5"
514 # Port 5 controls the configuration of the WAN LED and the
515 # section does not correspond to a real switch port.
517 # To toggle the use of green or orange LEDs for the WAN port,
518 # see the LED setting for wndr3700:green:wan in /etc/config/system.
520 # See the key above for switch port 1 for the meaning of the
521 # 'led' setting below.
522 uci
set network.@switch_port
[-1].led
='2'
526 ucidef_set_interfaces_lan_wan
"eth0" "eth1"