#!/pkg/bin/ksh
#
# Created by Ken Blanc, January 2008.
#
# Copyright (c) 2010-2019, 2021 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

# Parse the arguments to the script.
# None needed for igmpsn snooping at this time.


# 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. 

idx=1
sys_show_exec[$idx]='show version'
if [[ "$platform" == "panini" ]]; then
    sys_show__ksh[$idx]='ng_show_version'
else
    sys_show__ksh[$idx]='show_version'
fi
idx=$((idx+1))
sys_show_exec[$idx]='show running-config'
sys_show__ksh[$idx]='nvgen -c -l 1 -t 1 -o 1'
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping summary statistics debug'
sys_show__ksh[$idx]='igmpsn_show -S -t -y'
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping bridge-domain detail statistics debug'   
sys_show__ksh[$idx]='igmpsn_show -B -t -d -y'   
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping group debug '
sys_show__ksh[$idx]='igmpsn_show -G -t  '
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping group debug inherited '
sys_show__ksh[$idx]='igmpsn_show -G -H  '
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping group summary debug'
sys_show__ksh[$idx]='igmpsn_show -G -t -x'
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping port detail statistics debug'
sys_show__ksh[$idx]='igmpsn_show -I -t -d -y'
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping profile detail debug'
sys_show__ksh[$idx]='igmpsn_show -P -t -d'
idx=$((idx+1))
# TBD: when taking this out of comment, please make sure 
#      numbers are adjusted correctly.
#sys_show_exec[10]='show igmp snooping profile references debug'
#sys_show__ksh[10]='igmpsn_show -P -t -r'
sys_show_exec[$idx]='show igmp snooping profile summary debug'
sys_show__ksh[$idx]='igmpsn_show -P -t -x'
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping port group detail'
sys_show__ksh[$idx]='igmpsn_show -I -k -d'
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping trace error'
sys_show__ksh[$idx]='igmpsn_show_ltrace -E'
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping trace event'
sys_show__ksh[$idx]='igmpsn_show_ltrace -N'
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping trace all'
sys_show__ksh[$idx]='igmpsn_show_ltrace -A'
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping redundancy iccp'
sys_show__ksh[$idx]='igmpsn_show -R -u'
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping redundancy iccp debug'
sys_show__ksh[$idx]='igmpsn_show -R -t -u'
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping redundancy iccp statistics'
sys_show__ksh[$idx]='igmpsn_show -R -u -y'
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping redundancy iccp group port'
sys_show__ksh[$idx]='igmpsn_show -R -u -i -x'
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping redundancy iccp group port detail'
sys_show__ksh[$idx]='igmpsn_show -R -u -i -d -x'
idx=$((idx+1))
sys_show_exec[$idx]='show igmp snooping redundancy iccp group port detail statistics'
sys_show__ksh[$idx]='igmpsn_show -R -u -i -d -x -y'
idx=$((idx+1))
if [[ "$platform" = "ASR9k" || "$platform" = "asr9k" || "$platform" = "viking" ]] ; then
    sys_show_exec[$idx]='show igmp snooping platform trace'
    sys_show__ksh[$idx]='show_trace_vkg_igmpsn'
    idx=$((idx+1))
    sys_show_exec[$idx]='show igmp snooping platform interface all detail'
    sys_show__ksh[$idx]='show_vkg_igmpsn -a -i -d '
    idx=$((idx+1))
    sys_show_exec[$idx]='show igmp snooping platform resources debug'
    sys_show__ksh[$idx]='show_vkg_igmpsn -n -g '
    idx=$((idx+1))
elif [[ "$platform" == "panini" ]]; then
    sys_show_exec[$idx]='show  igmp snooping l2fib-trace rp'
    sys_show__ksh[$idx]='fretta_l2fib_trace -s R -l'
    idx=$((idx+1))
fi
sys_show_exec[$idx]='show platform'
if [[ "$platform" == "panini" ]]; then
    sys_show__ksh[$idx]='show_platform_sysdb'
else
    sys_show__ksh[$idx]='show_platform'
fi
idx=$((idx+1))
sys_show_exec[$idx]='show redundancy'
sys_show__ksh[$idx]='show_rmf_sysdb'
idx=$((idx+1))
sys_show_exec[$idx]=''
sys_show__ksh[$idx]=''
idx=$((idx+1))

# Parse the arguments to the script.
while [ $# -gt 0 ]; do
  case "$1" in
    -t) __cardtype="$2"; shift 2;;  
     *)  default_parser_function "$@"; shift $#;;
  esac
done

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

display() {
    # Print the output heading 
    print_main_heading "show tech-support igmp snooping"
     
    # Execute commands
    exec_commands sys_show

    # Print the closing heading. 
    print_main_heading "show tech-support igmp snooping complete"
}

# This function calls the display() function and sends the output to file if
# the file option has been set. 
. /pkg/bin/show_tech_file_fragment
