ar71xx: force hardwired interface parameters in ar71xx_add_device_eth
[openwrt.git] / target / linux / ar71xx / 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_interfaces_lan_wan() {
51 local lan_ifname=$1
52 local wan_ifname=$2
53
54 set_interface_lan "$lan_ifname"
55 set_interface_wan "$wan_ifname"
56 }
57
58 add_switch() {
59 local name=$1
60 local reset=$2
61 local enable=$3
62 uci batch <<EOF
63 add network switch
64 set network.@switch[-1].name='$name'
65 set network.@switch[-1].reset='$reset'
66 set network.@switch[-1].enable_vlan='$enable'
67 EOF
68 }
69
70 add_switch_vlan() {
71 local device=$1
72 local vlan=$2
73 local ports=$3
74 uci batch <<EOF
75 add network switch_vlan
76 set network.@switch_vlan[-1].device='$device'
77 set network.@switch_vlan[-1].vlan='$vlan'
78 set network.@switch_vlan[-1].ports='$ports'
79 EOF
80 }
81
82 [ -e /etc/config/network ] && exit 0
83
84 touch /etc/config/network
85
86 set_interface_loopback
87
88 . /lib/ar71xx.sh
89
90 board=$(ar71xx_board_name)
91
92 case "$board" in
93 all0258n)
94 set_interface_lan "eth0 eth1"
95 ;;
96
97 dir-825-b1)
98 set_interfaces_lan_wan "eth0.1" "eth1"
99 add_switch "rtl8366s" "1" "1"
100 add_switch_vlan "rtl8366s" "1" "0 1 2 3 5t"
101 ;;
102
103 nbg460n_550n_550nh)
104 set_interfaces_lan_wan "eth0" "eth1"
105 add_switch "rtl8366s" "1" "1"
106 add_switch_vlan "rtl8366s" "0" "0 1 2 3 5"
107 ;;
108
109 rb-433 |\
110 rb-433u)
111 set_interfaces_lan_wan "eth1" "eth0"
112 add_switch "switch0" "1" "1"
113 add_switch_vlan "switch0" "1" "1 2 5"
114 ;;
115
116 rb-450)
117 set_interfaces_lan_wan "eth1" "eth0"
118 add_switch "eth1" "1" "1"
119 add_switch_vlan "eth1" "1" "0 1 2 3 5"
120 ;;
121
122 rb-450g |\
123 routerstation-pro)
124 set_interfaces_lan_wan "eth1" "eth0"
125 add_switch "switch0" "1" "1"
126 add_switch_vlan "switch0" "1" "0 1 2 3 4"
127 ;;
128
129 rb-493g)
130 set_interfaces_lan_wan "eth0 eth1.1" "eth1.2"
131 add_switch "switch0" "1" "1"
132 add_switch_vlan "switch0" "1" "0 1 2 3 4"
133 add_switch "switch1" "1" "1"
134 add_switch_vlan "switch1" "1" "0t 1 2 3 4"
135 add_switch_vlan "switch1" "2" "0t 5"
136 ;;
137
138 pb92)
139 set_interfaces_lan_wan "eth0.1" "eth0.2"
140 add_switch "eth0" "1" "1"
141 add_switch_vlan "eth0" "1" "0t 1 3 4 5"
142 add_switch_vlan "eth0" "2" "0t 2"
143 ;;
144
145 tl-wa901nd)
146 set_interface_raw "eth" "eth0"
147 set_interface_lan "lan"
148 ;;
149
150 tl-wr1043nd)
151 set_interfaces_lan_wan "eth0.1" "eth0.2"
152 add_switch "rtl8366rb" "1" "1"
153 add_switch_vlan "rtl8366rb" "1" "1 2 3 4 5t"
154 add_switch_vlan "rtl8366rb" "2" "0 5t"
155 ;;
156
157 tl-wr841n-v1|\
158 tl-wr941nd)
159 set_interface_raw "eth" "eth0"
160 set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
161 ;;
162
163 wrt160nl)
164 set_interfaces_lan_wan "eth0" "eth1"
165 add_switch "eth0" "1" "1"
166 add_switch_vlan "eth0" "1" "0 1 2 3 4 5"
167 ;;
168
169 wzr-hp-g300nh)
170 set_interfaces_lan_wan "eth0.1" "eth1"
171 add_switch "switch0" "1" "1"
172 add_switch_vlan "switch0" "1" "0 1 2 3 5t"
173 ;;
174
175 aw-nr580 |\
176 bullet-m |\
177 eap7660d |\
178 rb-411 |\
179 tl-wa901nd-v2 |\
180 tl-wr703n |\
181 wp543)
182 set_interface_lan "eth0"
183 ;;
184
185 ap83 |\
186 jwap003 |\
187 pb42 |\
188 pb44 |\
189 routerstation)
190 set_interfaces_lan_wan "eth1" "eth0"
191 ;;
192
193 ap121 |\
194 ap121-mini |\
195 ap96 |\
196 dir-600-a1 |\
197 dir-615-c1 |\
198 ja76pf |\
199 rb750 |\
200 tew-632brp |\
201 tl-mr3220 |\
202 tl-mr3420 |\
203 tl-wr741nd |\
204 tl-wr741nd-v4 |\
205 whr-g301n |\
206 whr-hp-g300n |\
207 whr-hp-gn |\
208 wzr-hp-ag300h)
209 set_interfaces_lan_wan "eth0" "eth1"
210 add_switch "eth0" "1" "1"
211 add_switch_vlan "eth0" "1" "0 1 2 3 4"
212 ;;
213
214 *)
215 set_interfaces_lan_wan "eth0" "eth1"
216 ;;
217 esac
218
219 uci commit network
220
221 exit 0
This page took 0.048821 seconds and 5 git commands to generate.