forked from openwrt/openwrt
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
02_network
196 lines (188 loc) · 4.74 KB
/
02_network
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
. /lib/functions.sh
. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh
ramips_setup_interfaces()
{
local board="$1"
case $board in
ampedwireless,ally-00x19k|\
edimax,re23s|\
mikrotik,routerboard-m11g|\
netgear,ex6150|\
sercomm,na502|\
thunder,timecloud|\
tplink,re350-v1|\
tplink,re500-v1|\
tplink,re650-v1|\
ubnt,unifi-6-lite|\
ubnt,unifi-nanohd)
ucidef_set_interface_lan "lan"
;;
ampedwireless,ally-r1900k|\
gehua,ghl-r-001|\
hiwifi,hc5962|\
xiaomi,mi-router-3-pro|\
xiaomi,mi-router-ac2100|\
xiaomi,mi-router-cr6606|\
xiaomi,mi-router-cr6608|\
xiaomi,mi-router-cr6609|\
xiaomi,redmi-router-ac2100)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan"
;;
asiarf,ap7621-001|\
humax,e10|\
winstars,ws-wn583a6)
ucidef_set_interfaces_lan_wan "lan" "wan"
;;
asiarf,ap7621-nv1|\
glinet,gl-mt1300|\
iptime,a3002mesh|\
jcg,q20|\
lenovo,newifi-d1|\
mikrotik,routerboard-m33g|\
renkforce,ws-wn530hp3-a|\
xiaomi,mi-router-3g|\
xiaomi,mi-router-3g-v2|\
xiaomi,mi-router-4|\
xiaomi,mi-router-4a-gigabit)
ucidef_set_interfaces_lan_wan "lan1 lan2" "wan"
;;
gnubee,gb-pc1|\
gnubee,gb-pc2)
ucidef_set_interface_lan "lan1 lan2"
;;
linksys,re6500|\
netgear,wac104)
ucidef_set_interface_lan "lan1 lan2 lan3 lan4"
;;
mikrotik,routerboard-750gr3)
ucidef_set_interfaces_lan_wan "lan2 lan3 lan4 lan5" "wan"
;;
mikrotik,routerboard-760igs)
ucidef_set_interfaces_lan_wan "lan2 lan3 lan4 lan5" "wan sfp"
;;
tplink,eap235-wall-v1|\
tplink,eap615-wall-v1)
ucidef_set_interface_lan "lan0 lan1 lan2 lan3"
;;
tplink,tl-wpa8631p-v3)
ucidef_set_interface_lan "lan1 lan2 lan3 plc0"
;;
ubnt,edgerouter-x)
ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4" "eth0"
;;
ubnt,edgerouter-x-sfp)
ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4 eth5" "eth0"
;;
ubnt,usw-flex)
ucidef_set_interface_lan "lan1 lan2 lan3 lan4 lan5"
;;
zyxel,nr7101)
ucidef_set_interfaces_lan_wan "lan" "wan"
;;
zyxel,wap6805)
ucidef_set_interface_lan "lan1 lan2 lan3 lan4"
ucidef_set_interface "qtn" ifname "eth1" protocol "static" ipaddr "1.1.1.1" netmask "255.255.255.0"
;;
*)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
;;
esac
}
ramips_setup_macs()
{
local board="$1"
local lan_mac=""
local wan_mac=""
local label_mac=""
case $board in
ampedwireless,ally-00x19k)
lan_mac=$(mtd_get_mac_ascii hwconfig HW.LAN.MAC.Address)
label_mac=$lan_mac
;;
ampedwireless,ally-r1900k)
lan_mac=$(mtd_get_mac_ascii hwconfig HW.LAN.MAC.Address)
wan_mac=$(mtd_get_mac_ascii hwconfig HW.WAN.MAC.Address)
label_mac=$lan_mac
;;
asus,rt-ac65p|\
asus,rt-ac85p)
wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr)
label_mac=$(mtd_get_mac_binary factory 0x4)
;;
buffalo,wsr-1166dhp)
local index="$(find_mtd_index "board_data")"
wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
lan_mac=$wan_mac
;;
dlink,dir-860l-b1)
lan_mac=$(mtd_get_mac_ascii factory lanmac)
wan_mac=$(mtd_get_mac_ascii factory wanmac)
;;
edimax,ra21s|\
edimax,rg21s)
lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
;;
elecom,wrc-2533ghbk-i)
lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
label_mac=$wan_mac
;;
hiwifi,hc5962)
lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
label_mac=$lan_mac
[ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
wan_mac=$(macaddr_add "$lan_mac" 1)
;;
iodata,wnpr2600g)
wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
label_mac=$wan_mac
;;
iptime,t5004)
lan_mac=$(mtd_get_mac_ascii config ethaddr)
wan_mac=$(macaddr_add "$lan_mac" 1)
;;
jcg,y2|\
wavlink,wl-wn531a6|\
winstars,ws-wn583a6|\
zbtlink,zbt-we1326|\
zbtlink,zbt-wg3526-16m|\
zbtlink,zbt-wg3526-32m)
label_mac=$(mtd_get_mac_binary factory 0x4)
;;
linksys,e5600|\
linksys,ea6350-v4|\
linksys,ea7300-v1|\
linksys,ea7300-v2|\
linksys,ea7500-v2|\
linksys,ea8100-v1|\
linksys,ea8100-v2)
lan_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
wan_mac=$lan_mac
label_mac=$lan_mac
;;
mikrotik,routerboard-750gr3|\
mikrotik,routerboard-760igs|\
mikrotik,routerboard-m11g|\
mikrotik,routerboard-m33g)
label_mac=$(cat "/sys/firmware/mikrotik/hard_config/mac_base")
wan_mac=$label_mac
lan_mac=$(macaddr_add $label_mac 1)
;;
raisecom,msg1500-x-00)
lan_mac=$(mtd_get_mac_ascii Config protest_lan_mac)
wan_mac=$(mtd_get_mac_ascii Config protest_wan_mac)
label_mac=$lan_mac
;;
esac
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
[ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
}
board_config_update
board=$(board_name)
ramips_setup_interfaces $board
ramips_setup_macs $board
board_config_flush
exit 0