#include <stdlib.h>
#include <unistd.h>
#include "rpcclt_openapi.h"
#include "proc_util.h"
int main(int argc, char **argv)
{
char switch_os_revision_string[100];
char buf[100];
uint32_t vlanId;
uint32_t fdbIfNum;
uint32_t fdbId;
uint32_t value;
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 FDB 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");
}
do
{
memset(buf, 0, sizeof(buf));
mac.pstart = buf;
mac.size = sizeof(buf);
vlanId = 0;
fdbIfNum = 0;
fdbEntryType = 0;
{
printf("Failed to get the first entry from the forwarding database (Result = %d)\n", result);
break;
}
else
{
printf("Success: Get the first entry from the forwarding database. Found entry with VLAN-MAC: %d-%s\n", vlanId, (char *)mac.pstart);
{
{
printf("Failed to get the next entry from the forwarding database (Result = %d)\n", result);
break;
}
printf("Success: Cannot get the next entry from the forwarding database - entry not found (Result = %d)\n", result);
}
else
{
printf("Success: Get the next entry from the forwarding database. Found entry with VLAN-MAC: %d-%s\n", vlanId, (char *)mac.pstart);
}
}
fdbId = 0;
{
printf("Success: FDB with ID %d exists.\n", fdbId);
}
{
printf("Success: FDB with ID %d does not exist.\n", fdbId);
}
else
{
printf("Failed to verify FDB with ID %d exists. (Result = %d)\n", fdbId, result);
break;
}
{
{
printf("Success: Fdb Address Aging Timeout is %d.\n", value);
}
else
{
printf("Failed to get Fdb Address Aging Timeout for FDB with ID %d. (Result = %d)\n", fdbId, result);
}
value += 1;
{
printf("Success: Set Fdb Address Aging Timeout value: %d.\n", value);
}
else
{
printf("Failed to set Fdb Address Aging Timeout value: %d. (Result = %d)\n", value, result);
}
}
{
printf("Success: The maximum number of FDB entries supported on the platform: %d.\n", value);
}
else
{
printf("Failed to get maximum number of FDB entries supported on the platform. (Result = %d)\n", result);
}
{
printf("Success: The current number of FDB entries: %d.\n", value);
}
else
{
printf("Failed to get the current number of FDB entries. (Result = %d)\n", result);
}
{
printf("Success: The greatest number of FDB entries: %d.\n", value);
}
else
{
printf("Failed to get the greatest number of FDB entries. (Result = %d)\n", result);
}
{
printf("Success: The count greatest number of FDB entries is reset.\n");
}
else
{
printf("Failed to reset the greatest number of FDB entries. (Result = %d)\n", result);
}
{
printf("Success: The count of dynamic entries in the L2FDB: %d.\n", value);
}
else
{
printf("Failed to get the count of dynamic entries in the L2FDB. (Result = %d)\n", result);
}
{
printf("Success: The count of internally added entries in the L2FDB: %d.\n", value);
}
else
{
printf("Failed to get the count of internally added entries in the L2FDB. (Result = %d)\n", result);
}
{
printf("Success: The specified MAC is not restricted.\n");
}
{
printf("Success: The specified MAC is restricted.\n");
}
else
{
printf("Failed to verify if specified MAC is restricted. (Result = %d)\n", result);
}
{
printf("Success: Get the supported VLAN learning type: %s (%d).\n",
}
else
{
printf("Failed to get the supported VLAN learning type. (Result = %d)\n", result);
}
{
printf("Success: Get the next fdbID starting from a '%d' index.\n", fdbId);
}
else
{
printf("Cannot get the next fdbID starting from a '%d' index. (Result = %d)\n", fdbId, result);
}
{
printf("Success: Get the number of failed FDB insert: %d.\n", value);
}
else
{
printf("Failed to get the number of failed FDB insert. (Result = %d)\n", result);
}
{
printf("Success: Get the max limit of MAC entries supported by hardware: %d.\n", value);
}
else
{
printf("Failed to get the max limit of MAC entries supported by hardware. (Result = %d)\n", result);
}
{
printf("Success: Get the value of dynamic entries in the L2FDB for a %d interface: %d.\n", fdbIfNum, value);
}
else
{
printf("Failed to get the value of dynamic entries in the L2FDB for a %d interface. (Result = %d)\n", fdbIfNum, result);
}
{
printf("Success: Get the value of dynamic entries in the L2FDB for a VLAN %d: %d.\n", vlanId, value);
}
else
{
printf("Failed to get the value of dynamic entries in the L2FDB for a VLAN %d. (Result = %d)\n", vlanId, result);
}
{
printf("Success: Get the value of internal entries in the L2FDB for a %d interface: %d.\n", fdbIfNum, value);
}
else
{
printf("Failed to get the value of internal entries in the L2FDB for a %d interface. (Result = %d)\n", fdbIfNum, result);
}
{
printf("Success: Get the value of internal entries in the L2FDB for a VLAN %d: %d.\n", vlanId, value);
}
else
{
printf("Failed to get the value of internal entries in the L2FDB for a VLAN %d. (Result = %d)\n", vlanId, result);
}
memset(buf, 0x00, sizeof(buf));
mac.size = sizeof(buf);
vlanId = 0;
fdbIfNum = 0;
fdbEntryType = 0;
{
{
printf("Success: The specified FDB entry (VLAN = %d, MAC = %s, ifNum = %d) is deleted.\n",
vlanId, (char *)mac.pstart, fdbIfNum);
}
else
{
printf("Failed to delete the specified FDB entry. (Result = %d)\n", result);
}
}
{
printf("Success: Flushed all entries in fdb learned on interface %d.\n", fdbIfNum);
}
else
{
printf("Failed to flush all entries in fdb learned on interface %d. (Result = %d)\n", fdbIfNum, result);
}
{
printf("Success: Flushed all entries in fdb learned on VLAN %d.\n", vlanId);
}
else
{
printf("Failed to flush all entries in fdb learned on VLAN %d. (Result = %d)\n", vlanId, result);
}
{
printf("Success: Flushed all entries in fdb learned for MAC = %s.\n", (char *)mac.pstart);
}
else
{
printf("Failed to flush all entries in fdb learned for MAC = %s. (Result = %d)\n", (char *)mac.pstart, result);
}
{
printf("Success: Flushed all learned entries from the L2FDB.\n");
}
else
{
printf("Failed to flush all learned entries from the L2FDB. (Result = %d)\n", result);
}
}
while (0);
L7PROC_LOGF(L7PROC_LOG_SEVERITY_INFO, 0, "Stopping FDB API example application");
return 0;
}