#! /pkg/bin/ksh
# ---------------------------------------------------------------------
# l2vpn_show_tech_bgp - BGP l2vpn showtech script
#
# February 2017, Mark Sains
#
# Copyright (c) 2017, 2020 by cisco Systems, Inc.
# All rights reserved.
#----------------------------------------------------------------------

. /pkg/bin/show_tech_main_fragment

# Password flag to indicate whether log will include pw or not


# Parse the arguments to the script.
default_parser_function "$@"


# List each set of show commands to be run. Each set must finish with an empty
# string. Note that it is important to use single quotes rather than double
# quotes for the strings containing your commands; showtech infra expects the command
# exactly the way it was entered.
# Use "\" ahead of any special character (eg. |) used in the command line.
# Do "trace" cmds first, so events won't be lost while collecting other info

# -C 0x11 defined in ipv4/bgp/common/include/bgp_trace2_cat.h
# #define BGP_TR_CAT_L2VPN 17

sys_exec[1]='show bgp trace l2vpn location $location'
sys__ksh[1]='bgp_show_ltrace -i $fq_nodeid -C 0x11 -I default'
sys_exec[2]='show bgp l2vpn vpws'
sys__ksh[2]='bgp_show -V default -A 0x19 -W 0x44 -t'
sys_exec[3]='show bgp l2vpn vpws summary'
sys__ksh[3]='bgp_show -V default -A 0x19 -W 0x44 -n -s'
sys_exec[4]='show bgp l2vpn vpls'
sys__ksh[4]='bgp_show -V default -A 0x19 -W 0x41 -t'
sys_exec[5]='show bgp l2vpn vpls summary'
sys__ksh[5]='bgp_show -V default -A 0x19 -W 0x41 -n -s'
sys_exec[6]='show bgp l2vpn vpws standby'
sys__ksh[6]='bgp_show -V default -A 0x19 -W 0x44 -t -1'
sys_exec[7]='show bgp l2vpn vpws summary standby'
sys__ksh[7]='bgp_show -V default -A 0x19 -W 0x44 -n -s -1'
sys_exec[8]='show bgp l2vpn vpls standby'
sys__ksh[8]='bgp_show -V default -A 0x19 -W 0x41 -t -1'
sys_exec[9]='show bgp l2vpn vpls summary standby'
sys__ksh[9]='bgp_show -V default -A 0x19 -W 0x41 -n -s -1'
sys_exec[10]=''
sys__ksh[10]=''

rp_exec[1]='show bgp l2vpn evpn convergence'
rp__ksh[1]='bgp_show -V default -A 0x19 -W 0x46 -o -instance default'
rp_exec[2]='show bgp l2vpn evpn neighbors'
rp__ksh[2]='bgp_show -V default -A 0x19 -W 0x46 -n -instance default'
rp_exec[3]='show bgp l2vpn evpn advertised'
rp__ksh[3]='bgp_show -V default -A 0x19 -W 0x46 -g -instance default'
rp_exec[4]='show bgp l2vpn evpn'
rp__ksh[4]='bgp_show -V default -A 0x19 -W 0x46 -t -instance default'
rp_exec[5]='show bgp rt l2vpn evpn'
rp__ksh[5]='bgp_show -instance default -rt afi -value -tbl 0x19 0x46'
rp_exec[6]='show bgp vrf-db table all'
rp__ksh[6]='bgp_show -instance default -vrfdb -tbls'
rp_exec[7]='show proc bgp txgroup peer all detail'
rp__ksh[7]='txlib_show -E bgp -P -d -a'
rp_exec[8]=''
rp__ksh[8]=''

# A function called display() must be provided that calls the functions to
# run the required show commands. The display() function is called in
# /pkg/bin/show_tech_comp_file_frag
display() {
    case "$__cardtype" in
    "SYS")
        # system.tech
        exec_commands sys
        ;;

    "RP")
        exec_commands rp
        ;;

    esac
}

# 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
