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