From dbe9d916680d65abcaf67019072778581a77c809 Mon Sep 17 00:00:00 2001 From: jogo Date: Tue, 17 Apr 2012 11:47:56 +0000 Subject: [PATCH] packages: igmpproxy: Add configuration of igmpproxy through uci Signed-off-by: Viktar Palstsiuk git-svn-id: svn://svn.openwrt.org/openwrt/packages@31333 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- net/igmpproxy/Makefile | 8 +++---- net/igmpproxy/files/igmpproxy.conf | 43 ------------------------------------ net/igmpproxy/files/igmpproxy.config | 11 +++++++++ net/igmpproxy/files/igmpproxy.init | 34 +++++++++++++++++++++++++++- 4 files changed, 48 insertions(+), 48 deletions(-) delete mode 100644 net/igmpproxy/files/igmpproxy.conf create mode 100644 net/igmpproxy/files/igmpproxy.config diff --git a/net/igmpproxy/Makefile b/net/igmpproxy/Makefile index a4614a65c..de081cc33 100644 --- a/net/igmpproxy/Makefile +++ b/net/igmpproxy/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=igmpproxy PKG_VERSION:=0.1 -PKG_RELEASE:=7 +PKG_RELEASE:=8 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SF/igmpproxy @@ -33,7 +33,7 @@ define Package/igmpproxy/description endef define Package/igmpproxy/conffiles -/etc/igmpproxy.conf +/etc/config/igmpproxy endef TARGET_CFLAGS += -Dlog=igmpproxy_log @@ -45,8 +45,8 @@ define Build/Compile endef define Package/igmpproxy/install - $(INSTALL_DIR) $(1)/etc - $(INSTALL_CONF) ./files/igmpproxy.conf $(1)/etc/ + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_CONF) ./files/igmpproxy.config $(1)/etc/config/igmpproxy $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/igmpproxy.init $(1)/etc/init.d/igmpproxy $(INSTALL_DIR) $(1)/usr/sbin diff --git a/net/igmpproxy/files/igmpproxy.conf b/net/igmpproxy/files/igmpproxy.conf deleted file mode 100644 index e01b9189a..000000000 --- a/net/igmpproxy/files/igmpproxy.conf +++ /dev/null @@ -1,43 +0,0 @@ -######################################################## -# -# Example configuration file for the IgmpProxy -# -------------------------------------------- -# -# The configuration file must define one upstream -# interface, and one or more downstream interfaces. -# -# If multicast traffic originates outside the -# upstream subnet, the "altnet" option can be -# used in order to define legal multicast sources. -# (Se example...) -# -# The "quickleave" should be used to avoid saturation -# of the upstream link. The option should only -# be used if it's absolutely nessecary to -# accurately imitate just one Client. -# -######################################################## - -##------------------------------------------------------ -## Enable Quickleave mode (Sends Leave instantly) -##------------------------------------------------------ -quickleave - - -##------------------------------------------------------ -## Configuration for eth0 (Upstream Interface) -##------------------------------------------------------ -phyint br-wan upstream ratelimit 0 threshold 1 - altnet 192.168.1.0/24 - - -##------------------------------------------------------ -## Configuration for eth1 (Downstream Interface) -##------------------------------------------------------ -phyint br-lan downstream ratelimit 0 threshold 1 - - -##------------------------------------------------------ -## Configuration for eth2 (Disabled Interface) -##------------------------------------------------------ -phyint eth2 disabled diff --git a/net/igmpproxy/files/igmpproxy.config b/net/igmpproxy/files/igmpproxy.config new file mode 100644 index 000000000..ca625ac94 --- /dev/null +++ b/net/igmpproxy/files/igmpproxy.config @@ -0,0 +1,11 @@ +config igmpproxy + option quickleave 1 + +config phyint + option network wan + option direction upstream + list altnet 192.168.1.0/24 + +config phyint + option network lan + option direction downstream diff --git a/net/igmpproxy/files/igmpproxy.init b/net/igmpproxy/files/igmpproxy.init index 80e1badc1..a45978f5b 100644 --- a/net/igmpproxy/files/igmpproxy.init +++ b/net/igmpproxy/files/igmpproxy.init @@ -1,5 +1,5 @@ #!/bin/sh /etc/rc.common -# Copyright (C) 2010-2011 OpenWrt.org +# Copyright (C) 2010-2012 OpenWrt.org START=99 STOP=10 @@ -22,7 +22,39 @@ SERVICE_WRITE_PID=1 OPTIONS="" +igmp_header() { + local quickleave + config_get_bool quickleave "$1" quickleave 0 + + mkdir -p /var/etc + rm -f /var/etc/igmpproxy.conf + [ $quickleave -gt 0 ] && echo "quickleave" >> /var/etc/igmpproxy.conf + + [ -L /etc/igmpproxy.conf ] || ln -nsf /var/etc/igmpproxy.conf /etc/igmpproxy.conf +} + +igmp_add_phyint() { + local network direction altnets + + config_get network $1 network + config_get direction $1 direction + config_get altnets $1 altnet + + device=$(uci_get_state network "$network" ifname "$network") + echo -e "\nphyint $device $direction ratelimit 0 threshold 1" >> /var/etc/igmpproxy.conf + + if [ -n "$altnets" ]; then + local altnet + for altnet in $altnets; do + echo -e "\taltnet $altnet" >> /var/etc/igmpproxy.conf + done + fi +} + start() { + config_load igmpproxy + config_foreach igmp_header igmpproxy + config_foreach igmp_add_phyint phyint service_start /usr/sbin/igmpproxy $OPTIONS /etc/igmpproxy.conf } -- 2.11.0