openwrt/target/linux/ramips/mt7621/base-files/etc/board.d/02_network

337 lines
8.4 KiB
Plaintext

. /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|\
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|\
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|\
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"
;;
gnubee,gb-pc1)
ucidef_set_interface_lan "ethblack ethblue"
;;
gnubee,gb-pc2)
ucidef_set_interface_lan "ethblack ethblue ethyellow"
;;
linksys,re6500|\
netgear,wac104|\
zyxel,lte3301-plus)
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"
;;
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)
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