#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# show_tech_cef
#
# September 2008, David Jung, Tomasz Kalkowski
#
# Copyright (c) 2008-2011, 2013, 2017-2018 by cisco Systems, Inc.
# All rights reserved.
#--------------------------------------------------------------------
. /pkg/bin/show_tech_main_fragment
. /pkg/bin/show_tech_cef_helper

# ************************************************************
#  Variables for show tech-supoort cef
# ************************************************************

# Set the default values of the node for which show tech-support is to run
# and the file it is to write to. 
fib_tmpfile_dir="/dev/shmem"
protocol="ipv4"    
isVrf=0
vrf=""
default_node=$showtech_node_name
node_required=`node_conversion --2nodeid $default_node`
level=1
lword="brief"
compress=0
isPrefix=0
prefix=""
isMask=0
mask=""
net=""
route_recursion=0
cef_recursion=0
isIf=0
internal_if=""
external_if=""

# Read in the arguments to the script, setting node_required  
# according to these arguments.
# Note that it is important for security reasons that users can only enter 
# alphanumeric nodes and that anywhere calling this script must
# enforce this.  
while [ $# -gt 0 ]; do
  case "$1" in 
     -vrf) vrf="$2"; isVrf=1; shift 2;;
     -v4) protocol="ipv4"; shift 1;; 
     -v6) protocol="ipv6"; shift 1;; 
     -mpls) protocol="mpls"; shift 1;;
     -i) internal_if="$2"; isIf=1; shift 2;;
     -n) node_required="$2"; shift 2;;
     -bf) level=1; lword="brief"; shift 1;;
     -d) level=2; lword="detail"; shift 1;;
     -P) prefix="$2"; isPrefix=1; shift 2;;
     -M) mask_string="$2"; mask=$((16#${mask_string#0x})); typeset -i10 mask; isMask=1; shift 2;;
     -T) net="$2"; shift 2;;
     *) default_parser_function "$@"; shift $#;;
  esac
done

# **********************************************************************
# List of show commands for show tech-support cef
# **********************************************************************
GEN_CMDS=1
GEN_LOC_CMDS=2
V4_V6_VRF_IND_CMDS=3
V4_V6_VRF_DEP_CMDS=4
SHMEM_CMDS=5
MPLS_CMDS=6
DET_GEN_CMDS=9
DET_GEN_LOC_CMDS=10
DET_V6_LOC_CMDS=11
DET_V6_CMDS=12
DET_MPLS_CMDS=14
DET_V4_LOC_CMDS=15
DET_V4_CMDS=16
CEF_MSC_CMDS=18
CEF_EXC_CMDS=19
CEF_DROP_CMDS=20
TITLE_HEADER=0
TITLE_FOOTER=1
IS_VRF=1
NOT_VRF=0
CEF_COFO=0

#
# Protocol and VRF Independent Level 1 (brief) Commands
#
command1[0]='show version'
command1[1]='show install active'
command1[2]='show log proc fib_mgr'
cidx=3

if [ "$CEF_COFO" == "1" ]; then
    command1[cidx]='show rib opaque cofo-intf'; cidx=$((cidx+1))
    command1[cidx]='show rib opaque cofo-slabel'; cidx=$((cidx+1))
fi
command1[cidx]=''
#
# Protocol and VRF Independent, Location specific Level 1 (brief) Commands
#
command2[0]='show proc blocked location $location'
command2[1]='show cef resource detail location $location'
command2[2]='show mem summary location $location'
command2[3]='show cef external location $location'
cidx=4
#COFO related
if [ "$CEF_COFO" == "1" ]; then
    command2[cidx]='show cef global cofo tables summary location $location'; cidx=$((cidx+1))
    command2[cidx]='show cef global cofo tables location $location'; cidx=$((cidx+1))
    command2[cidx]='show cef global cofo interface location $location'; cidx=$((cidx+1))
fi
if [ "$isVrf" != "0" ]; then
    command2[cidx]='show rsi vrf $vrf location $location'; cidx=$((cidx+1))
