#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include "rpcclt_openapi.h"
#include "proc_util.h"
#define DISP_BUF_SIZE 1024
static void printAppMenu(char *name)
{
printf("Usage: %s <test#> <arg1> <arg2> ... \n", name);
printf("Test 1: Set the authentication manager Dynamic Vlan Creation Mode: %s 1 <dynamicVlanMode>\n", name);
printf("Test 2: Set the authentication manager Vlan Assignment Mode: %s 2 <vlanAssignmentMode>\n", name);
printf("Test 3: Set authentication manager method order: %s 3 <intIfNum><index><method>\n", name);
printf("Test 4: Set authentication manager method priority: %s 4 <intIfNum><index><method>\n", name);
printf("Test 5: Set the max users for the port: %s 5 <intIfNum><maxUsers>\n", name);
printf("Test 6: Set the authentication fail action (Unauthenticated vlan) value: %s 6 <intIfNum><vlanId>\n", name);
printf("Test 7: Display the authentication interface params: %s 7 <intIfNum>\n", name);
printf("Test 8: Display the authenticated clients info: %s 8 <intIfNum>\n", name);
printf("Test 9: Set authentication port configured control mode: %s 9 <intIfNum> <mode>\n", name);
printf("Test 10: Set authentication manager admin mode: %s 10 <mode>\n", name);
printf("Test 11: Set authentication manager host mode: %s 11 <intIfNum> <mode>\n", name);
printf("Test 12: Set authentication manager port guest VLAN ID: %s 12 <intIfNum> <vlan>\n", name);
printf("Test 13: Set authentication manager authentication periodic: %s 13 <intIfNum> <mode>\n", name);
printf("Test 14: Set authentication manager reauthentication periodic: %s 14 <intIfNum> <mode>\n", name);
printf("Test 15: Set authentication manager reauth period from server: %s 15 <intIfNum> <mode>\n", name);
printf("Test 16: Set the max number of failed authentication attempts value on the specified port: %s 16 <intIfNum> <maxAuthAttempts>\n", name);
printf("Test 17: Display the authentication manager authentication history table for all interfaces: %s 17\n", name);
printf("Test 18: Display the authentication manager authentication history table for all interfaces in reverse order: %s 18\n", name);
printf("Test 19: Display the authentication manager authentication history table on the specified port: %s 19 <intIfNum>\n", name);
printf("Test 20: Clear the authentication manager authentication history table on all interfaces: %s 20\n", name);
printf("Test 21: Clear the authentication manager authentication history table on the specified port: %s 21 <intIfNum>\n", name);
printf("Test 22: Run API sanity checks: %s 22 \n", name);
printf("Test 23: To initialize (or) re-authenticate the specific interface: %s 10 <intIfNum> <initialize>\n", name);
printf("Test 24: Sets the authentication admin control direction on the specified port: %s 11 <intIfNum> <cntrlDir>\n", name);
printf("Test 25: Gets Auth manager admin control direction on the specified port: %s 12 <intIfNum>\n", name);
return;
}
{
uint32_t index = 1;
uint32_t vlanType;
uint32_t timeLeft;
uint32_t clientsCount;
uint32_t terminationAction;
uint32_t vlanId;
uint32_t maxAuthAttempts;
uint32_t reAuthPeriod;
uint32_t sessionTimeout;
uint32_t sessionTime;
uint32_t maxUsers;
uint32_t intIfNum = 100;
uint32_t lIntIfNum;
char buffer[128];
uint32_t entryIndex = 0;
uint32_t reasonCode = 0;
char strTimestamp[256];
char reasonCodeStr[512];
badBufdescPointer.
pstart = (
void *) NULL;
badBufdescPointer.
size =
sizeof(buffer);
buf.pstart = buffer;
buf.size = sizeof(buffer);
zeroLenBuf.pstart = buffer;
zeroLenBuf.size = 0;
timeStamp.pstart = strTimestamp;
timeStamp.size = sizeof(strTimestamp);
reasonCodeBuff.pstart = reasonCodeStr;
reasonCodeBuff.size = sizeof(reasonCodeStr);
printf("Testing authmgr OpEN APIs sanity:\n");
printf("Testing openapiAuthMgrDynamicVlanCreationModeGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 2:(result = %d)\n", result);
printf("Testing openapiAuthMgrVlanAssignmentModeGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 2:(result = %d)\n", result);
printf("Testing openapiAuthMgrPortAuthMethodOrderGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 4:(result = %d)\n", result);
printf("Testing openapiAuthMgrPortAuthMethodPriorityGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 4:(result = %d)\n", result);
printf("Testing openapiAuthMgrPortMaxUsersGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrPortUnauthenticatedVlanGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrPortMaxAuthAttemptsGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrEnabledMethodGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 4:(result = %d)\n", result);
printf("Testing openapiAuthMgrEnabledPriorityGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 4:(result = %d)\n", result);
printf("Testing openapiAuthMgrNumClientsGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrLogicalPortClientMacAddrGet():\n");
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 openapiAuthMgrLogicalPortClientAuthStatusGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrLogicalPortClientAuthStateGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrLogicalPortClientReauthStateGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrLogicalPortUserNameGet():\n");
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 openapiAuthMgrLogicalPortClientAuthenticatedMethodGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrLogicalPortClientVlanTypeGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrLogicalPortSessionTimeGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrLogicalPortSessionTimeoutGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthmgrLogicalPortTimeLeftForTerminateActionGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrLogicalPortTerminationActionGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrLogicalPortFilterIdGet():\n");
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 openapiAuthMgrAuthenticationReAuthPeriodFromSeverGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrAuthenticationReAuthPeriodGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrLogicalPortFirstGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrLogicalPortNextGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiAuthMgrHistoryLogIndexNextGet():\n");
printf("NULL argument 1(client handle) :(result = %d)\n", result);
printf("NULL argument 2(intIfNum):(result = %d)\n", result);
printf("NULL argument 3(entryIndex):(result = %d)\n", result);
printf("Testing openapiAuthMgrHistoryLogReverseIndexNextGet():\n");
printf("NULL argument 1(client handle) :(result = %d)\n", result);
printf("NULL argument 2(intIfNum):(result = %d)\n", result);
printf("NULL argument 3(entryIndex):(result = %d)\n", result);
printf("Testing openapiAuthMgrHistoryLogEntryIsValid():\n");
printf("NULL argument 1(client handle) :(result = %d)\n", result);
printf("Testing openapiAuthMgrHistoryLogInterfacePurge():\n");
printf("NULL argument 1(client handle) :(result = %d)\n", result);
printf("Testing openapiAuthMgrHistoryLogPurgeAll():\n");
printf("NULL argument 1(client handle) :(result = %d)\n", result);
printf("Testing openapiAuthMgrHistoryLogTimestampGet():\n");
printf("NULL argument 1(client handle) :(result = %d)\n", result);
printf("NULL argument 4(timeStamp) :(result = %d)\n", result);
printf("NULL buffdesc pstart argument 4(timeStamp) :(result = %d)\n", result);
printf("buffdesc 0 length size argument 4(timeStamp) :(result = %d)\n", result);
printf("Testing openapiAuthMgrHistoryLogMethodGet():\n");
printf("NULL argument 1(client handle) :(result = %d)\n", result);
printf("NULL argument 4(method) :(result = %d)\n", result);
printf("Testing openapiAuthMgrHistoryLogReasonCodeGet():\n");
printf("NULL argument 1(client handle) :(result = %d)\n", result);
printf("NULL argument 4(reasonCode) :(result = %d)\n", result);
printf("Testing openapiAuthMgrHistoryLogReasonStringGet():\n");
reasonCode, &reasonCodeBuff);
printf("NULL argument 1(client handle) :(result = %d)\n", result);
entryIndex, reasonCode, NULL);
printf("NULL argument 5(reasonCodeStr) :(result = %d)\n", result);
entryIndex, reasonCode, &badBufdescPointer);
printf("NULL buffdesc pstart argument 5(reasonCodeStr) :(result = %d)\n", result);
entryIndex, reasonCode, &zeroLenBuf);
printf("buffdesc 0 length size argument 5(reasonCodeStr) :(result = %d)\n", result);
printf("Testing openapiAuthMgrHistoryLogAuthStatusGet():\n");
printf("NULL argument 1(client handle) :(result = %d)\n", result);
printf("NULL argument 4(authStatus) :(result = %d)\n", result);
printf("Testing openapiAuthMgrHistoryLogClientMacAddressGet():\n");
printf("NULL argument 1(client handle) :(result = %d)\n", result);
printf("NULL argument 4(macAddress) :(result = %d)\n", result);
&badBufdescPointer);
printf("NULL buffdesc pstart argument 4(macAddress) :(result = %d)\n", result);
&zeroLenBuf);
printf("buffdesc 0 length size argument 4(macAddress) :(result = %d)\n", result);
printf("Testing openapiAuthMgrHistoryLogVlanIdGet():\n");
printf("NULL argument 1(client handle) :(result = %d)\n", result);
printf("NULL argument 4(vlanId) :(result = %d)\n", result);
printf("Testing openapiAuthMgrHistoryLogVlanAssignedTypeGet():\n");
&vlanAssignedType);
printf("NULL argument 1(client handle) :(result = %d)\n", result);
entryIndex, NULL);
printf("NULL argument 4(vlanAssignedType):(result = %d)\n", result);
printf("Testing openapiAuthMgrHistoryLogFilterIdGet():\n");
printf("NULL argument 1(client handle) :(result = %d)\n", result);
printf("NULL argument 4(filterId) :(result = %d)\n", result);
&badBufdescPointer);
printf("NULL buffdesc pstart argument 4(filterId) :(result = %d)\n", result);
&zeroLenBuf);
printf("buffdesc 0 length size argument 4(filterId) :(result = %d)\n", result);
printf("Testing openapiAuthMgrPortAdminControlledDirectionsGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Authmgr OpEN APIs sanity done.\n");
return;
}
{
{
printf("Bad return code trying to set the authentication manager Dynamic Vlan Creation Mode (result = %d)\n", result);
}
else
{
printf(
"Authentication manager Dynamic Vlan Creation Mode is successfully %s\n", (
OPEN_ENABLE == dynamicVlanMode) ?
"enabled" :
"disabled");
}
return;
}
{
{
printf("Bad return code trying to set the authentication manager Vlan Assignment Mode (result = %d)\n", result);
}
else
{
printf(
"Authentication manager Vlan Assignment Mode is successfully %s\n", (
OPEN_ENABLE == vlanAssignmentMode) ?
"enabled" :
"disabled");
}
return;
}
{
{
printf("Bad return code trying to set authentication manager method order (result = %d)\n", result);
}
else
{
printf("Authentication manager method order successfully set.\n");
}
return;
}
{
{
printf("Bad return code trying to set authentication manager method priority (result = %d)\n", result);
}
else
{
printf("Authentication manager method priority successfully set.\n");
}
return;
}
{
{
printf("Bad return code trying to set the max users for the port (result = %d)\n", result);
}
else
{
printf("Setting of max users per port is succeeded. \n");
}
return;
}
void authMgrPortUnauthenticatedVlanSet(
openapiClientHandle_t *clientHandle, uint32_t intIfNum, uint32_t vlanId)
{
{
printf("Bad return code trying to set the Authentication fail action (Unauthenticated vlan) value (result = %d)\n", result);
}
else
{
printf("Authentication fail action (Unauthenticated vlan) value successfully set.\n");
}
return;
}
void authMgrPortMaxAuthAttemptsSet(
openapiClientHandle_t *clientHandle, uint32_t intIfNum, uint32_t maxAuthAttempts)
{
{
printf("Bad return code trying to set the max number of failed authentication attempts value on the specified port (result = %d)\n", result);
}
else
{
printf("Max number of failed authentication attempts value successfully set.\n");
}
return;
}
{
char buf[100];
char strFilter[256];
uint32_t vlanId;
uint32_t authStatus = 0, authState = 0, sessionTime = 0;
uint32_t sessionTimeout = 0, timeLeft = 0, terminationAction = 0;
memset(buf, '\0', sizeof(buf));
buffDesc.pstart = buf;
buffDesc.size = sizeof(buf);
memset(strFilter, '\0', sizeof(strFilter));
filterId.pstart = strFilter;
filterId.size = sizeof(strFilter);
{
printf ("Failed to get mac address for logical port %d \r\n", lIntIfNum);
return;
}
printf ("\r\n");
printf ("Mac address : %02X:%02X:%02X:%02X:%02X:%02X\r\n",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
{
printf ("Failed to get username for logical port %d \r\n", lIntIfNum);
return;
}
{
memset(userName, '\0', sizeof(userName));
buffDesc.pstart = userName;
buffDesc.size = sizeof(userName);
{
printf ("Failed to get username for logical port %d \r\n", lIntIfNum);
return;
}
printf("Username : %s\r\n", userName);
{
printf ("Failed to get auth state for logical port %d \r\n", lIntIfNum);
return;
}
{
printf ("Failed to get reAuthState for logical port %d \r\n", lIntIfNum);
return;
}
printf(
"Reauth State : %s \r\n", (reAuthState ==
OPEN_ENABLE) ?
"True" :
"False");
{
printf ("Failed to get authenticated method for logical port %d \r\n", lIntIfNum);
return;
}
{
printf ("Failed to get authenticated vlan and assignment reason for logical port %d \r\n", lIntIfNum);
return;
}
printf("Vlan Id : %d \r\n", vlanId);
{
printf ("Failed to get authenticated client's session time for logical port %d \r\n", lIntIfNum);
return;
}
printf("Session Time : %d \r\n", sessionTime);
{
printf ("Failed to get authenticated client's session timeout for logical port %d \r\n", lIntIfNum);
return;
}
printf("Session Timeout : %d \r\n", sessionTimeout);
{
printf ("Failed to get authenticated client's termination action for logical port %d \r\n", lIntIfNum);
return;
}
{
printf ("Failed to get time left for termination action for logical port %d \r\n", lIntIfNum);
return;
}
printf("Time left for Termination action : %d \r\n", timeLeft);
{
printf ("Failed to Filter-id for logical port %d \r\n", lIntIfNum);
return;
}
printf("Filter-Id : %s \r\n", (char *)filterId.pstart);
printf ("\n=========================\r\n");
}
else
{
printf("The authentication is still in progress for this client\r\n");
}
}
{
uint32_t lIntIfNum;
{
printf ("No clients are present on interface %d\r\n", intIfNum);
return;
}
do
{
authMgrAuthenticationClientsShow(client_handle, lIntIfNum);
}
{
uint32_t adminMode = 0, reAuthPeriod, clientsCount = 0;
char val[DISP_BUF_SIZE];
char *buf;
uint32_t len = 0, remLen = 0, idx = 0;
printf("Display the global and interface parameters of the port \n\n");
printf("===== Global Parameters ===== \n");
{
printf("Bad return code trying to get the admin mode (result = %d)\n", result);
return;
}
printf(
"\nAuthentication Enable : %s \n", (adminMode ==
OPEN_ENABLE)?
"Enabled":
"Disabled");
{
printf("Bad return code trying to get the dynamic VLAN creation mode (result = %d)\n", result);
return;
}
printf(
"\nDynamic VLAN Creation Mode : %s \n", (adminMode ==
OPEN_ENABLE)?
"Enabled":
"Disabled");
{
printf("Bad return code trying to get the dynamic VLAN creation mode (result = %d)\n", result);
return;
}
printf(
"\nDynamic VLAN-Port Assignment Mode : %s \n", (adminMode ==
OPEN_ENABLE)?
"Enabled":
"Disabled");
{
printf("Bad return code trying to get the port control mode (result = %d)\n", result);
return;
}
memset(val, '\0', sizeof(val));
switch (portControl)
{
strncpy(val, "auto", strlen("auto")+1);
break;
strncpy(val, "force-authorized", strlen("force-authorized")+1);
break;
strncpy(val, "force-unauthorized", strlen("force-unauthorized")+1);
break;
default:
strncpy(val, "none", strlen("none")+1);
break;
}
printf("\nPort Control Mode : %s \r\n", val);
{
printf("Bad return code trying to get the port control mode (result = %d)\n", result);
return;
}
memset(val, '\0', sizeof(DISP_BUF_SIZE));
switch (hostMode)
{
strncpy(val, "single-auth", strlen("single-auth")+1);
break;
strncpy(val, "multi-auth", strlen("multi-auth")+1);
break;
strncpy(val, "multi-host", strlen("multi-host")+1);
break;
strncpy(val, "multi-domain-multi-host", strlen("multi-domain-multi-host")+1);
break;
default:
strncpy(val, "none", strlen("none")+1);
break;
}
printf("\nHost Mode : %s \r\n", val);
memset(val, '\0', sizeof(DISP_BUF_SIZE));
remLen = DISP_BUF_SIZE -1;
buf = &val[0];
len = snprintf(buf, remLen, "Configured Methods : ");
remLen = remLen - len;
buf = buf + len;
for (idx = 0; idx <= 2; idx++)
{
len = 0;
{
switch (method)
{
len = snprintf(buf, remLen, "802.1X");
break;
len = snprintf(buf, remLen, "MAB");
break;
len = snprintf(buf, remLen, "Captive-Portal");
break;
default:
len = snprintf(buf, remLen, "undefined");
break;
}
}
buf += len;
remLen = remLen - len;
len = 0;
len = snprintf(buf, remLen, " ");
buf += len;
remLen = remLen - len;
}
printf("\r\n %s \r\n", val);
memset(val, '\0', sizeof(DISP_BUF_SIZE));
remLen = DISP_BUF_SIZE -1;
buf = &val[0];
len = snprintf(buf, remLen, "Configured Priority : ");
remLen = remLen - len;
buf = buf + len;
for (idx = 0; idx <= 2; idx++)
{
len = 0;
{
switch (method)
{
len = snprintf(buf, remLen, "802.1X");
break;
len = snprintf(buf, remLen, "MAB");
break;
len = snprintf(buf, remLen, "Captive-Portal");
break;
default:
len = snprintf(buf, remLen, "undefined");
break;
}
}
buf += len;
remLen = remLen - len;
len = 0;
len = snprintf(buf, remLen, " ");
buf += len;
remLen = remLen - len;
}
printf("\r\n %s \r\n", val);
memset(val, '\0', sizeof(DISP_BUF_SIZE));
remLen = DISP_BUF_SIZE -1;
buf = &val[0];
len = snprintf(buf, remLen, "Enabled methods : ");
remLen = remLen - len;
buf = buf + len;
for (idx = 0; idx <= 2; idx++)
{
len = 0;
{
switch (method)
{
len = snprintf(buf, remLen, "802.1X");
break;
len = snprintf(buf, remLen, "MAB");
break;
len = snprintf(buf, remLen, "Captive-Portal");
break;
default:
len = snprintf(buf, remLen, "undefined");
break;
}
}
buf += len;
remLen = remLen - len;
len = 0;
len = snprintf(buf, remLen, " ");
buf += len;
remLen = remLen - len;
}
printf("\r\n %s \r\n", val);
memset(val, '\0', sizeof(DISP_BUF_SIZE));
remLen = DISP_BUF_SIZE -1;
buf = &val[0];
len = snprintf(buf, remLen, "Enabled priority : ");
remLen = remLen - len;
buf = buf + len;
for (idx = 0; idx <= 2; idx++)
{
len = 0;
{
switch (method)
{
len = snprintf(buf, remLen, "802.1X");
break;
len = snprintf(buf, remLen, "MAB");
break;
len = snprintf(buf, remLen, "Captive-Portal");
break;
default:
len = snprintf(buf, remLen, "undefined");
break;
}
}
buf += len;
remLen = remLen - len;
len = 0;
len = snprintf(buf, remLen, " ");
buf += len;
remLen = remLen - len;
}
printf("\r\n %s \r\n", val);
{
printf("Bad return code trying to get the Reauthentication Periodic status (result = %d)\n", result);
return;
}
printf(
"\nReauthentication Enabled : %s\r\n", (
OPEN_TRUE == mode) ?
"True" :
"False");
{
printf("Bad return code trying to get the Reauthentication Periodic (result = %d)\n", result);
return;
}
printf("\nReauthentication Period : %d\r\n", reAuthPeriod);
{
printf("Bad return code trying to get the session timeout from Radius Server (result = %d)\n", result);
return;
}
printf(
"\nSession Timeout from Radius Server Enabled : %s\r\n", (
OPEN_TRUE == mode) ?
"True" :
"False");
reAuthPeriod = 0;
{
printf("Bad return code trying to get the max users ");
return;
}
printf("\nMax Users : %d\r\n", reAuthPeriod);
reAuthPeriod = 0;
{
printf("Bad return code trying to get the Guest VLAN Id ");
return;
}
printf("\nGuest VLAN Id : %d\r\n", reAuthPeriod);
reAuthPeriod = 0;
{
printf("Bad return code trying to get the Unauth VLAN Id ");
return;
}
printf("\nUnauth VLAN Id : %d\r\n", reAuthPeriod);
reAuthPeriod = 0;
{
printf("Bad return code trying to get the Max auth retry Attempts ");
return;
}
printf("\nMax Auth retry attempts : %d\r\n", reAuthPeriod);
{
printf ("Failed to get number of clients authenticated for logical port %d \r\n", intIfNum);
return;
}
printf("\nNumber of Authenticated clients : %d \r\n", clientsCount);
printf ("\n=========================\r\n");
printf ("\r\n");
return;
}
{
uint32_t ifNum;
if (argc < 4)
{
printf("Interface and mode parameters required.\n");
return;
}
errno = 0;
ifNum = strtoul(argv[2], NULL, 0);
if (errno != 0)
{
printf("Invalid interface parameter: (%s)\n", argv[2]);
return;
}
errno = 0;
mode = strtoul(argv[3], NULL, 0);
if (errno != 0)
{
printf("Invalid mode parameter: (%s)\n", argv[3]);
return;
}
{
printf("Bad return code trying to set port control mode (result = %d)\n", result);
}
else
{
printf("port control mode set. (result = %d)\n", result);
}
return;
}
{
printf("0 %s, 1 %s, 2 %s \n", argv[0], argv[1], argv[2]);
if (argc < 3)
{
printf("Mode parameter required.\n");
return;
}
errno = 0;
mode = strtoul(argv[2], NULL, 0);
if (errno != 0)
{
printf("Invalid mode parameter: (%s)\n", argv[2]);
return;
}
{
printf("Bad return code trying to set authentication manager admin mode (result = %d)\n", result);
}
else
{
printf("authentication manager admin mode set. (result = %d)\n", result);
}
return;
}
{
uint32_t ifNum;
if (argc < 4)
{
printf("Interface and enable parameters required.\n");
return;
}
errno = 0;
ifNum = strtoul(argv[2], NULL, 0);
if (errno != 0)
{
printf("Invalid interface parameter: (%s)\n", argv[2]);
return;
}
errno = 0;
mode = strtoul(argv[3], NULL, 0);
if (errno != 0)
{
printf("Invalid mode parameter: (%s)\n", argv[3]);
return;
}
{
printf("Bad return code trying to set port host mode configuration (result = %d)\n", result);
}
else
{
printf("Port host mode configuration set. (result = %d)\n", result);
}
return;
}
{
uint32_t ifNum;
uint32_t vlan;
if (argc < 4)
{
printf("Interface and VLAN ID parameters required.\n");
return;
}
errno = 0;
ifNum = strtoul(argv[2], NULL, 0);
if (errno != 0)
{
printf("Invalid interface parameter: (%s)\n", argv[2]);
return;
}
errno = 0;
vlan = strtoul(argv[3], NULL, 0);
if (errno != 0)
{
printf("Invalid VLAN ID parameter: (%s)\n", argv[3]);
return;
}
{
printf("Bad return code trying to set port guest VLAN ID (result = %d)\n", result);
}
else
{
printf("Port guest VLAN ID set. (result = %d)\n", result);
}
return;
}
{
uint32_t ifNum;
if (argc < 4)
{
printf("Interface and enable parameters required.\n");
return;
}
errno = 0;
ifNum = strtoul(argv[2], NULL, 0);
if (errno != 0)
{
printf("Invalid interface parameter: (%s)\n", argv[2]);
return;
}
errno = 0;
val = strtoul(argv[3], NULL, 0);
if (errno != 0)
{
printf("Invalid mode parameter: (%s)\n", argv[3]);
return;
}
{
printf("Bad return code trying to set periodic authentication configuration (result = %d)\n", result);
}
else
{
printf("periodic authentication configuration set. (result = %d)\n", result);
}
return;
}
{
uint32_t ifNum;
uint32_t val;
if (argc < 4)
{
printf("Interface and enable parameters required.\n");
return;
}
errno = 0;
ifNum = strtoul(argv[2], NULL, 0);
if (errno != 0)
{
printf("Invalid interface parameter: (%s)\n", argv[2]);
return;
}
errno = 0;
val = strtoul(argv[3], NULL, 0);
if (errno != 0)
{
printf("Invalid mode parameter: (%s)\n", argv[3]);
return;
}
{
printf("Bad return code trying to set reauthentication period configuration (result = %d)\n", result);
}
else
{
printf("Reauthentication period configuration set. (result = %d)\n", result);
}
return;
}
{
uint32_t ifNum;
uint32_t val;
if (argc < 4)
{
printf("Interface and enable parameters required.\n");
return;
}
errno = 0;
ifNum = strtoul(argv[2], NULL, 0);
if (errno != 0)
{
printf("Invalid interface parameter: (%s)\n", argv[2]);
return;
}
errno = 0;
val = strtoul(argv[3], NULL, 0);
if (errno != 0)
{
printf("Invalid mode parameter: (%s)\n", argv[3]);
return;
}
{
printf("Bad return code trying to set reauthentication period from server configuration (result = %d)\n", result);
}
else
{
printf("Reauthentication period from server configuration set. (result = %d)\n", result);
}
return;
}
uint32_t intIfNum,
uint32_t entryIndex)
{
char mac[100];
char strFilter[256];
char strTimeStamp[256];
char strReason[512];
char strVlanAssignedType[64];
uint32_t vlanId = 0, reasonCode = 0, authStatus = 0;
char intfNameStr[256];
memset(intfNameStr, 0, sizeof(intfNameStr));
intfName.pstart = intfNameStr;
intfName.size = sizeof(intfNameStr);
memset(strVlanAssignedType, '\0', sizeof(strVlanAssignedType));
memset(mac, '\0', sizeof(mac));
buffDesc.pstart = mac;
buffDesc.size = sizeof(mac);
memset(strFilter, '\0', sizeof(strFilter));
filterId.pstart = strFilter;
filterId.size = sizeof(strFilter);
memset(strTimeStamp, '\0', sizeof(strTimeStamp));
timeStamp.pstart = strTimeStamp;
timeStamp.size = sizeof(strTimeStamp);
memset(strReason, '\0', sizeof(strReason));
reason.pstart = strReason;
reason.size = sizeof(strReason);
{
printf("Bad return code trying to get interface name for %d interface. "
"(result = %d)\n", intIfNum, result);
snprintf(intfNameStr, sizeof(intfNameStr), "%s", "Unknown");
}
{
printf("No valid authentication history is present for the specified port:%s(%d) "
"and entry index:%d result:%d\r\n",
intfNameStr, intIfNum, entryIndex, result);
return;
}
printf ("\r\n");
printf ("Interface: %s(%d)\r\n", intfNameStr, intIfNum);
entryIndex, &timeStamp);
{
printf ("Failed to get time stamp for port:%s(%d) result:%d\r\n",
intfNameStr, intIfNum, result);
return;
}
printf ("Time Stamp : %s\r\n", strTimeStamp);
entryIndex, &buffDesc);
{
printf ("Failed to get MAC address for port:%s(%d) result:%d\r\n",
intfNameStr, intIfNum, result);
return;
}
printf ("\r\n");
printf ("MAC address : %s\r\n", mac);
{
printf ("Failed to get authentication method for port:%s(%d) result:%d\r\n",
intfNameStr, intIfNum, result);
return;
}
printf ("\r\n");
{
printf ("Failed to get authentication status for port:%s(%d) result:%d\r\n",
intfNameStr, intIfNum, result);
return;
}
printf ("\r\n");
{
printf ("Failed to get VLAN ID for port:%s(%d) result:%d\r\n",
intfNameStr, intIfNum, result);
return;
}
printf ("\r\n");
printf("VLAN ID : %d \r\n", vlanId);
entryIndex, &vlanAssignedType);
{
printf ("Failed to get VLAN assigned type for port:%s(%d) result:%d\r\n",
intfNameStr, intIfNum, result);
return;
}
switch (vlanAssignedType)
{
snprintf(strVlanAssignedType, sizeof(strVlanAssignedType), "%s", "Default Assigned VLAN");
break;
snprintf(strVlanAssignedType, sizeof(strVlanAssignedType), "%s", "Radius Assigned VLAN");
break;
snprintf(strVlanAssignedType, sizeof(strVlanAssignedType), "%s", "Unauthenticated VLAN");
break;
snprintf(strVlanAssignedType, sizeof(strVlanAssignedType), "%s", "Critical VLAN");
break;
snprintf(strVlanAssignedType, sizeof(strVlanAssignedType), "%s", "Guest VLAN");
break;
snprintf(strVlanAssignedType, sizeof(strVlanAssignedType), "%s", "Voice VLAN");
break;
snprintf(strVlanAssignedType, sizeof(strVlanAssignedType), "%s", "Monitor Mode VLAN");
break;
default:
snprintf(strVlanAssignedType, sizeof(strVlanAssignedType), "%s", "Not Assigned");
break;
}
printf ("\r\n");
printf("Vlan Assigned Type : %s \r\n", strVlanAssignedType);
entryIndex, &reasonCode);
{
printf ("Failed to get reason code for port:%s(%d) result:%d\r\n",
intfNameStr, intIfNum, result);
return;
}
entryIndex, reasonCode, &reason);
{
printf ("Failed to get reason string for port:%s(%d) for reason:%s result:%d\r\n",
intfNameStr, intIfNum,(char*)reason.pstart, result);
return;
}
printf ("\r\n");
printf("Reason (code) : %s (%d) \r\n", strReason, reasonCode);
entryIndex, &filterId);
{
printf ("Failed to get Filter ID for port:%s(%d) result:%d\r\n",
intfNameStr, intIfNum, result);
return;
}
printf ("\r\n");
printf("Filter ID: %s \r\n", strFilter);
return;
}
{
uint32_t entryIndex = 0;
uint32_t intIfNum = 0;
&intIfNum, &entryIndex))
{
printf ("No authentication history is present on the switch.\r\n");
return;
}
printf("\r\nAuthentication Manager Authentication History details:\r\n");
do
{
authMgrAuthenticationHistoryLogShow(client_handle, intIfNum, entryIndex);
printf ("\r\n");
&intIfNum, &entryIndex));
}
uint32_t intIfNum)
{
uint32_t entryIndex = 0;
uint32_t intf = 0;
&intf, &entryIndex))
{
printf ("No authentication history is present on the switch for port:%d.\r\n", intIfNum);
return;
}
printf("\r\nAuthentication Manager Authentication History details:\r\n");
do
{
if (intf == intIfNum)
{
authMgrAuthenticationHistoryLogShow(client_handle, intIfNum, entryIndex);
printf ("\r\n");
}
&intf, &entryIndex));
}
{
uint32_t entryIndex = 0;
uint32_t intIfNum = 0;
&intIfNum, &entryIndex))
{
printf ("No authentication history is present on the switch.\r\n");
return;
}
printf("\r\nAuthentication Manager Authentication History details:\r\n");
do
{
authMgrAuthenticationHistoryLogShow(client_handle, intIfNum, entryIndex);
printf ("\r\n");
&intIfNum, &entryIndex));
}
uint32_t intIfNum)
{
{
printf("Bad return code trying to clearing the history table for the "
"port %d (result = %d)\r\n", intIfNum, result);
}
else
{
printf("Authentication history table is cleared on the port %d\r\n", intIfNum);
}
return;
}
{
{
printf("Bad return code trying to clearing the history table on all "
"the ports (result = %d)\r\n", result);
}
else
{
printf("Authentication history table is cleared on all the ports.\r\n");
}
return;
}
void
{
{
printf("Bad return code trying to to initialize (or) re-authenticate "
"the specific interface. (result = %d)\n", result);
}
else
{
printf("Initialize (or) re-authenticate is successfully set on interface %d.\n",
intIfNum);
}
return;
}
void
uint32_t intIfNum,
{
{
printf("Bad return code trying to sets the authentication admin control "
"direction on the specified port. (result = %d)\n", result);
}
else
{
printf("Authentication admin control direction %d is successfully set on interface %d.\n",
cntrlDir, intIfNum);
}
return;
}
void
uint32_t intIfNum,
{
{
printf("Bad return code trying to gets Auth manager admin control "
"direction on the specified port. (result = %d)\n", result);
}
else
{
printf("Auth manager admin control direction of %d is successfully fetched on interface %d.\n",
*pCntrlDir, intIfNum);
}
return;
}
int main(int argc, char **argv)
{
uint32_t testNum;
char switch_os_revision_string[100];
int show_help = 1;
uint32_t recvMode;
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 authmgr 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)
{
recvMode = atoi(argv[2]);
if ((0 == recvMode) || (1 == recvMode))
{
authMgrDynamicVlanCreationModeSet(&clientHandle, mode);
}
show_help = 0;
}
break;
case 2:
if (argc == 3)
{
recvMode = atoi(argv[2]);
if ((0 == recvMode) || (1 == recvMode))
{
authMgrVlanAssignmentModeSet(&clientHandle, mode);
}
show_help = 0;
}
case 3:
if (argc == 5)
{
authMgrPortAuthMethodOrderSet(&clientHandle, atoi(argv[2]), atoi(argv[3]), atoi(argv[4]));
show_help = 0;
}
break;
case 4:
if (argc == 5)
{
authMgrPortAuthMethodPrioritySet(&clientHandle, atoi(argv[2]), atoi(argv[3]), atoi(argv[4]));
show_help = 0;
}
break;
case 5:
if (argc == 4)
{
authMgrPortMaxUsersSet(&clientHandle, atoi(argv[2]), atoi(argv[3]));
show_help = 0;
}
break;
case 6:
if (argc == 4)
{
authMgrPortUnauthenticatedVlanSet(&clientHandle, atoi(argv[2]), atoi(argv[3]));
show_help = 0;
}
break;
case 7:
if (argc == 3)
{
authMgrAuthenticationInterfaceShow(&clientHandle, atoi(argv[2]));
show_help = 0;
}
break;
case 8:
if (argc == 3)
{
authMgrAuthenticationClientsDisplay(&clientHandle, atoi(argv[2]));
show_help = 0;
}
break;
case 9:
if (argc == 4)
{
portControlModeSet(&clientHandle, argc, argv);
show_help = 0;
}
break;
case 10:
if (argc == 3)
{
authMgrAdminModeSet(&clientHandle, argc, argv);
show_help = 0;
}
break;
case 11:
if (argc == 4)
{
authHostModeSet(&clientHandle, argc, argv);
show_help = 0;
}
break;
case 12:
if (argc == 4)
{
portGuestVlanSet(&clientHandle, argc, argv);
show_help = 0;
}
break;
case 13:
if (argc == 4)
{
authenticationPeriodicSet(&clientHandle, argc, argv);
show_help = 0;
}
break;
case 14:
if (argc == 4)
{
reauthenticationPeriodSet(&clientHandle, argc, argv);
show_help = 0;
}
break;
case 15:
if (argc == 4)
{
reauthPeriodFromServerSet(&clientHandle, argc, argv);
show_help = 0;
}
break;
case 16:
if (argc == 4)
{
authMgrPortMaxAuthAttemptsSet(&clientHandle, atoi(argv[2]), atoi(argv[3]));
show_help = 0;
}
break;
case 17:
if (argc == 2)
{
authMgrAuthenticationHistoryDisplayAll(&clientHandle);
show_help = 0;
}
break;
case 18:
if (argc == 2)
{
authMgrAuthenticationHistoryDisplayAllInReverseOrder(&clientHandle);
show_help = 0;
}
break;
case 19:
if (argc == 3)
{
authMgrAuthenticationHistoryDisplay(&clientHandle, atoi(argv[2]));
show_help = 0;
}
break;
case 20:
if (argc == 2)
{
authMgrHistoryLogInterfaceClearAll(&clientHandle);
show_help = 0;
}
break;
case 21:
if (argc == 3)
{
authMgrHistoryLogInterfaceClear(&clientHandle, atoi(argv[2]));
show_help = 0;
}
break;
case 22:
if (argc == 2)
{
runSanity(&clientHandle);
show_help = 0;
}
break;
case 23:
if (argc == 4)
{
authMgrPortInitializeSet(&clientHandle, atoi(argv[2]), atoi(argv[3]));
show_help = 0;
}
break;
case 24:
if (argc == 4)
{
authMgrPortAdminControlledDirectionsSet(&clientHandle, atoi(argv[2]), atoi(argv[3]));
show_help = 0;
}
break;
case 25:
if (argc == 3)
{
authMgrPortAdminControlledDirectionsGet(&clientHandle, atoi(argv[2]), &cntrlDir);
show_help = 0;
}
break;
default:
break;
}
if (show_help == 1)
{
printAppMenu(argv[0]);
}
L7PROC_LOGF(L7PROC_LOG_SEVERITY_INFO, 0, "Stopping authmgr API example application");
return 0;
}