mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
114 lines
3.2 KiB
Bash
114 lines
3.2 KiB
Bash
#!/bin/sh
|
|
|
|
. /lib/functions.sh
|
|
. /usr/share/libubox/jshn.sh
|
|
|
|
source "/etc/device_info"
|
|
|
|
l2_mcast_config() {
|
|
# configure L2 mcast config for snooping
|
|
logger -s -p user.info -t "netmode" "Generating L2 mcast configuration"
|
|
|
|
# remove proxy sections
|
|
uci -q delete mcast.igmp_proxy_1
|
|
uci -q delete mcast.mc_proxy_MLD
|
|
|
|
# add igmp_snooping section
|
|
uci -q set mcast.igmp_snooping_1=snooping
|
|
uci -q set mcast.igmp_snooping_1.enable='1'
|
|
uci -q set mcast.igmp_snooping_1.proto='igmp'
|
|
uci -q set mcast.igmp_snooping_1.version='2'
|
|
uci -q set mcast.igmp_snooping_1.robustness='2'
|
|
uci -q set mcast.igmp_snooping_1.query_interval='125'
|
|
uci -q set mcast.igmp_snooping_1.query_response_interval='100'
|
|
uci -q set mcast.igmp_snooping_1.last_member_query_interval='10'
|
|
uci -q set mcast.igmp_snooping_1.fast_leave='1'
|
|
uci -q set mcast.igmp_snooping_1.snooping_mode='2'
|
|
uci -q set mcast.igmp_snooping_1.interface='br-lan'
|
|
uci -q add_list mcast.igmp_snooping_1.filter='239.0.0.0/8'
|
|
|
|
# add mld_snooping section
|
|
uci -q set mcast.mld_snooping_1=snooping
|
|
uci -q set mcast.mld_snooping_1.enable='1'
|
|
uci -q set mcast.mld_snooping_1.proto='mld'
|
|
uci -q set mcast.mld_snooping_1.version='2'
|
|
uci -q set mcast.mld_snooping_1.robustness='2'
|
|
uci -q set mcast.mld_snooping_1.query_interval='125'
|
|
uci -q set mcast.mld_snooping_1.query_response_interval='100'
|
|
uci -q set mcast.mld_snooping_1.last_member_query_interval='10'
|
|
uci -q set mcast.mld_snooping_1.fast_leave='1'
|
|
uci -q set mcast.mld_snooping_1.snooping_mode='2'
|
|
uci -q set mcast.mld_snooping_1.interface='br-lan'
|
|
|
|
uci -q commit mcast
|
|
}
|
|
|
|
l2_network_config() {
|
|
logger -s -p user.info -t "netmode" "Generating L2 network configuration"
|
|
|
|
# Configure L2 Network Mode
|
|
uci -q delete network.lan
|
|
uci -q delete network.wan
|
|
uci -q delete network.wan6
|
|
uci -q set network.lan=interface
|
|
uci -q set network.lan.proto='dhcp'
|
|
uci -q set network.lan.device='br-lan'
|
|
uci -q set network.lan.force_link='1'
|
|
uci -q set network.lan6=interface
|
|
uci -q set network.lan6.proto='dhcpv6'
|
|
uci -q set network.lan6.device='@lan'
|
|
uci -q set network.lan6.reqprefix='no'
|
|
uci -q delete network.br_lan.ports
|
|
uci -q set network.br_lan.bridge_empty='1'
|
|
|
|
add_port_to_br_lan() {
|
|
port="$1"
|
|
[ -n "$port" -a -d /sys/class/net/$port ] || continue
|
|
uci add_list network.br_lan.ports="$port"
|
|
}
|
|
|
|
if [ -f /etc/board.json ]; then
|
|
json_load_file /etc/board.json
|
|
json_select network
|
|
json_select lan
|
|
if json_is_a ports array; then
|
|
json_for_each_item add_port_to_br_lan ports
|
|
else
|
|
json_get_var device device
|
|
[ -n "$device" ] && uci add_list network.br_lan.ports="$device"
|
|
fi
|
|
json_select ..
|
|
json_select wan 2>/dev/null
|
|
json_get_var device device
|
|
[ -n "$device" ] && uci add_list network.br_lan.ports="$device"
|
|
json_cleanup
|
|
fi
|
|
|
|
uci -q commit network
|
|
|
|
# Disable DHCP Server
|
|
uci -q set dhcp.lan.ignore=1
|
|
uci -q commit dhcp
|
|
/etc/init.d/odhcpd disable
|
|
|
|
# Disable SSDPD
|
|
uci -q set ssdpd.ssdp.enabled="0"
|
|
uci -q commit ssdpd
|
|
|
|
# Update CWMP Agent WAN Interface
|
|
uci -q set cwmp.cpe.default_wan_interface="lan"
|
|
uci -q commit cwmp
|
|
|
|
# disable firewall
|
|
uci -q set firewall.globals.enabled="0"
|
|
uci -q commit firewall
|
|
}
|
|
|
|
network_mode="$(fw_printenv -n netmode 2>/dev/null)"
|
|
|
|
case "$network_mode" in
|
|
layer2|extender)
|
|
l2_network_config
|
|
l2_mcast_config
|
|
;;
|
|
esac
|