579ccc5bd3206330109417d07fa4e8a5e9218d79
[oweals/openwrt.git] / target / linux / ath79 / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions/system.sh
4 . /lib/functions/uci-defaults.sh
5 . /lib/functions/k2t.sh
6
7 ath79_setup_interfaces()
8 {
9         local board="$1"
10
11         case "$board" in
12         "etactica,eg200")
13                 ucidef_set_interface_lan "eth0" "dhcp"
14                 ;;
15         "avm,fritz300e"|\
16         "tplink,tl-mr10u"|\
17         "tplink,tl-wr703n"|\
18         "ubnt,unifiac-lite"|\
19         "ubnt,unifiac-mesh"|\
20         "ubnt,unifi")
21                 ucidef_set_interface_lan "eth0"
22                 ;;
23
24         "embeddedwireless,dorin")
25                 ucidef_add_switch "switch0" \
26                         "0@eth0" "1:wan" "2:lan:3" "3:lan:2"
27                 ;;
28
29         "glinet,ar150")
30                 ucidef_set_interfaces_lan_wan "eth1" "eth0"
31                 ;;
32
33         "glinet,ar300m")
34                 ucidef_set_interfaces_lan_wan "eth1" "eth0"
35                 ;;
36
37         "netgear,wnr612-v2"|\
38         "on,n150r")
39                 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
40                 ucidef_add_switch "switch0" \
41                 "0@eth1" "1:lan" "2:lan" "3:lan:3" "4:lan:4"
42                 ;;
43
44         "tplink,tl-archer-c7-v2")
45                 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
46                 ucidef_add_switch "switch0" \
47                         "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
48                 ;;
49
50         "tplink,tl-mr3020-v1")
51                 ucidef_set_interface_lan "eth0.1"
52                 ucidef_add_switch "switch0" "0@eth0" "1:lan"
53                 ;;
54         "tplink,tl-mr3220-v1"|\
55         "tplink,tl-mr3420-v1"|\
56         "tplink,tl-wr841-v7")
57                 ucidef_set_interface_wan "eth0"
58                 ucidef_add_switch "switch0" \
59                         "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
60                 ;;
61         "tplink,tl-wdr3600"|\
62         "tplink,tl-wdr4300")
63                 ucidef_add_switch "switch0" \
64                         "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
65                 ;;
66
67         "tplink,tl-wr740n-v2")
68                 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
69                 ucidef_add_switch "switch0" \
70                         "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
71                 ;;
72
73         "tplink,tl-wr1043nd-v1")
74                 ucidef_add_switch "switch0" \
75                         "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
76                 ;;
77         "tplink,tl-wr1043nd-v4")
78                 ucidef_add_switch "switch0" \
79                         "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
80                 ;;
81         "tplink,tl-wr1043nd-v2"|\
82         "tplink,tl-wr1043nd-v3")
83                 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
84                 ucidef_add_switch "switch0" \
85                         "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
86                 ;;
87         "tplink,tl-wr2543-v1")
88                 ucidef_add_switch "switch0" \
89                         "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
90                 ;;
91         "netgear,wndr3800")
92                 ucidef_set_interfaces_lan_wan "eth0" "eth1"
93                 ucidef_add_switch "switch0" \
94                         "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5u@eth0"
95
96                 ucidef_add_switch_attr "switch0" "blinkrate" 2
97                 ucidef_add_switch_port_attr "switch0" 1 led 6
98                 ucidef_add_switch_port_attr "switch0" 2 led 9
99                 ucidef_add_switch_port_attr "switch0" 5 led 2
100                 ;;
101         "buffalo,wzr-hp-g450h")
102                 ucidef_add_switch "switch0" \
103                         "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
104                 ;;
105         "phicomm,k2t")
106                 ucidef_add_switch "switch0" \
107                         "0@eth0" "3:lan:1" "5:lan:2" "4:wan"
108                 ;;
109         "ubnt,unifiac-pro")
110                 ucidef_add_switch "switch0" \
111                         "0@eth0" "2:lan" "3:wan"
112                 ;;
113         *)
114                 ucidef_set_interfaces_lan_wan "eth0" "eth1"
115                 ;;
116         esac
117 }
118
119 ath79_setup_macs()
120 {
121         local board="$1"
122
123         case "$board" in
124         avm,fritz300e)
125                 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
126                 ;;
127         phicomm,k2t)
128                 lan_mac=$(k2t_get_mac "lan_mac")
129                 wan_mac=$(k2t_get_mac "wan_mac")
130                 ;;
131         "tplink,tl-wr1043nd-v4")
132                 base_mac=$(mtd_get_mac_binary product-info 8)
133                 wan_mac=$(macaddr_add "$base_mac" 1)
134                 ;;
135         esac
136
137         [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
138         [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
139 }
140
141 board_config_update
142 board=$(board_name)
143 ath79_setup_interfaces $board
144 ath79_setup_macs $board
145 board_config_flush
146
147 exit 0