fi
command2[cidx]=''
command5[0]='show memory'
command5[1]=''
command18[0]='show rib table summary'
command18[1]='show cef proc-fsm location $location'
command18[2]='show cef message-queue location $location'
command18[3]='show cef misc location $location'
command18[4]='show cef imdr location $location'
command18[5]=''
command19[0]='show cef exceptions location $location'
command19[1]=''
command20[0]='show cef drops location $location'
command20[1]=''
#
# IPv4/IPv6 Level 1 (brief) VRF Independent commands
#
command3[0]='show rib $protocol clients'
command3[1]='show cef $protocol trace location $location'
command3[2]='run cat /net/$default_node/$fib_tmpfile_dir/fib_idb_recycle_$protocol.log'
if [ $isIf = 1 ]; then
    external_if=`convert_interface_fmt '-e' $internal_if`
    command3[3]='show cef $protocol interface $external_if location $location'
    command3[4]='show cef $protocol adjacency $external_if location $location'
    command3[5]='show cef $protocol adjacency $external_if remote detail location $location'
    command3[6]=''    
else
    command3[3]=''
fi
#
# IPv4/IPv6 (brief) VRF specific commands
#
if [ $isVrf = 0 ]; then
  command4[0]='show cef $protocol summary location $location'
  command4[1]='show cef $protocol unresolved location $location'
  command4[2]='show cef $protocol bgp-attribute summary $location'
  command4[3]='show cef $protocol generic-interface-list location $location'
  command4[4]='show route $protocol summary'
  command4[5]='show cef $protocol tables location $location'
  command4[6]='show cef $protocol tables summary location $location'
  command4[7]=''
else
  command4[0]='show cef vrf $vrf $protocol summary location $location'
  command4[1]='show cef vrf $vrf $protocol unresolved location $location'
  command4[2]='show cef vrf $vrf $protocol bgp-attribute summary $location'
  command4[3]='show route vrf $vrf $protocol summary'
  if [ $protocol = "ipv6" ]; then
    command4[4]='show rib vrf $vrf $protocol opaques tunnel-nexthop'
    command4[5]='show rib vrf $vrf $protocol opaques ipfrr'
    command4[6]=''
  else
    command4[4]=''
  fi
fi
#
# MPLS Level 1 (brief) VRF independent commands
#
command6[0]='show cef mpls interface location $location'
command6[1]='show cef mpls adjacency location $location'
command6[2]='show mpls forwarding labels 10 1048575 both-eos no-counters private location $location'
command6[3]='show mpls lsd forwarding'
command6[4]='show bcdl consumer mpls_lsd_v4'
command6[5]='show bcdl consumer mpls_lsd_v6'
command6[6]=''
#
# Protocol and VRF Independent Level 2 (detail) commands
# 
command9[0]='show bcdl table'
command9[1]=''  

#
# Protocol and VRF Independent Level 2 (detail) commands
# location dependent
command10[0]='show bcdlv2 consumers'
cidx=1
if [ "$CEF_COFO" == "1" ]; then
    command10[cidx]='show cef global cofo tables detail location $location'; cidx=$((cidx+1))
    command10[cidx]='show cef global cofo interface detail location $location'; cidx=$((cidx+1))
fi
command10[cidx]=''
#
# IPv6 Level 2 (detail) VRF Independent commands
#
command11[0]='show ipv6 neighbors location $location' 
command11[1]='show adjacency ipv6 detail location $location' 
command11[2]='show adjacency ipv6 remote detail location $location' 
command11[3]='show ipv6 trace ma location $location'
command11[4]=''
command12[0]='show bcdl consumers ipv6_rib'
if [ $isVrf = 1 ]; then
  command12[1]='show rib vrf $vrf ipv6 opaques ip-nexthop'
  command12[2]=''
else
  command12[1]=''
