ramips: add user-space support for TEW-691GR
[openwrt/staging/lynxis/omap.git] / target / linux / ramips / base-files / etc / uci-defaults / network
1 #!/bin/sh
2
3 . /etc/functions.sh
4 . /lib/ramips.sh
5 . /lib/functions/uci-defaults.sh
6
7 if [ ! -x /usr/sbin/maccalc ]; then
8 echo "$0: maccalc not found!"
9 return
10 fi
11
12 ramips_setup_rt3x5x_vlans()
13 {
14 if [ ! -x /sbin/swconfig ]; then
15 # legacy default
16 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
17 return
18 fi
19 local wanports=""
20 local lanports=""
21 swconfig dev rt305x set reset 1
22 for port in 5 4 3 2 1 0; do
23 if [ `swconfig dev rt305x port $port get disable` = "1" ]; then
24 continue
25 fi
26 if [ `swconfig dev rt305x port $port get lan` = "0" ]; then
27 wanports="$port $wanports"
28 else
29 lanports="$port $lanports"
30 fi
31 done
32 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
33 ucidef_add_switch "rt305x" "1" "1"
34 ucidef_add_switch_vlan "rt305x" "1" "$lanports 6t"
35 ucidef_add_switch_vlan "rt305x" "2" "$wanports 6t"
36 }
37
38 ramips_setup_interfaces()
39 {
40 local board="$1"
41
42 ucidef_set_interface_loopback
43
44 case $board in
45 all0256n | \
46 all5002)
47 ucidef_set_interface_lan "eth0"
48 ;;
49
50 dir-615-h1 | \
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 f5d8235-v1 | \
74 f5d8235-v2 | \
75 ur-336un)
76 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
77 ;;
78
79 v11st-fe)
80 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
81 ucidef_add_switch "switch0" "1" "1"
82 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
83 ucidef_add_switch_vlan "switch0" "2" "0 5t"
84 ;;
85
86 rt-n15 | \
87 wl-351)
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 5t"
91 ucidef_add_switch_vlan "switch0" "2" "4 5t"
92 ;;
93
94 rt-n56u)
95 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
96 ucidef_add_switch "switch0" "1" "1"
97 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
98 ucidef_add_switch_vlan "switch0" "2" "4 8t"
99 ;;
100
101 tew-691gr|\
102 tew-692gr)
103 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
104 ucidef_add_switch "switch0" "1" "1"
105 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
106 ucidef_add_switch_vlan "switch0" "2" "0t 5"
107 ;;
108
109 freestation5 | \
110 wcr-150gn)
111 ucidef_set_interfaces_lan_wan "eth0.2" "eth0.1"
112 ;;
113
114 wli-tx4-ag300n)
115 ucidef_set_interface_lan "eth0"
116 ;;
117
118 *)
119 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
120 if [ -n "${RT3X5X}" ]; then
121 ramips_setup_rt3x5x_vlans
122 else
123 ucidef_set_interfaces_lan_wan "eth0" "eth1"
124 fi
125 ;;
126 esac
127 }
128
129 ramips_setup_macs()
130 {
131 local board="$1"
132 local lan_mac=""
133 local wan_mac=""
134
135 case $board in
136 all0256n | \
137 all5002 | \
138 dir-615-h1)
139 lan_mac=$(ramips_get_mac_binary factory 40)
140 ;;
141 3g-6200n | \
142 argus-atp52b | \
143 bc2 | \
144 f5d8235-v1 | \
145 nw718 | \
146 psr-680w | \
147 rt-n15 | \
148 sl-r7205 | \
149 wl-351)
150 lan_mac=$(ramips_get_mac_binary factory 4)
151 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
152 ;;
153
154 w306r-v20)
155 lan_mac=$(ramips_get_mac_binary factory 4)
156 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 5)
157 ;;
158
159 fonera20n)
160 lan_mac=$(ramips_get_mac_binary factory 40)
161 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
162 ;;
163
164 dir-300-b1 |\
165 dir-300-b2 |\
166 dir-600-b1)
167 lan_mac=$(ramips_get_mac_binary devdata 16388)
168 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
169 ;;
170
171 dir-620-a1)
172 lan_mac=$(ramips_get_mac_binary factory 4)
173 lan_mac=$(maccalc or "$lan_mac" "02:00:00:00:00:00")
174 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
175 ;;
176
177 dir-645)
178 lan_mac=$(ramips_get_mac_nvram nvram lanmac)
179 wan_mac=$(ramips_get_mac_nvram nvram wanmac)
180 ;;
181
182 esr-9753 | \
183 ur-336un)
184 lan_mac=$(ramips_get_mac_binary devdata 16388)
185 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
186 ;;
187
188 nbg-419n | \
189 wcr-150gn)
190 lan_mac=$(ramips_get_mac_binary factory 4)
191 wan_mac=$(ramips_get_mac_binary factory 40)
192 ;;
193
194 f5d8235-v2)
195 lan_mac=$(ramips_get_mac_binary "u-boot" 262148)
196 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
197 ;;
198
199 rt-n56u)
200 lan_mac=$(ramips_get_mac_binary factory 4)
201 wan_mac=$(ramips_get_mac_binary factory 32772)
202 ;;
203
204 tew-691gr)
205 lan_mac=$(ramips_get_mac_binary factory 40)
206 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 3)
207 ;;
208
209 tew-692gr)
210 lan_mac=$(ramips_get_mac_binary factory 40)
211 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 4)
212 ;;
213
214 all0239-3g | \
215 carambola | \
216 w502u)
217 lan_mac=$(ramips_get_mac_binary factory 40)
218 wan_mac=$(ramips_get_mac_binary factory 46)
219 ;;
220
221 wl341v3)
222 lan_mac=$(ramips_get_mac_binary board-nvram 65440)
223 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
224 ;;
225
226 wli-tx4-ag300n)
227 lan_mac=$(ramips_get_mac_binary factory 4)
228 ;;
229
230 esac
231
232 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
233 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
234 }
235
236 [ -e /etc/config/network ] && exit 0
237
238 touch /etc/config/network
239
240 board=$(ramips_board_name)
241
242 ramips_setup_interfaces $board
243 ramips_setup_macs $board
244
245 uci commit network
246
247 exit 0