1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2010-2014 OpenWrt.org
6 PROG
=/usr
/sbin
/igmpproxy
7 CONFIGFILE
=/var
/etc
/igmpproxy.conf
9 # igmpproxy supports both a debug mode and verbosity, which are very useful
10 # when something isn't working.
12 # Debug mode will print everything to stdout instead of syslog. Generally
13 # verbosity should NOT be set as it will quickly fill your syslog.
15 # Put any debug or verbosity options into IGMP_OPTS
18 # OPTIONS="-d -v -v" - debug mode and very verbose, this will land in
19 # stdout and not in syslog
20 # OPTIONS="-v" - be verbose, this will write aditional information to syslog
26 config_get_bool quickleave
"$1" quickleave
0
29 rm -f /var
/etc
/igmpproxy.conf
30 [ $quickleave -gt 0 ] && echo "quickleave" >> /var
/etc
/igmpproxy.conf
32 [ -L /etc
/igmpproxy.conf
] ||
ln -nsf /var
/etc
/igmpproxy.conf
/etc
/igmpproxy.conf
36 local network direction altnets device up
38 config_get network
$1 network
39 config_get direction
$1 direction
40 config_get altnets
$1 altnet
42 local status
="$(ubus -S call "network.interface.
$network" status)"
43 [ -n "$status" ] ||
return
46 json_get_var device l3_device
49 [ -n "$device" -a "$up" = "1" ] ||
{
50 procd_append_param error
"$network is not up"
54 [[ "$direction" = "upstream" ]] && has_upstream
=1
56 echo -e "\nphyint $device $direction ratelimit 0 threshold 1" >> /var
/etc
/igmpproxy.conf
58 if [ -n "$altnets" ]; then
60 for altnet
in $altnets; do
61 echo -e "\taltnet $altnet" >> /var
/etc
/igmpproxy.conf
69 config_get network
$1 network
70 procd_add_interface_trigger
"interface.*" $network /etc
/init.d
/igmpproxy restart
73 igmp_add_firewall_routing
() {
74 config_get network
$1 network
75 config_get direction
$1 direction
77 [[ "$direction" = "downstream" ]] ||
return 0
80 json_add_string
type rule
81 json_add_string src
"$upstream"
82 json_add_string dest
"$network"
83 json_add_string family ipv4
84 json_add_string proto udp
85 json_add_string dest_ip
"224.0.0.0/4"
86 json_add_string target ACCEPT
90 igmp_add_firewall_network
() {
91 config_get network
$1 network
92 config_get direction
$1 direction
95 json_add_string
type rule
96 json_add_string src
"$network"
97 json_add_string proto igmp
98 json_add_string target ACCEPT
101 [[ "$direction" = "upstream" ]] && {
103 config_foreach igmp_add_firewall_routing phyint
108 procd_add_reload_trigger
"igmpproxy"
113 config_load igmpproxy
115 config_foreach igmp_header igmpproxy
116 config_foreach igmp_add_phyint phyint
117 [ -n "$has_upstream" ] ||
return
120 procd_set_param
command $PROG
121 [ -n "$OPTIONS" ] && procd_append_param
$OPTIONS
122 procd_append_param
command $CONFIGFILE
123 procd_set_param
file $CONFIGFILE
124 procd_set_param respawn
126 config_foreach igmp_add_network phyint
131 json_add_array firewall
132 config_foreach igmp_add_firewall_network phyint
141 procd_set_config_changed firewall