"Fossies" - the Fresh Open Source Software Archive

Member "aif-2.1.1/share/arno-iptables-firewall/plugins/50ipv6-over-ipv4.plugin" (16 Sep 2020, 3685 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 "50ipv6-over-ipv4.plugin": 2.1.0_vs_2.1.1.

    1 # ------------------------------------------------------------------------------
    2 #          -= Arno's Iptables Firewall(AIF) - IPv6-over-IPv4 plugin =-
    3 #
    4 PLUGIN_NAME="IPv6-over-IPv4 plugin"
    5 PLUGIN_VERSION="0.2BETA"
    6 PLUGIN_CONF_FILE="ipv6-over-ipv4.conf"
    7 #
    8 # Last changed          : October 8, 2010
    9 # Requirements          : kernel 2.6 with IPv6 support
   10 # Comments              : This plugin opens the (IPv4) protocols to enable
   11 #                         IPv6 tunneling. Only works with AIF 1.9+ !
   12 #
   13 # Author                : (C) Copyright 2010 by Arno van Amersfoort
   14 # Homepage              : https://rocky.eld.leidenuniv.nl/
   15 # Email                 : a r n o v a AT r o c k y DOT e l d DOT l e i d e n u n i v DOT n l
   16 #                         (note: you must remove all spaces and substitute the @ and the .
   17 #                         at the proper locations!)
   18 # ------------------------------------------------------------------------------
   19 # This program is free software; you can redistribute it and/or
   20 # modify it under the terms of the GNU General Public License
   21 # version 2 as published by the Free Software Foundation.
   22 #
   23 # This program is distributed in the hope that it will be useful,
   24 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   26 # GNU General Public License for more details.
   27 #
   28 # You should have received a copy of the GNU General Public License
   29 # along with this program; if not, write to the Free Software
   30 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
   31 # ------------------------------------------------------------------------------
   32 
   33 # Plugin start function
   34 plugin_start()
   35 {
   36   local src interface
   37   
   38   # Enable (allow) IPv6 tunnel traffic
   39   ####################################
   40   echo "${INDENT}Allowing IPv6 tunnel for $IPV6_OVER_IPV4_SERVER (INET) to interface(s): $IPV6_OVER_IPV4_IF"
   41   IFS=' ,'
   42   for src in $IPV6_OVER_IPV4_SERVER; do
   43     for interface in $IPV6_OVER_IPV4_IF; do
   44       ip4tables -A EXT_INPUT_CHAIN -s $src -i $interface -p 41 -j ACCEPT
   45     done
   46   done
   47 
   48   return 0
   49 }
   50 
   51 
   52 # Plugin stop function
   53 plugin_stop()
   54 {
   55   return 0
   56 }
   57 
   58 
   59 # Plugin status function
   60 plugin_status()
   61 {
   62   return 0
   63 }
   64 
   65 
   66 # Check sanity of eg. environment
   67 plugin_sanity_check()
   68 {
   69   if [ -z "$IPV6_OVER_IPV4_IF" -o -z "$IPV6_OVER_IPV4_SERVER" ]; then
   70     printf "\033[40m\033[1;31m${INDENT}ERROR: The plugin config file is not properly set!\033[0m\n" >&2
   71     return 1
   72   fi
   73 
   74   return 0
   75 }
   76 
   77 
   78 ############
   79 # Mainline #
   80 ############
   81 
   82 # Check where to find the config file
   83 CONF_FILE=""
   84 if [ -n "$PLUGIN_CONF_PATH" ]; then
   85   CONF_FILE="$PLUGIN_CONF_PATH/$PLUGIN_CONF_FILE"
   86 fi
   87 
   88 # Preinit to success:
   89 PLUGIN_RET_VAL=0
   90 
   91 # Check if the config file exists
   92 if [ ! -f "$CONF_FILE" ]; then
   93   printf "NOTE: Config file \"$CONF_FILE\" not found!\n        Plugin \"$PLUGIN_NAME v$PLUGIN_VERSION\" ignored!\n" >&2
   94 else
   95   # Source the plugin config file
   96   . "$CONF_FILE"
   97 
   98   if [ "$ENABLED" = "1" ] ||
   99      [ -n "$PLUGIN_LOAD_FILE" -a "$PLUGIN_CMD" = "stop" ] ||
  100      [ -n "$PLUGIN_LOAD_FILE" -a "$PLUGIN_CMD" = "status" ]; then
  101     # Show who we are:
  102     echo "${INDENT}$PLUGIN_NAME v$PLUGIN_VERSION"
  103 
  104     # Increment indention
  105     INDENT="$INDENT "
  106 
  107     # Only proceed if environment ok
  108     if ! plugin_sanity_check; then
  109       PLUGIN_RET_VAL=1
  110     else
  111       case $PLUGIN_CMD in
  112         start|'') plugin_start; PLUGIN_RET_VAL=$? ;;
  113         stop    ) plugin_stop; PLUGIN_RET_VAL=$? ;;
  114         status  ) plugin_status; PLUGIN_RET_VAL=$? ;;
  115         *       ) PLUGIN_RET_VAL=1; printf "\033[40m\033[1;31m${INDENT}ERROR: Invalid plugin option \"$PLUGIN_CMD\"!\033[0m\n" >&2 ;;
  116       esac
  117     fi
  118   fi
  119 fi