
#-----------------------------------------------------------------------
# Copyright (C) 2000-2001, Jean-Sebastien Morisset <jsmoriss@mvlan.net>
#-----------------------------------------------------------------------
# $Id: forward_interfaces.sh,v 1.5 2001/09/02 22:09:26 jsmoriss Exp $
#-----------------------------------------------------------------------
#  $RCSfile: forward_interfaces.sh,v $
#   $Author: jsmoriss $
# $Revision: 1.5 $
#     $Date: 2001/09/02 22:09:26 $
#   $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
#-----------------------------------------------------------------------

Forward_Interfaces () {

	# Prevent duplicate entries when using something like:
	# Forward_Interfaces "eth0 eth1" "eth0 eth1"
	[ "$1" = "$2" ] && DIRECTION="->" || DIRECTION="<->"

	for FIRST_INTERFACE in $1
	do
		Get_Interface_Vars $FIRST_INTERFACE FIRST
		for SECOND_INTERFACE in $2
		do
			Get_Interface_Vars $SECOND_INTERFACE SECOND
			if [ "$FIRST_INTERFACE" != "$SECOND_INTERFACE" \
				-a "$FIRST_VIRTUAL" = "no" -a "$SECOND_VIRTUAL" = "no" ]
			then
				for FIRST_NET in `Device_Subnets FIRST`
				do
					for SECOND_NET in `Device_Subnets SECOND`
					do
						Forward_Subnets "${FIRST_NET}${DIRECTION}${SECOND_NET}"
					done
				done
			fi
		done
	done
	unset DIRECTION
}

