#include <stdlib.h>
#include <unistd.h>
#include "rpcclt_openapi.h"
#include "proc_util.h"
void printPOEAppMenu()
{
printf("Usage: poe_example <test#> <arg1> <arg2> ... \n");
printf("Test 1: Get the PoE first interface: poe_example 1 <poe-type> \n");
printf("Test 2: Check PoE support on this platform: poe_example 2 \n");
printf("Test 3: Determine if the interface is capable of supporting PoE: poe_example 3 <poe-type> <interface> \n");
printf("Test 4: Get interface port terminal classification: poe_example 4 <interface> \n");
printf("Test 5: Get interface port sensors: poe_example 5 <interface> \n");
printf("Test 6: Get operational status of the port detection: poe_example 6 <interface> \n");
printf("Test 7: Get interface port error code: poe_example 7 <interface> \n");
printf("Test 8: Get all counters of PSE state machine: poe_example 8 <interface> \n");
printf("Test 9: Find max power limit: poe_example 9 <interface> \n");
printf("Test 10: Get detection mode of a unit: poe_example 10 \n");
printf("Test 11: Set detection mode of a unit: poe_example 11 <detection-mode> \n");
printf("Test 12: Get the current watt limit the PSE can deliver to a port: poe_example 12 <interface> \n");
printf("Test 13: Set the current watt limit the PSE can deliver to a port: poe_example 13 <interface> <power-limit> \n");
printf("Test 14: Get port priority value used in management algorithm: poe_example 14 <interface> \n");
printf("Test 15: Set port priority value used in management algorithm: poe_example 15 <interface> <power-priority> \n");
printf("Test 16: Get port detection mode of a given interface: poe_example 16 <interface> \n");
printf("Test 17: Set port detection mode of a given interface: poe_example 17 <interface> <detection-mode> \n");
printf("Test 18: Get port ability to provide POE high power: poe_example 18 <interface> \n");
printf("Test 19: Set port ability to provide POE high power: poe_example 19 <interface> <enable|disable> \n");
printf("Test 20: Get port ability of power up: poe_example 20 <interface> \n");
printf("Test 21: Set port ability of power up: poe_example 21 <interface> <af|high-inrush|pre-at|at|upoe> \n");
printf("Test 22: Get violation type of a given interface: poe_example 22 <interface> \n");
printf("Test 23: Set violation type of a given interface: poe_example 23 <interface> <violation-type> \n");
printf("Test 24: Get usage threshold in percent: poe_example 24 \n");
printf("Test 25: Set usage threshold in percent: poe_example 25 <threshold> \n");
printf("Test 26: Get port administrative mode: poe_example 26 <interface> \n");
printf("Test 27: Set port administrative mode: poe_example 27 <interface> <adminMode> \n");
printf("Test 28: Get unit PoE Management mode: poe_example 28 <unit> \n");
printf("Test 29: Set unit PoE Management mode: poe_example 29 <unit> <static|static-pri|dynamic|dynamic-pri|class>\n");
printf("Test 30: Get unit total power consumed: poe_example 30 <unit> \n");
printf("Test 31: Get firmware version: poe_example 31 <unit> \n");
printf("Test 32: Get main operational status: poe_example 32 <unit> \n");
printf("Test 33: Get unit threshold power: poe_example 33 <unit> \n");
printf("Test 34: Get unit total available power: poe_example 34 <unit> \n");
printf("Test 35: Display whether POE trap mode is enabled or not : poe_example 35 <unit> \n");
printf("Test 36: Get interface timer schedule name: poe_example 36 <interface> \n");
printf("Test 37: Reset PoE on a interface: poe_example 37 <interface> \n");
printf("Test 38: Reset PoE globally: poe_example 38 \n");
printf("Test 39: Set PoE administrative mode globally: poe_example 39 <enabled|disabled> \n");
printf("Test 40: Set PoE trap mode: poe_example 40 <unit> <enabled|disabled> \n");
printf("Test 41: Set global priority value used in management algorithm: poe_example 41 <critical|high|medium|low> \n");
printf("Test 42: Set global current watt limit the PSE can deliver: poe_example 42 <power-limit> \n");
printf("Test 43: Clear timer schedule ID associated with the given interface: poe_example 43 <interface> \n");
printf("Test 44: Set interface timer schedule name: poe_example 44 <interface> <timerschedulename>\n");
printf("Test 45: Test PoE OpEN API Sanity: poe_example 45 \n");
}
{
uint32_t interface = 0;
{
printf("Bad return code trying to get PoE first interface. (result = %d)\n", result);
}
else
{
printf("PoE first interface: %u\n", interface);
}
}
{
{
printf("Bad return code trying to check if PoE is supported on this platform. (result = %d)\n", result);
}
else
{
{
printf("PoE is supported on this platform.\n");
}
else
{
printf("PoE is not supported on this platform.\n");
}
}
}
{
{
{
printf("Interface %d is not a valid poe interface\n", interface);
}
else
{
printf("Bad return code trying to get port priority value used in management algorithm. (result = %d)\n", result);
}
}
else
{
printf("Interface (%u) is capable of supporting PoE.\n", interface);
}
}
void poePsePortPowerClassificationsGet(
openapiClientHandle_t *clientHandle, uint32_t unit, uint32_t interface)
{
uint32_t powerClass;
{
printf("Bad return code trying to get interface port terminal classification. (result = %d)\n", result);
}
else
{
switch (powerClass)
{
printf("Interface port terminal power class for interface (%u): 0\n", interface);
break;
printf("Interface port terminal power class for interface (%u): 1\n", interface);
break;
printf("Interface port terminal power class for interface (%u): 2\n", interface);
break;
printf("Interface port terminal power class for interface (%u): 3\n", interface);
break;
printf("Interface port terminal power class for interface (%u): 4\n", interface);
break;
printf("Interface port terminal power class for interface (%u): Unknown\n", interface);
break;
default:
break;
}
}
}
{
uint32_t power, current, voltage, temperature;
{
printf("Bad return code trying to get interface port terminal sensors. (result = %d)\n", result);
}
else
{
printf("Interface port (%u) terminal sensors: \n"
"\tPower Output : %u\n"
"\tCurrent Output : %u\n"
"\tVoltage Output : %u\n"
"\tTemperature Output : %u\n",
interface, power, current, voltage, temperature);
}
}
void poePsePortDetectionStatusGet(
openapiClientHandle_t *clientHandle, uint32_t unit, uint32_t interface)
{
uint32_t detectionStatus;
{
printf("Bad return code trying to get operational status of the port detection. (result = %d)\n", result);
}
else
{
switch (detectionStatus)
{
printf("Operational status of port detection for interface(%u): Requesting Power\n", interface);
break;
printf("Operational status of port detection for interface(%u): Disabled\n", interface);
break;
printf("Operational status of port detection for interface(%u): Searching\n", interface);
break;
printf("Operational status of port detection for interface(%u): Delivering Power\n", interface);
break;
printf("Operational status of port detection for interface(%u): Fault\n", interface);
break;
printf("Operational status of port detection for interface(%u): Test\n", interface);
break;
default:
printf("Operational status of port detection for interface(%u): Other Fault\n", interface);
break;
}
}
}
{
uint32_t errorCode;
{
printf("Bad return code trying to get interface port error code. (result = %d)\n", result);
}
else
{
switch (errorCode)
{
printf("Port error for interface(%u): MPS Absent\n", interface);
break;
printf("Port error for interface(%u): Short\n", interface);
break;
printf("Port error for interface(%u): Overload\n", interface);
break;
printf("Port error for interface(%u): Power Denied\n", interface);
break;
printf("Port error for interface(%u): Thermal Shutdown\n", interface);
break;
printf("Port error for interface(%u): Startup Failure\n", interface);
break;
default:
printf("Port error for interface(%u): No Error\n", interface);
break;
}
}
}
{
uint32_t mpsAbsentCtr, invalidSignatureCtr, powerDeniedCtr, overloadCtr, shortCtr;
{
printf("Bad return code trying to get interface port terminal sensors. (result = %d)\n", result);
}
else
{
printf("Counters of PSE state machine for interface (%u) : \n", interface);
printf("\tMPS Abscent counter : %u\n", mpsAbsentCtr);
printf("\tInvalid Signature counter : %u\n", invalidSignatureCtr);
printf("\tPower Denied counter : %u\n", powerDeniedCtr);
printf("\tOverload counter : %u\n", overloadCtr);
printf("\tShort counter : %u\n", shortCtr);
}
}
{
uint32_t maxPowerLimit;
{
printf("Bad return code trying to get max power limit for interface. (result = %d)\n", result);
}
else
{
printf("Max power limit for interface (%u): %u\n", interface, maxPowerLimit);
}
}
{
{
printf("Bad return code trying to get detection mode of a unit. (result = %d)\n", result);
}
else
{
switch (detectionMode)
{
printf("Detection mode of a unit : Invalid\n");
break;
printf("Detection mode of a unit : 4ptdot3af\n");
break;
printf("Detection mode of a unit : 4ptdot3af+legacy\n");
break;
default:
printf("Detection mode of a unit : None\n");
break;
}
}
}
{
{
printf("Bad return code trying to set detection mode of a unit. (result = %d)\n", result);
}
else
{
printf("Detection mode of a unit set successfully.\n");
}
}
{
uint32_t powerLimit;
{
printf("Bad return code trying to get the current watt limit the PSE can deliver to a port. (result = %d)\n", result);
}
else
{
printf("Current watt limit the PSE can deliver to a port (%u): %u\n", interface, powerLimit);
}
}
void poePsePortCurPowerLimitSet(
openapiClientHandle_t *clientHandle, uint32_t unit, uint32_t interface, uint32_t powerLimit)
{
{
printf("Bad return code trying to set the current watt limit the PSE can deliver to a port. (result = %d)\n", result);
}
else
{
printf("Current watt limit the PSE can deliver to a port (%u) set successfully.\n", interface);
}
}
void poePsePortCurPowerPriorityGet(
openapiClientHandle_t *clientHandle, uint32_t unit, uint32_t interface)
{
{
{
printf("Interface %d is not a valid poe interface\n", interface);
}
else
{
printf("Bad return code trying to get port priority value used in management algorithm. (result = %d)\n", result);
}
}
else
{
switch (powerPriority)
{
printf("Port priority : Critical\n");
break;
printf("Port priority : High\n");
break;
printf("Port priority : Medium\n");
break;
printf("Port priority : Low\n");
break;
default:
printf("Port priority : None\n");
break;
}
}
}
void poePsePortCurPowerPrioritySet(
openapiClientHandle_t *clientHandle, uint32_t unit, uint32_t interface, uint32_t powerPriority)
{
{
printf("Bad return code trying to set port priority value used in management algorithm. (result = %d)\n", result);
}
else
{
printf("Port priority value used in management algorithm for interface (%u) set successfully.\n", interface);
}
}
{
{
{
printf("Feature is not supported.\n");
}
else
{
printf("Bad return code trying to get port detection mode of a given interface. (result = %d)\n", result);
}
}
else
{
switch (detectionMode)
{
printf("Detection mode of a interface (%u) : Legacy\n", interface);
break;
printf("Detection mode of a interface (%u) : 2Pt-Dot3af\n", interface);
break;
printf("Detection mode of a interface (%u) : 2Pt-Dot3af + Legacy\n", interface);
break;
printf("Detection mode of a interface (%u) : 4Pt-Dot3af\n", interface);
break;
printf("Detection mode of a interface (%u) : 4ptdot3af+legacy\n", interface);
break;
default:
printf("Detection mode of a interface (%u) : None\n", interface);
break;
}
}
}
void poePsePortDetectionModeSet(
openapiClientHandle_t *clientHandle, uint32_t unit, uint32_t interface, uint32_t detectionMode)
{
{
{
printf("Feature is not supported.\n");
}
else
{
printf("Bad return code trying to set port detection mode of a given interface. (result = %d)\n", result);
}
}
else
{
printf("Detection mode for interface (%u) set successfully.\n", interface);
}
}
{
{
{
printf("Feature is not supported.\n");
}
else
{
printf("Bad return code trying to get port ability to provide PoE high power. (result = %d)\n", result);
}
}
else
{
switch (highPowerMode)
{
printf("High power mode for interface (%u) : disable\n", interface);
break;
printf("High power mode for interface (%u) : enable\n", interface);
break;
default:
printf("High power mode for interface (%u) : none\n", interface);
break;
}
}
}
{
{
printf("Bad return code trying to get main operational status. (result = %d)\n", result);
}
else
{
switch (status)
{
printf("Main operational status is on\n");
break;
printf("Main operational status is off\n");
break;
printf("Main operational status is faulty\n");
break;
default:
printf("Unrecognized main operational status %d\n", status);
break;
}
}
}
{
char buf[OPEN_MAX_POE_CARD_INFO_BUF_SIZE];
version.
size =
sizeof(buf);
{
printf("Bad return code trying to get POE firmware version. (result = %d)\n", result);
}
else
{
printf("POE Firmware version is '%s'\n", buf);
}
}
void poePsePortHighPowerModeSet(
openapiClientHandle_t *clientHandle, uint32_t unit, uint32_t interface, uint32_t highPowerMode)
{
{
{
printf("Feature is not supported.\n");
}
else
{
printf("Bad return code trying to set port ability to provide PoE high power. (result = %d)\n", result);
}
}
else
{
printf("High power mode for interface (%u) set successfully.\n", interface);
}
}
{
{
{
printf("Feature is not supported.\n");
}
else
{
printf("Bad return code trying to get port ability of power up. (result = %d)\n", result);
}
}
else
{
switch (powerUpMode)
{
printf("Power up mode for interface (%u) : af\n", interface);
break;
printf("Power up mode for interface (%u) : high-inrush\n", interface);
break;
printf("Power up mode for interface (%u) : pre-at\n", interface);
break;
printf("Power up mode for interface (%u) : at\n", interface);
break;
printf("Power up mode for interface (%u) : upoe\n", interface);
break;
default:
printf("Power up mode for interface (%u) : none\n", interface);
break;
}
}
}
void poePsePortPowerUpModeSet(
openapiClientHandle_t *clientHandle, uint32_t unit, uint32_t interface, uint32_t powerUpMode)
{
{
{
printf("Feature is not supported.\n");
}
else
{
printf("Bad return code trying to set port ability of power up. (result = %d)\n", result);
}
}
else
{
printf("Power up mode for interface (%u) set successfully.\n", interface);
}
}
{
{
{
printf("Feature is not supported.\n");
}
else
{
printf("Bad return code trying to get violation type of a given interface. (result = %d)\n", result);
}
}
else
{
switch (violationType)
{
printf("Violation type for interface (%u) : Class Based\n", interface);
break;
printf("Violation type for interface (%u) : User Defined\n", interface);
break;
default:
printf("Violation type for interface (%u) : None\n", interface);
break;
}
}
}
void poePsePortViolationTypeSet(
openapiClientHandle_t *clientHandle, uint32_t unit, uint32_t interface, uint32_t violationType)
{
{
{
printf("Feature is not supported.\n");
}
else
{
printf("Bad return code trying to set violation type of a given interface. (result = %d)\n", result);
}
}
else
{
printf("Violation type for interface (%u) set successfully.\n", interface);
}
}
{
uint32_t threshold;
{
printf("Bad return code trying to get usage threshold in percent. (result = %d)\n", result);
}
else
{
printf("Usage threshold : %u\n", threshold);
}
}
{
{
printf("Bad return code trying to set usage threshold in percent. (result = %d)\n", result);
}
else
{
printf("Usage threshold set successfully.\n");
}
}
{
{
printf("Bad return code trying to get port administrative mode. (result = %d)\n", result);
}
else
{
switch (adminMode)
{
printf("Administrative mode for interface (%u): Enabled\n", interface);
break;
printf("Administrative mode for interface (%u): Disabled\n", interface);
break;
default:
printf("Administrative mode for interface (%u): Undecoded Value = %u\n", interface, adminMode);
break;
}
}
}
void poePsePortAdminEnableSet(
openapiClientHandle_t *clientHandle, uint32_t interface, uint32_t adminMode)
{
{
printf("Bad return code trying to get port administrative mode. (result = %d)\n", result);
}
else
{
printf("Mode set successfully.\n");
}
}
{
{
printf("Bad return code trying to get PoE mgmt mode for unit %u. (result = %d)\n", unit, result);
}
else
{
switch (mode)
{
printf(" PoE mgmt mode is static\n");
break;
printf(" PoE mgmt mode is static priority\n");
break;
printf(" PoE mgmt mode is dynamic\n");
break;
printf(" PoE mgmt mode is dynamic priority\n");
break;
printf(" PoE mgmt mode is class\n");
break;
default:
printf(" PoE mgmt mode is invalid\n");
break;
}
}
}
{
{
printf("Bad return code trying to set PoE mgmt mode for unit %u. (result = %d)\n", unit, result);
}
else
{
printf("Management Mode set successfully.\n");
}
}
{
uint32_t powerconsumed;
{
printf("Bad return code trying to get PoE power consumed for unit %u. (result = %d)\n", unit, result);
}
else
{
printf("Power Consumed for unit %u = %u milliwatts\n", unit, powerconsumed);
}
}
{
uint32_t power;
{
printf("Bad return code trying to get PoE threshold power for unit %u. (result = %d)\n", unit, result);
}
else
{
printf("Threshold power for unit %u = %u milliwatts\n", unit, power);
}
}
{
uint32_t power;
{
printf("Bad return code trying to get PoE total available power for unit %u. (result = %d)\n", unit, result);
}
else
{
printf("Total available power for unit %u = %u milliwatts\n", unit, power);
}
}
{
{
printf("Bad return code trying to get PoE trap enabled (result = %d)\n", result);
}
else
{
switch (enable)
{
printf("Trap mode : disabled\n");
break;
printf("Trap mode : enabled\n");
break;
}
}
}
{
char buf[OPEN_MAX_POE_TIMER_NAME_BUF_LEN];
timerScheduleName.pstart = buf;
timerScheduleName.size = sizeof(buf);
{
printf("Bad return code trying to get POE port timer schedule name. (result = %d)\n", result);
}
else
{
printf("POE port timer schedule name is '%s'\n", buf);
}
}
{
{
printf("Bad return code trying to reset PoE on interface (%d) , result = %d\n", interface, result);
}
else
{
printf("PoE reset on interface was successfully \n");
}
}
{
{
printf("Bad return code trying to reset PoE, result = %d\n", result);
}
else
{
printf("Reset PoE successfully \n");
}
}
{
{
printf("Bad return code trying to set administrative mode(%d). (result = %d)\n", (uint32_t)adminMode, result);
}
else
{
printf("Mode set successfully.\n");
}
}
{
{
printf("Bad return code trying to set PoE trap (%d), result = %d\n", (uint32_t)trapMode, result);
}
else
{
printf("PoE trap mode set successfully \n");
}
}
{
{
printf("Bad return code trying to set priority value (%d) used in management algorithm. (result = %d)\n", (uint32_t)powerPriority, result);
}
else
{
printf("Port priority value (%d) used in management algorithm for all interfaces set successfully.\n", (uint32_t)powerPriority);
}
}
{
{
printf("Bad return code trying to set the current watt limit the PSE can deliver on all ports. (result = %d)\n", result);
}
else
{
printf("Current watt limit the PSE can deliver on all ports set successfully.\n");
}
}
uint32_t ifNum)
{
{
printf("Bad return code trying to clear timer scheduler associated with given interface. (result = %d)\n", result);
}
else
{
printf("Successfully cleared timer scheduler associated with given interface %u. \n", ifNum);
}
return;
}
uint32_t unit,
uint32_t ifNum,
char *timerScheduleName)
{
char str[OPEN_TIMERANGE_NAME_LEN_MAX];
memset(str, 0, sizeof(str));
strncpy(str, timerScheduleName, sizeof(str));
buffDesc.pstart = str;
buffDesc.size = strlen(str) + 1;
{
printf("Bad return code trying to set PoE port timer schedule name. (result = %d)\n", result);
}
else
{
printf("PoE port timer schedule name '%s' is SET on interface %d\n", str, ifNum);
}
}
{
uint32_t unit = 1;
uint32_t interface = 1;
uint32_t outputVal = 0;
uint32_t powerconsumed;
uint32_t power;
char buf[OPEN_MAX_POE_CARD_INFO_BUF_SIZE];
char str[OPEN_TIMERANGE_NAME_LEN_MAX];
char timerScheduleBuf[OPEN_MAX_POE_TIMER_NAME_BUF_LEN];
printf("\nTesting openapiPoeFirstInterfaceGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid PoE type to get PoE first interface. (result = %d)\n", result);
printf("Invalid unit number to get PoE first interface. (result = %d)\n", result);
printf("NULL return address to get PoE first interface. (result = %d)\n", result);
printf("openapiPoeFirstInterfaceGet() sanity successful. \n");
printf("\nTesting openapiPoeIsSupported(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit number to determine PoE support. (result = %d)\n", result);
printf("NULL PoE support flag to determine PoE support. (result = %d)\n", result);
printf("openapiPoeIsSupported() sanity successful. \n");
printf("\nTesting openapiPoeIsValidInterface(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid PoE type to determine if the interface is capable of supporting PoE. (result = %d)\n", result);
printf("Invalid interface to determine if the interface is capable of supporting PoE. (result = %d)\n", result);
printf("NULL validation flag to determine if the interface is capable of supporting PoE. (result = %d)\n", result);
printf("openapiPoeIsValidInterface() sanity successful. \n");
printf("\nTesting openapiPoePsePortPowerClassificationsGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit number to get interface port terminal classification. (result = %d)\n", result);
printf("Invalid interface to get interface port terminal classification. (result = %d)\n", result);
printf("NULL output parameter to get interface port terminal classification. (result = %d)\n", result);
printf("openapiPoePsePortPowerClassificationsGet() sanity successful. \n");
printf("\nTesting openapiPoePsePortSensorsGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit number to get interface port terminal sensors. (result = %d)\n", result);
printf("Invalid interface to get interface port terminal sensors. (result = %d)\n", result);
printf("NULL output parameters to get interface port terminal sensors. (result = %d)\n", result);
printf("openapiPoePsePortSensorsGet() sanity successful. \n");
printf("\nTesting openapiPoePsePortDetectionStatusGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit number to get operational status of the port detection. (result = %d)\n", result);
printf("Invalid interface to get operational status of the port detection. (result = %d)\n", result);
printf("NULL output parameter to get operational status of the port detection. (result = %d)\n", result);
printf("openapiPoePsePortDetectionStatusGet() sanity successful. \n");
printf("\nTesting openapiPoePsePortErrorCodeGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid interface to get interface error code. (result = %d)\n", result);
printf("NULL output parameter to get interface error code. (result = %d)\n", result);
printf("openapiPoePsePortErrorCodeGet() sanity successful. \n");
printf("\nTesting openapiPoePsePortCountersGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid interface to get all counters of PSE state machine. (result = %d)\n", result);
printf("NULL output parameters to get all counters of PSE state machine. (result = %d)\n", result);
printf("openapiPoePsePortCountersGet() sanity successful. \n");
buffdesc.pstart = str;
buffdesc.size = sizeof(str);
printf("\n Testing openapiPoePethPsePortTimerCtrlClear(): \n");
printf("NULL Client Handle. (result = %d) \n", result);
printf("NULL interface. (result = %d) \n", result);
printf("openapiPoePethPsePortTimerCtrlClear() sanity successful. \n");
printf("\nTesting openapiPoePseMainPowerMgmtModeGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit number. (result = %d)\n", result);
printf("NULL pointer to mode. (result = %d)\n", result);
printf("openapiPoePseMainPowerMgmtModeGet() sanity successful. \n");
printf("\nTesting openapiPoePseMainPowerMgmtModeSet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit number. (result = %d)\n", result);
printf("Invalid mode. (result = %d)\n", result);
printf("openapiPoePseMainPowerMgmtModeSet() sanity successful. \n");
printf("\nTesting openapiPoePseMainConsumptionPowerGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit number. (result = %d)\n", result);
printf("NULL pointer to power. (result = %d)\n", result);
printf("openapiPoePseMainConsumptionPowerGet() sanity successful. \n");
printf("\nTesting openapiPoeFWImageVersionGet(): \n");
version.pstart = buf;
version.size = sizeof(buf);
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit. (result = %d)\n", result);
printf("Invalid NULL buffdesc. (result = %d)\n", result);
version.size = sizeof(buf) + 10;
printf("Invalid buffdesc size. (result = %d)\n", result);
version.size = sizeof(buf);
version.pstart = NULL;
printf("Invalid buffdesc pstart. (result = %d)\n", result);
printf("openapiPoeFWImageVersionGet() sanity successful. \n");
printf("\nTesting openapiPoePseMainOperStatusGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit. (result = %d)\n", result);
printf("NULL status pointer. (result = %d)\n", result);
printf("openapiPoePseMainOperStatusGet() sanity successful. \n");
printf("\nTesting openapiPoePseThresholdPowerGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit. (result = %d)\n", result);
printf("NULL value pointer. (result = %d)\n", result);
printf("openapiPoePseThresholdPowerGet() sanity successful. \n");
printf("\nTesting openapiPoePseTotalAvailablePowerGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit. (result = %d)\n", result);
printf("NULL value pointer. (result = %d)\n", result);
printf("openapiPoePseTotalAvailablePowerGet() sanity successful. \n");
printf("\nTesting openapiPoeTrapModeGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit. (result = %d)\n", result);
printf("NULL status pointer. (result = %d)\n", result);
printf("openapiPoeTrapModeGet() sanity successful. \n");
printf("\nTesting openapiPoePsePortTimerScheduleNameSet(): \n");
timerSchedule.pstart = timerScheduleBuf;
timerSchedule.size = sizeof(timerScheduleBuf);
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit. (result = %d)\n", result);
printf("Invalid interface. (result = %d)\n", result);
printf("Invalid NULL buffdesc. (result = %d)\n", result);
timerSchedule.size = sizeof(timerScheduleBuf) + 10;
printf("Invalid buffdesc size. (result = %d)\n", result);
timerSchedule.size = sizeof(timerScheduleBuf);
timerSchedule.pstart = NULL;
printf("Invalid buffdesc pstart. (result = %d)\n", result);
printf("\nTesting openapiPoePsePortTimerScheduleNameGet(): \n");
timerSchedule.pstart = timerScheduleBuf;
timerSchedule.size = sizeof(timerScheduleBuf);
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit. (result = %d)\n", result);
printf("Invalid interface. (result = %d)\n", result);
printf("Invalid NULL buffdesc. (result = %d)\n", result);
timerSchedule.size = sizeof(timerScheduleBuf) + 10;
printf("Invalid buffdesc size. (result = %d)\n", result);
timerSchedule.size = sizeof(timerScheduleBuf);
timerSchedule.pstart = NULL;
printf("Invalid buffdesc pstart. (result = %d)\n", result);
printf("\nTesting openapiPoePsePortReset(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit number to reset PoE on interface. (result = %d)\n", result);
printf("Invalid interface to reset PoE on interface. (result = %d)\n", result);
printf("openapiPoePsePortReset() sanity successful. \n");
printf("\nTesting openapiPoePseMainReset(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit number to reset PoE globally. (result = %d)\n", result);
printf("openapiPoePseMainReset() sanity successful. \n");
printf("\nTesting openapiPoePseMainPortAdminEnableSet (): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit. (result = %d)\n", result);
printf("openapiPoePseMainPortAdminEnableSet() sanity successful. \n");
printf("\nTesting openapiPoeTrapModeSet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit. (result = %d)\n", result);
printf("NULL status pointer. (result = %d)\n", result);
printf("openapiPoeTrapModeSet() sanity successful. \n");
printf("\nTesting openapiPoePseMainCurPowerPrioritySet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit. (result = %d)\n", result);
printf("openapiPoePseMainCurPowerPrioritySet() sanity successful. \n");
printf("\nTesting openapiPoePseMainCurPowerLimitSet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid unit. (result = %d)\n", result);
printf("openapiPoePseMainCurPowerLimitSet() sanity successful. \n");
}
int main(int argc, char **argv)
{
uint32_t testNum;
char switch_os_revision_string[100];
uint32_t arg1, arg2;
uint32_t unit = 0;
if (argc < 2)
{
printPOEAppMenu();
exit(1);
}
testNum = atoi(argv[1]);
l7proc_crashlog_register();
{
printf("\nFailed to initialize RPC to OpEN. Exiting (result = %d)\n", result);
exit(2);
}
{
sleep(1);
}
L7PROC_LOGF(L7PROC_LOG_SEVERITY_INFO, 0, "Starting PoE 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 != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poeFirstInterfaceGet(&clientHandle, arg1, unit);
break;
case 2:
if (argc != 2)
{
printPOEAppMenu();
exit(1);
}
poeIsSupported(&clientHandle, unit);
break;
case 3:
if (argc != 4)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
arg2 = atoi(argv[3]);
poeIsValidInterface(&clientHandle, arg1, arg2);
break;
case 4:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePsePortPowerClassificationsGet(&clientHandle, unit, arg1);
break;
case 5:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePsePortSensorsGet(&clientHandle, unit, arg1);
break;
case 6:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePsePortDetectionStatusGet(&clientHandle, unit, arg1);
break;
case 7:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePsePortErrorCodeGet(&clientHandle, arg1);
break;
case 8:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePsePortCountersGet(&clientHandle, arg1);
break;
case 9:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poeFindMaxPowerLimit(&clientHandle, unit, arg1);
break;
case 10:
if (argc != 2)
{
printPOEAppMenu();
exit(1);
}
poePseMainDetectionModeGet(&clientHandle, unit);
break;
case 11:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePseMainDetectionModeSet(&clientHandle, unit, arg1);
break;
case 12:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePsePortCurPowerLimitGet(&clientHandle, unit, arg1);
break;
case 13:
if (argc != 4)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
arg2 = atoi(argv[3]);
poePsePortCurPowerLimitSet(&clientHandle, unit, arg1, arg2);
break;
case 14:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePsePortCurPowerPriorityGet(&clientHandle, unit, arg1);
break;
case 15:
if (argc != 4)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
arg2 = atoi(argv[3]);
poePsePortCurPowerPrioritySet(&clientHandle, unit, arg1, arg2);
break;
case 16:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePsePortDetectionModeGet(&clientHandle, unit, arg1);
break;
case 17:
if (argc != 4)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
arg2 = atoi(argv[3]);
poePsePortDetectionModeSet(&clientHandle, unit, arg1, arg2);
break;
case 18:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePsePortHighPowerModeGet(&clientHandle, unit, arg1);
break;
case 19:
if (argc != 4)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
if (strcmp("enable", argv[3]) == 0)
{
arg2 = 1;
}
else if(strcmp("disable", argv[3]) == 0)
{
arg2 = 0;
}
else
{
printf("\nInvalid high-power mode\n\n");
printPOEAppMenu();
exit(1);
}
poePsePortHighPowerModeSet(&clientHandle, unit, arg1, arg2);
break;
case 20:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePsePortPowerUpModeGet(&clientHandle, unit, arg1);
break;
case 21:
if (argc != 4)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
if (strcmp("af", argv[3]) == 0)
{
}
else if (strcmp("high-inrush", argv[3]) == 0)
{
}
else if (strcmp("pre-at", argv[3]) == 0)
{
}
else if (strcmp("at", argv[3]) == 0)
{
}
else if (strcmp("upoe", argv[3]) == 0)
{
}
else
{
printf("\nInvalid power-up mode\n\n");
printPOEAppMenu();
exit(1);
}
poePsePortPowerUpModeSet(&clientHandle, unit, arg1, arg2);
break;
case 22:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePsePortViolationTypeGet(&clientHandle, unit, arg1);
break;
case 23:
if (argc != 4)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
arg2 = atoi(argv[3]);
poePsePortViolationTypeSet(&clientHandle, unit, arg1, arg2);
break;
case 24:
if (argc != 2)
{
printPOEAppMenu();
exit(1);
}
poePseMainUsageThresholdGet(&clientHandle, unit);
break;
case 25:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePseMainUsageThresholdSet(&clientHandle, unit, arg1);
break;
case 26:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePsePortAdminEnableGet(&clientHandle, arg1);
break;
case 27:
if (argc != 4)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
arg2 = atoi(argv[3]);
poePsePortAdminEnableSet(&clientHandle, arg1, arg2);
break;
case 28:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePseMgmtModeGet(&clientHandle, arg1);
break;
case 29:
if (argc != 4)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
if (0 == strcmp(argv[3], "static"))
{
}
else if (0 == strcmp(argv[3], "static-pri"))
{
}
else if (0 == strcmp(argv[3], "dynamic"))
{
}
else if (0 == strcmp(argv[3], "dynamic-pri"))
{
}
else if (0 == strcmp(argv[3], "class"))
{
}
else
{
printPOEAppMenu();
exit(1);
}
poePseMgmtModeSet(&clientHandle, arg1, arg2);
break;
case 30:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePseMainConsumptionPowerGet(&clientHandle, arg1);
break;
case 31:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poeFWImageVersionGet(&clientHandle, arg1);
break;
case 32:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePseMainOperStatusGet(&clientHandle, arg1);
break;
case 33:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePseThresholdPowerGet(&clientHandle, arg1);
break;
case 34:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePseTotalAvailablePowerGet(&clientHandle, arg1);
break;
case 35:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
trapPoeGet(&clientHandle, arg1);
break;
case 36:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePortTimerScheduleNameGet(&clientHandle, unit, arg1);
break;
case 37:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePortReset(&clientHandle, unit, arg1);
break;
case 38:
if (argc != 2)
{
printPOEAppMenu();
exit(1);
}
poeReset(&clientHandle, unit);
break;
case 39:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
if (0 == strcmp(argv[2], "enabled"))
{
}
else if (0 == strcmp(argv[2], "disabled"))
{
}
else
{
printPOEAppMenu();
exit(1);
}
poePseMainAdminEnableSet(&clientHandle, unit, arg1);
break;
case 40:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
if (0 == strcmp(argv[2], "enabled"))
{
}
else if (0 == strcmp(argv[2], "disabled"))
{
}
else
{
printPOEAppMenu();
exit(1);
}
trapPoeSet(&clientHandle, unit, arg1);
break;
case 41:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
if (0 == strcmp(argv[2], "critical"))
{
}
else if (0 == strcmp(argv[2], "high"))
{
}
else if (0 == strcmp(argv[2], "medium"))
{
}
else if (0 == strcmp(argv[2], "low"))
{
}
else
{
printPOEAppMenu();
exit(1);
}
poePseMainCurPowerPrioritySet(&clientHandle, unit, arg1);
break;
case 42:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePseMainCurPowerLimitSet(&clientHandle, unit, arg1);
break;
case 43:
if (argc != 3)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePethPsePortTimerCtrlClear(&clientHandle, arg1);
break;
case 44:
if (argc != 4)
{
printPOEAppMenu();
exit(1);
}
arg1 = atoi(argv[2]);
poePortTimerScheduleNameSet(&clientHandle, unit, arg1, argv[3]);
break;
case 45:
if (argc != 2)
{
printPOEAppMenu();
exit(1);
}
poeOpENAPIsSanity(&clientHandle);
break;
default:
printPOEAppMenu();
break;
}
L7PROC_LOGF(L7PROC_LOG_SEVERITY_INFO, 0, "Stopping PoE API example application");
return 0;
}