85d0eba1408177ab5731500fd81cc334a0526d7a
[openwrt/svn-archive/archive.git] / target / linux / lantiq / base-files / etc / uci-defaults / 02_network
1 #!/bin/sh
2 #
3 # Copyright (C) 2011-2012 OpenWrt.org
4 #
5
6 [ -e /etc/config/network ] && exit 0
7
8 set_atm_wan() {
9 local vpi=$1
10 local vci=$2
11 local encaps=$3
12 local payload=$4
13 uci batch <<EOF
14 set network.atm='atm-bridge'
15 set network.atm.vpi='$vpi'
16 set network.atm.vci='$vci'
17 set network.atm.encaps='$encaps'
18 set network.atm.payload='$payload'
19 set network.wan='interface'
20 set network.wan.ifname='nas0'
21 set network.wan.proto='pppoe'
22 set network.wan.username='foo'
23 set network.wan.password='bar'
24 set network.wan.ipv6='1'
25 set network.wan6='interface'
26 set network.wan6.ifname='@wan'
27 set network.wan6.proto='dhcpv6'
28 EOF
29 }
30
31 set_adsl_modem() {
32 local annex=$1
33 local firmware=$2
34 uci batch <<EOF
35 set network.dsl='adsl'
36 set network.dsl.annex='$annex'
37 set network.dsl.firmware='$firmware'
38 EOF
39 }
40
41 set_vdsl_modem() {
42 local annex=$1
43 local firmware=$2
44 local tone=$3
45 local xfer_mode=$4
46 uci batch <<EOF
47 set network.dsl='vdsl'
48 set network.dsl.annex='$annex'
49 set network.dsl.firmware='$firmware'
50 set network.dsl.tone='$tone'
51 set network.dsl.xfer_mode='$xfer_mode'
52 EOF
53 }
54
55 . /lib/functions/uci-defaults.sh
56 . /lib/functions/lantiq.sh
57
58 touch /etc/config/network
59
60 ucidef_set_interface_loopback
61 ucidef_set_interface_lan 'eth0'
62
63 vpi=1
64 vci=32
65 annex="a"
66 encaps="llc"
67 payload="bridged"
68 lan_mac=""
69 wan_mac=""
70
71 board=$(lantiq_board_name)
72
73 case "$board" in
74 # adm6996
75 ARV4510PW)
76 lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
77 wan_mac=$(macaddr_add "$lan_mac" 1)
78 ucidef_set_interface_lan "eth0.1"
79 ucidef_add_switch "switch0" "1" "1"
80 ucidef_add_switch_vlan "switch0" "1" "3 2 1 0 5t"
81 ;;
82
83 ARV4520PW)
84 ucidef_set_interface_lan "eth0.1"
85 ucidef_add_switch "switch0" "1" "1"
86 ucidef_add_switch_vlan "switch0" "1" "3 2 1 0 5t"
87 ;;
88
89 ACMP252|GIGASX76X)
90 ucidef_set_interface_lan "eth0.1"
91 ucidef_add_switch "switch0" "1" "1"
92 ucidef_add_switch_vlan "switch0" "1" "4 3 2 1 5t"
93 ;;
94
95 # ar8316
96 ARV4519PW|ARV7510PW22|ARV7518PW|ARV752DPW22|ARV8539PW22)
97 ucidef_set_interface_lan "eth0.1"
98 ucidef_add_switch "switch0" "1" "1"
99 ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
100 ;;
101
102 # rtl8306g
103 ARV7519PW)
104 lan_mac=$(mtd_get_mac_binary board_config 22)
105 wan_mac=$(macaddr_add "$lan_mac" 1)
106 ucidef_set_interface_lan "eth0.1"
107 ucidef_add_switch "switch0" "1" "1"
108 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4t"
109 ;;
110
111 WBMR)
112 ucidef_set_interface_lan "eth0.1"
113 ucidef_add_switch "switch0" "1" "1"
114 ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
115 ;;
116
117 VG3503J)
118 ucidef_set_interface_lan 'eth0'
119 uci set network.lan.type='none'
120 ;;
121
122 DGN3500*)
123 ucidef_set_interface_lan "eth0.1"
124 ucidef_add_switch "switch0" "1" "1"
125 ucidef_add_switch_vlan "switch0" "1" "3 2 1 0 5t"
126 ;;
127
128 GR7000)
129 ucidef_set_interface_wan "eth0"
130 uci set network.lan.ifname=''
131 ;;
132
133 H201L)
134 ucidef_set_interface_lan "eth0.1"
135 ucidef_add_switch "switch0" "1" "1"
136 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4t"
137 ;;
138
139 #rtl8306g
140 P2601HNFX)
141 ucidef_set_interface_lan "eth0.1"
142 ucidef_add_switch "switch0" "1" "1"
143 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
144 ;;
145
146 P2812HNUF*)
147 lan_mac=$(mtd_get_mac_ascii uboot-env ethaddr)
148 wan_mac=$(macaddr_add "$lan_mac" 1)
149 ucidef_set_interface_lan 'eth0.1'
150 ucidef_add_switch "switch0" "1" "1"
151 ucidef_add_switch_vlan "switch0" "1" "0 1 2 4 5 6t"
152 ;;
153
154 TDW8970|TDW8980)
155 lan_mac=$(mtd_get_mac_binary boardconfig 61696)
156 wan_mac=$(macaddr_add "$lan_mac" 1)
157 ucidef_set_interface_lan 'eth0.1'
158 ucidef_add_switch "switch0" "1" "1"
159 ucidef_add_switch_vlan "switch0" "1" "0 2 4 5 6t"
160 ;;
161
162 ARV7519RW22)
163 lan_mac=$(mtd_get_mac_binary boardconfig 22)
164 wan_mac=$(macaddr_add "$lan_mac" 1)
165 ;;
166
167 BTHOMEHUBV2B|BTHOMEHUBV3A)
168 lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
169 wan_mac=$(macaddr_add "$lan_mac" 1)
170 ;;
171
172 BTHOMEHUBV5A)
173 lan_mac=$(mtd_get_mac_binary caldata 4364)
174 wan_mac=$(macaddr_add "$lan_mac" 1)
175 ucidef_set_interface_lan 'eth0.1'
176 ucidef_add_switch "switch0" "1" "1"
177 ucidef_add_switch_vlan "switch0" "1" "0 1 2 4 6t"
178 ;;
179
180 VGV7519)
181 lan_mac=$(mtd_get_mac_binary board_config 22)
182 wan_mac=$(macaddr_add "$lan_mac" 1)
183 ;;
184
185 VGV7510KW22)
186 lan_mac=$(mtd_get_mac_binary board_config 22)
187 wan_mac=$(macaddr_add "$lan_mac" 1)
188 ucidef_set_interface_lan 'eth0.1'
189 ucidef_add_switch "switch0" "1" "1"
190 ucidef_add_switch_vlan "switch0" "1" "2 3 4 5 6t"
191 ;;
192
193 esac
194
195 [ -z "$(ls /lib/modules/`uname -r`/ltq_atm*)" ] || set_atm_wan "$vpi" "$vci" "$encaps" "$payload"
196
197 if [ -n "$(grep "system type.*: VR9" /proc/cpuinfo)" ]; then
198 set_vdsl_modem "$annex" "/lib/firmware/vdsl.bin" "av" "ptm"
199 else
200 set_adsl_modem "$annex" "/lib/firmware/adsl.bin"
201 fi
202
203 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
204 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
205
206 uci commit network
207
208 exit 0