#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# show_tech_pbr_util - pbr specific show tech command
#
# Oct 2013, Shengjun Ma 
#
# Copyright (c) 2013-2016 by Cisco Systems, Inc.
# All rights reserved.
#--------------------------------------------------------------------

# Include the PD commands, if they exist.
if [ -f /pkg/bin/show_tech_pbr_pd_util ]; then
    . /pkg/bin/show_tech_pbr_pd_util
fi

display_pbr_ma_vrf_sys() {

    pbr_ma_vrf_sys_exec[1]='show pbr vrf process ma'
    pbr_ma_vrf_sys__ksh[1]='pbr_show_oper vrf -V NONE -I NONE -p ma -n NONE'

    pbr_ma_vrf_sys_exec[2]=''

    exec_commands pbr_ma_vrf_sys
}

display_pbr_ea_vrf_rplc() {

    pbr_ea_vrf_rplc_exec[1]='show pbr vrf process ea location'
    pbr_ea_vrf_rplc__ksh[1]='pbr_show_oper vrf -V NONE -I NONE -p ea'

    pbr_ea_vrf_rplc_exec[2]='show pbr vrf process ea verbose location'
    pbr_ea_vrf_rplc__ksh[2]='pbr_show_oper vrf -V NONE -I NONE -p ea -v'

    pbr_ea_vrf_rplc_exec[3]=''

    case "$__cardtype" in
    "RP")
        ;;
    "DRP")
        ;;
    "LC")
        # Currently, we only have PBR EA on the LC

        exec_commands pbr_ea_vrf_rplc

        if type display_pbr_ea_pd_vrf_lc | grep -i -q function; then
            display_pbr_ea_pd_vrf_lc
        fi

        ;;
    esac
}

display_pbr_ma_intf_rplc() {

    pbr_ma_intf_rplc_exec[1]='show pbr internal database interface process ma v'
    pbr_ma_intf_rplc__ksh[1]='pbr_show_oper database -d interface -p ma \
                              -n NONE -N NONE -V NONE -I NONE -t NONE'

    pbr_ma_intf_rplc__ksh[2]=''

    exec_commands pbr_ma_intf_rplc
}

display_pbr_ea_intf_rplc() {

    pbr_ea_intf_rplc_exec[1]='show pbr internal database interface process ea verbose location'
    pbr_ea_intf_rplc__ksh[1]='pbr_show_oper database -d interface -p ea \
                              -v -N NONE -V NONE -I NONE -t NONE'

    pbr_ea_intf_rplc__ksh[2]=''

    case "$__cardtype" in
    "RP")
        ;;
    "DRP")
        ;;
    "LC")
        # Currently, we only have PBR EA on the LC

        exec_commands pbr_ea_intf_rplc

        if type display_pbr_ea_pd_intf_lc | grep -i -q function; then
            display_pbr_ea_pd_intf_lc
        fi

        ;;
    esac
}

display_pbr_ea_redir_rplc() {
    pbr_ea_redir_rplc_exec[1]='show pbr redirect nexthop location '
    pbr_ea_redir_rplc__ksh[1]='pbr_show_oper redirect -p ea -v'

    pbr_ea_redir_rplc_exec[2]='show pbr redirect nexthop state location '
    pbr_ea_redir_rplc__ksh[2]='pbr_show_oper redirect -p ea -v'

    pbr_ea_redir_rplc__ksh[3]=''

    case "$__cardtype" in
    "RP")
        ;;
    "DRP")
        ;;
    "LC")
        # Currently, we only have PBR EA on the LC

        exec_commands pbr_ea_redir_rplc

        ;;
    esac
}

display_pbr_stats_rplc() {

    pbr_stats_rplc_exec[1]='show pbr internal statistics'
    pbr_stats_rplc__ksh[1]='pbr_show_oper internal -p ea'

    pbr_stats_rplc__ksh[2]=''

    case "$__cardtype" in
    "RP")
        ;;
    "DRP")
        ;;
    "LC")
        # Currently, we only have stats in PBR EA on the LC

        exec_commands pbr_stats_rplc

        if type display_pbr_pd_stats_lc | grep -i -q function; then
            display_pbr_pd_stats_lc
        fi

        ;;
    esac
}

#should be distributed to all RP
display_pbr_trace_rplc() {

    pbr_trace_rplc_exec[1]='show pbr trace all'
    pbr_trace_rplc__ksh[1]='pbr_show_ltrace -Uall'

    pbr_trace_rplc__ksh[2]=''

    exec_commands pbr_trace_rplc

    if type display_pbr_pd_trace_lc | grep -i -q function; then
        display_pbr_pd_trace_lc
    fi
}

display_vservice_mgr_nsh_rplc() {
    vservice_mgr_nsh_rplc_exec[1]='show pbr service-node table detail type sf location '$location
    vservice_mgr_nsh_rplc__ksh[1]='vservice_db_show -d -e 7'

    vservice_mgr_nsh_rplc_exec[2]='show pbr service-node table detail type sff location '$location
    vservice_mgr_nsh_rplc__ksh[2]='vservice_db_show -d -e 8'

    vservice_mgr_nsh_rplc_exec[3]='show pbr service-node table detail type sfm location '$location
    vservice_mgr_nsh_rplc__ksh[3]='vservice_db_show -d -e 9'

    vservice_mgr_nsh_rplc_exec[4]='show pbr service-node table detail type sfd location '$location
    vservice_mgr_nsh_rplc__ksh[4]='vservice_db_show -d -e 10'

    vservice_mgr_nsh_rplc_exec[5]='show pbr service-node table detail type sfp location '$location
    vservice_mgr_nsh_rplc__ksh[5]='vservice_db_show -d -e 11'

    vservice_mgr_nsh_rplc_exec[6]=''

    exec_commands vservice_mgr_nsh_rplc

}

#should be distributed to all RP
display_vservice_trace_rplc() {

    vservice_trace_rplc_exec[1]='show vservice trace manager '
    vservice_trace_rplc__ksh[1]='vservice_show_ltrace -M'
    vservice_trace_rplc_exec[2]='show vservice trace client location '$location
    vservice_trace_rplc__ksh[2]='vservice_show_ltrace -C'

    vservice_trace_rplc__ksh[3]=''

    exec_commands vservice_trace_rplc
        
}