fi
#
# MPLS Level 2 (detail) commands
#
command14[0]='show cef mpls trace location $location'
command14[1]=''
#
# IPv4 Level 2 (detail) VRF Independent Commands
#
command15[0]='show arp location $location'
command15[1]='show arp traffic location $location'
command15[2]='show ipv4 trace location $location'
command15[3]='show rib ipv4 opaques ipfrr'
command15[4]=''
command16[0]='show bcdl consumers ipv4_rib'
if [ $isVrf = 1 ]; then 
  command16[1]='show rib vrf $vrf ipv4 opaques tunnel-nexthop'
  command16[2]=''
else
  command16[1]=''
fi

# **********************************************************************
# Functions
# **********************************************************************

# The funtion do_show_route_command() takes 2 arguments. 
# It outputs show route command and if find to be a recursive route,
# it recursively outputs the show route command.

do_show_route_command() {
    typeset route_next
    # SET ARGUMENT VARIABLES
    route_ip_version=$1
    route_prefix=$2
    route_isvrf=$3
    route_vrf=$4
    route_result_loop_count=0
    route_vrf_loop_count=0
    route_next=""
    nexthop_afi=""

    # SET COMMAND STRING ACCORDING TO PREFIX AND MASK OPTIONS PROVIDED
    if [ $route_isvrf = "0" ]; then
        if [ $isPrefix = 0 ]; then
            route_command="show route $route_ip_version summary detail"
        else
            if [ $route_recursion = 0 ] && [ $isMask = 1 ]; then
                route_command="show route $route_ip_version unicast $route_prefix/$mask detail"
            else
                route_command="show route $route_ip_version unicast $route_prefix detail"
            fi
        fi
    else
        if [ $isPrefix = 0 ]; then
            route_command="show route vrf $route_vrf $route_ip_version summary detail"
        else
            if [ $route_recursion = 0 ] && [ $isMask = 1 ]; then
                route_command="show route vrf $route_vrf $route_ip_version unicast $route_prefix/$mask detail"
            else
                route_command="show route vrf $route_vrf $route_ip_version unicast $route_prefix detail"
            fi
        fi
    fi

    # Get show route output and if it is a recursive route, run it recursively
    run_single_command "$route_command"
    if [ $isPrefix = 1 ]; then
        if [ $route_isvrf = "0" ]; then
            run_single_command_no_heading "$route_command" | grep "RIB_PRIORITY_RECURSIVE" | while read LINE; do
                nexthop_string=`run_single_command_no_heading "$route_command" | grep "Nexthop"`
                nexthop_afi=`echo $nexthop_string | cut -f 7 -d' '`
                if [ $route_ip_version = "ipv4" ]; then
                    run_single_command_no_heading "$route_command" | grep '    [0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' |  while read route_result_prefix; do
                        route_result_prefix1=`echo $route_result_prefix | cut -f 1 -d','`
                        route_recursion=$route_recursion+1
                        do_show_route_command $route_ip_version $route_result_prefix1 $NOT_VRF 
                    done
                else
                     # For Normal/recursive, non vrf IPv6 routes
                     if [[ "$nexthop_afi" != "IPv4" ]]; then       
                         run_single_command_no_heading "$route_command" | grep '    [0-f]\{1,4\}:*:[0-f]\{1,4\}' |  while read route_result_prefix; do
                             route_result_prefix1=`echo $route_result_prefix | cut -f 1 -d','`
                             route_recursion=$route_recursion+1
                             do_show_route_command $route_ip_version $route_result_prefix1 $NOT_VRF
                         done
              	    fi
                     # For IPv6 routes going over IPv4 routes
                     route_result_prefix1=""
                     run_single_command_no_heading "$route_command"  | grep '    ::ffff:' | while read route_result_prefix1; do
                         route_result_prefix=`perl -e '$a=shift; $a =~ m/::ffff:(.*?), from ::ffff:/; print $1;' "$route_result_prefix1"`
                         oldMask=isMask
                         isMask=0
                         do_show_route_command "ipv4" $route_result_prefix $NOT_VRF
                         isMask=oldMask
                     done                         
                fi
            done
        else
            # If it is VRF output, look for which vrf next hop is in, assuming nexthop vrf is in same vrf for all equal paths
            run_single_command_no_heading "$route_command" | grep "RIB_PRIORITY_RECURSIVE" | while read LINE; do
                nexthop_string=`run_single_command_no_heading "$route_command" | grep "Nexthop"`
                nexthop=`echo $nexthop_string | cut -f 1 -d' '`
                nexthop_afi=`echo $nexthop_string | cut -f 7 -d' '`
                if [ $route_ip_version = "ipv4" ]; then
                    run_single_command_no_heading "$route_command" | grep -E "    [0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}" | while read route_result_prefix; do
                        route_result_prefix1=`echo $route_result_prefix | cut -f 1 -d','`
                        route_recursion=$route_recursion+1
                        if [ "$nexthop" = "Nexthop"  ]; then
                            route_vrf_new=`echo $nexthop_string | cut -f 2 -d'"'`
                            if [ $route_vrf_new = "default" ]; then
                                do_show_route_command $route_ip_version $route_result_prefix1 $NOT_VRF
                            else
                                do_show_route_command $route_ip_version $route_result_prefix1 $IS_VRF $route_vrf_new
                            fi
                        else
                            do_show_route_command $route_ip_version $route_result_prefix1 $IS_VRF $route_vrf
                        fi
                    done
                else

		#
		# This is for ipv6 normal/recursive route
		#
		    if [[ "$nexthop_afi" != "IPv4" ]]; then
			run_single_command_no_heading "$route_command" | grep "    [0-f]\{1,4\}:*:[0-f]\{1,4\}" |  while read route_result_prefix; do
			    route_result_prefix1=`echo $route_result_prefix | cut -f 1 -d','`
			    route_recursion=$route_recursion+1
			    if [ "$nexthop" = "Nexthop"  ]; then
				route_vrf_new=`echo $nexthop_string | cut -f 2 -d'"'`
				if [ $route_vrf_new = "default" ]; then
				    do_show_route_command $route_ip_version $route_result_prefix1 $NOT_VRF
				else
				    do_show_route_command $route_ip_version $route_result_prefix1 $IS_VRF $route_vrf_new
				fi
			    else
				do_show_route_command $route_ip_version $route_result_prefix1 $IS_VRF $route_vrf
			    fi
			done
		    fi

		    #
		    # This if for ipv6 routes going over ipv4 routes
		    #
		    route_result_prefix1=""
		    run_single_command_no_heading "$route_command" | grep '    ::ffff:' | while read route_result_prefix1; do
			route_result_prefix=`perl -e '$a=shift; $a =~ m/::ffff:(.*?), from ::ffff:/; print $1;' "$route_result_prefix1"`
		        oldMask=isMask
			isMask=0
			do_show_route_command "ipv4" $route_result_prefix $NOT_VRF
			isMask=oldMask
		    done
		fi
            done
	    
        fi
    fi
}

