# SCCS_ID - "@(#)routeadm	1.4	86/07/01"
#
#   Copyright (c) 1986  The Wollongong Group, Inc.  All Rights Reserved
#
ETC=/etc
LIB=/usr/ethernet/ua
ROUTEFORM=$LIB/Route.form
Menu=/tmp/Route$$.menu
trap "rm -f $Menu" 0
while true;do
RET=`shform -u $ROUTEFORM`
if [ $? -ne 0 ]
then
	message "shform failed. Perhaps $ROUTEFORM is missing!"
	exit 1
fi
set $RET
case $1 in
\'Enter\')
	eval Cmd=$2
	if [ "$Cmd" = "Add" ]
	then
		comm=add
		if [ "$5" = "'Network'" ]
		then
			flags=1
		else
			flags=0
		fi
	elif [ "$Cmd" = "Delete" ]
	then
		comm=delete
		flags=""
	elif [ "$Cmd" = "Show" ]
	then
		echo "Menu=Network Routes" > $Menu
		echo "Prompt=Press ENTER to Continue" >> $Menu
		netstat -r | awk '{ print "Name=",$0 }' >> $Menu
		clear
		shform -u $Menu > /dev/null
		clear
		continue
	else
		message "Command must be Add, Delete or Show"
		continue
	fi
	eval dest=$3
	if [ "$dest" = "" ]
	then
		message "Destination must be specified"
		continue
	fi
	eval gate=$4
	if [ "$gate" = "" ]
	then
		message "Gateway must be specified"
	else
		RET=`route $comm $dest $gate $flags 2>&1`
		if [ $? -eq 0 ]
		then
			message -c "Route Table updated."
			if [ $? -ne 0 ]
			then
				exit 0
			fi
		else
			message "Route command failed.\n$RET"
		fi
	fi
	;;
\'Help\')
	message -i "This command is used to update the routing table maintained by the network. When using the \"Add\" command, be sure to specify if the destination is a network or host.\n\nPress ENTER to continue"
	;;
\'Cancel\')
	exit 0
	;;
 *)
	message "Invalid Key Pressed."
	;;
esac
done
