
#-----------------------------------------------------------------------
# Copyright (C) 2000-2001, Jean-Sebastien Morisset <jsmoriss@mvlan.net>
#-----------------------------------------------------------------------
# $Id: set_mode_num.sh,v 1.4 2001/08/11 17:01:20 jsmoriss Exp $
#-----------------------------------------------------------------------
#  $RCSfile: set_mode_num.sh,v $
#   $Author: jsmoriss $
# $Revision: 1.4 $
#     $Date: 2001/08/11 17:01:20 $
#   $Locker:  $ 
#     $Name:  $
#-----------------------------------------------------------------------
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by 
# the Free Software Foundation <http://www.gnu.org/copyleft/gpl.txt>.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License (LICENSE file in archive) for more details.
#
#-----------------------------------------------------------------------
# README
#-----------------------------------------------------------------------
#
# A bourne shell function used by rcf; a very secure, fast, and complete
# firewall for linux <http://jsmoriss.mvlan.net/linux/rcf.html>.
#
#-----------------------------------------------------------------------
# FUNCTION
#-----------------------------------------------------------------------

Set_Mode_Num () {
	# Set the PUBLIC_INTERFACES_MODE etc. variables.
	# Numeric values are easier to test against.
	#
	for interface_type in PUBLIC PRIVATE DMZ MZ
	do
		for group_type in INTERFACES CLUSTERS
		do
			eval value=\"\$${interface_type}_${group_type}_SECURITY\"
			[ "$value" ] && case $value in
				o*|O*)
					if [ "$interface_type" != "PRIVATE" ]
					then
						echo ""
						echo "WARNING: open mode is only supported on private interfaces!"
						echo "Please change the value of ${interface_type}_${group_type}_SECURITY."
						echo ""
						exit 1
					fi
					eval ${interface_type}_${group_type}_MODE=\"0\"
					;;
				r*|R*)	eval ${interface_type}_${group_type}_MODE=\"1\" ;;
				s*|S*)	eval ${interface_type}_${group_type}_MODE=\"2\" ;;
				p*|P*)	eval ${interface_type}_${group_type}_MODE=\"3\" ;;
				*)		echo "WARNING: Setting ${interface_type}_${group_type}_MODE to paranoid."
						eval ${interface_type}_${group_type}_MODE=\"3\" ;;
			esac
		done
	done
	unset interface_type group_type value
}