# The funtion do_show_cef_command() takes ip version and prefix as arguments. 
# It outputs show cef command and if it is found to be a recursive route,
# it recursively outputs the show cef command.

do_show_cef_command() {
    # SET ARGUMENT VARIABLES
    cef_ip_version=$1
    cef_prefix=$2
    cef_isvrf=$3
    cef_vrf=$4
    cef_line=0
    last_cef_prefix=$cef_prefix

    if [ "$node_required" = "all" ]; then
        loc_string=""
    else
        loc_string="location $location"
    fi
    
    
    # SET COMMAND STRING ACCORDING TO PREFIX AND MASK OPTIONS PROVIDED
    if [ $cef_isvrf = "0" ]; then
        if [ $isPrefix = 0 ]; then
            cef_command="show cef $cef_ip_version summary $loc_string"
        else
            if [ $cef_recursion = 0 ] && [ $isMask = 1 ]; then
                cef_string="show cef $cef_ip_version $cef_prefix/$mask"
            else
                cef_string="show cef $cef_ip_version $cef_prefix"
            fi
        fi
    else
        if [ $isPrefix = 0 ]; then
            cef_command="show cef vrf $cef_vrf $cef_ip_version summary $loc_string"
        else
            if [ $cef_recursion = 0 ] && [ $isMask = 1 ]; then
                cef_string="show cef vrf $cef_vrf $cef_ip_version $cef_prefix/$mask"
            else
                cef_string="show cef vrf $cef_vrf $cef_ip_version $cef_prefix"
            fi
        fi
    fi
    
    # Get show cef output and if it is a recursive route, run it recursively
    if [ $isPrefix = 1 ]; then
        cef_command="$cef_string detail $loc_string"
    else
        cef_command="$cef_string $loc_string"
    fi
    run_single_command "$cef_command"
    if [ $level = 2 ]; then
        run_single_command "$cef_string hardware egress detail $loc_string"
        run_single_command "$cef_string hardware ingress detail $loc_string"
    fi
    if [ $cef_isvrf = "0" ]; then
        if [ $cef_ip_version = "ipv4" ]; then
            run_single_command_no_heading "$cef_command" | grep '   via [0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' |  while read via cef_result_prefix var3 var4 var5 var6; do
                if [ "$var5" = "recursive" ]; then
                    cef_result_prefix1=`echo $cef_result_prefix | cut -f 1 -d','`
                    cef_recursion=$cef_recursion+1
                    do_show_cef_command $cef_ip_version $cef_result_prefix1 $NOT_VRF
                fi
            done
        else
            run_single_command_no_heading "$cef_command" | grep '   via [0-f]\{1,4\}:*:[0-f]\{1,4\}' |  while read via cef_result_prefix var3 var4 var5 var6; do
               run_single_command_no_heading "$cef_command" | grep '   via [0-f]\{1,4\}:*:[0-f]\{1,4\}' |  while read via cef_result_prefix var3 var4 var5 var6; do
                  if [ "$var5" = "recursive" ]; then            
                      cef_recursion=$cef_recursion+1
                      nexthop_string=`run_single_command_no_heading "$cef_command" | grep " - '"`
                      cef_vrf_new=`echo $nexthop_string | cut -f 2 -d"'"`
                      # Temporary just for CSCsz70848
                      if [[ $cef_vrf_new = "Unknown" ]]; then
                          cef_vrf_new="default"
                      fi     
                      if [[ $cef_vrf_new = "default" ]]; then
                          run_single_command_no_heading "$cef_command" | grep '    next hop ::ffff:' | while read cef_result_prefix1; do 
                              cef_result_prefix=`perl -e '$a=shift; $a =~ m/::ffff:(.*?)[ ]+/; print $1;' "$cef_result_prefix1"`
                              oldMask=isMask
    		              isMask=0
                              do_show_cef_command "ipv4" $cef_result_prefix $NOT_VRF
                              isMask=oldMask
                          done
                      else
  		           do_show_cef_command $cef_ip_version $cef_result_prefix $IS_VRF 
                      fi
                  fi
              done
           fi           
     else
         # If it is VRF output, look for which vrf next hop is in, assuming nexthop vrf is in same vrf for all equal paths
         nexthop_string=`run_single_command_no_heading "$cef_command" | grep " - '"`
         nexthop=`echo $nexthop_string | cut -f 5 -d' '`
         nexthop=`echo $nexthop_string | cut -f 1 -d' '`
         if [ $cef_ip_version == "ipv4" ]; then
             run_single_command_no_heading "$cef_command" | grep '   via [0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' |  while read via cef_result_prefix var3 var4 var5 var6; do
                 if [ "$var5" = "recursive" ]; then
                     cef_result_prefix1=`echo $cef_result_prefix | cut -f 1 -d','`
                     cef_recursion=$cef_recursion+1
                     if [ "$nexthop" = "next" ]; then
                         cef_vrf_new=`echo $nexthop_string | cut -f 2 -d"'"`
                         if [ $cef_vrf_new = "default" ]; then 
                             do_show_cef_command $cef_ip_version $cef_result_prefix1 $NOT_VRF
                          else
                              do_show_cef_command $cef_ip_version $cef_result_prefix1 $IS_VRF $cef_vrf_new
                          fi
                     else
                         if [[ "$last_cef_prefix" != "$cef_result_prefix1" ]]; then
	                      do_show_cef_command $cef_ip_version $cef_result_prefix1 IS_VRF $cef_vrf
 	                 fi
	             fi
 	         fi            
             done
         else
             run_single_command_no_heading "$cef_command" | grep '   via [0-f]\{1,4\}:*:[0-f]\{1,4\}' |  while read via cef_result_prefix var3 var4 var5 var6; do
	         cef_result_prefix1=`echo $cef_result_prefix | cut -f 1 -d','`
  		 cef_recursion=$cef_recursion+1
	   	 if [ "$nexthop" = "next" ]; then
                     cef_vrf_new=`echo $nexthop_string | cut -f 2 -d"'"`
                     # Temporary just for CSCsz70848
                     if [[ $cef_vrf_new = "Unknown" ]]; then
                         cef_vrf_new="default"
                     fi     
                     if [ $cef_vrf_new = "default" ]; then
                         run_single_command_no_heading "$cef_command" | grep '    next hop ::ffff:' | while read cef_result_prefix1; do 
                             cef_result_prefix=`perl -e '$a=shift; $a =~ m/::ffff:(.*?)[ ]+/; print $1;' "$cef_result_prefix1"`
                             do_show_cef_command "ipv4" $cef_result_prefix $NOT_VRF
                         done
                     else
		   	 do_show_cef_command $cef_ip_version $cef_result_prefix1 $IS_VRF $cef_vrf_new
                     fi
  		 else
                    if [[ "$last_cef_prefix" != "$cef_result_prefix1" ]]; then 
                         do_show_cef_command $cef_ip_version $cef_result_prefix1 IS_VRF $cef_vrf
                    fi
	   	 fi
            done
   	       cef_result_prefix1=""
                 run_single_command_no_heading "$cef_command" | grep '    next hop ::ffff:' | while read cef_result_prefix1; do 
  		   cef_result_prefix=`perl -e '$a=shift; $a =~ m/::ffff:(.*?)[ ]+/; print $1;' "$cef_result_prefix1"`
  		   oldMask=isMask
  		   isMask=0
  		   do_show_cef_command "ipv4" $cef_result_prefix $NOT_VRF
  		   isMask=oldMask
                 done         
	 fi     
    fi
}

