#include <stdlib.h>
#include <unistd.h>
#include "rpcclt_openapi.h"
#include "proc_util.h"
#define MAX_STRING_LEN 256
int main(int argc, char **argv)
{
char switch_os_revision_string[100] = {0};
uint32_t groupId = 0;
uint32_t newGroupId = 0;
uint32_t vlanId = 0;
uint32_t newVlanId = 0;
uint32_t prot = 0;
uint32_t ifNum = 0;
uint32_t nextIfNum = 0;
char bufGroupName[17] = {0};
char bufProtList[512] = {0};
open_buffdesc protList = {.pstart = bufProtList, .size =
sizeof(bufProtList)};
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 Protocol-Based VLAN API example application");
switch_os_revision.pstart = switch_os_revision_string;
switch_os_revision.
size =
sizeof(switch_os_revision_string);
{
printf ("\nNetwork OS version = %s\n\n", switch_os_revision_string);
}
else
{
printf ("\nNetwork OS version retrieve error\n\n");
}
do
{
groupId = 10;
switch (result)
{
printf("The new Protocol-Based VLAN group with specified ID (%d) has been successfully created. (result = %d)\n",
groupId, result);
break;
printf("Protocol-Based VLAN group with specified ID (%d) already exists. (result = %d)\n",
groupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to created new Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
groupId, result);
break;
}
{
break;
}
switch (result)
{
printf("ID of the first created Protocol-Based VLAN group is %d. (result = %d)\n",
newGroupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to get ID of the first Protocol-Based VLAN group. (result = %d)\n",
result);
break;
}
switch (result)
{
printf("ID of the next created Protocol-Based VLAN group is %d. (result = %d)\n",
newGroupId, result);
break;
printf("Protocol-Based VLAN group with specified ID (%d) was not found. (result = %d)\n",
groupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to get ID of the next Protocol-Based VLAN group. (result = %d)\n",
result);
break;
}
strcpy(groupName.pstart, "new_name");
groupName.size = strlen(groupName.pstart) + 1;
switch (result)
{
printf("The name (%s) of the Protocol-Based VLAN group with specified ID (%d) has been successfully set. (result = %d)\n",
bufGroupName, groupId, result);
break;
printf("Protocol-Based VLAN group with specified ID (%d) was not found. (result = %d)\n",
groupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to set the name (%s) of the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
bufGroupName, groupId, result);
break;
}
{
memset(bufGroupName, 0, sizeof(bufGroupName));
groupName.size = 17;
switch (result)
{
printf("The name of the Protocol-Based VLAN group with specified ID (%d) is %s. (result = %d)\n",
groupId, bufGroupName, result);
break;
printf("Protocol-Based VLAN group with specified ID (%d) was not found. (result = %d)\n",
groupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to get the name of the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
groupId, result);
break;
}
switch (result)
{
printf("The ID of the Protocol-Based VLAN group with specified name (%s) is %d. (result = %d)\n",
bufGroupName, newGroupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to get the ID of the Protocol-Based VLAN group with specified name (%s). (result = %d)\n",
bufGroupName, result);
break;
}
}
vlanId = 10;
{
switch (result)
{
printf("The VLAN (%d) has been successfully added to the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
vlanId, groupId, result);
break;
printf("Protocol-Based VLAN group with specified ID (%d) was not found. (result = %d)\n",
groupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to add the VLAN (%d) to the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
vlanId, groupId, result);
break;
}
{
switch (result)
{
printf("The VLAN ID of the Protocol-Based VLAN group with specified ID (%d) is %d. (result = %d)\n",
groupId, newVlanId, result);
break;
printf("Protocol-Based VLAN group with specified ID (%d) was not found. (result = %d)\n",
groupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to get the VLAN ID of the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
groupId, result);
break;
}
switch (result)
{
printf("The VLAN (%d) has been successfully deleted from the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
vlanId, groupId, result);
break;
printf("Protocol-Based VLAN group with specified ID (%d) was not found. (result = %d)\n",
groupId, result);
break;
printf("VLAN (%d) was not found in the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
vlanId, groupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to delete the VLAN (%d) from the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
vlanId, groupId, result);
break;
}
}
}
prot = 0x0800;
switch (result)
{
printf("The protocol (%d) has been successfully added to the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
prot, groupId, result);
break;
printf("Protocol-Based VLAN group with specified ID (%d) was not found. (result = %d)\n",
groupId, result);
break;
printf("Protocol (%d) is already added to the group with specified ID (%d). (result = %d)\n",
prot, groupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to add the protocol (%d) to the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
prot, groupId, result);
break;
}
{
switch (result)
{
printf("The list of protocols of the Protocol-Based VLAN group with specified ID (%d) is %s. (result = %d)\n",
groupId, bufProtList, result);
break;
printf("Protocol-Based VLAN group with specified ID (%d) was not found. (result = %d)\n",
groupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to get the list of protocols of the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
groupId, result);
break;
}
switch (result)
{
printf("The protocol (%d) has been successfully deleted from the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
prot, groupId, result);
break;
printf("Protocol-Based VLAN group with specified ID (%d) was not found. (result = %d)\n",
groupId, result);
break;
printf("Protocol (%d) was not found in the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
prot, groupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to delete the protocol (%d) from the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
prot, groupId, result);
break;
}
}
ifNum = 1;
switch (result)
{
printf("The interface (%d) could be used for the Protocol-Based VLAN configuration. (result = %d)\n",
ifNum, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("The interface (%d) could not be used for the Protocol-Based VLAN configuration. (result = %d)\n",
ifNum, result);
break;
}
switch (result)
{
printf("The interface (%d) has been successfully added to the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
ifNum, groupId, result);
break;
printf("Protocol-Based VLAN group with specified ID (%d) was not found. (result = %d)\n",
groupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to add the protocol (%d) to the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
ifNum, groupId, result);
break;
}
{
switch (result)
{
printf("The first interface number of the Protocol-Based VLAN group with specified ID (%d) is %d. (result = %d)\n",
groupId, nextIfNum, result);
break;
printf("Protocol-Based VLAN group with specified ID (%d) was not found. (result = %d)\n",
groupId, result);
break;
printf("An interface (%d) was not found in the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
nextIfNum, groupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to get the first interface number of the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
groupId, result);
break;
}
switch (result)
{
printf("The interface (%d) has been successfully deleted from the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
ifNum, groupId, result);
break;
printf("Protocol-Based VLAN group with specified ID (%d) was not found. (result = %d)\n",
groupId, result);
break;
printf("Interface (%d) was not found in the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
ifNum, groupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to delete the interface (%d) from the Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
ifNum, groupId, result);
break;
}
}
switch (result)
{
printf("Protocol-Based VLAN group with specified ID (%d) has been successfully deleted. (result = %d)\n",
groupId, result);
break;
printf("Protocol-Based VLAN group with specified ID (%d) was not found. (result = %d)\n",
groupId, result);
break;
printf("Invalid parameter was passed. (result = %d)\n",
result);
break;
default:
printf("Failed to delete Protocol-Based VLAN group with specified ID (%d). (result = %d)\n",
groupId, result);
break;
}
printf("Press enter to continue...\n");
getchar();
} while(0);
L7PROC_LOGF(L7PROC_LOG_SEVERITY_INFO, 0, "Stopping Protocol-Based VLAN API example application");
return 0;
}