}
igmp_add_phyint() {
- local network direction altnets device up
+ local network direction altnets device up
- config_get network $1 network
- config_get direction $1 direction
- config_get altnets $1 altnet
+ config_get network $1 network
+ config_get direction $1 direction
+ config_get altnets $1 altnet
+
+ local status="$(ubus -S call "network.interface.$network" status)"
+ [ -n "$status" ] || return
- json_load "$(ifstatus $network)"
+ json_load "$status"
json_get_var device l3_device
json_get_var up up
return;
}
+ append netdevs "$device"
+
+ [[ "$direction" = "upstream" ]] && has_upstream=1
+
echo -e "\nphyint $device $direction ratelimit 0 threshold 1" >> /var/etc/igmpproxy.conf
if [ -n "$altnets" ]; then
local network
config_get network $1 network
- procd_add_interface_trigger "interface.*" $network /etc/init.d/igmpproxy restart
+ procd_add_interface_trigger "interface.*" $network /etc/init.d/igmpproxy reload
+}
+
+igmp_add_firewall_routing() {
+ config_get network $1 network
+ config_get direction $1 direction
+
+ [[ "$direction" = "downstream" ]] || return 0
+
+ json_add_object ""
+ json_add_string type rule
+ json_add_string src "$upstream"
+ json_add_string dest "$network"
+ json_add_string family ipv4
+ json_add_string proto udp
+ json_add_string dest_ip "224.0.0.0/4"
+ json_add_string target ACCEPT
+ json_close_object
+}
+
+igmp_add_firewall_network() {
+ config_get network $1 network
+ config_get direction $1 direction
+
+ json_add_object ""
+ json_add_string type rule
+ json_add_string src "$network"
+ json_add_string proto igmp
+ json_add_string target ACCEPT
+ json_close_object
+
+ [[ "$direction" = "upstream" ]] && {
+ upstream="$network"
+ config_foreach igmp_add_firewall_routing phyint
+ }
}
service_triggers() {
}
start_service() {
+ has_upstream=
+ netdevs=
config_load igmpproxy
- procd_open_instance
config_foreach igmp_header igmpproxy
config_foreach igmp_add_phyint phyint
+ [ -n "$has_upstream" ] || return
+
+ procd_open_instance
procd_set_param command $PROG
[ -n "$OPTIONS" ] && procd_append_param $OPTIONS
procd_append_param command $CONFIGFILE
procd_set_param file $CONFIGFILE
+ procd_set_param netdev $netdevs
procd_set_param respawn
procd_open_trigger
config_foreach igmp_add_network phyint
procd_close_trigger
+
+ procd_open_data
+
+ json_add_array firewall
+ config_foreach igmp_add_firewall_network phyint
+ json_close_array
+
+ procd_close_data
+
procd_close_instance
}
+
+service_started() {
+ procd_set_config_changed firewall
+}