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