lantiq: fix sx76x default uci network configuration
[openwrt/svn-archive/archive.git] / target / linux / lantiq / base-files / etc / uci-defaults / 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.unit='0'
16 set network.atm.vpi='$vpi'
17 set network.atm.vci='$vci'
18 set network.atm.encaps='$encaps'
19 set network.atm.payload='$payload'
20 set network.wan='interface'
21 set network.wan.ifname='nas0'
22 set network.wan.proto='pppoe'
23 set network.wan.username='foo'
24 set network.wan.password='bar'
25 EOF
26 }
27
28 set_adsl() {
29 local fwannex=$1
30 local annex=$2
31 uci batch <<EOF
32 set network.adsl='adsl-device'
33 set network.adsl.fwannex='$fwannex'
34 set network.adsl.annex='$annex'
35 EOF
36 }
37
38 . /lib/functions/uci-defaults.sh
39 . /lib/lantiq.sh
40
41 touch /etc/config/network
42
43 ucidef_set_interface_loopback
44 ucidef_set_interface_lan 'eth0'
45
46 vpi=1
47 vci=32
48 encaps="llc"
49 payload="bridged"
50 fwannex=$(lantiq_dsl_fwannex)
51 board=$(lantiq_board_name)
52 dsl=$(lantiq_soc_has_adsl)
53
54 case "$board" in
55 # annex B with adm6996
56 ARV4520PW)
57 ucidef_set_interface_lan "eth0.1"
58 ucidef_add_switch "eth0" "1" "1"
59 ucidef_add_switch_vlan "eth0" "1" "3 2 1 0 5t"
60 set_adsl "b" "b2p"
61 ;;
62
63 GIGASX76X)
64 ucidef_set_interface_lan "eth0.1"
65 ucidef_add_switch "eth0" "1" "1"
66 ucidef_add_switch_vlan "eth0" "1" "4 3 2 1 5t"
67 set_adsl "b" "b2p"
68 ;;
69
70 # annex A with ar8316
71 ARV4519PW|ARV7518PW)
72 ucidef_set_interface_lan "eth0.1"
73 ucidef_add_switch "eth0" "1" "1"
74 ucidef_add_switch_vlan "eth0" "1" "0t 2 3 4 5"
75 set_adsl "a" "a2p"
76 ;;
77
78 ARV7525PW|ARV4525PW|*)
79 set_adsl "$fwannex" "${fwannex}2p"
80 ;;
81 esac
82
83 [ -z "$dsl" ] || set_atm_wan "$vpi" "$vci" "$encaps" "$payload"
84
85 uci commit network
86
87 exit 0