952146478cce8b682f55400252e3ffadf632fd3a
[openwrt/staging/wigyori.git] / target / linux / ramips / mt7621 / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . /lib/functions/uci-defaults.sh
5 . /lib/functions/system.sh
6
7 ramips_setup_interfaces()
8 {
9 local board="$1"
10
11 case $board in
12 asiarf,ap7621-001)
13 ucidef_set_interfaces_lan_wan "lan" "wan"
14 ;;
15 asiarf,ap7621-nv1|\
16 lenovo,newifi-d1|\
17 mikrotik,routerboard-m33g|\
18 xiaomi,mir3g|\
19 xiaomi,mir3g-v2)
20 ucidef_set_interfaces_lan_wan "lan1 lan2" "wan"
21 ;;
22 gehua,ghl-r-001|\
23 hiwifi,hc5962|\
24 xiaomi,mir3p)
25 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan"
26 ;;
27 gnubee,gb-pc1|\
28 gnubee,gb-pc2)
29 ucidef_set_interface_lan "lan1 lan2"
30 ;;
31 linksys,re6500)
32 ucidef_set_interface_lan "lan1 lan2 lan3 lan4"
33 ;;
34 mikrotik,routerboard-m11g|\
35 netgear,ex6150|\
36 thunder,timecloud|\
37 tplink,re350-v1|\
38 tplink,re650-v1|\
39 ubnt,unifi-nanohd)
40 ucidef_set_interface_lan "lan"
41 ;;
42 mikrotik,routerboard-750gr3)
43 ucidef_set_interfaces_lan_wan "lan2 lan3 lan4 lan5" "wan"
44 ;;
45 ubnt,edgerouter-x)
46 ucidef_set_interface_lan "eth0 eth1 eth2 eth3 eth4"
47 ;;
48 ubnt,edgerouter-x-sfp)
49 ucidef_set_interface_lan "eth0 eth1 eth2 eth3 eth4 eth5"
50 ;;
51 *)
52 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
53 ;;
54 esac
55 }
56
57 ramips_setup_macs()
58 {
59 local board="$1"
60 local lan_mac=""
61 local wan_mac=""
62 local label_mac=""
63
64 case $board in
65 asus,rt-ac65p|\
66 asus,rt-ac85p)
67 wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr)
68 label_mac=$(mtd_get_mac_binary factory 0x4)
69 ;;
70 buffalo,wsr-1166dhp)
71 local index="$(find_mtd_index "board_data")"
72 wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
73 lan_mac=$wan_mac
74 ;;
75 dlink,dir-860l-b1)
76 lan_mac=$(mtd_get_mac_ascii factory lanmac)
77 wan_mac=$(mtd_get_mac_ascii factory wanmac)
78 ;;
79 edimax,ra21s|\
80 edimax,rg21s)
81 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
82 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
83 ;;
84 hiwifi,hc5962)
85 lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
86 label_mac=$lan_mac
87 [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
88 wan_mac=$(macaddr_add "$lan_mac" 1)
89 ;;
90 iodata,wnpr2600g)
91 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
92 label_mac=$wan_mac
93 ;;
94 mikrotik,routerboard-750gr3|\
95 mikrotik,routerboard-m11g|\
96 mikrotik,routerboard-m33g)
97 label_mac=$(mtd_get_mac_binary hard_config 0x10)
98 ;;
99 zbtlink,zbt-we1326|\
100 zbtlink,zbt-wg3526-16m|\
101 zbtlink,zbt-wg3526-32m)
102 label_mac=$(mtd_get_mac_binary factory 0x4)
103 ;;
104 esac
105
106 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
107 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
108 [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
109 }
110
111 board_config_update
112 board=$(board_name)
113 ramips_setup_interfaces $board
114 ramips_setup_macs $board
115 board_config_flush
116
117 exit 0