generic: ar8216: use ar8216_read_port_link to get the CPU port link parameters
[openwrt.git] / target / linux / lantiq / base-files / etc / uci-defaults / network
1 #!/bin/sh
2 #
3 # Copyright (C) 2011 OpenWrt.org
4 #
5
6 set_interface_loopback() {
7 uci batch <<EOF
8 set network.loopback='interface'
9 set network.loopback.ifname='lo'
10 set network.loopback.proto='static'
11 set network.loopback.ipaddr='127.0.0.1'
12 set network.loopback.netmask='255.0.0.0'
13 EOF
14 }
15
16 set_interface_raw() {
17 local cfg=$1
18 local ifname=$2
19
20 uci batch <<EOF
21 set network.$cfg='interface'
22 set network.$cfg.ifname='$ifname'
23 set network.$cfg.proto='none'
24 EOF
25 }
26
27 set_interface_lan() {
28 local ifname=$1
29
30 uci batch <<EOF
31 set network.lan='interface'
32 set network.lan.ifname='$ifname'
33 set network.lan.type='bridge'
34 set network.lan.proto='static'
35 set network.lan.ipaddr='192.168.1.1'
36 set network.lan.netmask='255.255.255.0'
37 EOF
38 }
39
40 set_interface_wan() {
41 local ifname=$1
42
43 uci batch <<EOF
44 set network.wan='interface'
45 set network.wan.ifname='$ifname'
46 set network.wan.proto='dhcp'
47 EOF
48 }
49
50 set_atm_wan() {
51 local vpi=$1
52 local vci=$2
53 local encaps=$3
54 local payload=$4
55 uci batch <<EOF
56 set network.atm='atm-bridge'
57 set network.atm.unit='0'
58 set network.atm.vpi='$vpi'
59 set network.atm.vci='$vci'
60 set network.atm.encaps='$encaps'
61 set network.atm.payload='$payload'
62 set network.atm.fwannex='$annex'
63 set network.atm.annex='$annex'
64 set network.wan='interface'
65 set network.wan.ifname='nas0'
66 set network.wan.proto='pppoe'
67 set network.wan.username='foo'
68 set network.wan.password='bar'
69 EOF
70 }
71
72 set_adsl() {
73 local fwannex=$1
74 local annex=$2
75 uci batch <<EOF
76 set network.adsl='adsl-device'
77 set network.adsl.fwannex='$fwannex'
78 set network.adsl.annex='$annex'
79 EOF
80 }
81
82 set_interfaces_lan_wan() {
83 local lan_ifname=$1
84 local wan_ifname=$2
85
86 set_interface_lan "$lan_ifname"
87 set_interface_wan "$wan_ifname"
88 }
89
90 add_switch() {
91 local name=$1
92 local reset=$2
93 local enable=$3
94 uci batch <<EOF
95 add network switch
96 set network.@switch[-1].name='$name'
97 set network.@switch[-1].reset='$reset'
98 set network.@switch[-1].enable_vlan='$enable'
99 EOF
100 }
101
102 add_switch_vlan() {
103 local device=$1
104 local vlan=$2
105 local ports=$3
106 uci batch <<EOF
107 add network switch_vlan
108 set network.@switch_vlan[-1].device='$device'
109 set network.@switch_vlan[-1].vlan='$vlan'
110 set network.@switch_vlan[-1].ports='$ports'
111 EOF
112 }
113
114 [ -e /etc/config/network ] && exit 0
115
116 . /lib/lantiq.sh
117
118 touch /etc/config/network
119
120 set_interface_loopback
121 set_interface_lan 'eth0'
122
123
124 vpi=1
125 vci=32
126 encaps="llc"
127 payload="bridged"
128 fwannex=$(lantiq_dsl_fwannex)
129 annex="$fwannex"
130
131 board=$(lantiq_board_name)
132 case "$board" in
133 GIGASX76X)
134 set_interface_lan "eth0.1"
135 add_switch "eth0" "1" "1"
136 add_switch_vlan "eth0" "1" "1 2 3 4 5t"
137 ;;
138
139 *)
140 # custom foo goes here
141 true
142 ;;
143 esac
144
145 dsl=$(lantiq_soc_has_adsl)
146 [ -z "$dsl" ] || set_atm_wan "$vpi" "vci" "$encaps" "$payload" "$annex"
147 [ -z "$fwannex" ] || set_adsl "$fwannex" "$annex"
148
149 uci commit network
150
151 exit 0
This page took 0.047975 seconds and 5 git commands to generate.