#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 dot1x port Eapol Frames Received Stats: %s 1 <intIfNum>\n", name);
printf("Test 2: Get the dot1x port Eapol Frames Transmitted Stats: %s 2 <intIfNum>\n", name);
printf("Test 3: Get the dot1x port Eapol Start Frames Received Stats: %s 3 <intIfNum>\n", name);
printf("Test 4: Get the dot1x port Eapol Logoff Frames Received Stat: %s 4 <intIfNum>\n", name);
printf("Test 5: Get number of EAP Response/Identity frames received: %s 5 <intIfNum>\n", name);
printf("Test 6: Get the dot1x port Eap Response Frames Received Stat: %s 6 <intIfNum>\n", name);
printf("Test 7: Get the dot1x port Eap Request Id Frames Transmitted Stat: %s 7 <intIfNum>\n", name);
printf("Test 8: Get the dot1x port Eap Request Frames Transmitted Stat: %s 8 <intIfNum>\n", name);
printf("Test 9: Get the dot1x port Invalid Eapol Frames Received Stat: %s 9 <intIfNum>\n", name);
printf("Test 10: Get the dot1x port Eap Length error Frames Received Stat: %s 10 <intIfNum>\n", name);
printf("Test 11: Get the dot1x port Last Eapol Frame Version Stat: %s 11 <intIfNum>\n", name);
printf("Test 12: Get the dot1x port Last Eapol Frame Source Stat: %s 12 <intIfNum>\n", name);
printf("Test 13: Clear the dot1x stats on the specified port: %s 13 <intIfNum>\n", name);
printf("Test 14: Run API sanity checks: %s 14 \n", name);
return;
}
{
uint32_t eapolLogoffFramesRx;
uint32_t eapolFramesRx;
uint32_t eapolFramesTx;
uint32_t lastEapolFrameVersion;
uint32_t eapReqFramesTx;
uint32_t eapRespIdFramesRx;
uint32_t eapolStartFramesRx;
uint32_t eapResponseFramesRx;
uint32_t invalidEapolFramesRx;
uint32_t eapLengthErrorFramesRx;
uint32_t intIfNum = 1;
uint32_t eapReqIdFramesTx;
char buffer[128];
badBufdescPointer.
pstart = (
void *) NULL;
badBufdescPointer.
size =
sizeof(buffer);
badBufdescPointer.size = 0;
zeroLenBuf.pstart = buffer;
zeroLenBuf.size = 0;
printf("Testing dot1x_eap_stats OpEN APIs sanity:\n");
printf("Testing openapiDot1xPortEapolFramesRxGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiDot1xPortEapolFramesTxGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiDot1xPortEapolStartFramesRxGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiDot1xPortEapolLogoffFramesRxGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiDot1xPortEapRespIdFramesRxGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiDot1xPortEapResponseFramesRxGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiDot1xPortEapReqIdFramesTxGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiDot1xPortEapReqFramesTxGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiDot1xPortInvalidEapolFramesRxGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiDot1xPortEapLengthErrorFramesRxGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiDot1xPortLastEapolFrameVersionGet():\n");
printf("NULL client handle:(result = %d)\n", result);
printf("NULL argument 3:(result = %d)\n", result);
printf("Testing openapiDot1xPortLastEapolFrameSourceGet():\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);
return;
}
void dot1xPortEapolFramesRxGet(
openapiClientHandle_t *clientHandle, uint32_t intIfNum, uint32_t *eapolFramesRx)
{
{
printf("Bad return code trying to get the dot1x port Eapol Frames Received Stats (result = %d)\n", result);
}
else
{
printf("EAPOL frames received :- %u\n", *eapolFramesRx);
}
return;
}
void dot1xPortEapolFramesTxGet(
openapiClientHandle_t *clientHandle, uint32_t intIfNum, uint32_t *eapolFramesTx)
{
{
printf("Bad return code trying to get the dot1x port Eapol Frames Transmitted Stats (result = %d)\n", result);
}
else
{
printf("EAPOL frames transmitted :- %u\n", *eapolFramesTx);
}
return;
}
void dot1xPortEapolStartFramesRxGet(
openapiClientHandle_t *clientHandle, uint32_t intIfNum, uint32_t *eapolStartFramesRx)
{
{
printf("Bad return code trying to get the dot1x port Eapol Start Frames Received Stats (result = %d)\n", result);
}
else
{
printf("EAPOL start frames received :- %u\n", *eapolStartFramesRx);
}
return;
}
void dot1xPortEapolLogoffFramesRxGet(
openapiClientHandle_t *clientHandle, uint32_t intIfNum, uint32_t *eapolLogoffFramesRx)
{
{
printf("Bad return code trying to get the dot1x port Eapol Logoff Frames Received Stat (result = %d)\n", result);
}
else
{
printf("EAPOL logoff frames received :- %u\n", *eapolLogoffFramesRx);
}
return;
}
void dot1xPortEapRespIdFramesRxGet(
openapiClientHandle_t *clientHandle, uint32_t intIfNum, uint32_t *eapRespIdFramesRx)
{
{
printf("Bad return code trying to get number of EAP Response/Identity frames received (result = %d)\n", result);
}
else
{
printf("EAP Resp/Id frames received :- %u\n", *eapRespIdFramesRx);
}
return;
}
void dot1xPortEapResponseFramesRxGet(
openapiClientHandle_t *clientHandle, uint32_t intIfNum, uint32_t *eapResponseFramesRx)
{
{
printf("Bad return code trying to get the dot1x port Eap Response Frames Received Stat (result = %d)\n", result);
}
else
{
printf("EAP Response frames received :- %u\n", *eapResponseFramesRx);
}
return;
}
void dot1xPortEapReqIdFramesTxGet(
openapiClientHandle_t *clientHandle, uint32_t intIfNum, uint32_t *eapReqIdFramesTx)
{
{
printf("Bad return code trying to get the dot1x port Eap Request Id Frames Transmitted Stat (result = %d)\n", result);
}
else
{
printf("EAP Req/Id frames transmitted :- %u\n", *eapReqIdFramesTx);
}
return;
}
void dot1xPortEapReqFramesTxGet(
openapiClientHandle_t *clientHandle, uint32_t intIfNum, uint32_t *eapReqFramesTx)
{
{
printf("Bad return code trying to get the dot1x port Eap Request Frames Transmitted Stat (result = %d)\n", result);
}
else
{
printf("EAP Request frames transmitted :- %u\n", *eapReqFramesTx);
}
return;
}
void dot1xPortInvalidEapolFramesRxGet(
openapiClientHandle_t *clientHandle, uint32_t intIfNum, uint32_t *invalidEapolFramesRx)
{
{
printf("Bad return code trying to get the dot1x port Invalid Eapol Frames Received Stat (result = %d)\n", result);
}
else
{
printf("Invalid EAPOL frames received :- %u\n", *invalidEapolFramesRx);
}
return;
}
void dot1xPortEapLengthErrorFramesRxGet(
openapiClientHandle_t *clientHandle, uint32_t intIfNum, uint32_t *eapLengthErrorFramesRx)
{
{
printf("Bad return code trying to get the dot1x port Eap Length error Frames Received Stat (result = %d)\n", result);
}
else
{
printf("EAP length error frames :- %u\n", *eapLengthErrorFramesRx);
}
return;
}
void dot1xPortLastEapolFrameVersionGet(
openapiClientHandle_t *clientHandle, uint32_t intIfNum, uint32_t *lastEapolFrameVersion)
{
{
printf("Bad return code trying to get the dot1x port Last Eapol Frame Version Stat (result = %d)\n", result);
}
else
{
printf("last EAPOL version received :- %u\n", *lastEapolFrameVersion);
}
return;
}
{
unsigned char macAddrBuf[OPEN_MAC_ADDR_LEN];
memset(macAddrBuf, 0, sizeof(macAddrBuf));
lastEapolFrameSource.pstart = macAddrBuf;
lastEapolFrameSource.size = sizeof(macAddrBuf);
{
printf("Bad return code trying to get the dot1x port Last Eapol Frame Source Stat (result = %d)\n", result);
}
else
{
printf("last EAPOL version received :- %02X:%02X:%02X:%02X:%02X:%02X\n",
macAddrBuf[0], macAddrBuf[1], macAddrBuf[2], macAddrBuf[3],
macAddrBuf[4], macAddrBuf[5]);
}
return;
}
{
{
printf("Bad return code trying to clear the dot1x stats on the specified port (result = %d)\n", result);
}
else
{
printf("Dot1x stats cleared for interface %u\n", intIfNum);
}
return;
}
int main(int argc, char **argv)
{
uint32_t testNum;
char switch_os_revision_string[100];
int show_help = 1;
uint32_t eapolLogoffFramesRx;
uint32_t eapolFramesRx;
uint32_t eapolFramesTx;
uint32_t lastEapolFrameVersion;
uint32_t eapReqFramesTx;
uint32_t eapRespIdFramesRx;
uint32_t eapolStartFramesRx;
uint32_t eapResponseFramesRx;
uint32_t invalidEapolFramesRx;
uint32_t eapLengthErrorFramesRx;
uint32_t eapReqIdFramesTx;
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 dot1x_eap_stats 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)
{
dot1xPortEapolFramesRxGet(&clientHandle, atoi(argv[2]), &eapolFramesRx);
show_help = 0;
}
break;
case 2:
if (argc == 3)
{
dot1xPortEapolFramesTxGet(&clientHandle, atoi(argv[2]), &eapolFramesTx);
show_help = 0;
}
break;
case 3:
if (argc == 3)
{
dot1xPortEapolStartFramesRxGet(&clientHandle, atoi(argv[2]), &eapolStartFramesRx);
show_help = 0;
}
break;
case 4:
if (argc == 3)
{
dot1xPortEapolLogoffFramesRxGet(&clientHandle, atoi(argv[2]), &eapolLogoffFramesRx);
show_help = 0;
}
break;
case 5:
if (argc == 3)
{
dot1xPortEapRespIdFramesRxGet(&clientHandle, atoi(argv[2]), &eapRespIdFramesRx);
show_help = 0;
}
break;
case 6:
if (argc == 3)
{
dot1xPortEapResponseFramesRxGet(&clientHandle, atoi(argv[2]), &eapResponseFramesRx);
show_help = 0;
}
break;
case 7:
if (argc == 3)
{
dot1xPortEapReqIdFramesTxGet(&clientHandle, atoi(argv[2]), &eapReqIdFramesTx);
show_help = 0;
}
break;
case 8:
if (argc == 3)
{
dot1xPortEapReqFramesTxGet(&clientHandle, atoi(argv[2]), &eapReqFramesTx);
show_help = 0;
}
break;
case 9:
if (argc == 3)
{
dot1xPortInvalidEapolFramesRxGet(&clientHandle, atoi(argv[2]), &invalidEapolFramesRx);
show_help = 0;
}
break;
case 10:
if (argc == 3)
{
dot1xPortEapLengthErrorFramesRxGet(&clientHandle, atoi(argv[2]), &eapLengthErrorFramesRx);
show_help = 0;
}
break;
case 11:
if (argc == 3)
{
dot1xPortLastEapolFrameVersionGet(&clientHandle, atoi(argv[2]), &lastEapolFrameVersion);
show_help = 0;
}
break;
case 12:
if (argc == 3)
{
dot1xPortLastEapolFrameSourceGet(&clientHandle, atoi(argv[2]));
show_help = 0;
}
break;
case 13:
if (argc == 3)
{
dot1xPortStatsClear(&clientHandle, atoi(argv[2]));
show_help = 0;
}
break;
case 14:
if (argc == 2)
{
runSanity(&clientHandle);
show_help = 0;
}
break;
default:
break;
}
if (show_help == 1)
{
printAppMenu(argv[0]);
}
L7PROC_LOGF(L7PROC_LOG_SEVERITY_INFO, 0, "Stopping dot1x_eap_stats API example application");
return 0;
}