#!/pkg/bin/ksh
#--------------------------------------------------------------------
# ospfv3_show_tech - show tech-support command for ospfv3
#
# March 2004, Paul Wells
# July  2014, Balaji Venkatraman
# Feb   2017, Manish Kumar
# Copyright (c) 2004-2017 by cisco Systems, Inc.
# All rights reserved.
#--------------------------------------------------------------------

### Required by show_tech
. /pkg/bin/show_tech_main_fragment

### List the sets of show commands to 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.

    index=1
## Command set 1 - configuration & other basic info
### Variable initialization
standby=""
rp_role="active"
process_name=""
process_args="+"
__cardtype="unspecified"
showtech_argv="" 
showtech_argc="0"
skip_traces="0"
skip_active="0"
skip_standby="0"

# Find node id corresponding to node name.

if [[ "$platform" = "panini" ]]; then
    ospf_node_name=`node_list_generation -f MY`

    #Scapa platform check
    check_platform_type=`get_platform_type`

    if [[ "$check_platform_type" == "SCAPA" ]] ; then
        ospf_int_node_name=$(node_conversion -S $ospf_node_name)
    else
        ospf_int_node_name=$(node_conversion -N $ospf_node_name)
    fi

    ospf_node_id=`node_conversion -i $ospf_int_node_name`
else
    ospf_node_name=$(uname -n)
    ospf_node_id=`node_conversion -i $ospf_node_name`
    ospf_int_node_name=`node_conversion -E $ospf_node_name`
fi

# Read in the arguments to the script, setting mode
# according to these arguments.
# Note that it is important for security reasons that users can only enter
# alphanumeric filenames and nodes and that anywhere calling this script must
# enforce this.
  
while [ $# -gt 0 ]; do
  case "$1" in
     -P) process_name="$2"; shift 2;;
     -ST) skip_traces=1; shift 1;;
     -SA) skip_active=1; shift 1;;
     -SS) skip_standby=1; shift 1;;
     -t) __cardtype="$2"; shift 2;;
      *)  showtech_argv="$showtech_argv $1"; (( showtech_argc+=1 )); shift 1;;
    esac
  done
 
  config_exec[$index]="show version"
 if [[ "$platform" = "panini" ]]; then
   config__ksh[$index]="ng_show_version"
 else
   config__ksh[$index]="show_version"
 fi
 index=$((index + 1))


 config_exec[$index]="show install active"
 if [[ "$platform" = "panini" ]]; then
   config__ksh[$index]="sdr_instcmd show install active"
 else
   config__ksh[$index]="instcmd show install active"
 fi
 index=$((index + 1))

 config_exec[$index]="show redundancy"
 config__ksh[$index]="redcon_show"
 index=$((index + 1))

 config_exec[$index]="show running router ospfv3 $process_name"
 config__ksh[$index]="nvgen -c -q gl/ipv6-ospfv3/proc/"
 index=$((index + 1))

 config_exec[$index]="show process ospfv3 location all"
 config__ksh[$index]="sysmgr_show -o -p ospfv3 -n all"
 index=$((index + 1))

if [ "$process_name" = "" ]; then
   config__ksh[$index]="nvgen -c -q gl/ipv6-ospfv3/proc/"
else
   config__ksh[$index]="nvgen -c -q gl/ipv6-ospfv3/proc/$process_name/"
