#! /pkg/bin/ksh
# ---------------------------------------------------------------------
# crypto_session_show_tech - show tech-support session, ca, engine and key options script
#
# November 2011, Virupaxappa G 
#
# Copyright (c) 2011-2012, 2014, 2017 by cisco Systems, Inc.
# All rights reserved.
#--------------------------------------------------------------------

. /pkg/bin/show_tech_main_fragment

__cardtype="unspecified"

# Parse the arguments to the script.

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

if [ "$__filename" = "unspecified" ]; then
    echo "show_tech_crypto: output file not specified"
    exit
fi

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

# ***********************************************************
#  Show commands to be run by the show tech-support commands
# ***********************************************************

# Commands that run on once per system


#crypto ca commands
sys_show_exec[1]='show crypto ca certificates detail'
sys_show__ksh[1]='pki_cmd show certificates detail'

sys_show_exec[2]='show crypto ca crls detail' 
sys_show__ksh[2]='pki_cmd show crls detail'

#crypto key commands
sys_show_exec[3]='show crypto key authentication rsa'
sys_show__ksh[3]='ce_cmd show key rsapubauth one'

sys_show_exec[4]='show crypto key mypubkey dsa'
sys_show__ksh[4]='ce_cmd show key mydsa nooption'

sys_show_exec[5]='show crypto key mypubkey rsa'
sys_show__ksh[5]='ce_cmd show key myrsa nooption'


#crypto engine commands
sys_show_exec[6]='show crypto engine statistics detail location 0/0/CPU0'
sys_show__ksh[6]='crypto_engine_cmd show statistics 0/0/CPU0 2081 0x2'

sys_show_exec[7]='show crypto engine statistics detail location 0/RSP0/CPU0'
sys_show__ksh[7]='crypto_engine_cmd show statistics 0/RSP0/CPU0 1 0x2'

#common commands

sys_show_exec[8]='show install active'
if [[ "$platform" != "viking" ]]; then
    sys_show__ksh[8]='sdr_instcmd show install active'
else
    sys_show__ksh[8]='instcmd show install active'
fi

if [[ "$platform" != "viking" ]]; then
    sys_show_exec[9]='show install repository'
    sys_show__ksh[9]='sdr_instcmd show install repository'
else
    sys_show_exec[9]='show install inactive'
    sys_show__ksh[9]='instcmd show install inactive'
fi

sys_show_exec[10]='show version'
if [[ "$platform" != "viking" ]]; then
    sys_show__ksh[10]='ng_show_version'
else
    sys_show__ksh[10]='show_version'
fi

sys_show_exec[11]='show platform'
if [[ "$platform" != "viking" ]]; then
    sys_show__ksh[11]='show_platform_sysdb'
else
    sys_show__ksh[11]='show_platform_vkg'
fi

sys_show_exec[12]='show interfaces brief'
sys_show__ksh[12]='show_interface -a -o 0x2'

sys_show_exec[13]='show logging '
sys_show__ksh[13]='show_logging'

sys_show_exec[14]='show running-config '
sys_show__ksh[14]='nvgen -c -l 1 -t 1 -o 1'

sys_show__ksh[15]=''
#############################################################
# Commands that run on all RPs
rp__ksh[1]=''

display() {

     print_main_heading "show tech-support crypto session,engine,ca and key options "
         
     if [ "$__cardtype" == "SYS" ]; then
         exec_commands sys_show
         exec_commands sys_trace
     else
         case "$__cardtype" in
         "RP")
             exec_commands rplc_show
             exec_commands rp
             ;;
         "DRP")
             exec_commands rplc_show
             exec_commands rp
             ;;
         esac
     fi

    print_main_heading "show tech-support crypto session,engine,ca and key options complete"
}

# Run the appropriate function depending on the node specified and if a
# file is specified write the output to that file. We need to redirect
# stderr to stdout when writing to a file because some of the show
# commands output to stderr instead of stdout
. /pkg/bin/show_tech_file_fragment
