f98162c6b240c1bf069f2dcf9cb7b3401d8ea557
[openwrt/staging/chunkeey.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 w502u)
24 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
25 ;;
26
27 wl-351)
28 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
29 ucidef_add_switch "rtl8366rb" "1" "1"
30 ucidef_add_switch_vlan "rtl8366rb" "1" "0 1 2 3 5t"
31 ucidef_add_switch_vlan "rtl8366rb" "2" "4 5t"
32 ;;
33
34 wli-tx4-ag300n)
35 ucidef_set_interface_lan "eth0"
36 ;;
37
38 rt-n15)
39 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
40 ucidef_add_switch "rtl8366s" "1" "1"
41 ucidef_add_switch_vlan "rtl8366s" "1" "1 2 3 4 5t"
42 ucidef_add_switch_vlan "rtl8366s" "2" "0 5t"
43 ;;
44
45 *)
46 RT3X5X=`cat /proc/cpuinfo | grep RT3.5`
47 if [ -n "${RT3X5X}" ]; then
48 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
49 else
50 ucidef_set_interfaces_lan_wan "eth0" "eth1"
51 fi
52 ;;
53 esac
54 }
55
56 ramips_setup_macs()
57 {
58 local board="$1"
59 local lan_mac=""
60 local wan_mac=""
61
62 case $board in
63 f5d8235-v2)
64 lan_mac=$(ramips_get_mac_nvram "u-boot" 262148)
65 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
66 ;;
67
68 argus-atp52b | \
69 b2c | \
70 nw718 | \
71 rt-n15 | \
72 wl-351)
73 lan_mac=$(ramips_get_mac_binary factory 4)
74 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
75 ;;
76
77 dir-300-b1 |\
78 dir-300-b2 |\
79 dir-600-b1)
80 lan_mac=$(ramips_get_mac_binary devdata 16388)
81 wan_mac=$(/usr/sbin/maccalc add "$lan_mac" 1)
82 ;;
83
84 esr-9753 | \
85 nbg-419n)
86 lan_mac=$(ramips_get_mac_binary factory 4)
87 wan_mac=$(ramips_get_mac_binary factory 40)
88 ;;
89
90 w502u)
91 lan_mac=$(ramips_get_mac_binary factory 40)
92 wan_mac=$(ramips_get_mac_binary factory 46)
93 ;;
94
95 wli-tx4-ag300n)
96 lan_mac=$(ramips_get_mac_binary factory 4)
97 ;;
98
99 esac
100
101 [ -n $lan_mac ] && ucidef_set_interface_macaddr lan $lan_mac
102 [ -n $wan_mac ] && ucidef_set_interface_macaddr wan $wan_mac
103 }
104
105 [ -e /etc/config/network ] && exit 0
106
107 touch /etc/config/network
108
109 board=$(ramips_board_name)
110
111 ramips_setup_interfaces $board
112 ramips_setup_macs $board
113
114 uci commit network
115
116 exit 0