
#-----------------------------------------------------------------------
# Copyright (C) 2000-2001, Jean-Sebastien Morisset <jsmoriss@mvlan.net>
#-----------------------------------------------------------------------
# $Id: get_interface_vars.sh,v 1.6 2001/11/25 18:05:22 jsmoriss Exp $
#-----------------------------------------------------------------------
#  $RCSfile: get_interface_vars.sh,v $
#   $Author: jsmoriss $
# $Revision: 1.6 $
#     $Date: 2001/11/25 18:05:22 $
#   $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
#-----------------------------------------------------------------------

Get_Interface_Vars () {
	if [ "$1" ]
	then
		ucase_interface=`echo $1|To_Upper_Fix`
		[ "$2" ] && prefix="${2}_" || prefix=""

		device="`echo $1|sed -n -e 's/^\([^\:]*\).*\$/\1/p'`"
		[ "$device" != "$1" ] && virtual="yes" || virtual="no"

		eval \
			${prefix}INTOPT="$1" \
			${prefix}DEVICE="$device" \
			${prefix}VIRTUAL="$virtual" \
			${prefix}NETADDR=\"\$${ucase_interface}_IPADDR\" \
			${prefix}IPADDR=\"\$${ucase_interface}_IPADDR\" \
			${prefix}BITLEN=\"\$${ucase_interface}_BITLEN\" \
			${prefix}NETMASK=\"\$${ucase_interface}_NETMASK\" \
			${prefix}NETWORK=\"\$${ucase_interface}_NETWORK\" \
			${prefix}BROADCAST=\"\$${ucase_interface}_BROADCAST\" \
			${prefix}INCHAIN=\"\$${ucase_interface}_INCHAIN\" \
			${prefix}OUTCHAIN=\"\$${ucase_interface}_OUTCHAIN\" \
			${prefix}IPSEC=\"\$${ucase_interface}_IPSEC\"

		unset ucase_interface prefix device virtual
	else
		echo "ERROR: Get_Interface_Vars function needs at least one argument!"
	fi
}