do_print_title() {
    # Get Arguments
    footer=$1
    complete=""
    nodeid=$node_required

    # Footer remark
    if [ $footer = "1" ]; then
        complete="Completed"
    fi
    
    if [ "$node_required" = "all" ]; then
        loc_string=""
    else
        # The return code (0 on success) from `node_conversion --2name $1` is
        # put into the variable name_valid.                                            
        name=`node_conversion --2name $nodeid`
        name_valid=$?
        # The return code (0 on success) from `node_conversion --2extname $nodeid`
        # is put into the variable ext_name_valid.
        ext_node_name=`node_conversion --2extname $nodeid`
        ext_name_valid=$?
        if [ "$name_valid" = "0" ]; then
        truncated_name=${name#*e}
        else
            echo "Unable to recognize nodename: show run will fail on this node"
        fi

        if [ "$ext_name_valid" = "0" ]; then
            loc_string="location $ext_node_name"
        elif [ "$name_valid" = "0" ]; then
            loc_string="location $name"
        else
            loc_string="location nodeid $nodeid"
        fi
    fi
    if [ $isMask = 1 ]; then
        print_mask="/$mask"
    else
        print_mask="" 
    fi
    if [ $isVrf = 0 ]; then
        print_main_heading "show tech-support cef $protocol $prefix$print_mask ${external_if} ${lword} $loc_string $complete"
    else
        print_main_heading "show tech-support cef vrf $vrf $protocol $prefix$print_mask ${external_if} ${lword} $loc_string $complete"
    fi
}

do_run_commands() {
    # SET ARGUMENT Variables 
    all_or_one=$1    # 0=all locations, 1=one location
    command_id=$2    # Command ID to execute

    # Execute commands depending on all or one location
    if [ $all_or_one = "0" ]; then
        run_commands_on_all_nodes $command_id
    else
        run_commands $command_id
    fi
}

# A function called display() must be provided that calls the functions to 
# run the required show commands. The display() function will be called in 
# the /pkg/bin/show_tech_comp_file_frag
display() {
    if [ "$node_required" = "all" ]; then
        nodes=0
    else
        nodes=1
        location=`node_conversion --2extname $node_required`
    fi
    # Print Title
    do_print_title $TITLE_HEADER

    ###################
    # Level 1 Commands
    ###################
    # Print Protocol, VRF, Prefix, and Location independant Level 1 commands
    run_commands $GEN_CMDS

    # Print Protocol, VRF and Prefix independant, Location Dependant Level 1 Commands
    do_run_commands $nodes $GEN_LOC_CMDS

    # Print Shared Window Memory output
    print_command_heading "show Shared Window memory $location"
    do_run_commands $nodes $SHMEM_CMDS | grep -E "Location:|Shared window"
    
    # We need multiple snapshots from some cmnds to see delta.
    do_run_commands $nodes $CEF_MSC_CMDS
    do_run_commands $nodes $CEF_EXC_CMDS
    do_run_commands $nodes $CEF_DROP_CMDS    
    print_command_heading "Sleeping for 10 seconds"
    sleep 10
    do_run_commands $nodes $CEF_MSC_CMDS
    do_run_commands $nodes $CEF_EXC_CMDS
    do_run_commands $nodes $CEF_DROP_CMDS    

    # Print Prefix Specific Commands
    if [ $isPrefix = 1 ] && [ $protocol != "mpls" ]; then
        if [ $isVrf = 1 ]; then
            do_show_route_command $protocol $prefix $IS_VRF $vrf
            do_show_cef_command $protocol $prefix $IS_VRF $vrf
        else
            do_show_route_command $protocol $prefix $NOT_VRF
            do_show_cef_command $protocol $prefix $NOT_VRF
        fi
    fi

    # Print Protocol Specific Level 1 Commands
    case "$protocol" in
        ipv4) do_run_commands $nodes $V4_V6_VRF_IND_CMDS; do_run_commands $nodes $V4_V6_VRF_DEP_CMDS;;
        ipv6) do_run_commands $nodes $V4_V6_VRF_IND_CMDS; do_run_commands $nodes $V4_V6_VRF_DEP_CMDS;;
        mpls) do_run_commands $nodes $MPLS_CMDS;;
        *) ;;
    esac

    # Print rib bcdl redistribution history
    if [ $isPrefix = 1 ] && [ $protocol != "mpls" ]; then
        run_single_command_no_heading "show rib $protocol clients" | grep 'bcdl' |  while read var1 var2 bcdl_client_id var4 var5; do
            run_single_command "show rib $protocol client-id $bcdl_client_id redistribution history" | grep -E "Table ID:|$prefix"
        done
    fi

    ###################
    # Level 2 Commands
    ###################
    if [ $level = 2 ]; then
        # Print Protocol, VRF, Prefix, and Location independant Level 2 commands
        run_commands $DET_GEN_CMDS

        # Print Protocol, VRF and Prefix independant, Location Dependant Level 2 Commands
        do_run_commands $nodes $DET_GEN_LOC_CMDS

        # Print Protocol Specific Level 2 Commands
        case "$protocol" in
            ipv4) do_run_commands $nodes $DET_V4_LOC_CMDS; run_commands $DET_V4_CMDS;;
            ipv6) do_run_commands $nodes $DET_V6_LOC_CMDS; run_commands $DET_V6_CMDS;;
            mpls) do_run_commands $nodes $DET_MPLS_CMDS;;
            *) ;;
        esac
    fi

    # Print Footer
    do_print_title $TITLE_FOOTER
}

# 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
