📄 api_test.c
字号:
showMplsLdpParam(&in, out);
showMplsLdpParamDisplay(sty, out);
RET_UB(out);
/* cmd: show mpls ldp entity stats */
out = (mpls_comm_oam_t *)GET_UB(MPLS_DATA_SIZE_MAX);
if(!out)
{
sdp_printf(sty, "Memory allocate failed!");
return SDP_CMD_SUCCESS;
}
memset(out, 0x0, sizeof(out));
showMplsLdpEntityStats(&in, out);
showMplsLdpEntityStatsDisplay(sty, out);
RET_UB(out);
/* cmd: Show mpls ldp session stats */
out = (mpls_comm_oam_t *)GET_UB(MPLS_DATA_SIZE_MAX);
if(!out)
{
sdp_printf(sty, "Memory allocate failed!");
return SDP_CMD_SUCCESS;
}
memset(out, 0x0, sizeof(out));
showMplsLdpSessionStats(&in, out);
showMplsLdpSessionStatsDisplay(sty, out);
RET_UB(out);
/* cmd: Show mpls ldp session stats */
out = (mpls_comm_oam_t *)GET_UB(MPLS_DATA_SIZE_MAX);
if(!out)
{
sdp_printf(sty, "Memory allocate failed!");
return SDP_CMD_SUCCESS;
}
memset(out, 0x0, sizeof(out));
showMplsLdpIntTransportAddr(&in, out);
showMplsLdpIntTransportAddrDisplay(sty, out);
RET_UB(out);
/* cmd: Show mpls ldp session stats */
out = (mpls_comm_oam_t *)GET_UB(MPLS_DATA_SIZE_MAX);
if(!out)
{
sdp_printf(sty, "Memory allocate failed!");
return SDP_CMD_SUCCESS;
}
memset(out, 0x0, sizeof(out));
showMplsLdpAtmLabelGet(&in, out);
showMplsLdpAtmLabelGetDisplay(sty, out);
RET_UB(out);
/* cmd: Show ip traffic-engineering configuration */
out = (mpls_comm_oam_t *)GET_UB(MPLS_DATA_SIZE_MAX);
if(!out)
{
sdp_printf(sty, "Memory allocate failed!");
return SDP_CMD_SUCCESS;
}
memset(out, 0x0, sizeof(out));
showIpTrafficEngConfFilterNo(&in, out);
showIpTrafficEngConfFilterNoDisplay(sty, out);
RET_UB(out);
/*************************************************************/
/* Below four APIs are tested in show command */
/* cmd: show mpls ldp bindings */
/* cmd: Show mpls atm_ldp capability */
/* cmd: show mpls forwarding-table */
/* cmd: show mpls tunnel */
/*************************************************************/
return SDP_CMD_SUCCESS;
}
/****************************************************************************
* FUNCTION NAME : show_mpls_ldp_forward_table
* DESCRIPTION : show mpls ldp forward table
* AUTHOR/DATE : Xu.XiaoGang/ 20021017
****************************************************************************/
#include "mlblop.h"
#include "mqosfil.h"
typedef struct {
mpls_comm_oam_t oam_t_value;
forwardingtable_t forwart_t_value[MPLS_TABLE_SHOW_ITEM_LEN];
}mpls_forward_table_show_struct;
#define SHOW_FORWARD_RESULT_FLAG 0xFFFFFFFF
extern mpls_forward_table_item *mpls_table_bi_link_head;
extern mpls_forward_table_item *mpls_table_bi_link_tail;
extern ulong mpls_table_item_num ;
extern mpls_filter_item *mpls_filter_bi_link_head;
extern mpls_filter_item *mpls_filter_bi_link_tail;
extern ulong mpls_filter_item_num;
/* printf in telnet */
void show_forward_table_sty(struct sty *sty,mpls_forward_table_show_struct forward_table_show, ULONG total_array_index){
ULONG array_index;
uchar *label_operate_string[2]={"GENERAL LABEL","ATM LABEL"};
for( array_index=0; array_index<total_array_index; array_index++ ){
//sdp_printf(sty, "dest_addr:%x",);
sdp_printf(sty, "local label type:%s\t",label_operate_string[forward_table_show.forwart_t_value[array_index].localLabel.type]);
switch(forward_table_show.forwart_t_value[array_index].localLabel.type){
case GEN_LABEL_TYPE:
sdp_printf(sty, "General value:%5d",forward_table_show.forwart_t_value[array_index].localLabel.label.label);
break;
case ATM_LABEL_TYPE:
sdp_printf(sty, "ATM VPI:%5d",forward_table_show.forwart_t_value[array_index].localLabel.label.atm.vpi);
sdp_printf(sty, "ATM VCI:%5d",forward_table_show.forwart_t_value[array_index].localLabel.label.atm.vci);
break;
default:
break;
}
sdp_printf(sty, "\n");
{
uchar tmp_num;
output_label_link *tmp_label_link;
for(tmp_num=0; (tmp_num<forward_table_show.forwart_t_value[array_index].remoteNum)&&(tmp_num<MPLS_LBL_BINDS_MAX); tmp_num ++){
sdp_printf(sty, "local label type:%s\t",label_operate_string[forward_table_show.forwart_t_value[array_index].remoteBinds[tmp_num].remoteBinds.type]);
/* copy output label value */
switch(forward_table_show.forwart_t_value[array_index].remoteBinds[tmp_num].remoteBinds.type){
case GEN_LABEL_TYPE:
sdp_printf(sty, "General value:%5d",forward_table_show.forwart_t_value[array_index].remoteBinds[tmp_num].remoteBinds.label.label);
break;
case ATM_LABEL_TYPE:
sdp_printf(sty, "ATM VPI:%5d",forward_table_show.forwart_t_value[array_index].remoteBinds[tmp_num].remoteBinds.label.atm.vpi);
sdp_printf(sty, "ATM VPI:%5d",forward_table_show.forwart_t_value[array_index].remoteBinds[tmp_num].remoteBinds.label.atm.vci);
break;
default:
break;
}
sdp_printf(sty, "nexthop:%10x",
forward_table_show.forwart_t_value[array_index].remoteBinds[tmp_num].nextHop);
sdp_printf(sty, "module:%5d,port:%5d",
forward_table_show.forwart_t_value[array_index].remoteBinds[tmp_num].outIf.module,
forward_table_show.forwart_t_value[array_index].remoteBinds[tmp_num].outIf.port);
tmp_label_link = tmp_label_link->next;
}/* end of for output label num */
}/* end of local broad */
array_index = array_index + 1;
}/* end of for */
return;
}
enum{SHOW_ZERO, SHOW_START, SHOW_ADDR};
/****************************************************************************
* FUNCTION NAME : sdp_show_mpls_fwd
* DESCRIPTION: :
* show mpls label and ingress label content
*
* INPUT : TYPE PARAMETERS DESCRIPTIONs
*
*
* OUTPUT : for telnet show command
* AUTHOR/DATE : Xu.XiaoGang/ 20021022
* GLOBAL : none
* NOTE :
* 2002.12.25 xuxiaogang 修改show mpls forwarding 的显示信息
****************************************************************************/
int16 sdp_show_mpls_fwd(struct sty *sty,SDP_PARAM_STRU *para_group,int16 is_no,int16 telnet_num)
{
ulong start_index, array_index, total_array_index, init_start_index;
ulong i;
ulong egress_num, ingress_num;
mpls_forward_table_item *tmp_forward_item;
mpls_filter_item *tmp_filter_item;
mpls_forward_table_show_struct forward_table_show;
UCHAR *label_operate_string[3]={"","GENERAL LABEL","ATM LABEL"};
ulong parameter1, parameter2; /* if p2 > 0 is mask, p1 is ip address */
/* if p2 == 0 , p1 is start index */
uchar show_type;
ulong from_start_index;
if( (para_group[0].param_flag == SDP_PARAM_NO_USE)
||(para_group[1].param_flag == SDP_PARAM_NO_USE) ){
show_type = SHOW_ZERO;
start_index = 0;
}
if(para_group[1].param_flag == SDP_PARAM_NO_USE){
parameter1 = para_group[0].param_un.param_int32;
show_type = SHOW_START;
start_index = parameter1;
parameter2 = 0;
}else{
parameter1 = para_group[0].param_un.param_int32;
parameter2 = para_group[1].param_un.param_int32;
show_type = SHOW_ADDR;
start_index = 0;
}
from_start_index = start_index;
memset((UCHAR *)&forward_table_show, 0, sizeof(mpls_forward_table_show_struct));
forward_table_show.oam_t_value.DataNum = 0;
//start_index = forward_table_show.oam_t_value.DataNum;
array_index = 0;
init_start_index = 0;
tmp_forward_item = mpls_table_bi_link_head->next;
tmp_filter_item = mpls_filter_bi_link_head->bi_link_next;
/* copy Egress and interior label foreard tabel */
for( i=0; (i<mpls_table_item_num)&&(array_index<MPLS_TABLE_SHOW_ITEM_LEN)&&(tmp_forward_item!=NULL); i++){
/*
* added to show address and start types show mpls forwarding content
* xgxu:20021108
*/
switch(show_type){
case SHOW_ZERO:
/* go to next step */
break;
case SHOW_START:
if( i < start_index ){
tmp_forward_item = tmp_forward_item->next;
continue;
}
break;
case SHOW_ADDR:
if( (parameter1 & parameter2)!=tmp_forward_item->dest_addr ){
tmp_forward_item = tmp_forward_item->next;
continue;
}
break;
default:
break;
}
forward_table_show.forwart_t_value[array_index].ifIndex = 0;
forward_table_show.forwart_t_value[array_index].localLabel.type =
tmp_forward_item->input_label->label_value.type;
/* copy input label */
switch(tmp_forward_item->input_label->label_value.type){
case GEN_LABEL_TYPE:
forward_table_show.forwart_t_value[array_index].localLabel.label.label =
tmp_forward_item->input_label->label_value.gen_label;
break;
case ATM_LABEL_TYPE:
forward_table_show.forwart_t_value[array_index].localLabel.label.atm.vpi =
tmp_forward_item->input_label->label_value.atm_label.vpi;
forward_table_show.forwart_t_value[array_index].localLabel.label.atm.vci =
tmp_forward_item->input_label->label_value.atm_label.vci;
break;
default:
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -