428089ceb716c46e91e0ffc9cfcbf373b42a45e3
[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 . /lib/functions/uci-defaults.sh
32 . /lib/functions/lantiq.sh
33
34 touch /etc/config/network
35
36 ucidef_set_interface_loopback
37 ucidef_set_interface_lan 'eth0'
38
39 vpi=1
40 vci=32
41 encaps="llc"
42 payload="bridged"
43 lan_mac=""
44 wan_mac=""
45
46 board=$(lantiq_board_id)
47
48 case "$board" in
49 # adm6996
50 ARV4510PW)
51 lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
52 wan_mac=$(macaddr_add "$lan_mac" 1)
53 ucidef_set_interface_lan "eth0.1"
54 ucidef_add_switch "switch0" "1" "1"
55 ucidef_add_switch_vlan "switch0" "1" "3 2 1 0 5t"
56 ;;
57
58 ARV4520PW)
59 ucidef_set_interface_lan "eth0.1"
60 ucidef_add_switch "switch0" "1" "1"
61 ucidef_add_switch_vlan "switch0" "1" "3 2 1 0 5t"
62 ;;
63
64 ACMP252|GIGASX76X)
65 ucidef_set_interface_lan "eth0.1"
66 ucidef_add_switch "switch0" "1" "1"
67 ucidef_add_switch_vlan "switch0" "1" "4 3 2 1 5t"
68 ;;
69
70 # ar8316
71 ARV4519PW|ARV7510PW22|ARV7518PW|ARV752DPW22)
72 ucidef_set_interface_lan "eth0.1"
73 ucidef_add_switch "switch0" "1" "1"
74 ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
75 ;;
76
77 # rtl8306g
78 ARV7519PW)
79 lan_mac=$(mtd_get_mac_binary board_config 22)
80 wan_mac=$(macaddr_add "$lan_mac" 1)
81 ucidef_set_interface_lan "eth0.1"
82 ucidef_add_switch "switch0" "1" "1"
83 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4t"
84 ;;
85
86 WBMR)
87 ucidef_set_interface_lan "eth0.1"
88 ucidef_add_switch "switch0" "1" "1"
89 ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
90 ;;
91
92 VG3503J)
93 ucidef_set_interface_lan 'eth0'
94 uci set network.lan.type='none'
95 ;;
96
97 DGN3500*)
98 lan_mac=$(mtd_get_mac_ascii uboot-env ethaddr)
99 wan_mac=$(macaddr_add "$lan_mac" 1)
100 ucidef_set_interface_lan "eth0.1"
101 ucidef_add_switch "switch0" "1" "1"
102 ucidef_add_switch_vlan "switch0" "1" "3 2 1 0 5t"
103 ;;
104
105 GR7000)
106 ucidef_set_interface_wan "eth0"
107 uci set network.lan.ifname=''
108 ;;
109
110 H201L)
111 ucidef_set_interface_lan "eth0.1"
112 ucidef_add_switch "switch0" "1" "1"
113 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4t"
114 ;;
115
116 #rtl8306g
117 P2601HNFX)
118 ucidef_set_interface_lan "eth0.1"
119 ucidef_add_switch "switch0" "1" "1"
120 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
121 ;;
122
123 P2812HNUFX)
124 ucidef_set_interface_lan 'eth0.1'
125 ucidef_add_switch "switch0" "1" "1"
126 ucidef_add_switch_vlan "switch0" "1" "0 1 2 4 5 6t"
127 ;;
128
129 TDW8970)
130 lan_mac=$(mtd_get_mac_binary boardconfig 61696)
131 wan_mac=$(macaddr_add "$lan_mac" 1)
132 ;;
133
134 ARV7519*)
135 lan_mac=$(mtd_get_mac_binary boardconfig 22)
136 wan_mac=$(macaddr_add "$lan_mac" 1)
137 ;;
138
139 BTHOMEHUBV2B)
140 lan_mac=$(mtd_get_mac_ascii uboot_env ethaddr)
141 wan_mac=$(macaddr_add "$lan_mac" 1)
142 ;;
143 esac
144
145 [ -z "$(ls /lib/modules/`uname -r`/ltq_atm*)" ] || set_atm_wan "$vpi" "$vci" "$encaps" "$payload"
146 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
147 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
148
149 uci commit network
150
151 exit 0