#include <stdlib.h>
#include <unistd.h>
#include "rpcclt_openapi.h"
#include "proc_util.h"
static void printAppMenu(char *name)
{
printf("Usage: %s <test#> <arg1> <arg2> ... \n", name);
printf("Test 1: Gets the MVR admin mode: %s 1 \n", name);
printf("Test 2: Sets the MVR admin mode: %s 2 <adminMode>\n", name);
printf("Test 3: Gets the MVR query time: %s 3 \n", name);
printf("Test 4: Sets the MVR query time: %s 4 <queryTime>\n", name);
printf("Test 5: Gets the MVR mode type: %s 5 \n", name);
printf("Test 6: Sets the MVR mode type: %s 6 <modeType>\n", name);
printf("Test 7: Gets the MVR multicast vlan: %s 7 \n", name);
printf("Test 8: Sets the MVR multicast vlan: %s 8 <multicastVlan>\n", name);
printf("Test 9: Check if receivers participate in specific vlan: %s 9 <vlanId> \n", name);
printf("Test 10: Gets the MVR interface mode: %s 10 <ifNum> \n", name);
printf("Test 11: Sets the MVR interface mode: %s 11 <ifNum> <intfMode>\n", name);
printf("Test 12: Gets the interface MVR type of a specified interface: %s 12 <ifNum> \n", name);
printf("Test 13: Sets the interface MVR type of a specified interface: %s 13 <ifNum> <intfMvrType>\n", name);
printf("Test 14: Gets the immediate leave mode of a specified interface: %s 14 <ifNum> \n", name);
printf("Test 15: Sets the immediate leave mode of a specified interface: %s 15 <ifNum> <immediateMode>\n", name);
printf("Test 16: Add static group IP address: %s 16 <groupIp>\n", name);
printf("Test 17: Delete static group IP address: %s 17 <groupIp>\n", name);
printf("Test 18: Add specified interface to the group: %s 18 <ifNum> <groupIp>\n", name);
printf("Test 19: Delete specified interface from the group: %s 19 <ifNum> <groupIp>\n", name);
printf("Test 20: Display MVR group entries: %s 20\n", name);
printf("Test 21: List MVR members: %s 21\n", name);
printf("Test 22: Get next MVR interface: %s 22 <ifNum>\n", name);
printf("Test 23: Get the number of the group entries: %s 23 \n", name);
printf("Test 24: Get the group IDs registered on specified interface: %s 24 <ifNum>\n", name);
printf("Test 25: Get the group IPs statically registered on specified interface: %s 25 <ifNum>\n", name);
printf("Test 26: Get the global PDU counter values: %s 26 \n", name);
return;
}
{
{
printf("Bad return code trying to gets the MVR admin mode. (result = %d)\n",
result);
}
else
{
printf("MVR admin mode is %u.\n", *adminMode);
}
return;
}
{
{
printf("Bad return code trying to sets the MVR admin mode. (result = %d)\n",
result);
}
else
{
printf("MVR admin mode set successfully.\n");
}
return;
}
{
{
printf("Bad return code trying to gets the MVR query time. (result = %d)\n",
result);
}
else
{
printf("MVR query time is %u.\n", *queryTime);
}
return;
}
{
{
printf("Bad return code trying to set the MVR query time. (result = %d)\n",
result);
}
else
{
printf("MVR query time set successfully.\n");
}
return;
}
OPEN_MVR_MODE_TYPE_t *modeType)
{
{
printf("Bad return code trying to gets the MVR mode type. (result = %d)\n",
result);
}
else
{
printf("MVR mode type is %u.\n", *modeType);
}
return;
}
OPEN_MVR_MODE_TYPE_t modeType)
{
{
printf("Bad return code trying to sets the MVR mode type. (result = %d)\n",
result);
}
else
{
printf("MVR mode type set successfully.\n");
}
return;
}
uint32_t *multicastVlan)
{
{
printf("Bad return code trying to gets the MVR multicast vlan. (result = %d)\n",
result);
}
else
{
printf("MVR multicast vlan is %u.\n", *multicastVlan);
}
return;
}
uint32_t multicastVlan)
{
{
printf("Bad return code trying to sets the MVR multicast vlan. (result = %d)\n",
result);
}
else
{
printf("MVR multicast vlan set successfully.\n");
}
return;
}
{
rxVlanParticipationStatus)) !=
{
printf("Bad return code trying to check if receivers participate"
" in specific vlan. (result = %d)\n", result);
}
else
{
printf("Receivers %s participated in vlan %u.\n",
(*rxVlanParticipationStatus ==
OPEN_TRUE )?
"" :
"not",
vlanId);
}
return;
}
{
{
printf("Bad return code trying to gets the MVR interface mode. (result = %d)\n",
result);
}
else
{
printf("MVR interface mode is %u.\n", *intfMode);
}
return;
}
{
{
printf("Bad return code trying to gets the MVR interface mode. (result = %d)\n",
result);
}
else
{
printf("MVR interface mode set successfully.\n");
}
return;
}
OPEN_MVR_INTF_TYPE_t *intfMvrType)
{
{
printf("Bad return code trying to gets the interface MVR type of a"
" specified interface. (result = %d)\n", result);
}
else
{
printf("MVR interfaece type is %u.\n", *intfMvrType);
}
return;
}
OPEN_MVR_INTF_TYPE_t intfMvrType)
{
{
printf("Bad return code trying to sets the interface MVR type"
" of a specified interface. (result = %d)\n", result);
}
else
{
printf("MVR interface type set successfully.\n");
}
return;
}
{
{
printf("Bad return code trying to gets the immediate leave mode "
"of a specified interface. (result = %d)\n", result);
}
else
{
printf("MVR immediate mode is %u.\n", *immediateMode);
}
return;
}
{
{
printf("Bad return code trying to sets the immediate leave mode of a"
" specified interface. (result = %d)\n", result);
}
else
{
printf("MVR immediate mode set successfully.\n");
}
return;
}
{
uint32_t inetIpAddr = 0;
char str[40];
memset(str, 0, sizeof(str));
strncpy(str, groupIp, sizeof(str) - 1);
ipBuffdesc.
size = strlen(str) + 1;
{
printf("ERROR: Bad return code trying to convert internet address string "
"to a 32 bit integer. result = %d.\n", result);
return;
}
{
printf("Bad return code trying to add static group IP address. (result = %d)\n",
result);
}
else
{
printf("Group IP added successfully.\n");
}
return;
}
{
uint32_t inetIpAddr = 0;
char str[40];
memset(str, 0, sizeof(str));
strncpy(str, groupIp, sizeof(str) - 1);
ipBuffdesc.pstart = str;
ipBuffdesc.size = strlen(str) + 1;
{
printf("ERROR: Bad return code trying to convert internet address string "
"to a 32 bit integer. result = %d.\n", result);
return;
}
{
printf("Bad return code trying to delete static group IP address."
" (result = %d)\n", result);
}
else
{
printf("Group IP deleted successfully.\n");
}
return;
}
char * groupIp)
{
uint32_t inetIpAddr = 0;
char str[40];
memset(str, 0, sizeof(str));
strncpy(str, groupIp, sizeof(str) - 1);
ipBuffdesc.pstart = str;
ipBuffdesc.size = strlen(str) + 1;
{
printf("ERROR: Bad return code trying to convert internet address string "
"to a 32 bit integer. result = %d.\n", result);
return;
}
{
printf("Bad return code trying to add specified interface to the group."
" (result = %d)\n", result);
}
else
{
printf("Addition of specific interface to the group was successful.\n");
}
return;
}
char* groupIp)
{
uint32_t inetIpAddr = 0;
char str[40];
memset(str, 0, sizeof(str));
strncpy(str, groupIp, sizeof(str) - 1);
ipBuffdesc.pstart = str;
ipBuffdesc.size = strlen(str) + 1;
{
printf("ERROR: Bad return code trying to convert internet address string "
"to a 32 bit integer. result = %d.\n", result);
return;
}
{
printf("Bad return code trying to delete specified interface to the group."
" (result = %d)\n", result);
}
else
{
printf("Deletion of specific interface to the group was successful.\n");
}
return;
}
{
uint32_t groupId = 0, nextGroupId = 0;
uint32_t groupIp = 0;
char ipDescStr[32];
ipDesc.pstart = ipDescStr;
ipDesc.size = sizeof(ipDescStr)-1;
printf ("\nGroup Id IP Address\n");
printf ("-------- ----------------\n");
do
{
{
&groupIp))
{
openAddr.
addr.
ipv4 = groupIp;
printf ("%-8u %-15s\n", nextGroupId, (char *)ipDesc.pstart);
}
groupId = nextGroupId;
}
return;
}
{
uint32_t groupIp = 0, nextGroupIp = 0, groupId = 0;
char ipDescStr[32];
uint32_t intfNum = 0;
OPEN_MVR_ENTRY_TYPE_t type;
ipDesc.pstart = ipDescStr;
ipDesc.size = sizeof(ipDescStr)-1;
{
printf ("\nMVR Group IP Status Members\n");
printf ("--------------- --------------- -----------------------"
"--------------\n");
while (nextGroupIp != 0)
{
&groupId))
{
openAddr.addr.ipv4 = nextGroupIp;
memset (ipDescStr, 0, 32);
printf ("%-17.15s %-17.15s ", (char *)ipDesc.pstart,
intfNum, &intfNum))
{
groupId, &type))
{
if (OPEN_MVR_STATIC_TYPE == type)
{
printf ("%u(s) ", intfNum);
}
else
{
printf ("%u(d) ", intfNum);
}
}
}
printf ("\n");
intfNum = 0;
}
{
nextGroupIp = 0;
}
}
}
else
{
printf ("No MVR members.\n");
}
return;
}
uint32_t *nextIfNum)
{
{
printf("Bad return code trying to get next MVR interface.\n");
}
else
{
printf ("Next MVR interface is %u.\n", *nextIfNum);
}
return;
}
{
{
printf("Bad return code trying to get the number of the group entries. (result = %d)\n", result);
}
else
{
printf("Number of group entries is %u.\n", *groupEntries);
}
return;
}
uint32_t ifNum)
{
uint32_t groupId = 0;
{
printf ("Group ID's configured for given interface : ");
do
{
printf ("%u ", groupId);
printf ("\n");
}
else
{
printf("No Group configured for the entered interface.\n");
}
return;
}
uint32_t ifNum)
{
uint32_t groupIp = 0;
char ipDescStr[32] = {0};
ipDesc.pstart = ipDescStr;
ipDesc.size = sizeof(ipDescStr)-1;
{
printf ("Group IP for interface : ");
do
{
openAddr.addr.ipv4 = groupIp;
memset (ipDescStr, 0, 32);
printf ("%s ", (char *)ipDesc.pstart);
printf ("\n");
}
else
{
printf("No group IP configured.\n");
}
return;
}
{
uint32_t counterValue = 0;
{
printf("Bad return code trying to get the global PDU counter values. (result = %d)\n", result);
}
else
{
printf ("IGMP Query Received %u\n", counterValue);
}
counterValue = 0;
{
printf("Bad return code trying to get the global PDU counter values. (result = %d)\n", result);
}
else
{
printf ("IGMP Report V1 Received %u\n", counterValue);
}
counterValue = 0;
{
printf("Bad return code trying to get the global PDU counter values. (result = %d)\n", result);
}
else
{
printf ("IGMP Report V2 Received %u\n", counterValue);
}
counterValue = 0;
{
printf("Bad return code trying to get the global PDU counter values. (result = %d)\n", result);
}
else
{
printf ("IGMP Leave Received %u\n", counterValue);
}
counterValue = 0;
{
printf("Bad return code trying to get the global PDU counter values. (result = %d)\n", result);
}
else
{
printf ("IGMP Query Transmitted %u\n", counterValue);
}
counterValue = 0;
{
printf("Bad return code trying to get the global PDU counter values. (result = %d)\n", result);
}
else
{
printf ("IGMP Report V1 Transmitted %u\n", counterValue);
}
counterValue = 0;
{
printf("Bad return code trying to get the global PDU counter values. (result = %d)\n", result);
}
else
{
printf ("IGMP Report V2 Transmitted %u\n", counterValue);
}
counterValue = 0;
{
printf("Bad return code trying to get the global PDU counter values. (result = %d)\n", result);
}
else
{
printf ("IGMP Leave Transmitted %u\n", counterValue);
}
counterValue = 0;
{
printf("Bad return code trying to get the global PDU counter values. (result = %d)\n", result);
}
else
{
printf ("IGMP Packet Receive Failures %u\n", counterValue);
}
counterValue = 0;
{
printf("Bad return code trying to get the global PDU counter values. (result = %d)\n", result);
}
else
{
printf ("IGMP Packet Transmit Failures %u\n", counterValue);
}
return;
}
int main(int argc, char **argv)
{
uint32_t testNum;
char switch_os_revision_string[100];
uint32_t show_help = 1, value = 0;
OPEN_MVR_MODE_TYPE_t modeType;
OPEN_MVR_INTF_TYPE_t intfMvrType;
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 MVR 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)
{
mvrAdminModeGet(&client_handle, &val);
show_help = 0;
}
break;
case 2:
if (argc == 3)
{
mvrAdminModeSet(&client_handle, atoi(argv[2]));
show_help = 0;
}
break;
case 3:
if (argc == 2)
{
mvrQueryTimeGet(&client_handle, &value);
show_help = 0;
}
break;
case 4:
if (argc == 3)
{
mvrQueryTimeSet(&client_handle, atoi(argv[2]));
show_help = 0;
}
break;
case 5:
if (argc == 2)
{
mvrModeTypeGet(&client_handle, &modeType);
show_help = 0;
}
break;
case 6:
if (argc == 3)
{
mvrModeTypeSet(&client_handle, atoi(argv[2]));
show_help = 0;
}
break;
case 7:
if (argc == 2)
{
mvrMulticastVlanGet(&client_handle, &value);
show_help = 0;
}
break;
case 8:
if (argc == 3)
{
mvrMulticastVlanSet(&client_handle, atoi(argv[2]));
show_help = 0;
}
break;
case 9:
if (argc == 3)
{
mvrIsReceiversInVlan(&client_handle, atoi(argv[2]), &boolVal);
show_help = 0;
}
break;
case 10:
if (argc == 3)
{
mvrIntfModeGet(&client_handle, atoi(argv[2]), &val);
show_help = 0;
}
break;
case 11:
if (argc == 4)
{
mvrIntfModeSet(&client_handle, atoi(argv[2]), atoi(argv[3]));
show_help = 0;
}
break;
case 12:
if (argc == 3)
{
mvrIntfMvrTypeGet(&client_handle, atoi(argv[2]), &intfMvrType);
show_help = 0;
}
break;
case 13:
if (argc == 4)
{
mvrIntfMvrTypeSet(&client_handle, atoi(argv[2]), atoi(argv[3]));
show_help = 0;
}
break;
case 14:
if (argc == 3)
{
mvrIntfImmediateModeGet(&client_handle, atoi(argv[2]), &val);
show_help = 0;
}
break;
case 15:
if (argc == 4)
{
mvrIntfImmediateModeSet(&client_handle, atoi(argv[2]), atoi(argv[3]));
show_help = 0;
}
break;
case 16:
if (argc == 3)
{
mvrGroupIpAdd(&client_handle, argv[2]);
show_help = 0;
}
break;
case 17:
if (argc == 3)
{
mvrGroupIpDelete(&client_handle, argv[2]);
show_help = 0;
}
break;
case 18:
if (argc == 4)
{
mvrIntfGroupIpAdd(&client_handle, atoi(argv[2]), argv[3]);
show_help = 0;
}
break;
case 19:
if (argc == 4)
{
mvrIntfGroupIpDelete(&client_handle, atoi(argv[2]), argv[3]);
show_help = 0;
}
break;
case 20:
if (argc == 2)
{
mvrGroupEntriesDisplay(&client_handle);
show_help = 0;
}
break;
case 21:
if (argc == 2)
{
mvrListMembers(&client_handle);
show_help = 0;
}
break;
case 22:
if (argc == 3)
{
mvrIntfGetNext(&client_handle, atoi(argv[2]), &value);
show_help = 0;
}
break;
case 23:
if (argc == 2)
{
mvrGroupNumGet(&client_handle, &value);
show_help = 0;
}
break;
case 24:
if (argc == 3)
{
mvrIntfGroupIdGet(&client_handle, atoi(argv[2]));
show_help = 0;
}
break;
case 25:
if (argc == 3)
{
mvrIntfStaticGroupIpGet(&client_handle, atoi(argv[2]));
show_help = 0;
}
break;
case 26:
if (argc == 2)
{
mvrPduCountersGet(&client_handle);
show_help = 0;
}
break;
default:
break;
}
if (show_help == 1)
{
printAppMenu(argv[0]);
}
L7PROC_LOGF(L7PROC_LOG_SEVERITY_INFO, 0, "Stopping MVR API example application");
return 0;
}