fi
 index=$((index + 1))

 config_exec[$index]=""
 config__ksh[$index]=""

 index=1
 ### ospfv3 specific commands
 for rp_role in "active" "standby"
 do
   if [[ "$skip_active" == 1 ]]  && [[ "$rp_role" == "active" ]]; then
       continue
   fi

   if [[ "$skip_standby" == 1 ]]  && [[ "$rp_role" == "standby" ]]; then
       continue
   fi

   if [ "$rp_role" == "active" ] ; then
       standby=""
   else
       standby="standby"
   fi
   ospfv3_exec[$index]="show ospfv3  $process_name $standby"
   ospfv3__ksh[$index]="ospfv3_show_ospf -T $process_args -v + -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby vrf all"
   ospfv3__ksh[$index]="ospfv3_show_ospf -T $process_args -v all -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby summary"
   ospfv3__ksh[$index]="ospfv3_show -C -T $process_args -v + -L $rp_role -f 0x0"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby vrf all summary"
   ospfv3__ksh[$index]="ospfv3_show -C -T $process_args -v all -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby interface"
   ospfv3__ksh[$index]="ospfv3_show_intf -T $process_args -v + -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -b 0x"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby vrf all interface"
   ospfv3__ksh[$index]="ospfv3_show_intf -T $process_args -v all -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -b 0x0"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby virtual-links"
   ospfv3__ksh[$index]="ospfv3_show_virtual -T $process_args -v + -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby vrf all virtual-links"
   ospfv3__ksh[$index]="ospfv3_show_virtual -T $process_args -v all -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby vrf all sham-links"
   ospfv3__ksh[$index]="ospfv3_show -S -T $process_args -v all -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby neighbor detail"
   ospfv3__ksh[$index]="ospfv3_show_nbr -T $process_args -v + -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -i 0x0 -a 0x0 -d 0x1 -j 0x0"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby vrf all neighbor detail"
   ospfv3__ksh[$index]="ospfv3_show_nbr -T $process_args -v all -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -i 0x0 -a 0x0 -d 0x1 -j 0x0"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby database database-summary"
   ospfv3__ksh[$index]="ospfv3_show_dbase -T $process_args -v + -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -s 0x1"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby vrf all database database-summary"
   ospfv3__ksh[$index]="ospfv3_show_dbase -T $process_args -v all -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -s 0x1"
   index=$((index + 1))
 
   ospfv3_exec[$index]="show ospfv3  $process_name $standby database router"
   ospfv3__ksh[$index]="ospfv3_show_dbase -T $process_args -v + -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -s 0x0 -o 0x0 -a 0x0 -r 0x0 -i 0x0 -l 0x0 -m 0x0 -n 0x0 -d 0x0 -g 0x0 -k 0x0 -w 0x0 -t 0x2001"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby database router self-originate"
   ospfv3__ksh[$index]="ospfv3_show_dbase -T $process_args -v + -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -s 0x0 -o 0x1 -a 0x0 -r 0x0 -i 0x0 -l 0x0 -m 0x0 -n 0x0 -d 0x0 -g 0x0 -k 0x0 -w 0x0 -t 0x2001"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby vrf all database router"
   ospfv3__ksh[$index]="ospfv3_show_dbase -T $process_args -v all -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -s 0x0 -o 0x0 -a 0x0 -r 0x0 -i 0x0 -l 0x0 -m 0x0 -n 0x0 -d 0x0 -g 0x0 -k 0x0 -w 0x0 -t 0x2001"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby vrf all database router self-originate"
   ospfv3__ksh[$index]="ospfv3_show_dbase -T $process_args -v all -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -s 0x0 -o 0x1 -a 0x0 -r 0x0 -i 0x0 -l 0x0 -m 0x0 -n 0x0 -d 0x0 -g 0x0 -k 0x0 -w 0x0 -t 0x2001"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby database network"
   ospfv3__ksh[$index]="ospfv3_show_dbase -T $process_args -v + -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -s 0x0 -o 0x0 -a 0x0 -r 0x0 -i 0x0 -l 0x0 -m 0x0 -n 0x0 -d 0x0 -g  0x0 -k 0x0 -w 0x0 -t 0x2002"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby stat prot"
   ospfv3__ksh[$index]="ospfv3_show_stats_proto -T $process_args -v + -L $rp_role -p 0x0"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby stat raw-io"
   ospfv3__ksh[$index]="ospfv3_show_stats_raw -T $process_args -v + -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby stat rib-batch"
   ospfv3__ksh[$index]="ospfv3_show_stats_rib -T $process_args -v + -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby stat rib-thread"
   ospfv3__ksh[$index]="ospfv3_show -A -T $process_args -v + -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby stat prefix-priority"
   ospfv3__ksh[$index]="ospfv3_show -E -T $process_name -v + -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby stat nsr"
   ospfv3__ksh[$index]="ospfv3_show -D -T $process_name -v + -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby stat npl"
   ospfv3__ksh[$index]="ospfv3_show -G -T $process_args -v + -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby border-routers"
   ospfv3__ksh[$index]="ospfv3_show_border -T $process_args -v + -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby vrf all border-routers"
   ospfv3__ksh[$index]="ospfv3_show_border -T $process_args -v all -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name retransmission-list"
   ospfv3__ksh[$index]="ospfv3_show_retrans -T $process_args -v + -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -i 0x0 -p 0x0"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name vrf all retransmission-list"
   ospfv3__ksh[$index]="ospfv3_show_retrans -T $process_args -v all -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -i 0x0 -p 0x0"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name request-list"
   ospfv3__ksh[$index]="ospfv3_show_reqlist -T $process_args -v + -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -i 0x0 -p 0x0"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name vrf all request-list"
   ospfv3__ksh[$index]="ospfv3_show_reqlist -T $process_args -v all -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -i 0x0 -p 0x0"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby flood-list"
   ospfv3__ksh[$index]=" ospfv3_show_flood -T $process_args -v + -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -p 0x0"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby vrf all flood-list"
   ospfv3__ksh[$index]=" ospfv3_show_flood -T $process_args -v all -L $rp_role -X 0x0 -Y 0x0 -f 0x0 -p 0x0"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby maxage-list"
   ospfv3__ksh[$index]="ospfv3_show_maxage -T $process_args -v + -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby vrf all maxage-list"
   ospfv3__ksh[$index]="ospfv3_show_maxage -T $process_args -v all -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby bad-checksum"
   ospfv3__ksh[$index]="ospfv3_show -I -T $process_args -v + -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $standby stat issu"
   ospfv3__ksh[$index]="ospfv3_show -H -T $process_args -v + -L $rp_role"

   index=$((index + 1))


 done
 ospfv3_exec[$index]=""
 ospfv3__ksh[$index]=""
 index=1
 ## Command set 3 - non-ospf commands
 other_exec[$index]="show ipv6 interface brief"
 other__ksh[$index]="show_ipv6_interface -b -v default"
    index=$((index + 1))
 
 other_exec[$index]="show route ipv6 summary detail"
 other__ksh[$index]="show_ipv6_rib -X 0x2 -Y 0x1 -Z ________ -V ________ -s -D ipv6 ________"
    index=$((index + 1))
 
 other_exec[$index]="show route ipv6 multicast summary detail"
 other__ksh[$index]="show_ipv6_rib -X 0x2 -Y 0x2 -Z ________ -V ________ -D ipv6 ________"
    index=$((index + 1))
 
 other_exec[$index]="show route vrf all ipv6 summary"
 other__ksh[$index]="show_ipv6_rib -X 0x2 -Y 0x1 -Z all -V ________ -S ipv6 all"
    index=$((index + 1))
 
 other_exec[$index]="show logging process ospfv3 $process_name"
 other__ksh[$index]="show_logging -p ospfv3 $process_name"
    index=$((index + 1))
 
 other_exec[$index]=""
 other__ksh[$index]=""
    index=1
	
 ## Command set 4 - ospfv3 traces
