#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# show_tech_ether_common - Shared show tech-support script for ethernet
#
# July 2006, Ross Denham
#
# Copyright (c) 2006-2009, 2012 by cisco Systems, Inc.
# All rights reserved.
#--------------------------------------------------------------------


# This script fragment contains the code for the following functions
# - print_main_heading
# - print_command_heading
# - run_single_command
# - run_commands
# - run_single_command_on_all_nodes
# - run_commands_on_all_nodes
# - default_parser_function
. /pkg/bin/show_tech_main_fragment

# List each set of show commands to be run. Each set must finish with an empty
# string. Note that it is important to use single quotes rather than double 
# quotes for the strings containing your commands. 

# Command 1 - traces 
command1[0]='show ethernet driver trace location all'
command1[1]='show ethernet infra trace location all'
command1[2]='show arp trace location all'
command1[3]='show arp-gmp trace all location all'
command1[4]=''   

# Command 2 - Global show commands (supporting location all or running globally)              
#     [note: ARP command is implicitly default vrf, but specifying 'all' 
#           excludes default VRF - so both commands needed]
#           ARP-GMP config implicitly shows data for all VRFs including default
command2[0]='show arp location all'
command2[1]='show arp vrf all location all'
command2[2]='show arp traffic location all'
command2[3]='show arp vrf all traffic location all'
command2[4]='show arp-gmp config'
command2[5]='show arp-gmp routes'
command2[6]='show arp-gmp vrf'
command2[7]='show processes ether_caps_partner location all'
command2[8]='show processes ether_caps_ea location all'
command2[9]='show processes ether_sock location all'
command2[10]='show processes vlan_ma location all'
command2[11]='show processes vlan_ea location all'
command2[12]='show processes arp location all'
command2[13]='show processes arp_gmp location all'
command2[14]='show ethernet trunk'
command2[15]='show ethernet trunk detail'
command2[16]='show ethernet tags'
command2[17]='show ethernet tags match-order'
command2[18]='show ethernet tags detail'
command2[19]='' 

# Command 3 - Local show commands (not supporting location all)    
command3[0]='show arp idb all location $location'
command3[1]=''

# Command 4 - Interface specific commands
command4[0]='show controllers $external_if all'
command4[1]='show arp-gmp interface $external_if'
command4[2]='' 
             
# Initialise any variables used. 
                                                       
internal_if="unspecified"
external_if=""

# Parse the arguments to the script.
# Usage: 
# 
# -I  : Run commands for a specific interface
while [ $# -gt 0 ]; do
  case "$1" in
     -I) internal_if="$2"; shift 2;;
     *)  default_parser_function "$@"; shift $#;;
  esac
done

#
# We only want to run on RP/DRP/LC type nodes, not SPs or any fabric nodes and
# the such.  So we just tell showtech infra that we are only interested in 
# locations with CPU in the name (this is simply a globbing expression that 
# will expand to all valid CPU type node IDs)
#
get_node_list *CPU*

# A function called display() must be provided that calls the functions to 
# run the required show commands. The display() function will be called in 
# the /pkg/bin/show_tech_comp_file_frag

display() {
     #
     # Note: 'interface' is the only supported option (and this only adds 
     # information, doesn't filter any).  
     #
     # Some commands do not support "location all" - so call these for each 
     # location.
     #

     # Print the output heading 
     print_main_heading "show tech-support ethernet common"

     run_commands 2
     run_commands_on_all_nodes 3

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

     run_commands 1
    
     # Print the closing heading. 
     print_main_heading "show tech-support ethernet common complete"
}

display


