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