"Fossies" - the Fresh Open Source Software Archive 
Member "aif-2.1.1/share/arno-iptables-firewall/plugins/50linux-upnp-igd.plugin" (16 Sep 2020, 3936 Bytes) of package /linux/privat/aif-2.1.1.tar.gz:
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the latest
Fossies "Diffs" side-by-side code changes report for "50linux-upnp-igd.plugin":
2.1.0_vs_2.1.1.
1 # ------------------------------------------------------------------------------
2 # -= Arno's Iptables Firewall(AIF) - Linux UPnP IGD plugin =-
3 #
4 PLUGIN_NAME="Linux UPnP IGD plugin"
5 PLUGIN_VERSION="1.0a"
6 PLUGIN_CONF_FILE="linux-upnp-igd.conf"
7 #
8 # Last changed : October 10, 2011
9 # Requirements : kernel 2.6 + linux-igd
10 # Comments : An UPnP-enabled application can tell linux-igd what public ports
11 # have to be forwarded back to the application.
12 # This plugin adds a new chain into the FORWARD chain
13 # where the UPnP daemon "linuxigd" can insert its ports.
14 # In "upnpd.conf" you must set the forward_chain_name = UPNP_FORWARD
15 #
16 # Author : (C) Copyright 2007-2011 by Joerg Straube
17 # Homepage : http://joerg.li/
18 # Email : j o e r g DOT s t r a u b e AT i a e t h DOT c h
19 # (note: you must remove all spaces and substitute the @ and the .
20 # at the proper locations!)
21 # ------------------------------------------------------------------------------
22 # This program is free software; you can redistribute it and/or
23 # modify it under the terms of the GNU General Public License
24 # version 2 as published by the Free Software Foundation.
25 #
26 # This program is distributed in the hope that it will be useful,
27 # but WITHOUT ANY WARRANTY; without even the implied warranty of
28 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 # GNU General Public License for more details.
30 #
31 # You should have received a copy of the GNU General Public License
32 # along with this program; if not, write to the Free Software
33 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 # ------------------------------------------------------------------------------
35
36 # Plugin start function
37 plugin_start()
38 {
39 # Create new UPNP_FORWARD chain to be used by linuxigd (aka upnpd):
40 iptables -N UPNP_FORWARD 2>/dev/null
41 iptables -F UPNP_FORWARD
42 iptables -N UPNP_FORWARD_HOOK 2>/dev/null
43 iptables -F UPNP_FORWARD_HOOK
44
45 # Insert rule into the FORWARD chain:
46 IFS=' ,'
47 for eif in $EXT_IF; do
48 iptables -A UPNP_FORWARD_HOOK -i $eif ! -o $eif -j UPNP_FORWARD
49 done
50
51 iptables -A FORWARD -j UPNP_FORWARD_HOOK
52
53 return 0
54 }
55
56
57 # Plugin stop function
58 plugin_stop()
59 {
60 iptables -D FORWARD -j UPNP_FORWARD_HOOK 2>/dev/null
61
62 iptables -F UPNP_FORWARD_HOOK
63 iptables -X UPNP_FORWARD_HOOK 2>/dev/null
64
65 iptables -F UPNP_FORWARD
66 iptables -X UPNP_FORWARD 2>/dev/null
67
68 return 0
69 }
70
71
72 # Plugin status function
73 plugin_status()
74 {
75 return 0
76 }
77
78
79 # Check sanity of eg. environment
80 plugin_sanity_check()
81 {
82 return 0
83 }
84
85
86 ############
87 # Mainline #
88 ############
89
90 # Check where to find the config file
91 CONF_FILE=""
92 if [ -n "$PLUGIN_CONF_PATH" ]; then
93 CONF_FILE="$PLUGIN_CONF_PATH/$PLUGIN_CONF_FILE"
94 fi
95
96 # Preinit to success:
97 PLUGIN_RET_VAL=0
98
99 # Check if the config file exists
100 if [ ! -f "$CONF_FILE" ]; then
101 printf "NOTE: Config file \"$CONF_FILE\" not found!\n Plugin \"$PLUGIN_NAME v$PLUGIN_VERSION\" ignored!\n" >&2
102 else
103 # Source the plugin config file
104 . "$CONF_FILE"
105
106 if [ "$ENABLED" = "1" ] ||
107 [ -n "$PLUGIN_LOAD_FILE" -a "$PLUGIN_CMD" = "stop" ] ||
108 [ -n "$PLUGIN_LOAD_FILE" -a "$PLUGIN_CMD" = "status" ]; then
109 # Show who we are:
110 echo "${INDENT}$PLUGIN_NAME v$PLUGIN_VERSION"
111
112 # Increment indention
113 INDENT="$INDENT "
114
115 # Only proceed if environment ok
116 if ! plugin_sanity_check; then
117 PLUGIN_RET_VAL=1
118 else
119 case $PLUGIN_CMD in
120 start|'') plugin_start; PLUGIN_RET_VAL=$? ;;
121 stop ) plugin_stop; PLUGIN_RET_VAL=$? ;;
122 status ) plugin_status; PLUGIN_RET_VAL=$? ;;
123 * ) PLUGIN_RET_VAL=1; printf "\033[40m\033[1;31m${INDENT}ERROR: Invalid plugin option \"$PLUGIN_CMD\"!\033[0m\n" >&2 ;;
124 esac
125 fi
126 fi
127 fi