#include <stdlib.h>
#include <unistd.h>
#include "rpcclt_openapi.h"
#include "proc_util.h"
#define MAC_STRING_SIZE 18
static void printAppMenu(char *name)
{
printf("Usage: %s <test#> <arg1> <arg2> ... \n", name);
printf("Test 1: Add MAC association to VLAN: %s 1 macAddress vlanId\n", name);
printf("Test 2: Delete MAC association to VLAN: %s 2 macAddress\n", name);
printf("Test 3: Gets the vlan association of a given MAC: %s 3 macAddress>\n", name);
printf("Test 4: Gets the next vlan mac association of a given MAC: %s 4 macAddress>\n", name);
return;
}
char *macAddr, uint32_t vlanId)
{
char mac[MAC_STRING_SIZE] = "";
strncpy(mac, macAddr, MAC_STRING_SIZE-1);
bufId.
size = strlen (macAddr);
{
printf("Bad return code trying to add mac vlan association. (result = %d)\n", result);
}
else
{
printf ("MAC VLAN association added successfully.\n");
}
return;
}
{
char mac[MAC_STRING_SIZE] = "";
uint32_t vlanId;
strncpy(mac, macAddr, MAC_STRING_SIZE-1);
bufId.pstart = mac;
bufId.size = strlen (macAddr);
{
printf("Bad return code trying to get mac vlan association for MAC %s . (result = %d)\n",
macAddr, result);
}
else
{
{
printf("Bad return code trying to del mac vlan association. (result = %d)\n", result);
}
else
{
printf ("MAC VLAN association deleted successfully.\n");
}
}
return;
}
{
char mac[MAC_STRING_SIZE] = "";
uint32_t vlanId;
strncpy(mac, macAddr, MAC_STRING_SIZE-1);
bufId.pstart = mac;
bufId.size = strlen (macAddr);
{
printf("Bad return code trying to get mac vlan association for MAC %s . (result = %d)\n",
macAddr, result);
}
else
{
printf ("VLAN ID associated to MAC %s is %u.\n", macAddr, vlanId);
}
return;
}
{
char mac[MAC_STRING_SIZE] = "";
char nextMac[MAC_STRING_SIZE] = "";
uint32_t vlanId;
strncpy(mac, macAddr, MAC_STRING_SIZE-1);
bufId.pstart = mac;
bufId.size = strlen (macAddr);
nextBufId.pstart = nextMac;
nextBufId.size = MAC_STRING_SIZE;
{
printf("Bad return code trying to get mac vlan association for MAC %s . (result = %d)\n",
macAddr, result);
}
else
{
printf ("Next MAC VLAN association of MAC %s is %s-%u.\n", macAddr, nextMac, vlanId);
}
return;
}
int main(int argc, char **argv)
{
uint32_t testNum;
char switch_os_revision_string[100];
int show_help = 1;
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 MAC VLAN 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 == 4)
{
macVlanAddAssociation (&client_handle, argv[2], atoi(argv[3]));
show_help = 0;
}
break;
case 2:
if (argc == 3)
{
macVlanDelAssociation (&client_handle, argv[2]);
show_help = 0;
}
break;
case 3:
if (argc == 3)
{
macVlanGetAssociation (&client_handle, argv[2]);
show_help = 0;
}
break;
case 4:
if (argc == 3)
{
macVlanGetNextAssociation (&client_handle, argv[2]);
show_help = 0;
}
break;
default:
break;
}
if (show_help == 1)
{
printAppMenu(argv[0]);
}
L7PROC_LOGF(L7PROC_LOG_SEVERITY_INFO, 0, "Stopping MAC VLAN API example application");
return 0;
}