ramips: rt288x: add support for the Buffalo WLI-TX4-AG300N board
[openwrt.git] / target / linux / ramips / base-files / etc / uci-defaults / network
1 #!/bin/sh
2
3 . /etc/functions.sh
4 . /lib/ramips.sh
5 . /lib/functions/uci-defaults.sh
6
7 if [ ! -x /usr/sbin/maccalc ]; then
8         echo "$0: maccalc not found!"
9         return
10 fi
11
12 ramips_setup_interfaces()
13 {
14         local board="$1"
15
16         ucidef_set_interface_loopback
17
18         case $board in
19         argus-atp52b | \
20         b2c | \
21         f5d8235-v2 | \
22         nw718)
23                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
24                 ;;
25
26         wl-351)
27                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
28                 ucidef_add_switch "rtl8366rb" "1" "1"
29                 ucidef_add_switch_vlan "rtl8366rb" "1" "0 1 2 3 5t"
30                 ucidef_add_switch_vlan "rtl8366rb" "2" "4 5t"
31                 ;;
32
33         wli-tx4-ag300n)
34                 ucidef_set_interface_lan "eth0"
35                 ;;
36
37         rt-n15)
38                 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
39                 ucidef_add_switch "rtl8366s" "1" "1"
40                 ucidef_add_switch_vlan "rtl8366s" "1" "1 2 3 4 5t"
41                 ucidef_add_switch_vlan "rtl8366s" "2" "0 5t"
42                 ;;
43
44         *)
45                 RT3X5X=`cat /proc/cpuinfo | grep RT3.5`
46                 if [ -n "${RT3X5X}" ]; then
47                         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
48                 else
49                         ucidef_set_interfaces_lan_wan "eth0" "eth1"
50                 fi
51                 ;;
52         esac
53 }
54
55 ramips_setup_macs()
56 {
57         local board="$1"
58         local lan_mac=""
59         local wan_mac=""
60
61         case $board in
62         f5d8235-v2)
63                 lan_mac=$(ramips_get_mac_nvram "u-boot" 262148)
64                 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
65                 ;;
66
67         argus-atp52b | \
68         b2c | \
69         nw718 | \
70         rt-n15 | \
71         wl-351)
72                 lan_mac=$(ramips_get_mac_binary factory 4)
73                 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
74                 ;;
75
76         dir-300-b1 |\
77         dir-300-b2 |\
78         dir-600-b1)
79                 lan_mac=$(ramips_get_mac_binary devdata 16388)
80                 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
81                 ;;
82
83         esr-9753 | \
84         nbg-419n)
85                 lan_mac=$(ramips_get_mac_binary factory 4)
86                 wan_mac=$(ramips_get_mac_binary factory 40)
87                 ;;
88
89         wli-tx4-ag300n)
90                 lan_mac=$(ramips_get_mac_binary factory 4)
91                 ;;
92
93         esac
94
95         [ -n $lan_mac ] && ucidef_set_interface_macaddr lan $lan_mac
96         [ -n $wan_mac ] && ucidef_set_interface_macaddr wan $wan_mac
97 }
98
99 [ -e /etc/config/network ] && exit 0
100
101 touch /etc/config/network
102
103 board=$(ramips_board_name)
104
105 ramips_setup_interfaces $board
106 ramips_setup_macs $board
107
108 uci commit network
109
110 exit 0