summaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
blob: 247a27d1459c6f382ad65f8db86b33a6f7ff77ac (plain)
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343

. /lib/functions.sh
. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh

ramips_setup_interfaces()
{
	local board="$1"

	case $board in
	alfa-network,ax1800rm|\
	ampedwireless,ally-r1900k|\
	asus,rt-ax53u|\
	buffalo,wsr-2533dhpl2|\
	buffalo,wsr-2533dhpls|\
	gehua,ghl-r-001|\
	h3c,tx1800-plus|\
	h3c,tx1801-plus|\
	h3c,tx1806|\
	haier,har-20s2u1|\
	hiwifi,hc5962|\
	mercusys,mr70x-v1|\
	netgear,wax202|\
	sim,simax1800t|\
	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|\
	z-router,zr-2660|\
	zyxel,wsm20)
		ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan"
		;;
	arcadyan,we420223-99)
		ucidef_set_interface_lan "swp0 swp1"
		;;
	ampedwireless,ally-00x19k|\
	asus,rp-ac56|\
	asus,rp-ac87|\
	dlink,dap-1620-b1|\
	dlink,dap-x1860-a1|\
	dlink,dra-1360-a1|\
	edimax,re23s|\
	linksys,re7000|\
	mikrotik,ltap-2hnd|\
	mikrotik,routerboard-m11g|\
	netgear,eax12|\
	netgear,ex6150|\
	sercomm,na502|\
	sercomm,na502s|\
	thunder,timecloud|\
	tplink,eap613-v1|\
	tplink,re350-v1|\
	tplink,re500-v1|\
	tplink,re650-v1|\
	tplink,re650-v2|\
	ubnt,unifi-6-lite|\
	ubnt,unifi-flexhd|\
	ubnt,unifi-nanohd|\
	yuncore,fap690|\
	wavlink,wl-wn573hx1|\
	zyxel,nwa50ax|\
	zyxel,nwa55axe)
		ucidef_set_interface_lan "lan"
		;;
	asiarf,ap7621-001|\
	humax,e10|\
	wavlink,ws-wn572hp3-4g|\
	winstars,ws-wn583a6)
		ucidef_set_interfaces_lan_wan "lan" "wan"
		;;
	asiarf,ap7621-nv1|\
	beeline,smartbox-flash|\
	beeline,smartbox-giga|\
	elecom,wrc-x1800gs|\
	glinet,gl-mt1300|\
	iodata,wn-deax1800gr|\
	iptime,a3002mesh|\
	jcg,q20|\
	lenovo,newifi-d1|\
	mikrotik,routerboard-m33g|\
	mts,wg430223|\
	oraybox,x3a|\
	renkforce,ws-wn530hp3-a|\
	xiaomi,mi-router-3g|\
	xiaomi,mi-router-3g-v2|\
	xiaomi,mi-router-4|\
	xiaomi,mi-router-4a-gigabit|\
	xiaomi,mi-router-4a-gigabit-v2)
		ucidef_set_interfaces_lan_wan "lan1 lan2" "wan"
		;;
	bolt,arion)
		ucidef_set_interfaces_lan_wan "lan" "wan"
		ucidef_set_interface "eth_data" device "modem.103" protocol "static" ipaddr "10.22.127.222" netmask "255.255.255.255"
		ucidef_set_interface "eth_om" device "modem.4094" protocol "static" ipaddr "169.254.0.2" netmask "255.255.255.252"
		uci add_list firewall.@zone[1].network='eth_data'
		uci add_list firewall.@zone[1].network='eth_om'
		;;
	cudy,m1800|\
	yuncore,ax820|\
	zyxel,nr7101)
		ucidef_set_interfaces_lan_wan "lan" "wan"
		;;
	dlink,covr-x1860-a1)
		ucidef_set_interfaces_lan_wan "ethernet" "internet"
		;;
	elecom,wmc-s1267gs2|\
	linksys,re6500|\
	netgear,wac104|\
	zyxel,lte3301-plus)
		ucidef_set_interface_lan "lan1 lan2 lan3 lan4"
		;;
	gnubee,gb-pc1)
		ucidef_set_interface_lan "ethblack ethblue"
		;;
	gnubee,gb-pc2)
		ucidef_set_interface_lan "ethblack ethblue ethyellow"
		;;
	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"
		;;
	mqmaker,witi)
		ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan1 wan2"
		;;
	tozed,zlt-s12-pro)
		ucidef_set_interface_lan "lan1 lan2 lan3 wan"
		ucidef_set_interface "wwan" device "/dev/ttyUSB0" protocol "ncm"
		uci add_list firewall.@zone[1].network='wwan'
		;;
	tplink,deco-m4r-v4)
		ucidef_set_interfaces_lan_wan "eth1" "eth0"
		;;
	tplink,eap235-wall-v1|\
	tplink,eap615-wall-v1)
		ucidef_set_interface_lan "lan0 lan1 lan2 lan3"
		;;
	tplink,er605-v2)
		ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4" "eth0"
		;;
	tplink,tl-wpa8631p-v3)
		ucidef_set_interface_lan "lan1 lan2 lan3 plc0"
		;;
	tplink,mr600-v2-eu)
		ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan"
		;;
	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,lte5398-m904)
		ucidef_set_interface_lan "lan1 lan2"
		ucidef_set_interface "wan" device "/dev/cdc-wdm0" protocol "qmi"
		;;
	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"
		;;
	comfast,cf-e390ax|\
	comfast,cf-ew72-v2|\
	meig,slt866)
		ucidef_set_interfaces_lan_wan "lan" "wan"
		;;
	*)
		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
	alfa-network,ax1800rm|\
	jcg,y2|\
	wavlink,wl-wn531a6|\
	wavlink,wl-wn533a8|\
	winstars,ws-wn583a6|\
	zbtlink,zbt-we1326|\
	zbtlink,zbt-wg3526-16m|\
	zbtlink,zbt-wg3526-32m)
		label_mac=$(mtd_get_mac_binary factory 0x4)
		;;
	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
		;;
	arcadyan,we420223-99)
		label_mac=$(mtd_get_mac_ascii board_data mac)
		lan_mac=$label_mac
		ucidef_set_network_device_mac eth0 $(macaddr_add "$label_mac" 3)
	;;
	asus,rt-ac65p|\
	asus,rt-ac85p)
		wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr)
		label_mac=$(mtd_get_mac_binary factory 0x4)
		;;
	beeline,smartbox-flash)
		wan_mac=$(mtd_get_mac_encrypted_arcadyan "board_data")
		label_mac=$(macaddr_add "$wan_mac" 3)
		lan_mac=$label_mac
		;;
	buffalo,wsr-1166dhp|\
	buffalo,wsr-2533dhpl2|\
	buffalo,wsr-2533dhpls)
		wan_mac=$(mtd_get_mac_ascii board_data "mac")
		lan_mac=$wan_mac
		label_mac=$wan_mac
		;;
	comfast,cf-e390ax)
		lan_mac=$(cat /sys/class/net/eth0/address)
		label_mac=$lan_mac
		wan_mac=$(macaddr_add "$lan_mac" 1)
		;;
	dlink,covr-x1860-a1)
		label_mac=$(mtd_get_mac_ascii config2 factory_mac)
		wan_mac=$(macaddr_add "$label_mac" 3)
		lan_mac=$label_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-2533ghbk2-t|\
	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
		;;
	h3c,tx1800-plus|\
	h3c,tx1801-plus|\
	h3c,tx1806)
		label_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
		lan_mac=$(macaddr_add "$label_mac" 1)
		wan_mac=$label_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 u-boot-env ethaddr)
		wan_mac=$(macaddr_add "$lan_mac" 1)
		;;
	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
		;;
	belkin,rt1800|\
	linksys,e7350)
		lan_mac=$(mtd_get_mac_ascii Config lan_hwaddr)
		wan_mac=$(mtd_get_mac_ascii Config wan_hwaddr)
		label_mac=$lan_mac
		;;
	mikrotik,ltap-2hnd)
		label_mac=$(cat "/sys/firmware/mikrotik/hard_config/mac_base")
		lan_mac=$label_mac
		;;
	tplink,er605-v2)
		CI_UBIPART="firmware"
		label_mac=$(mtd_get_mac_uci_config_ubi "tddp")
		lan_mac=$label_mac
		wan_mac=$(macaddr_add "$label_mac" 1)
		;;
	tplink,mr600-v2-eu)
		label_mac=$(cat "/sys/class/net/eth0/address")
		wwan_mac=$(macaddr_add $label_mac 1)
		ucidef_set_interface "wwan0" device "/dev/cdc-wdm0" protocol "qmi" macaddr "$wwan_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)
		;;
	mts,wg430223)
		wan_mac=$(mtd_get_mac_encrypted_arcadyan "board_data")
		label_mac=$wan_mac
		lan_mac=$(macaddr_add "$wan_mac" 2)
		;;
	netgear,eax12)
		lan_mac=$(mtd_get_mac_ascii Config mac)
		label_mac=$lan_mac
		;;
	netgear,wax202)
		lan_mac=$(mtd_get_mac_ascii Config mac)
		wan_mac=$(macaddr_add "$lan_mac" 1)
		label_mac=$lan_mac
		;;
	yuncore,ax820)
		label_mac=$(mtd_get_mac_binary Factory 0x4)
		;;
	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