#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# show_tech_ip_rib - IP RIB show tech-support script
#
# Copyright (c) 2004-2023 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


# Initialise any variables used. 
afi_in="afi_all"
afi="ipv4"
private="0x0"
vrf_all="0x0"
vrf_in=""
vrf_one="0x0"
__cardtype="Unspecified"
VERBOSE_LEVEL_MIN="0x1"
VERBOSE_LEVEL_MAX="0x3"
detail_level=$VERBOSE_LEVEL_MIN
detail_level_str=""
# Parse the arguments to the script.
# Usage: 
# 
# -A [ipv4|ipv6]         : AFI to run commands for
# -L [0x1]               : Detail level
#        0x1=default
#        0x2=vrf all
#        0x3=vrf-all + private
#        0x4=specific vrf
# -f <filename>          : save the output to filename
# 

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

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

# Set detail_level_str
case "$detail_level" in
    0x1) detail_level_str="Brief \(default\)";;
    0x2) detail_level_str="Detail with all VRF routes";vrf_all="0x1";;
    0x3) detail_level_str="Detail with all VRF routes and private";private="0x1";;
    0x4) detail_level_str="Detail with specific VRF routes";vrf_one="0x1";;
    *) echo "Invalid Debug level entered: $detail_level"; exit;;
esac

if [ $private == "0x1" ];then
    priv_arg="-*"
    priv_str="private"
    vrf_all="0x1"
else 
    priv_str=""
    priv_arg=""
fi

if [[ $vrf_all == "0x1" || $vrf_one == "0x1" ]]; then
    # Fetch the list of vrfs through show run vrf
    vrf_list=`nvgen -c -q gl/rsi/ | grep -E vrf | cut -c 5-`
fi



#Platform specific commands
# find a media to store showtech output
uname -a | grep hfr > /dev/null 2>&1;  RC=$?
uname -a | grep prp > /dev/null 2>&1;  RC1=$?
uname -a | grep enxr > /dev/null 2>&1; RC2=$?
uname -a | grep asr9k > /dev/null 2>&1; RC3=$?  
uname -a | grep xrvr > /dev/null 2>&1; RC4=$?

if [[ "$RC" -eq "0" ]]; then
    platform="hfr"
elif [[ "$RC1" -eq "0" ]]; then
    platform="prp"
elif [[ "$RC2" -eq "0" ]]; then
    platform="enxr"
elif [[ "$RC3" -eq "0" ]]; then 
    platform="viking"
elif [[ "$RC4" -eq "0" ]]; then 
    platform="xrvr"
else
    platform="panini"
fi 

# Commands that run on once per system
i=1
j=1
common_exec[$((i++))]='show clock'
common__ksh[$((j++))]='iosclock -e 0x0'
common_exec[$((i++))]='show platform'
if [[ "$platform" = "viking" ]]; then 
     common__ksh[$((j++))]='show_platform_vkg -e'
elif [[ "$platform" = "panini" ]]; then
     common__ksh[$((j++))]='show_platform_sysdb -v'
elif [[ "$platform" = "hfr" ]]; then
     common__ksh[$((j++))]='shelfmgr_show_hfr -e'
else 
     common__ksh[$((j++))]='show_platform -a'
fi
common_exec[$((i++))]='show version'
if [[ "$platform" = "panini" ]]; then 
     common__ksh[$((j++))]='ng_show_version'
else
     common__ksh[$((j++))]='show_version'
fi
if [[ "$platform" = "panini" ]]; then 
     common_exec[$((i++))]='show install active'
     common__ksh[$((j++))]='sdr_instcmd show install active'
else
     common_exec[$((i++))]='show install active summary'
     common__ksh[$((j++))]='instcmd show install active summary'
fi
common_exec[$((i++))]='show redundancy'
common__ksh[$((j++))]='redcon_show'

common_exec[$((i++))]='show svd role'
common__ksh[$((j++))]='show_rsi_agent -c 0x48'

common_exec[$((i++))]='show proc blocked'
if [[ "$platform" = "panini" ]]; then
    common__ksh[$((j++))]='sh_proc_ng_blocked'
else
    common__ksh[$((j++))]='show_processes -b'
fi 

if [[ "$platform" -ne "panini" && "$platform" -ne "fretta" ]]; then
common_exec[$((i++))]='show install which component ip-rib'
common__ksh[$((j++))]='instcmd show install which component ip-rib detail'
fi