trace_exec[$index]="show ospfv3  $process_name active trace all"
trace__ksh[$index]="ospfv3_get_all_traces -T $process_args -L active"
index=$((index + 1))

trace_exec[$index]="show ospfv3  $process_name standby trace all"
trace__ksh[$index]="ospfv3_get_all_traces -T $process_args -L standby"
index=$((index + 1))

trace_exec[$index]="show ital trace location $ospf_int_node_name"
trace__ksh[$index]="ital_show_ltrace -i $ospf_node_id"
index=$((index + 1))

#
# Call the showtech infra default parser - using set to recreate the $#, $@,
# etc. - "--" is necessary so set doesn"t try to interpret any of the
# arguments we are passing through
#
if [[ $showtech_argc -ne 0 ]]; then
  set -- $showtech_argv
  default_parser_function $@
fi
 
if [ "$__cardtype" == "unspecified" ]; then
  __cardtype=`node_type`
fi
  
### display - run the show commands
### MUST be named display.
### Called by show_tech_file_fragment().
display() {
 
   # Print the output heading
   print_main_heading "show tech-support routing ospfv3"
 
   if [ "$__cardtype" == "SYS" ]; then
           exec_commands Basic
           exec_commands config
           exec_commands ospfv3
           exec_commands other
 
           if [ "$skip_traces" == "0" ]; then
               exec_commands trace
           fi
   fi    
   enable_techs /pkg/bin/ospfv3_show_tech_routes   
       # Print the closing heading. 
       print_main_heading "show tech-support routing ospfv3 complete"
  }
  
### This mandatory bit calls display() and handles output redirection.
. /pkg/bin/show_tech_file_fragment
 
