ramips: add support for Zbtlink WA05 router
[openwrt/openwrt.git] / target / linux / ramips / base-files / etc / uci-defaults / 02_network
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . /lib/ramips.sh
5 . /lib/functions/uci-defaults.sh
6
7 ramips_setup_rt3x5x_vlans()
8 {
9 if [ ! -x /sbin/swconfig ]; then
10 # legacy default
11 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
12 return
13 fi
14 local wanports=""
15 local lanports=""
16 for port in 5 4 3 2 1 0; do
17 if [ `swconfig dev rt305x port $port get disable` = "1" ]; then
18 continue
19 fi
20 if [ `swconfig dev rt305x port $port get lan` = "0" ]; then
21 wanports="$port $wanports"
22 else
23 lanports="$port $lanports"
24 fi
25 done
26 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
27 ucidef_add_switch "rt305x" "1" "1"
28 ucidef_add_switch_vlan "rt305x" "1" "$lanports 6t"
29 ucidef_add_switch_vlan "rt305x" "2" "$wanports 6t"
30 }
31
32 ramips_setup_interfaces()
33 {
34 local board="$1"
35
36 ucidef_set_interface_loopback
37
38 case $board in
39 3g300m | \
40 w150m | \
41 all0256n | \
42 all5002 | \
43 all5003 | \
44 broadway | \
45 dcs-930| \
46 ncs601w | \
47 wnce2001)
48 ucidef_add_switch "switch0" "1" "0"
49 ucidef_set_interface_lan "eth0"
50 ;;
51
52 3g-6200nl | \
53 wl-330n | \
54 wmr300)
55 ucidef_set_interface_lan "eth0.1"
56 ;;
57
58 3g-6200n | \
59 b2c | \
60 nw718 | \
61 psr-680w | \
62 sl-r7205 | \
63 w502u | \
64 wr6202)
65 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
66 ;;
67
68 awapn2403)
69 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
70 ucidef_add_switch "switch0" "1" "1"
71 ucidef_add_switch_vlan "switch0" "1" "0 6t"
72 ucidef_add_switch_vlan "switch0" "2" "1 6t"
73 ;;
74
75 br-6475nd)
76 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
77 ucidef_add_switch "switch0" "1" "1"
78 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 9t"
79 ucidef_add_switch_vlan "switch0" "2" "0 9t"
80 ;;
81
82 asl26555)
83 ucidef_set_interface_lan "eth0.1"
84 ucidef_add_switch "switch0" "1" "1"
85 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
86 ;;
87
88 cy-swr1100)
89 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
90 ucidef_add_switch "switch0" "1" "1"
91 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 9t"
92 ucidef_add_switch_vlan "switch0" "2" "4 9t"
93 ;;
94
95 dir-610-a1 | \
96 dir-300-b7 | \
97 dir-320-b1 | \
98 dir-615-h1 | \
99 hlk-rm04 | \
100 mzk-w300nh2)
101 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
102 ucidef_add_switch "switch0" "1" "1"
103 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
104 ucidef_add_switch_vlan "switch0" "2" "4 6t"
105 ;;
106
107 awm002-evb | \
108 argus-atp52b | \
109 dir-645 | \
110 f5d8235-v1 | \
111 f5d8235-v2 | \
112 hg255d | \
113 rt-n14u | \
114 wrtnode | \
115 ur-326n4g | \
116 zbt-wa05)
117 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
118 ucidef_add_switch "switch0" "1" "1"
119 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
120 ucidef_add_switch_vlan "switch0" "2" "0 6t"
121 ;;
122
123 ur-336un)
124 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
125 ;;
126
127 br6524n | \
128 v11st-fe)
129 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
130 ucidef_add_switch "switch0" "1" "1"
131 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
132 ucidef_add_switch_vlan "switch0" "2" "0 5t"
133 ;;
134
135 ar725w | \
136 rt-n15 | \
137 wl-351)
138 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
139 ucidef_add_switch "switch0" "1" "1"
140 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
141 ucidef_add_switch_vlan "switch0" "2" "4 5t"
142 ;;
143
144 rt-n56u)
145 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
146 ucidef_add_switch "switch0" "1" "1"
147 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
148 ucidef_add_switch_vlan "switch0" "2" "4 8t"
149 ;;
150
151 tew-691gr|\
152 tew-692gr)
153 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
154 ucidef_add_switch "switch0" "1" "1"
155 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
156 ucidef_add_switch_vlan "switch0" "2" "0t 5"
157 ;;
158
159 wcr-150gn)
160 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
161 ucidef_add_switch "switch0" "1" "1"
162 ucidef_add_switch_vlan "switch0" "1" "0 6t"
163 ucidef_add_switch_vlan "switch0" "2" "6t"
164 ;;
165
166 d105 | \
167 na930 | \
168 omni-emb-hpm|\
169 wli-tx4-ag300n)
170 ucidef_set_interface_lan "eth0"
171 ;;
172
173 *)
174 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
175 if [ -n "${RT3X5X}" ]; then
176 ramips_setup_rt3x5x_vlans
177 else
178 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
179 fi
180 ;;
181 esac
182 }
183
184 ramips_setup_macs()
185 {
186 local board="$1"
187 local lan_mac=""
188 local wan_mac=""
189
190 case $board in
191 br-6475nd)
192 lan_mac=$(mtd_get_mac_binary devdata 13)
193 wan_mac=$(mtd_get_mac_binary devdata 7)
194 ;;
195
196 w306r-v20)
197 wan_mac=$(macaddr_add "$lan_mac" 5)
198 ;;
199
200 tew-691gr)
201 wan_mac=$(macaddr_add "$lan_mac" 3)
202 ;;
203
204 tew-692gr)
205 wan_mac=$(macaddr_add "$lan_mac" 4)
206 ;;
207
208 m3 |\
209 m4 |\
210 x5 |\
211 x8)
212 lan_mac=$(macaddr_add "$lan_mac" -1)
213 ;;
214
215 dir-620-a1)
216 lan_mac=$(macaddr_setbit_la "$lan_mac")
217 wan_mac=$(macaddr_add "$lan_mac" 1)
218 ;;
219
220 cy-swr1100 | \
221 dir-645)
222 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
223 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
224 ;;
225
226 nbg-419n | \
227 wcr-150gn)
228 wan_mac=$(mtd_get_mac_binary factory 40)
229 ;;
230
231 rt-n56u)
232 wan_mac=$(mtd_get_mac_binary factory 32772)
233 ;;
234
235 all0239-3g | \
236 carambola | \
237 freestation5 | \
238 w502u | \
239 wnce2001)
240 wan_mac=$(mtd_get_mac_binary factory 46)
241 ;;
242
243 wl341v3)
244 lan_mac=$(mtd_get_mac_binary board-nvram 65440)
245 wan_mac=$(macaddr_add "$lan_mac" 1)
246 ;;
247
248 *)
249 wan_mac=$(macaddr_add "$lan_mac" 1)
250 ;;
251
252 esac
253
254 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
255 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
256 }
257
258 [ -e /etc/config/network ] && exit 0
259
260 touch /etc/config/network
261
262 board=$(ramips_board_name)
263
264 ramips_setup_interfaces $board
265 ramips_setup_macs $board
266
267 uci commit network
268
269 exit 0