
#-----------------------------------------------------------------------
# DESCRIPTION
#-----------------------------------------------------------------------
#
# Description for users installing this module - where and what it does,
# etc. In this case, TCP-TEMPLATE is a blank template you can use to
# create your own modules.
#
# After installing the module, the user should execute rc.firewall with
# the --update-config parameter. The necessary options will be added to
# the configuration file.
#
#-----------------------------------------------------------------------
# CHANGES
#-----------------------------------------------------------------------
#
# 2000-10-14  Jean-Sebastien Morisset <jsmoriss@jsm-mv.dyndns.org>
#             Each change to this file should be documented.
#
#-----------------------------------------------------------------------
# MODULE CONFIGURATION
#-----------------------------------------------------------------------
#
#   (N)ame       : A simple name for this module (a-zA-Z0-9 only)
#   (A)ction     : Options which should be listed in the configuration
#                  file (accept, ignore, deny, etc.).
#   (T)ype       : The service type (servers, clients, hostports, etc.).
#   (V)alue      : The default option value when creating a new config 
#                  file. This is applied to all (N)ame options.
#   (D)escription: A multi-line description/comment for the config file.
#
#N# template
#A# accept ignore deny
#T# clients
#   |--------------------------------------------------------------------|
#D# A multi-line description/comment used for the configuration files.
#D# Simply add lines as necessary. The rulers (above/bellow) help you keep
#D# your text within 72 columns.
#   |--------------------------------------------------------------------|
#
#-----------------------------------------------------------------------
# START OF MODULE CODE
#-----------------------------------------------------------------------


#--------------------------------------------------------------------
# Local Variables
#--------------------------------------------------------------------
# If you define new variables and/or functions within a module, you
# should always keep them in lower case. This will avoid any 
# conflicts with rc.firewall variables and function names.
#--------------------------------------------------------------------

module_name="template"      # module name used in options
service_name="My Template"  # displayed on-screen
service_port="12345"        # port number for this service

#--------------------------------------------------------------------
# Template Server (Port XX)
#--------------------------------------------------------------------

ucase_module_name="`echo $module_name|tr '[a-z]' '[A-Z]'`"

for ACTION in IGNORE DENY ACCEPT
do
	case $ACTION in
		IGNORE)	ACTION_LOG_MSG="$LOG_MSG"; ACTION_LOG="$LOG";;
		DENY)	ACTION_LOG_MSG="(logged)"; ACTION_LOG="-l"  ;;
		ACCEPT)	ACTION_LOG_MSG=""        ; ACTION_LOG=""    ;;
	esac

	for HOST in `Option_Value $ACTION $INTERFACE $ucase_module_name CLIENTS`
	do
		case $ACTION in
			IGNORE|DENY)
				echo "Deny $INTERFACE $IPADDR $service_name <- $HOST $ACTION_LOG_MSG"
				ipchains -A $INCHAIN -j DENY -p tcp -s $HOST -d $IPADDR $service_port $ACTION_LOG
				;;
			ACCEPT)
				Accept_Hostports $INTERFACE tcp "$service_name" $HOST $service_port
				;;
		esac
	done
done

unset module_name service_name service_port ucase_module_name

