#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# show_tech_hw_ack - HW ACK specific show tech commands - fast mode
#
# Copyright (c) 2023 by cisco Systems, Inc.
# All rights reserved.
#--------------------------------------------------------------------

#
# include the standard show tech-support functions
#
. /pkg/bin/show_tech_main_fragment

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

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


#
# tech of service-layer
#
# include function to collect service layer info
# Service Layer API only runs on RP/DRP
#
if [ -f /pkg/bin/show_tech_hw_ack_sl ]; then
    . /pkg/bin/show_tech_hw_ack_sl
fi


#
# tech of insight
#
# include tech insight
#
if [ -f /pkg/bin/show_tech_insight ]; then
    enable_techs "" /pkg/bin/show_tech_insight
fi


#
# List of show system commands
#
# Commands that run on once per system
index=1
sys_exec[index]='show platform'
sys__ksh[index]='show_platform_sysdb'

((index++))
sys_exec[index]='show version'
sys__ksh[index]='show_version'

((index++))
sys_exec[index]='show install active'
sys__ksh[index]='sdr_instcmd show install active'

((index++))
sys_exec[index]='show install active summary'
sys__ksh[index]='sdr_instcmd show install active summary'

((index++))
sys_exec[index]='show redundancy location $location'
sys__ksh[index]='redcon_show -n $fq_nodeid'

((index++))
sys_exec[index]='show logging'
sys__ksh[index]='show_logging'

((index++))
sys_exec[index]=''
sys__ksh[index]=''


#
# tech of CEF, on RP/LC cards
#
index=1
cef_exec[index]='show cef global gribi aft internal location $location'
cef__ksh[index]='fib_show_command -s --global --gribi-aft-tbl --internal'

((index++))
cef_exec[index]='show cef object-queue detail location $location'
cef__ksh[index]='fib_show_command -O 0x0 --object-queue -d'

((index++))
cef_exec[index]='show cef ipv6 object-queue detail location $location'
cef__ksh[index]='fib_show_command -O 0x1 --object-queue -d'

((index++))
cef_exec[index]='show cef message-queue location $location'
cef__ksh[index]='fib_show_command --msg_q'

((index++))
cef_exec[index]='show cef retry-db location $location'
cef__ksh[index]='fib_show_command -O 0x0 --retry_db'

((index++))
cef_exec[index]='show cef ipv6 retry-db location $location'
cef__ksh[index]='fib_show_command -O 0x1 --retry_db'

((index++))
cef_exec[index]='show cef trace location $location'
cef__ksh[index]='show_fib_trace -P 0x3'

((index++))
cef_exec[index]=''
cef__ksh[index]=''

display_hw_ack_cef() {
    exec_commands cef
}


#
# tech of CEF PD, on RP/LC cards
#
enable_techs "" /pkg/bin/show_tech_cef_pd

if [ -f /pkg/bin/show_tech_ofa ]; then
    enable_techs "" /pkg/bin/show_tech_ofa
fi

##################################################################
# This is called from the show tech infra for each card requested
##################################################################

display() {
    #
    # Display a header
    #
    print_main_heading "show tech-support hw-ack start"

    if [ "$__cardtype" == "SYS" ]; then
        exec_commands sys
    else
        case "$__cardtype" in
            "RP"|"DRP")
                if [ -f /pkg/bin/show_tech_hw_ack_sl ]; then
                    display_hw_ack_sl
                fi
                display_hw_ack_cef
                ;;
            "LC")
                display_hw_ack_cef
                ;;
        esac
    fi

    #
    # Display a footer
    #
    print_main_heading "show tech-support hw-ack complete"
}

#
# Use the standard show tech-support infra to call our display function and
# send the output to console or file
#
. /pkg/bin/show_tech_file_fragment

