#!/pkg/bin/ksh
###
### June 2004, Simon Osborne
###
### Copyright (c) 2004-2006 by cisco Systems, Inc.
### All rights reserved.
###
### This shell is called when debug (or no debug) rib/routing is requested,
### and exists to allow the afi-all parameter to be supported.
###
### The first parameters given will be the flags to be specified for the call
### to debug, followed by -X and the AFI tag, and then the string which, when
### appended to the afi, determines the sysdb tuple to be set.
###

#
# Initialise the variables we will use.
#
flag1=
flag2=

#
# The first arguments given will be the flags to be passed to the debug
# command. The -X flag is used to indicate where the end of these flags is.
#
# Supported flags are:
# -O  Used with ACL debug to indicate that any existing ACL debug setting
#     should be overwritten.
# -n  Indicates that the 'no' form of this command was selected.
#
param="$1";
shift;
until test "$param" = -X
do
    if test "$param" = -O
    then
        flag1=-O;
    elif test "$param" = -n
    then
        flag2=-n;
    else
        exit 1
    fi
    
    param="$1";
    shift;
done

#
# Following the -X flag, is an argument specifying the AFI for which debug
# has been requested. If this is ipv4 or ipv6 we call the respective commands.
# If this is afi-all we must call both commands.
#
afi="$1"
shift
if test "$afi" = ipv4 -o "$afi" = ipv6
then
    debug $flag1 $flag2 $afi$1
elif test "$afi" = afi-all
then
    debug $flag1 $flag2 ipv4$1
    debug $flag1 $flag2 ipv6$1    
else
    exit 1
fi 

