#include <stdlib.h>
#include <unistd.h>
#include "rpcclt_openapi.h"
#include "proc_util.h"
#define L7_DOT1Q_MAX_VLAN_ID
static void printAppMenu(char *name)
{
printf("Usage: %s <test#> <arg1> <arg2> ... \n", name);
printf("Test 1: Get the global MVRP mode: %s 1 n", name);
printf("Test 2: set the global MVRP mode: %s 2 <mode>(0-Disable,1-Enable)\n", name);
printf("Test 3: Gets the MVRP periodic state machine mode: %s 3 n", name);
printf("Test 4: Sets the MVRP periodic state machine mode: %s 4 <mode>\n", name);
printf("Test 5: Get the MVRP mode for the specified interface: %s 5 <intIfNum> <mode>(0-Disable,1-Enable)\n", name);
printf("Test 6: Set the MVRP mode for the given interface: %s 6 <intIfNum><mode>(0-Disable,1-Enable)\n", name);
printf("Test 7: Check if the current interface is valid for MVRP: %s 7 <intIfNum>\n", name);
printf("Test 8: Given the current interface, get the next valid MVRP interface: %s 8 <intIfNum>\n", name);
printf("Test 9: Get the value of specified MVRP counter: %s 9 <type> \n", name);
printf("Test 10: Get the value of specified MVRP counter for an interface: %s 10 <intIfNum> <type> \n", name);
printf("Test 11: Get MVRP VLAN array in the system: %s 11 <vlanType>>\n", name);
printf("Test 12: Get MVRP VLAN array on an interface: %s 12 <intIfNum> <vlanType>\n", name);
printf("Test 13: Clear MVRP traffic counters on specified interface: %s 13 <intIfNum>\n", name);
printf("Test 14: Clear global MVRP traffic counters: %s 14 \n", name);
printf("Test 15: Clear all MVRP traffic counters: %s 15 \n", name);
printf("Test 16: Run API sanity checks: %s 16 \n", name);
return;
}
{
uint32_t count;
uint32_t counter;
uint32_t intIfNum, nextIfNum;
uint32_t max_interfaces;
{
printf ("Can't get Interface Count.\n");
}
printf("Testing mvrp OpEN APIs sanity:\n");
printf("Testing openapiMvrpModeGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 2:(result = %d)\n", result);
printf("Testing openapiMvrpPeriodicStateMachineModeGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 2:(result = %d)\n", result);
printf("Testing openapiMvrpIntfModeGet():\n");
intIfNum = 1;
printf("NULL client handle:(result = %d)\n", result);
printf("greater than maximum value argument 3:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiMvrpIsValidIntfGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("greater than maximum value argument 3:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiMvrpValidIntfNextGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("greater than maximum value argument 3:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiMvrpTrafficPduCounterGet():\n");
type = 0;
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiMvrpIntfTrafficPduCounterGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("greater than maximum value argument 4:(result = %d)\n", result);
printf("NULL argument 4:(result = %d)\n", result);
printf("Testing openapiMvrpVlanArrayGet():\n");
vlanType = 0;
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 4:(result = %d)\n", result);
printf("NULL argument 4:(result = %d)\n", result);
printf("Testing openapiMvrpIntfVlanArrayGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("greater than maximum value argument 5:(result = %d)\n", result);
printf("NULL argument 5:(result = %d)\n", result);
printf("NULL argument 5:(result = %d)\n", result);
printf("greater than maximum value argument 5:(result = %d)\n", result);
printf("Testing openapiMvrpTrafficCountersPerIfClear():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("greater than maximum value argument 2:(result = %d)\n", result);
printf("Testing openapiMvrpTrafficGlobalCountersClear():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("Testing openapiMvrpTrafficCountersClear():\n");
printf("NULL client handle:(result = %d)\n", result);
return;
}
{
{
printf("Bad return code trying to get the global MVRP mode. (result = %d)\n", result);
}
else
{
printf("Global MVRP mode is %d\n", *mode);
}
return;
}
{
{
printf("Bad return code trying to set the global MVRP mode. (result = %d)\n", result);
}
else
{
printf("MVRP mode is set\n");
}
return;
}
{
{
printf("Bad return code trying to gets the MVRP periodic state machine mode. (result = %d)\n", result);
}
else
{
printf("MVRP periodic state machine mode is %d\n", *mode);
}
return;
}
{
{
printf("Bad return code trying to sets the MVRP periodic state machine mode. (result = %d)\n", result);
}
else
{
printf("MVRP Periodic state machine mode set\n");
}
return;
}
{
{
printf("Bad return code trying to get the MVRP mode for the specified interface. (result = %d)\n", result);
}
else
{
printf("MVRP mode on interface %d is %d\n", intIfNum, *mode);
}
return;
}
{
{
printf("Bad return code trying to set the MVRP mode for the given interface. (result = %d)\n", result);
}
else
{
printf("MVRP mode on interface %d is set\n", intIfNum);
}
return;
}
{
{
printf("Bad return code trying to check if the current interface is valid for MVRP. (result = %d)\n", result);
}
else
{
{
printf("\n This is valid MVRP interface \n");
}
else
{
printf("\n This is not valid MVRP interface \n");
}
}
return;
}
{
{
printf("Bad return code trying to given the current interface, get the next valid MVRP interface. (result = %d)\n", result);
}
else
{
printf("Next valid MVRP interface is %d\n", *nextIfNum);
}
return;
}
{
{
printf("Bad return code trying to get the value of specified MVRP counter. (result = %d)\n", result);
}
else
{
printf("MSRP Pdu counter of type %d is %d\n", type, *counter);
}
return;
}
{
{
printf("Bad return code trying to get the value of specified MVRP counter for an interface. (result = %d)\n", result);
}
else
{
printf("MVRP Pdu counter of type %d on interface %d is %dn",
type, intIfNum, *counter);
}
return;
}
{
int i = 0, max = 0;
{
printf("Bad return code trying to get MVRP VLAN array in the system. (result = %d)\n", result);
}
else
{
max = *count;
printf("\n MVRP Vlan list is\n");
for(i=0;i<max;i++)
{
printf(
"%d,", vlanList->
ids[i]);
}
}
return;
}
{
int i = 0, max = 0;
{
printf("Bad return code trying to get MVRP VLAN array on an interface. (result = %d)\n", result);
}
else
{
max = *count;
printf("\n MVRP Vlan list is\n");
for(i=0;i<max;i++)
{
printf(
"%d,", vlanList->
ids[i]);
}
}
return;
}
{
{
printf("Bad return code trying to clear MVRP traffic counters on specified interface. (result = %d)\n", result);
}
else
{
printf("MVRP Counters on interface %d cleared\n", intIfNum);
}
return;
}
{
{
printf("Bad return code trying to clear global MVRP traffic counters. (result = %d)\n", result);
}
else
{
printf("MVRP Global counters are cleared.\n");
}
return;
}
{
{
printf("Bad return code trying to clear all MVRP traffic counters. (result = %d)\n", result);
}
else
{
printf("All MVRP Traffic ounters are cleared.\n");
}
return;
}
int main(int argc, char **argv)
{
uint32_t testNum;
char switch_os_revision_string[100];
int show_help = 1;
uint32_t counter, count;
uint32_t intIfNum;
uint32_t nextIfNum;
if (argc < 2)
{
printAppMenu(argv[0]);
return -1;
}
testNum = atoi(argv[1]);
l7proc_crashlog_register();
{
printf("\nFailed to initialize RPC to OpEN. Exiting (result = %d)\n", result);
return -1;
}
{
sleep(1);
}
L7PROC_LOGF(L7PROC_LOG_SEVERITY_INFO, 0, "Starting mvrp API example application");
printf("\n");
switch_os_revision.
pstart = switch_os_revision_string;
switch_os_revision.
size =
sizeof(switch_os_revision_string);
printf("Network OS version = %s\n", switch_os_revision_string);
else
printf("Network OS version retrieve error\n");
printf("\n");
switch (testNum)
{
case 1:
if (argc == 2)
{
mvrpModeGet(&client_handle, &mode);
show_help = 0;
}
break;
case 2:
if (argc == 3)
{
mode = atoi(argv[2]);
mvrpModeSet(&client_handle, mode);
show_help = 0;
}
break;
case 3:
if (argc == 2)
{
mvrpPeriodicStateMachineModeGet(&client_handle, &mode);
show_help = 0;
}
break;
case 4:
if (argc == 3)
{
mode = atoi(argv[2]);
mvrpPeriodicStateMachineModeSet(&client_handle, mode);
show_help = 0;
}
break;
case 5:
if (argc == 3)
{
intIfNum = atoi(argv[2]);
mvrpIntfModeGet(&client_handle, intIfNum, &mode);
show_help = 0;
}
break;
case 6:
if (argc == 4)
{
intIfNum = atoi(argv[2]);
mode = atoi(argv[3]);
mvrpIntfModeSet(&client_handle, intIfNum, mode);
show_help = 0;
}
break;
case 7:
if (argc == 3)
{
intIfNum = atoi(argv[2]);
mvrpIsValidIntfGet(&client_handle, intIfNum, &isValid);
show_help = 0;
}
break;
case 8:
if (argc == 3)
{
intIfNum = atoi(argv[2]);
mvrpValidIntfNextGet(&client_handle, intIfNum, &nextIfNum);
show_help = 0;
}
break;
case 9:
if (argc == 3)
{
type = atoi(argv[2]);
mvrpTrafficPduCounterGet(&client_handle, type, &counter);
show_help = 0;
}
break;
case 10:
if (argc == 4)
{
intIfNum = atoi(argv[2]);
type = atoi(argv[3]);
mvrpIntfTrafficPduCounterGet(&client_handle, intIfNum, type, &counter);
show_help = 0;
}
break;
case 11:
if (argc == 3)
{
vlanType = atoi(argv[2]);
mvrpVlanArrayGet(&client_handle, vlanType, &vlanList, &count);
show_help = 0;
}
break;
case 12:
if (argc == 4)
{
intIfNum = atoi(argv[2]);
vlanType = atoi(argv[3]);
mvrpIntfVlanArrayGet(&client_handle, intIfNum, vlanType, &vlanList, &count);
show_help = 0;
}
break;
case 13:
if (argc == 3)
{
intIfNum = atoi(argv[2]);
mvrpTrafficCountersPerIfClear(&client_handle, intIfNum);
show_help = 0;
}
break;
case 14:
if (argc == 2)
{
mvrpTrafficGlobalCountersClear(&client_handle);
show_help = 0;
}
break;
case 15:
if (argc == 2)
{
mvrpTrafficCountersClear(&client_handle);
show_help = 0;
}
break;
case 16:
if (argc == 2)
{
runSanity(&client_handle);
show_help = 0;
}
break;
default:
break;
}
if (show_help == 1)
{
printAppMenu(argv[0]);
}
L7PROC_LOGF(L7PROC_LOG_SEVERITY_INFO, 0, "Stopping msrp API example application");
return 0;
}