common_exec[$((i++))]='show running-config router rib'
common__ksh[$((j++))]='nvgen -c -q gl/rib/'

common_exec[$((i++))]='show run router static'
common__ksh[$((j++))]='nvgen -c -q gl/static/router/'

common_exec[$((i++))]='show placement program bgp'                                                          
common__ksh[$((j++))]='placed_show -p bgp'

common_exec[$((i++))]=''
common__ksh[$((j++))]=''   


nodename=$showtech_node_name
nodelocation=`node_conversion -E $nodename`

#     echo "card" $__cardtype
#     echo "node" $nodelocation

# SysDB NULL path specifier
sysdb_null_path="________"
vrf_name="$sysdb_null_path"
table_filter="$sysdb_null_path"

# RIB AFI dependent commands
i=1
j=1

commonAFI_exec[$((i++))]='show processes $proc_str'
commonAFI__ksh[$((j++))]='sysmgr_show -o -p $proc_str'

commonAFI_exec[$((i++))]='show placement program $proc_str'
commonAFI__ksh[$((j++))]='placed_show -p $proc_str'

commonAFI_exec[$((i++))]='show rib $afi trace location mgmt-nodes'
commonAFI__ksh[$((j++))]='$afi_ltrace_func -i mgmt-nodes'

commonAFI_exec[$((i++))]='show route $afi $priv_str'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -s $priv_arg'

commonAFI_exec[$((i++))]='show route $afi multicast'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x2 -Z $vrf_name -V $table_filter -s'

commonAFI_exec[$((i++))]='show route $afi summary'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -S'

commonAFI_exec[$((i++))]='show route vrf all $afi summary'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z all -V $table_filter -S'

commonAFI_exec[$((i++))]='show route $afi multicast summary'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x2 -Z $vrf_name -V $table_filter -S'

commonAFI_exec[$((i++))]='show route vrf all $afi multicast summary'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x2 -Z all -V $table_filter -S'

commonAFI_exec[$((i++))]='show route $afi summary detail'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -D'

commonAFI_exec[$((i++))]='show route vrf all $afi summary detail'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z all -V $table_filter -D'

commonAFI_exec[$((i++))]='show route $afi multicast summary detail'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x2 -Z $vrf_name -V $table_filter -D'

commonAFI_exec[$((i++))]='show route vrf all $afi multicast summary detail'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x2 -Z all -V $table_filter -D'

commonAFI_exec[$((i++))]='show rib $afi protocols'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -z'

commonAFI_exec[$((i++))]='show rib vrf all $afi protocols'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z all -V $table_filter -z'

commonAFI_exec[$((i++))]='show rib $afi next-hop detail'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -o -*'

commonAFI_exec[$((i++))]='show rib $afi next-hop summary'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -o -8'

commonAFI_exec[$((i++))]='show rib $afi multicast next-hop'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x2 -Z $vrf_name -V $table_filter -o'

commonAFI_exec[$((i++))]='show rib $afi next-hop damp'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -o -j'

commonAFI_exec[$((i++))]='show rib $afi attributes summary'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -b'

commonAFI_exec[$((i++))]='show rib $afi extcomms summary'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -2'

commonAFI_exec[$((i++))]='show rib $afi nhid'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -{ base'

commonAFI_exec[$((i++))]='show rib $afi nhid history'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -{ history'

commonAFI_exec[$((i++))]='show rib $afi nhid feid'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -{ feid'

commonAFI_exec[$((i++))]='show route $afi backup $priv_str'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -e $priv_arg'

commonAFI_exec[$((i++))]='show route $afi multicast backup'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x2 -Z $vrf_name -V $table_filter -e'

commonAFI_exec[$((i++))]='show route $afi deleted'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -d'

commonAFI_exec[$((i++))]='show route $afi multicast deleted'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x2 -Z $vrf_name -V $table_filter -d'

commonAFI_exec[$((i++))]='show route $afi quarantined'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -Q'

commonAFI_exec[$((i++))]='show rib $afi clients'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -r'

commonAFI_exec[$((i++))]='show rib $afi clients protocols'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -u'

commonAFI_exec[$((i++))]='show rib $afi clients redistribution'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -v'

commonAFI_exec[$((i++))]='show rib $afi clients redistribution history all'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -G'

commonAFI_exec[$((i++))]='show rib $afi clients redistribution history opaque'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -K'

commonAFI_exec[$((i++))]='show rib $afi tables summary'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -0'

commonAFI_exec[$((i++))]='show rib $afi tables'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -4'

commonAFI_exec[$((i++))]='show rib $afi tables statistics'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -W'

commonAFI_exec[$((i++))]='show rib $afi opaque summary'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -E summary'

commonAFI_exec[$((i++))]='show rib $afi update-groups'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -k'

commonAFI_exec[$((i++))]='show rib $afi update-groups pruned-nodes'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -^'

commonAFI_exec[$((i++))]='show rib $afi statistics'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -a'

commonAFI_exec[$((i++))]='show rib $afi statistics all'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter -c all -a'

commonAFI_exec[$((i++))]='show rib $afi vpn-attributes'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -1 all'

commonAFI_exec[$((i++))]='show rib $afi vpn-attributes summary'
commonAFI__ksh[$((j++))]='$afi_func -X $afi_code -2'

commonAFI_exec[$((i++))]='show $afi int brief'
commonAFI__ksh[$((j++))]='$afi_func_interface -b -v default'

commonAFI_exec[$((i++))]='show bcdlv2 $bcdls_group_name'
commonAFI__ksh[$((j++))]='show_bcdlv2 -C 0x1 -B $bcdls_group_name'

commonAFI_exec[$((i++))]='show bcdlv2 $bcdls_group_name consumers'
commonAFI__ksh[$((j++))]='show_bcdlv2 -C 0x6 -B $bcdls_group_name'

commonAFI_exec[$((i++))]='show bcdlv2 $bcdls_group_name producer-view statistics'
commonAFI__ksh[$((j++))]='show_bcdlv2 -C 0x12 -B bcdls_$afi_rib'

commonAFI_exec[$((i++))]='show bcdlv2 $bcdls_group_name producer-view basic'
commonAFI__ksh[$((j++))]='show_bcdlv2 -C 0xa -B $bcdls_group_name'

commonAFI_exec[$((i++))]='show bcdlv2 $bcdls_group_name update-groups'
commonAFI__ksh[$((j++))]='show_bcdlv2 -C 0x5 -B $bcdls_group_name'


# SIDMGR commands
commonAFI_exec[$((i++))]='show running-config segment-routing srv6'
commonAFI__ksh[$((j++))]='nvgen -c -q gl/sr/ord_2/srv6/'

commonAFI_exec[$((i++))]='show segment-routing srv6 manager internal'
commonAFI__ksh[$((j++))]='sidmgr_show -T 0x4 -I'

commonAFI_exec[$((i++))]='show segment-routing srv6 locator internal'
commonAFI__ksh[$((j++))]='sidmgr_show -T 0x1 -I'

commonAFI_exec[$((i++))]='show segment-routing srv6 sid all internal'
commonAFI__ksh[$((j++))]='sidmgr_show -T 0x3 -I -a'

commonAFI_exec[$((i++))]='show segment-routing srv6 block internal'
commonAFI__ksh[$((j++))]='sidmgr_show -T 0x5 -I -a'

commonAFI_exec[$((i++))]='show segment-routing srv6 micro-segment local-sid internal'
commonAFI__ksh[$((j++))]='sidmgr_show -T 0x6 -I -a'

commonAFI_exec[$((i++))]='show segment-routing srv6 base local-sid internal'
commonAFI__ksh[$((j++))]='sidmgr_show -T 0x7 -I -a'

commonAFI_exec[$((i++))]='show segment-routing srv6 trace location mgmt-nodes'
commonAFI__ksh[$((j++))]='sidmgr_show_ltrace -i mgmt-nodes -T 0x7'

# IIDMGR commands
commonAFI_exec[$((i++))]='show rib ipv6 iid manager internal'
commonAFI__ksh[$((j++))]='iidmgr_show_client -T 0x3 -I'

commonAFI_exec[$((i++))]='show rib ipv6 iid all internal'
commonAFI__ksh[$((j++))]='iidmgr_show_client -T 0x2 -a -I '

commonAFI_exec[$((i++))]='show rib ipv6 iid trace all location all'
commonAFI__ksh[$((j++))]='iidmgr_show_ltrace -i all -P ipv6_rib -T all'

commonAFI_exec[$((i++))]='show route vrf **iid ipv6'
commonAFI__ksh[$((j++))]='show_ipv6_rib -X 0x2 -Y 0x1 -Z **iid -V $table_filter -s'


# RUMP commands
commonAFI_exec[$((i++))]='show rib $afi rump trace location mgmt-nodes'
commonAFI__ksh[$((j++))]='$afi_rump_ltrace_func -i mgmt-nodes'


# RIB commands for standby
i=1
j=1

commonSBY_exec[$((i++))]='show rib $afi clients $standby_in_exec'
commonSBY__ksh[$((j++))]='$afi_func -X $afi_code $standby_in_ksh -r'

commonSBY_exec[$((i++))]='show rib $afi tables summary $standby_in_exec'
commonSBY__ksh[$((j++))]='$afi_func -X $afi_code $standby_in_ksh -0'

commonSBY_exec[$((i++))]='show rib $afi tables $standby_in_exec'
commonSBY__ksh[$((j++))]='$afi_func -X $afi_code $standby_in_ksh -4'

commonSBY_exec[$((i++))]='show rib $afi tables statistics $standby_in_exec'
commonSBY__ksh[$((j++))]='$afi_func -X $afi_code $standby_in_ksh -W'

commonSBY_exec[$((i++))]='show rib $afi nhid history standby'
commonSBY__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_name -V $table_filter $standby_in_ksh -{ history'

commonSBY_exec[$((i++))]='show rib $afi vpn-attributes $standby_in_exec'
commonSBY__ksh[$((j++))]='$afi_func -X $afi_code -t -1 all'

commonSBY_exec[$((i++))]='show rib $afi vpn-attributes summary $standby_in_exec'
commonSBY__ksh[$((j++))]='$afi_func -X $afi_code -t -2'

commonSBY_exec[$((i++))]='show segment-routing srv6 manager internal $standby_in_exec'
commonSBY__ksh[$((j++))]='sidmgr_show -T 0x4 -I $standby_in_sid_ksh'

commonSBY_exec[$((i++))]='show segment-routing srv6 locator internal $standby_in_exec'
commonSBY__ksh[$((j++))]='sidmgr_show -T 0x1 -I $standby_in_sid_ksh'

commonSBY_exec[$((i++))]='show segment-routing srv6 sid all internal $standby_in_exec'
commonSBY__ksh[$((j++))]='sidmgr_show -T 0x3 -I $standby_in_sid_ksh -a'

commonSBY_exec[$((i++))]='show segment-routing srv6 block internal $standby_in_exec'
commonSBY__ksh[$((j++))]='sidmgr_show -T 0x5 -I $standby_in_sid_ksh -a'

commonSBY_exec[$((i++))]='show segment-routing srv6 micro-segment local-sid internal $standby_in_exec'
commonSBY__ksh[$((j++))]='sidmgr_show -T 0x6 -I $standby_in_sid_ksh -a'

commonSBY_exec[$((i++))]='show segment-routing srv6 base local-sid internal $standby_in_exec'
commonSBY__ksh[$((j++))]='sidmgr_show -T 0x7 -I $standby_in_sid_ksh -a'

# IIDMGR on standby
commonSBY_exec[$((i++))]='show rib ipv6 iid manager internal standby'
commonSBY__ksh[$((j++))]='iidmgr_show_client -T 0x3 -I -S'

commonSBY_exec[$((i++))]='show rib ipv6 iid all internal standby'
commonSBY__ksh[$((j++))]='iidmgr_show_client -T 0x2 -a -I -S'

commonSBY_exec[$((i++))]='show route vrf **iid ipv6 standby'
commonSBY__ksh[$((j++))]='show_ipv6_rib -X 0x2 -Y 0x1 -Z **iid -V $table_filter -s -t'


# RIB commands at detail level 0x1
i=1
j=1

level1_exec[$((i++))]='show rib $vrf $afi label-rpf summary'
level1__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_i_ksh -V $table_filter -}'

level1_exec[$((i++))]='show rib $vrf $afi next-hop summary'
level1__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_i_ksh -V $table_filter -o -8'

level1_exec[$((i++))]='show rib $vrf $afi opaques summary'
level1__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_i_ksh -V $table_filter -E summary'

level1_exec[$((i++))]='show rib $vrf $afi protocols'
level1__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_i_ksh -V $table_filter -z'

level1_exec[$((i++))]='show rib $vrf $afi statistics'
level1__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_i_ksh -V $table_filter -a'

level1_exec[$((i++))]='show rib $vrf $afi next-hop'
level1__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_i_ksh -V $table_filter -o'

level1_exec[$((i++))]='show rib $vrf $afi next-hop damped'
level1__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_i_ksh -V $table_filter -o -j'

level1_exec[$((i++))]='show rib $afi vpn-attributes private'
level1__ksh[$((j++))]='$afi_func -X $afi_code -['

level1_exec[$((i++))]='show route $vrf $afi $priv_str'
level1__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_i_ksh -V $table_filter -s $priv_arg'

level1_exec[$((i++))]='show route $vrf $afi deleted $priv_str'
level1__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_i_ksh -V $table_filter -d $priv_arg'

level1_exec[$((i++))]='show route $vrf $afi quarantined $priv_str'
level1__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x1 -Z $vrf_i_ksh -V $table_filter -Q $priv_arg'

level1_exec[$((i++))]='show route $vrf $afi multicast'
level1__ksh[$((j++))]='$afi_func -X $afi_code -Y 0x2 -Z $vrf_i_ksh -V $table_filter -s'

level1_exec[$((i++))]=''
level1__ksh[$((j++))]=''   

# Logs will be printed at the end of showtech
i=1
j=1
commonLOG_exec[$((i++))]='show logging'                     
commonLOG__ksh[$((j++))]='show_logging'

commonLOG_exec[$((i++))]=''
commonLOG__ksh[$((j++))]=''   

do_show_afi_command() {
    afi=$1
    afi_code=$2
    proc_str=$afi"_rib"
    afi_func="show_"$afi"_rib"
    bcdls_group_name="bcdls_"$afi"_rib"
    found_vrf="0x0"
    if [[ "$afi" == "ipv4" ]]; then 
        afi_func_interface="show_ip_interface"
    else
        afi_func_interface="show_ipv6_interface"
    fi
    afi_ltrace_func="show_"$afi"_rib_ltrace"
    afi_rump_ltrace_func="show_"$afi"_rump_ltrace"
    rib_running=$(sysmgr_show -o -p $afi"_rib" | grep -c -E "Process state: Run") 
    no_standby=$(placed_show -p $afi"_rib" | grep "CPU." | grep -c "NONE")
    print_main_heading "show tech-Support RIB $afi"

    exec_commands commonAFI

    if [[ $rib_running == 1 ]]; then
        if [[ $no_standby == 0 ]]; then
            standby_in_exec='standby'
            standby_in_ksh='-t'
            standby_in_sid_ksh='-S'
            exec_commands commonSBY
        fi
    fi

    if [[ $vrf_all == "0x1" ]]; then
        for vrf_i in $vrf_list;do
            vrf_i_ksh=$vrf_i
            vrf="vrf $vrf_i"
            exec_commands level1
        done
    fi

    if [[ $vrf_one == "0x1" ]]; then
        for vrf_i in $vrf_list;do
            if [[ $vrf_i == $vrf_in ]]; then
                found_vrf="0x1"
                vrf_i_ksh=$vrf_i
                vrf="vrf $vrf_i"
                exec_commands level1
                break
            fi
        done
        if [[ $found_vrf == "0x0" ]]; then
            echo "error: Provided invalid vrf name"
        fi
    fi

    print_main_heading "show tech-Support RIB $afi completed"
}


display() {

     # Print the output heading
     print_main_heading "show tech-Support IP RIB  \(Verbosity: $detail_level_str\)"

     if [[ "$__cardtype" == "SYS" ]]; then

         exec_commands common  

         if [[ "$afi_in" == "ipv4" || "$afi_in" == "afi_all" ]]; then
             do_show_afi_command "ipv4" "0x1"              
         fi
    
         if [[ "$afi_in" == "ipv6" || "$afi_in" == "afi_all" ]]; then
             do_show_afi_command "ipv6" "0x2"
         fi
         
         exec_commands commonLOG

     fi
     
     # Print the closing heading. 
     print_main_heading "show tech-Support IP RIB completed"
}


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

if [[ "$afi" = "ipv4" || "$afi" = "ipv6" ]]; then
    . /pkg/bin/show_tech_file_fragment
else
    echo "usage: show_tech_ip_rib -A [ipv4|ipv6] "
fi

