packages: igmpproxy: Add configuration of igmpproxy through uci
authorjogo <jogo@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Tue, 17 Apr 2012 11:47:56 +0000 (11:47 +0000)
committerjogo <jogo@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Tue, 17 Apr 2012 11:47:56 +0000 (11:47 +0000)
Signed-off-by: Viktar Palstsiuk <viktar.palstsiuk@promwad.com>
git-svn-id: svn://svn.openwrt.org/openwrt/packages@31333 3c298f89-4303-0410-b956-a3cf2f4a3e73

net/igmpproxy/Makefile
net/igmpproxy/files/igmpproxy.conf [deleted file]
net/igmpproxy/files/igmpproxy.config [new file with mode: 0644]
net/igmpproxy/files/igmpproxy.init

index a4614a6..de081cc 100644 (file)
@@ -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 (file)
index e01b918..0000000
+++ /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 (file)
index 0000000..ca625ac
--- /dev/null
@@ -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
index 80e1bad..a45978f 100644 (file)
@@ -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
 }