#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: Get the global MSRP mode: %s 1 \n", name);
printf("Test 2: set the global MSRP mode: %s 2 <mode>(0-Disable, 1-Enable)\n", name);
printf("Test 3: Get the MSRP boundary propagate mode: %s 3 \n", name);
printf("Test 4: Set the MSRP boundary propagate mode: %s 4 <mode>(0-Disable, 1-Enable)\n", name);
printf("Test 5: Get the MSRP mode for the specified interface: %s 5 <intIfNum>\n", name);
printf("Test 6: Set the MSRP mode for the given interface: %s 6 <intIfNum><mode>(0-Disable, 1-Enable)\n", name);
printf("Test 7: Get the MSRP SR Qav priority: %s 7 <intIfNum> <trClass> (0-Class A or 1-Class B)\n", name);
printf("Test 8: Set the MSRP SR Qav priority: %s 8 <intIfNum> <trClass>(0-Class A or 1-Class B) <priority>(0-7)\n", name);
printf("Test 9: Get the MSRP Sr Qav remapped priority: %s 9 <intIfNum> <trClass>(0-Class A or 1-Class B)\n", name);
printf("Test 10: Set the MSRP Sr Qav remapped priority: %s 10 <intIfNum> <trClass>(0-Class A or 1-Class B) <remap>(0-7)\n", name);
printf("Test 11: Get the MSRP talker pruning mode: %s 11 \n", name);
printf("Test 12: Set the MSRP talker pruning mode: %s 12 <mode>(0-Disable, 1-Enable)\n", name);
printf("Test 13: Get the maximum number of the ports, where MSRP registrations are allowed: %s 13 \n", name);
printf("Test 14: Set the maximum number of the ports, where MSRP registrations are allowed: %s 14 <maxFanInPorts>\n", name);
printf("Test 15: Get the MSRP SR class PVID value on the interface: %s 15 <intIfNum>\n", name);
printf("Test 16: Set the MSRP SR class PVID value on the interface: %s 16 <intIfNum> <pvid>(1-4094)\n", name);
printf("Test 17: Get the delta bandwidth values for the interface: %s 17 <intIfNum>\n", name);
printf("Test 18: Set the delta bandwidth values for the interface: %s 18 <intIfNum> <trafficClass>(0-Class A or 1-Class B) <deltaBandwidth>(0-75)\n", name);
printf("Test 19: Get the max free bandwidth values for the interface: %s 19 <intIfNum>\n", name);
printf("Test 20: Get the current used bandwidth values for the interface: %s 20 <intIfNum>\n", name);
printf("Test 21: Check if a port is boundary port: %s 21 <intIfNum> <trClass>(0-Class A or 1-Class B)\n", name);
printf("Test 22: Get the next stream index to the given index: %s 22 <currentIndex>\n", name);
printf("Test 23: Get the MSRP Reservation Information: %s 23 <intIfNum> <streamId>\n", name);
printf("Test 24: Get the value of specified MSRP counter: %s 24 <type>\n", name);
printf("Test 25: Get the value of specified MSRP counter for an interface: %s 25 <intIfNum> <type> \n", name);
printf("Test 26: Get Failed Registration Counter: %s 26 <intIfNum>\n", name);
printf("Test 27: Get the MSRP Stream Information: %s 27 <streamId>\n", name);
printf("Test 28: Clear MSRP traffic counters on specified interface: %s 28 <intIfNum>\n", name);
printf("Test 29: Clear all MSRP traffic counters: %s 29 \n", name);
printf("Test 30: Run API sanity checks: %s 30 \n", name);
return;
}
{
uint64_t trClassB;
uint32_t maxFanInPorts;
uint32_t remap;
uint64_t trClassA;
uint32_t counter;
uint32_t deltaClassA;
uint32_t deltaClassB;
uint32_t priority;
uint32_t pvid;
uint16_t nextIndex;
uint32_t streamId;
uint64_t total;
uint32_t intIfNum;
uint16_t currentIndex;
char buffer[128];
badBufdescPointer.
pstart = (
void *) NULL;
badBufdescPointer.
size =
sizeof(buffer);
badBufdescPointer.size = 0;
buf.pstart = buffer;
buf.size = sizeof(buffer);
zeroLenBuf.pstart = buffer;
zeroLenBuf.size = 0;
printf("Testing msrp OpEN APIs sanity:\n");
printf("Testing openapiMsrpModeGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 2:(result = %d)\n", result);
printf("Testing openapiMsrpBoundaryPropagateModeGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 2:(result = %d)\n", result);
printf("Testing openapiMsrpIntfModeGet():\n");
intIfNum = 1;
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiMsrpSrQavPriorityGet():\n");
trClass = 0;
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 4:(result = %d)\n", result);
printf("Testing openapiMsrpSrQavPrioritySet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("less than minimum value argument 4:(result = %d)\n", result);
printf("greater than maximum value argument 4:(result = %d)\n", result);
printf("Testing openapiMsrpSrQavRePriorityGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 4:(result = %d)\n", result);
printf("Testing openapiMsrpSrQavRePrioritySet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("less than minimum value argument 4:(result = %d)\n", result);
printf("greater than maximum value argument 4:(result = %d)\n", result);
printf("Testing openapiMsrpTalkerPruningModeGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 2:(result = %d)\n", result);
printf("Testing openapiMsrpMaxFanInPortsGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 2:(result = %d)\n", result);
printf("Testing openapiMsrpSRclassPVIDGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiMsrpQavDeltaBandwidthGet():\n");
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 openapiMsrpQavMaxRateGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 5:(result = %d)\n", result);
printf("NULL argument 5:(result = %d)\n", result);
printf("NULL argument 5:(result = %d)\n", result);
printf("Testing openapiMsrpQavCurrentBandwidthGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 5:(result = %d)\n", result);
printf("NULL argument 5:(result = %d)\n", result);
printf("NULL argument 5:(result = %d)\n", result);
printf("Testing openapiMsrpIsBoundaryPortGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 4:(result = %d)\n", result);
printf("Testing openapiMsrpStreamIndexedNextGet():\n");
currentIndex = 1;
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiMsrpReservationInformationGet():\n");
buf.pstart = &reservationInfo;
buf.size = sizeof(reservationInfo);
streamId = 1;
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("NULL buffdesc pstart argument 3:(result = %d)\n", result);
printf("buffdesc 0 length size argument 3:(result = %d)\n", result);
printf("Testing openapiMsrpTrafficPduCounterGet():\n");
type = 2;
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiMsrpIntfTrafficPduCounterGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 4:(result = %d)\n", result);
printf("Testing openapiMsrpFailedRegistrationCounterGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiMsrpStreamInformationGet():\n");
buf.pstart = (void *)&streamInfo;
buf.size = sizeof(streamInfo);
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("NULL buffdesc pstart argument 3:(result = %d)\n", result);
printf("buffdesc 0 length size argument 3:(result = %d)\n", result);
printf("Testing openapiMsrpTrafficCountersPerIfClear():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("Testing openapiMsrpTrafficCountersClear():\n");
printf("NULL client handle:(result = %d)\n", result);
return;
}
{
{
printf("Bad return code trying to get the global MSRP mode. (result = %d)\n", result);
}
else
{
printf("Global Msrp mode is %d.\n",*mode);
}
return;
}
{
{
printf("Bad return code trying to set the global MSRP mode. (result = %d)\n", result);
}
else
{
printf("Global MSRP mode is set\n");
}
return;
}
{
{
printf("Bad return code trying to get the MSRP boundary propagate mode. (result = %d)\n", result);
}
else
{
printf("MSRP boundary propogation mode is %d.\n", *mode);
}
return;
}
{
{
printf("Bad return code trying to set the MSRP boundary propagate mode. (result = %d)\n", result);
}
else
{
printf("MSRP boundary propogation mode is set.\n");
}
return;
}
{
{
printf("Bad return code trying to get the MSRP mode for the specified interface. (result = %d)\n", result);
}
else
{
printf("MSRP mode on interface %d is %d.\n",intIfNum, *mode);
}
return;
}
{
{
printf("Bad return code trying to set the MSRP mode for the given interface. (result = %d)\n", result);
}
else
{
printf("MSRP mode on interface %d is set.\n",intIfNum);
}
return;
}
{
{
printf("Bad return code trying to get the 802.1Qav priority. (result = %d)\n", result);
}
else
{
printf("MSRP Sr Qav priority of type %d on interface %d is %d.\n",
trClass, intIfNum, *priority);
}
return;
}
{
{
printf("Bad return code trying to set the 802.1Qav priority. (result = %d)\n", result);
}
else
{
printf("MSRP Sr Qav priority of type %d on interface %d is set.\n",
trClass, intIfNum);
}
return;
}
{
{
printf("Bad return code trying to get the 802.1Qav remapped priority. (result = %d)\n", result);
}
else
{
printf("MSRP Sr Qav remapped priority of type %d on interface %d is %d.\n",
trClass, intIfNum, *remap);
}
return;
}
{
{
printf("Bad return code trying to set the 802.1Qav remapped priority. (result = %d)\n", result);
}
else
{
printf("MSRP Sr Qav remapped priority of type %d on interface %d is set.\n",
trClass, intIfNum);
}
return;
}
{
{
printf("Bad return code trying to get the MSRP talker pruning mode. (result = %d)\n", result);
}
else
{
printf("MSRP talker pruning mode is %d\n",*mode);
}
return;
}
{
{
printf("Bad return code trying to set the MSRP talker pruning mode. (result = %d)\n", result);
}
else
{
printf("MSRP talker pruning mode is set.\n");
}
return;
}
{
{
printf("Bad return code trying to get the maximum number of the ports, where MSRP registrations are allowed. (result = %d)\n", result);
}
else
{
printf("MSRP max fan in ports is %d\n",*maxFanInPorts);
}
return;
}
{
{
printf("Bad return code trying to set the maximum number of the ports, where MSRP registrations are allowed. (result = %d)\n", result);
}
else
{
printf("MSRP maximum fan in ports is set.\n");
}
return;
}
{
{
printf("Bad return code trying to get the MSRP SR class PVID value on the interface. (result = %d)\n", result);
}
else
{
printf("MSRP SRclass PVID on interface %d is %d.\n", intIfNum, *pvid);
}
return;
}
{
{
printf("Bad return code trying to set the MSRP SR class PVID value on the interface. (result = %d)\n", result);
}
else
{
printf("MSRP SRclass PVID on interface %d is set.\n", intIfNum);
}
return;
}
void msrpQavDeltaBandwidthGet(
openapiClientHandle_t *client_handle, uint32_t intIfNum, uint32_t *deltaClassA, uint32_t *deltaClassB)
{
{
printf("Bad return code trying to get the delta bandwidth values for the interface. (result = %d)\n", result);
}
else
{
printf("MSRP Qav Delta bandwidth on interface %d is Class A %d, Class B %d\n",
intIfNum, *deltaClassA, *deltaClassB);
}
return;
}
{
{
printf("Bad return code trying to get the delta bandwidth values for the interface. (result = %d)\n", result);
}
else
{
printf("MSRP Qav Delta bandwidth on interface %d is set.\n", intIfNum);
}
return;
}
void msrpQavMaxRateGet(
openapiClientHandle_t *client_handle, uint32_t intIfNum, uint64_t *trClassA, uint64_t *trClassB, uint64_t *total)
{
{
printf("Bad return code trying to get the max free bandwidth values for the interface. (result = %d)\n", result);
}
else
{
printf("MSRP Qav Max rate on interface %d is Class A %llu, Class B %llu, Total %llu \n", intIfNum, *trClassA, *trClassB, *total);
}
return;
}
void msrpQavCurrentBandwidthGet(
openapiClientHandle_t *client_handle, uint32_t intIfNum, uint64_t *trClassA, uint64_t *trClassB, uint64_t *total)
{
{
printf("Bad return code trying to get the current used bandwidth values for the interface. (result = %d)\n", result);
}
else
{
printf("MSRP Qav current bandwidth on interface %d is \n"
"Class A %llu, Class B %llu, Total %llu\n", intIfNum, *trClassA, *trClassB, *total);
}
return;
}
{
{
printf("Bad return code trying to check if a port is boundary port. (result = %d)\n", result);
}
else
{
printf("MSRP interface %d boundary port status is %d.\n",
intIfNum, *isBoundary);
}
return;
}
void msrpStreamIndexedNextGet(
openapiClientHandle_t *client_handle, uint16_t currentIndex, uint16_t *nextIndex)
{
{
printf("Bad return code trying to given the next stream index to the given index. (result = %d)\n", result);
}
else
{
printf("MSRP next stream index(present index %d) is %d\n",
currentIndex, *nextIndex);
}
return;
}
void msrpReservationInformationGet(
openapiClientHandle_t *client_handle, uint32_t streamId, uint32_t intIfNum)
{
reservationInfo.pstart = &resInfo;
reservationInfo.size = sizeof(resInfo);
{
printf("Bad return code trying to get the MSRP Reservation Information. (result = %d)\n", result);
}
else
{
printf("MSRP reservation information on interface %d is\n", intIfNum);
printf("StreamId: \r\n%u \n MAC addr-%02x:%02x:%02x:%02x:%02x:%02x\n"
"Listener type %u talker type %u\n"
"Fail code %u fail interface %u\n",
}
return;
}
{
{
printf("Bad return code trying to get the value of specified MSRP 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 MSRP counter for an interface. (result = %d)\n", result);
}
else
{
printf("MSRP traffic PDU counter of type %d on interface %d is %d.\n",
type, intIfNum, *counter);
}
return;
}
void msrpFailedRegistrationCounterGet(
openapiClientHandle_t *client_handle, uint32_t intIfNum, uint32_t *counter)
{
{
printf("Bad return code trying to get Failed Registration Counter. (result = %d)\n", result);
}
else
{
printf("MSRP failed registration counter on interface %d is %d\n",
intIfNum, *counter);
}
return;
}
{
streamInfo.pstart = &strInfo;
streamInfo.size = sizeof(strInfo);
{
printf("Bad return code trying to get the MSRP Stream Information. (result = %d)\n", result);
}
else
{
printf("\r\nstreamId:%u \nsourceMac:%02x:%02x:%02x:%02x:%02x:%02x\n"
"Destination Mac:%02x:%02x:%02x:%02x:%02x:%02x\n"
"Latency %u vlanId %u Rank %d\n" , strInfo.
streamID,
strInfo.
accLatency, strInfo.
vlanId, strInfo.
rank);
}
return;
}
{
{
printf("Bad return code trying to clear MSRP traffic counters on specified interface. (result = %d)\n", result);
}
else
{
printf("MSGRP Traffic counters cleared on interface %d\n", intIfNum);
}
return;
}
{
{
printf("Bad return code trying to clear all MSRP traffic counters. (result = %d)\n", result);
}
else
{
printf("All MSGRP Traffic counters cleared \n");
}
return;
}
int main(int argc, char **argv)
{
uint32_t testNum;
char switch_os_revision_string[100];
int show_help = 1;
uint64_t trClassB;
uint32_t maxFanInPorts;
uint32_t remap;
uint64_t trClassA;
uint32_t counter;
uint32_t deltaClassA;
uint32_t deltaClassB;
uint32_t priority;
uint32_t pvid;
uint32_t deltaBandwidth;
uint16_t nextIndex;
uint32_t streamId;
uint64_t total;
uint32_t intIfNum;
uint32_t strId;
uint16_t currentIndex;
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 msrp 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)
{
msrpModeGet(&client_handle, &mode);
show_help = 0;
}
break;
case 2:
if (argc == 3)
{
mode = atoi(argv[2]);
msrpModeSet(&client_handle, mode);
show_help = 0;
}
break;
case 3:
if (argc == 2)
{
msrpBoundaryPropagateModeGet(&client_handle, &mode);
show_help = 0;
}
break;
case 4:
if (argc == 3)
{
mode = atoi(argv[2]);
msrpBoundaryPropagateModeSet(&client_handle, mode);
show_help = 0;
}
break;
case 5:
if (argc == 3)
{
intIfNum = atoi(argv[2]);
msrpIntfModeGet(&client_handle, intIfNum, &mode);
show_help = 0;
}
break;
case 6:
if (argc == 4)
{
intIfNum = atoi(argv[2]);
mode = atoi(argv[3]);
msrpIntfModeSet(&client_handle, intIfNum, mode);
show_help = 0;
}
break;
case 7:
if (argc == 4)
{
intIfNum = atoi(argv[2]);
trClass = atoi(argv[3]);
msrpSrQavPriorityGet(&client_handle, intIfNum, trClass, &priority);
show_help = 0;
}
break;
case 8:
if (argc == 5)
{
intIfNum = atoi(argv[2]);
trClass = atoi(argv[3]);
priority = atoi(argv[4]);
msrpSrQavPrioritySet(&client_handle, intIfNum, trClass, priority);
show_help = 0;
}
break;
case 9:
if (argc == 4)
{
intIfNum = atoi(argv[2]);
trClass = atoi(argv[3]);
msrpSrQavRePriorityGet(&client_handle, intIfNum, trClass, &remap);
show_help = 0;
}
break;
case 10:
if (argc == 5)
{
intIfNum = atoi(argv[2]);
trClass = atoi(argv[3]);
remap = atoi(argv[4]);
msrpSrQavRePrioritySet(&client_handle, intIfNum, trClass, remap);
show_help = 0;
}
break;
case 11:
if (argc == 2)
{
msrpTalkerPruningModeGet(&client_handle, &mode);
show_help = 0;
}
break;
case 12:
if (argc == 3)
{
mode = atoi(argv[2]);
msrpTalkerPruningModeSet(&client_handle, mode);
show_help = 0;
}
break;
case 13:
if (argc == 2)
{
msrpMaxFanInPortsGet(&client_handle, &maxFanInPorts);
show_help = 0;
}
break;
case 14:
if (argc == 3)
{
maxFanInPorts = atoi(argv[2]);
msrpMaxFanInPortsSet(&client_handle, maxFanInPorts);
show_help = 0;
}
break;
case 15:
if (argc == 3)
{
intIfNum = atoi(argv[2]);
msrpSRclassPVIDGet(&client_handle, intIfNum, &pvid);
show_help = 0;
}
break;
case 16:
if (argc == 4)
{
intIfNum = atoi(argv[2]);
pvid = atoi(argv[3]);
msrpSRclassPVIDSet(&client_handle, intIfNum, pvid);
show_help = 0;
}
break;
case 17:
if (argc == 3)
{
intIfNum = atoi(argv[2]);
msrpQavDeltaBandwidthGet(&client_handle, intIfNum, &deltaClassA, &deltaClassB);
show_help = 0;
}
break;
case 18:
if (argc == 5)
{
intIfNum = atoi(argv[2]);
trafficClass = atoi(argv[3]);
deltaBandwidth = atoi(argv[4]);
msrpQavDeltaBandwidthSet(&client_handle, intIfNum, trafficClass, deltaBandwidth);
show_help = 0;
}
break;
case 19:
if (argc == 3)
{
intIfNum = atoi(argv[2]);
msrpQavMaxRateGet(&client_handle, intIfNum, &trClassA, &trClassB, &total);
show_help = 0;
}
break;
case 20:
if (argc == 3)
{
intIfNum = atoi(argv[2]);
msrpQavCurrentBandwidthGet(&client_handle, intIfNum, &trClassA, &trClassB, &total);
show_help = 0;
}
break;
case 21:
if (argc == 4)
{
intIfNum = atoi(argv[2]);
trClass = atoi(argv[3]);
msrpIsBoundaryPortGet(&client_handle, intIfNum, trClass, &isBoundary);
show_help = 0;
}
break;
case 22:
if (argc == 3)
{
currentIndex = atoi(argv[2]);
msrpStreamIndexedNextGet(&client_handle, currentIndex, &nextIndex);
show_help = 0;
}
break;
case 23:
if (argc == 4)
{
intIfNum = atoi(argv[2]);
strId = atoi(argv[3]);
msrpReservationInformationGet(&client_handle, strId, intIfNum);
show_help = 0;
}
break;
case 24:
if (argc == 3)
{
type = atoi(argv[2]);
msrpTrafficPduCounterGet(&client_handle, type, &counter);
show_help = 0;
}
break;
case 25:
if (argc == 4)
{
intIfNum = atoi(argv[2]);
type = atoi(argv[3]);
msrpIntfTrafficPduCounterGet(&client_handle, intIfNum, type, &counter);
show_help = 0;
}
break;
case 26:
if (argc == 3)
{
intIfNum = atoi(argv[2]);
msrpFailedRegistrationCounterGet(&client_handle, intIfNum, &counter);
show_help = 0;
}
break;
case 27:
if (argc == 3)
{
streamId = atoi(argv[2]);
msrpStreamInformationGet(&client_handle, streamId);
show_help = 0;
}
break;
case 28:
if (argc == 3)
{
intIfNum = atoi(argv[2]);
msrpTrafficCountersPerIfClear(&client_handle, intIfNum);
show_help = 0;
}
break;
case 29:
if (argc == 2)
{
msrpTrafficCountersClear(&client_handle);
show_help = 0;
}
break;
case 30:
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;
}