#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 Flow Control mode of the system: %s 1 \n", name);
printf("Test 2: Set the Flow Control mode of the system: %s 2 <mode>\n", name);
printf("Test 3: Get the Flow Control mode of the interafce: %s 3 <ifNum>\n", name);
printf("Test 4: Set the Flow Control mode of the interafce: %s 4 <ifNum> <mode>\n", name);
printf("Test 5: Get the Flow Control operational mode of the interafce: %s 5 <ifNum>\n", name);
printf("Test 6: Get the pause frames receive count of the interafce: %s 6 <ifNum> \n", name);
printf("Test 7: Get the pause frames transmit count of the interafce: %s 7 <ifNum> \n", name);
return;
}
{
{
printf("Bad return code trying to get the Flow Control mode of the system."
" (result = %d)\n", result);
}
else
{
printf("Flow Control mode of the system is %u.\n", *mode);
}
return;
}
{
{
printf("Bad return code trying to set the Flow Control mode of the system."
" (result = %d)\n", result);
}
else
{
printf("Flow Control mode of the system set successfully.\n");
}
return;
}
{
{
printf("Bad return code trying to get the Flow Control mode of the "
"interafce. (result = %d)\n", result);
}
else
{
printf("Flow Control mode of the interface is %u.\n", *mode);
}
return;
}
{
{
printf("Bad return code trying to set the Flow Control mode of the "
"interafce. (result = %d)\n", result);
}
else
{
printf("Flow Control mode of the interface set successfully.\n");
}
return;
}
{
{
printf("Bad return code trying to get the Flow Control operational mode of"
" the interafce. (result = %d)\n", result);
}
else
{
printf("Flow Control operational mode of the interface is %u.\n", *mode);
}
return;
}
uint32_t ifNum, uint32_t *rxCount)
{
{
printf("Bad return code trying to get the pause frames receive count of the "
"interafce. (result = %d)\n", result);
}
else
{
printf("Pause frames receive count of the interafce is %u.\n", *rxCount);
}
return;
}
uint32_t ifNum, uint32_t *txCount)
{
{
printf("Bad return code trying to get the pause frames transmit count of the"
" interafce. (result = %d)\n", result);
}
else
{
printf("Pause frames transmit count of the interafce is %u.\n", *txCount);
}
return;
}
int main(int argc, char **argv)
{
uint32_t testNum, ifNum, rxCount, txCount;
char switch_os_revision_string[100];
int show_help = 1;
if (argc < 2)
{
printAppMenu(argv[0]);
return -1;
}
testNum = atoi(argv[1]);
if (argc > 2)
{
ifNum = atoi(argv[2]);
}
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 FlowControl 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)
{
flowControlModeGet(&client_handle, &mode);
show_help = 0;
}
break;
case 2:
if (argc == 3)
{
flowControlModeSet(&client_handle, atoi(argv[2]));
show_help = 0;
}
break;
case 3:
if (argc == 3)
{
flowControlIfModeGet(&client_handle, ifNum, &mode);
show_help = 0;
}
break;
case 4:
if (argc == 4)
{
flowControlIfModeSet(&client_handle, ifNum, atoi(argv[3]));
show_help = 0;
}
break;
case 5:
if (argc == 3)
{
flowControlIfOperModeGet(&client_handle, ifNum, &operMode);
show_help = 0;
}
break;
case 6:
if (argc == 3)
{
flowControlIfPauseFramesRxGet(&client_handle, ifNum, &rxCount);
show_help = 0;
}
break;
case 7:
if (argc == 3)
{
flowControlIfPauseFramesTxGet(&client_handle, ifNum, &txCount);
show_help = 0;
}
break;
default:
break;
}
if (show_help == 1)
{
printAppMenu(argv[0]);
}
L7PROC_LOGF(L7PROC_LOG_SEVERITY_INFO, 0, "Stopping FlowControl API example application");
return 0;
}