#!/pkg/bin/ksh
# -----------------------------------------------------------------------------
# l2vpn_show_tech_fast_bridging_ethernet - Shared show tech-support fast script 
#                                          for l2vpn bridging
#
# October 2008, Simon Osborne
#
# Copyright (c) 2008 by cisco Systems, Inc.
# All rights reserved.
#------------------------------------------------------------------------------


#
# Load the script provided by show-tech infra, which provides worker functions
#
. /pkg/bin/show_tech_main_fragment


#
# Parse the arguments to the script - card type and interface filter are the 
# only support options currently.  No need to use the default parser function,
# as this has been done by caller.
#
__cardtype="unspecified"
internal_if="unspecified"
external_if=""
ether_arg_string=""
bundle_only_arg_string=""

while [ "$#" -gt "0" ]; do
    case "$1" in
        -I) internal_if="$2"; shift 2;;
        -t) __cardtype="$2"; shift 2;;
        *) shift;;
    esac
done

if [ "$internal_if" != "unspecified" ]; then
    external_if=`convert_interface_fmt '-e' $internal_if`
fi

if [ "$__cardtype" == "unspecified" ]; then
    __cardtype=`node_type`
fi

#
# List of commands to be run.  East set must finish with a pair of empty 
# strings.  Note that it is important to use single quotes rather than double 
# quotes for the strings containing your commands.
#
# For all of these the __ksh variable is the process that will actually be 
# spawned, the _exec variable is just a string that is printed in the output to
# describe it. 
#

###############################################################################
# Show commands that run once per LR                                          #
###############################################################################
sys_exec[1]='show l2vpn bridge-domain summary'
sys__ksh[1]='l2vpn_show 0xa'

sys_exec[2]='show l2vpn bridge-domain private'
sys__ksh[2]='l2vpn_show -p 0x9'

sys_exec[3]='show l2vpn bridge-domain hardware'
sys__ksh[3]='l2vpn_show -h 0x9'

sys_exec[4]=''
sys__ksh[4]=''

###############################################################################
# Show commands that run from the RP for all nodes                            #
###############################################################################

rp_loc_exec[1]='show l2vpn forwarding bridge-domain debug location $location'
rp_loc__ksh[1]='l2fib_show_client -l $fq_nodeid -B -D '

rp_loc_exec[2]='show l2vpn forwarding bridge-domain detail location $location'
rp_loc__ksh[2]='l2fib_show_client -l $fq_nodeid -B -d'

rp_loc_exec[3]='show l2vpn forwarding bridge-domain private location $location'
rp_loc__ksh[3]='l2fib_show_client -l $fq_nodeid -B -p'

rp_loc_exec[4]='show l2vpn forwarding bridge-domain mac-address debug location $location'
rp_loc__ksh[4]='l2fib_show_client -l $fq_nodeid -B -m -D'

rp_loc_exec[5]='show l2vpn forwarding bridge-domain mac-address detail location $location'
rp_loc__ksh[5]='l2fib_show_client -l $fq_nodeid -B -m -d'

rp_loc_exec[6]='show l2vpn forwarding bridge-domain mac-address private location $location'
rp_loc__ksh[6]='l2fib_show_client -l $fq_nodeid -B -m -p'

rp_loc_exec[7]='show l2vpn forwarding bridge-domain mac-address aging location $location'
rp_loc__ksh[7]='l2fib_show_client -l $fq_nodeid -B -m -z'

rp_loc_exec[8]='show l2vpn forwarding retry-list location $location'
rp_loc__ksh[8]='l2fib_show_client -l $fq_nodeid -r'

rp_loc_exec[9]=''
rp_loc__ksh[9]=''

#
# The display() function is the one that does all the work - called by us as 
# this is a worker script.
#
display() {
    print_main_heading "show tech-support l2vpn bridging"
        
    if [ "$__cardtype" == "SYS" ]; then
        exec_commands sys
    else
        case "$__cardtype" in
        "RP")
            exec_commands rp_loc
            ;;
        esac
    fi
    
    print_main_heading "show tech-support l2vpn bridging complete"
}

display

