#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] = {0};
char bufVidMac[OPEN_MFDB_VIDMAC_LENGTH] = {0};
char bufMac[OPEN_MFDB_MAC_LENGTH] = {0};
char bufDesc[OPENAPI_MFDB_DESCR_LEN] = {0};
char bufFrwdIntMask[OPEN_MFDB_INTF_LIST_LENGTH] = {0};
char bufFltIntMask[OPEN_MFDB_INTF_LIST_LENGTH] = {0};
char bufAbsPortMask[OPEN_MFDB_INTF_LIST_LENGTH] = {0};
uint32_t vlanId = 0;
uint32_t maxEntries = 0;
uint32_t mostEntries = 0;
uint32_t currEntries = 0;
uint32_t matchType = OPEN_MATCH_GETNEXT;
vidMac.
pstart = bufVidMac;
vidMac.
size =
sizeof(bufVidMac);
mac.pstart = bufMac;
mac.size = sizeof(bufMac);
desc.pstart = bufDesc;
desc.size = sizeof(bufDesc);
frwdIntMask.pstart = bufFrwdIntMask;
frwdIntMask.size = sizeof(bufFrwdIntMask);
fltIntMask.pstart = bufFltIntMask;
fltIntMask.size = sizeof(bufFltIntMask);
absPortMask.pstart = bufAbsPortMask;
absPortMask.size = sizeof(bufAbsPortMask);
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 MFDB 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");
do
{
strcpy((char *)vidMac.pstart, "00:00:00:00:00:00:00:00");
vidMac.size = strlen((char *)vidMac.pstart) + 1;
{
printf("The first entry in the MFDB table is %s\n", (char *)vidMac.pstart);
result =
openapiMfdbEntryDataGet(&clientHandle, &vidMac, nextProt, &mac, &vlanId, &compId, &type, &desc, &frwdIntMask, &fltIntMask, &absPortMask);
{
printf("Data of entry %s is retrieved successfully.\n", (char *)vidMac.pstart);
}
else
{
printf("Failed to retrieve the data for entry in the MFDB table. (Result = %d)\n", result);
}
{
printf("The next entry in the MFDB table is %s\n", (char *)vidMac.pstart);
}
else
{
printf("Failed to retrieve the next entry in the MFDB table. (Result = %d)\n", result);
}
}
else
{
printf("Failed to retrieve the first entry in the MFDB table. (Result = %d)\n", result);
}
{
printf("VLAN-MAC entry(%s) exists in the MFDB table.\n", (char *)vidMac.pstart);
}
{
printf("VLAN-MAC entry(%s) doesn't exist in the MFDB table.\n", (char *)vidMac.pstart);
}
else
{
printf("Failed to check f a VLANID-MAC entry exists in the MFDB table. (Result = %d)\n", result);
}
strcpy((char *)vidMac.pstart, "00:00:00:00:00:00:00:00");
vidMac.size = strlen((char *)vidMac.pstart) + 1;
memset(desc.pstart, 0, sizeof(bufDesc));
desc.size = sizeof(bufDesc);
memset(frwdIntMask.pstart, 0, sizeof(bufFrwdIntMask));
frwdIntMask.size = sizeof(bufFrwdIntMask);
memset(fltIntMask.pstart, 0, sizeof(bufFltIntMask));
fltIntMask.size = sizeof(bufFltIntMask);
{
printf("First entry of the same user retrieved successful. Data of entry %s is:\n\tcomponent ID - %u,\n\ttype - %u,\n\tdescription - %s,\n"
"\tforward interface mask - %s,\n\tfilter interface mask - %s\n", (char *)vidMac.pstart, (uint32_t)nextCompId, (uint32_t)type, (char *)desc.pstart,
(char *)frwdIntMask.pstart, (char *)fltIntMask.pstart);
}
else
{
printf("Failed to retrieve the first MFDB entry of the same user. (Result = %d)\n", result);
}
{
printf("VLAN-MAC entry(%s) exists in the MFDB table.\n", (char *)vidMac.pstart);
}
{
printf("VLAN-MAC entry(%s) doesn't exist in the MFDB table.\n", (char *)vidMac.pstart);
}
else
{
printf("Failed to check if a VLANID-MAC entry exists in the MFDB table. (Result = %d)\n", result);
}
strcpy((char *)vidMac.pstart, "00:00:00:00:00:00:00:00");
vidMac.size = strlen((char *)vidMac.pstart) + 1;
memset(absPortMask.pstart, 0, sizeof(bufAbsPortMask));
absPortMask.size = sizeof(bufAbsPortMask);
{
printf("Forwarding interfaces of the first VLANID-MAC entry retrieved successful. Absolute port mask of entry %s is: %s\n",
(char *)vidMac.pstart, (char *)absPortMask.pstart);
}
else
{
printf("Failed to retrieve the forwarding interfaces of the first VLANID-MAC entry. (Result = %d)\n", result);
}
strcpy((char *)vidMac.pstart, "00:00:00:00:00:00:00:00");
vidMac.size = strlen((char *)vidMac.pstart) + 1;
memset(absPortMask.pstart, 0, sizeof(bufAbsPortMask));
absPortMask.size = sizeof(bufAbsPortMask);
{
printf("Forwarding interfaces of the first learned VLANID-MAC entry retrieved successful. Absolute port mask of entry %s is: %s\n",
(char *)vidMac.pstart, (char *)absPortMask.pstart);
}
else
{
printf("Failed to retrieve the forwarding interfaces of the first learned VLANID-MAC entry. (Result = %d)\n", result);
}
{
printf("The maximum number of entries that the MFDB table can hold is %d\n", maxEntries);
}
else
{
printf("Failed to retrieve the maximum number of entries that the MFDB table can hold. (Result = %d)\n", result);
}
{
printf("The most number of entries ever in the MFDB table is %d\n", mostEntries);
}
else
{
printf("Failed to retrieve the most number of entries ever in the MFDB table. (Result = %d)\n", result);
}
{
printf("The number of current entries in the MFDB table is %d\n", currEntries);
}
else
{
printf("Failed to retrieve the number of current entries in the MFDB table. (Result = %d)\n", result);
}
printf("Press enter to continue...\n");
getchar();
} while (0);
L7PROC_LOGF(L7PROC_LOG_SEVERITY_INFO, 0, "Stopping MFDB API example application");
return 0;
}