#!/pkg/bin/ksh
#--------------------------------------------------------------------
# ospfv3_show_tech - show tech-support command for ospfv3
#
# March 2004, Paul Wells
# July  2014, Balaji Venkatraman
#
# Copyright (c) 2004-2005, 2008-2009, 2014 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
### Variable initialization
rp_role="active"
process_name=""
process_args="+"
__cardtype="unspecified"
showtech_argv=""
showtech_argc="0"
skip_active="0"
det="0"
### Required argument parsing
### All local options must be upper-case.
while (( $# > 0 )); do
    case "$1" in
        -T) tag="$2"; shift 2;;
        -D) det=detail; shift 1;;
        -t) __cardtype="$2"; shift 2;;
         *) showtech_argv="$showtech_argv $1"; (( showtech_argc+=1 )); shift 1;;
    esac
done

 # 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

 index=1

 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))

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

 config_exec[$index]="show running router ospf $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))

 config_exec[$index]="show logging process ospfv3 $process_name"
 config__ksh[$index]="show_logging -p ospfv3 $process_name"
 index=$((index + 1))

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

 index=1
 ### ospfv3 specific commands
 for rp_role in "active" "standby"
 do
   ospfv3_exec[$index]="show ospfv3  $process_name $rp_role"
   ospfv3__ksh[$index]="ospfv3_show_ospf -T $process_args -v + -L $rp_role"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $rp_role 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 $rp_role 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 $rp_role 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 $rp_role 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 message-queue"
   ospfv3__ksh[$index]="ospfv3_show -B -T $process_args -v + -L $rp_role"

   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 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 $rp_role 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 $rp_role 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 $rp_role 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 $rp_role database"
   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"

   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $rp_role route"
   ospfv3__ksh[$index]="ospfv3_show_top -T $process_args -v + -L $rp_role"

   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $rp_role 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 $rp_role 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 $rp_role database inter-area prefix"
   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 0x2003"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $rp_role database inter-area 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 0x2004"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $rp_role database external"
   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 0x4005"

   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $rp_role database nssa-external"
   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 0x2007"

   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $rp_role database link"
   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 0x0"

   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $rp_role database prefix"
   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 -d 0x0 -t 0x2009"
   index=$((index + 1))

   ospfv3_exec[$index]="show ospfv3  $process_name $rp_role trace all"
   ospfv3__ksh[$index]="ospfv3_get_all_traces -T $process_args -L $rp_role"
   index=$((index + 1))
   ospfv3_exec[$index]="show ospfv3  $process_name $rp_role 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]=""


  display() {

   # Print the output heading
   print_main_heading "show tech-support routing ospfv3"

   if [ "$__cardtype" == "SYS" ]; then
       exec_commands config
       exec_commands ospfv3
   fi

      # Print the closing heading.
   print_main_heading "show tech-support routing ospfv3 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

