#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: Set IPv6 router advertise Minimum advertisement interval: %s 1 <ifNum> <val>\n", name);
printf("Test 2: Get IPv6 router advertise Minimum advertisement interval: %s 2 <ifNum>\n", name);
printf("Test 3: Set IPv6 router advertise Maximum advertisement interval: %s 3 <ifNum> <val>\n", name);
printf("Test 4: Get IPv6 router advertise Maximum advertisement interval: %s 4 <ifNum>\n", name);
printf("Test 5: Set IPv6 router advertise lifetime: %s 5 <ifNum> <val>\n", name);
printf("Test 6: Get IPv6 router advertise lifetime: %s 6 <ifNum>\n", name);
printf("Test 7: Set IPv6 router advertise link mtu: %s 7 <ifNum> <val>\n", name);
printf("Test 8: Get IPv6 router advertise link mtu: %s 8 <ifNum>\n", name);
printf("Test 9: Set IPv6 router preference: %s 9 <ifNum> <val>\n", name);
printf("Test 10: Get IPv6 router preference: %s 10 <ifNum>\n", name);
printf("Test 11: Set IPv6 router advertise managed flag: %s 11 <ifNum> <flag>\n", name);
printf("Test 12: Get IPv6 router advertise managed flag: %s 12 <ifNum>\n", name);
printf("Test 13: Set IPv6 router advertise other-config flag: %s 13 <ifNum> <flag>\n", name);
printf("Test 14: Get IPv6 router advertise other-config flag: %s 14 <ifNum>\n", name);
printf("Test 15: Set IPv6 hop limit advertised on the interface to unspecified(0): %s 15 <ifNum> <flag>\n", name);
printf("Test 16: Get whether IPv6 hop limit advertised on the interface to unspecified(0): %s 16 <ifNum>\n", name);
printf("Test 17: Set IPv6 router advertise suppression: %s 17 <ifNum> <flag>\n", name);
printf("Test 18: Get IPv6 router advertise suppression: %s 18 <ifNum>\n", name);
printf("Test 19: Set IPv6 router as per prefix attributes: %s 19 <ifNum><prefix><plen><prefLife><validLife><lifeDecrFlags><onLink><autonomous>\n", name);
printf("Test 20: Get IPv6 router as per prefix attributes: %s 20 <ifNum> <prefix> <plen>\n", name);
return;
}
{
switch(result)
{
printf("\nSuccessfully set the IPv6 router advertise Minimum advertisement interval.\n");
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to set IPv6 router advertise Minimum advertisement interval. (result = %d)\n", result);
break;
}
return;
}
{
uint32_t val = 0;
switch(result)
{
printf("\nThe IPv6 router advertise Minimum advertisement interval is %u seconds.\n", val);
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to get IPv6 router advertise Minimum advertisement interval. (result = %d)\n", result);
break;
}
return;
}
{
switch(result)
{
printf("\nSuccessfully set the IPv6 router advertise Maximum advertisement interval.\n");
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to set IPv6 router advertise Maximum advertisement interval. (result = %d)\n", result);
break;
}
return;
}
{
uint32_t val = 0;
switch(result)
{
printf("\nThe IPv6 router advertise Maximum advertisement interval is %u seconds.\n", val);
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to get IPv6 router advertise Maximum advertisement interval. (result = %d)\n", result);
break;
}
return;
}
{
switch(result)
{
printf("\nSuccessfully set the IPv6 router advertise lifetime.\n");
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to set IPv6 router advertise lifetime. (result = %d)\n", result);
break;
}
return;
}
{
uint32_t val = 0;
switch(result)
{
printf("\nThe IPv6 router advertise lifetime is %u seconds.\n", val);
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to get IPv6 router advertise lifetime. (result = %d)\n", result);
break;
}
return;
}
{
switch(result)
{
printf("\nSuccessfully set the IPv6 router advertise link mtu.\n");
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to set IPv6 router advertise link mtu. (result = %d)\n", result);
break;
}
return;
}
{
uint32_t val = 0;
switch(result)
{
printf("\nThe IPv6 router advertise link mtu is %u.\n", val);
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to get IPv6 router advertise link mtu. (result = %d)\n", result);
break;
}
return;
}
{
switch(result)
{
printf("\nSuccessfully set the IPv6 router preference.\n");
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to set IPv6 router preference. (result = %d)\n", result);
break;
}
return;
}
{
uint32_t val = 0;
switch(result)
{
printf("\nThe IPv6 router preference is %u.\n", val);
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to get IPv6 router preference. (result = %d)\n", result);
break;
}
return;
}
{
if (1 < flag)
{
printf("\nERROR: Invalid flag value. Expected 0(for False) or 1(for True).\n");
return;
}
if (1 == flag)
{
}
switch(result)
{
printf("\nSuccessfully set IPv6 router advertise managed flag.\n");
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to set IPv6 router advertise managed flag. (result = %d)\n", result);
break;
}
return;
}
{
switch(result)
{
printf("\nThe IPv6 router advertise managed flag of given interface is %u.\n", flag);
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to get IPv6 router advertise managed flag. (result = %d)\n", result);
break;
}
return;
}
{
if (1 < flag)
{
printf("\nERROR: Invalid flag value. Expected 0(for False) or 1(for True).\n");
return;
}
if (1 == flag)
{
}
switch(result)
{
printf("\nSuccessfully set IPv6 router advertise other-config flag.\n");
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to set IPv6 router advertise other-config flag. (result = %d)\n", result);
break;
}
return;
}
{
switch(result)
{
printf("\nThe IPv6 router advertise other-config flag of given interface is %u.\n", flag);
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to get IPv6 router advertise other-config flag. (result = %d)\n", result);
break;
}
return;
}
{
if (1 < flag)
{
printf("\nERROR: Invalid flag value. Expected 0(for False) or 1(for True).\n");
return;
}
if (1 == flag)
{
}
switch(result)
{
printf("\nSuccessfully set IPv6 hop limit advertised on the interface to unspecified(0).\n");
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to set IPv6 hop limit advertised on the interface to unspecified(0). (result = %d)\n", result);
break;
}
return;
}
{
switch(result)
{
printf("\nThe IPv6 router advertise other-config flag of given interface is %u.\n", flag);
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to get whether IPv6 hop limit is advertised on given interface to unspecified(0) (result = %d)\n", result);
break;
}
return;
}
{
if (1 < flag)
{
printf("\nERROR: Invalid flag value. Expected 0(for False) or 1(for True).\n");
return;
}
if (1 == flag)
{
}
switch(result)
{
printf("\nSuccessfully set IPv6 router advertise suppression.\n");
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to set IPv6 router advertise suppression. (result = %d)\n", result);
break;
}
return;
}
{
switch(result)
{
printf("\nThe IPv6 router advertise managed flag of given interface is %u.\n", flag);
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to get IPv6 router advertise suppression (result = %d)\n", result);
break;
}
return;
}
uint32_t plen, uint32_t prefLife, uint32_t validLife, uint16_t lifeDecrFlags,
uint32_t onLink, uint32_t autonomous)
{
if (1 < onLink)
{
printf("\nERROR: Invalid onLink flag value. Expected 0(for False) or 1(for True).\n");
return;
}
if (1 == onLink)
{
}
if (1 < autonomous)
{
printf("\nERROR: Invalid autonomous flag value. Expected 0(for False) or 1(for True).\n");
return;
}
if (1 == autonomous)
{
}
result =
openapiIp6RtrRadvPrefixSet(client_handle, ifNum, *prefix, plen, prefLife, validLife, lifeDecrFlags, openOnLinkFlag, openAutoFlag);
switch(result)
{
printf("\nSuccessfully set IPv6 router as per prefix attributes.\n");
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to set IPv6 router as per prefix attributes. (result = %d)\n", result);
break;
}
return;
}
void ip6RtrRadvPrefixGet(
openapiClientHandle_t *client_handle, uint32_t ifNum,
char *ipAddrStr, uint32_t plen)
{
uint32_t prefLife = 0;
uint32_t validLife = 0;
char str[40];
memset(str, 0, sizeof(str));
strncpy(str, ipAddrStr, sizeof(str) - 1);
ipBuffdesc.
size = strlen(str) + 1;
{
printf("\nERROR: Invalid IP-address input.\n");
return;
}
switch(result)
{
printf("\nFollowing are the IPv6 router info as per given prefix attributes: ");
printf("\n Preferred life is %u seconds.", prefLife);
printf("\n Valid life is %u seconds.", validLife);
printf("\n Onlink flag value is %u.", onLink);
printf("\n Autonomous flag value is %u.\n", autonomous);
break;
printf("\nERROR: Invalid argument passed.\n");
break;
default:
printf("\nERROR: Bad return code trying to get IPv6 router as per prefix attributes. (result = %d)\n", result);
break;
}
return;
}
int main(int argc, char **argv)
{
uint32_t testNum = 0;
uint32_t ifNum = 0;
uint32_t val = 0;
uint32_t plen = 0;
uint32_t prefLife = 0;
uint32_t validLife = 0;
uint32_t lifeDecrFlags = 0;
uint32_t onLink = 0;
uint32_t autonomous = 0;
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 IP6RADV 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)
{
ifNum = atoi(argv[2]);
val = atoi(argv[3]);
ip6RtrRadvMinAdvIntSet(&client_handle, ifNum, val);
show_help = 0;
}
break;
case 2:
if (argc == 3)
{
ifNum = atoi(argv[2]);
ip6RtrRadvMinAdvIntGet(&client_handle, ifNum);
show_help = 0;
}
break;
case 3:
if (argc == 4)
{
ifNum = atoi(argv[2]);
val = atoi(argv[3]);
ip6RtrRadvMaxAdvIntSet(&client_handle, ifNum, val);
show_help = 0;
}
break;
case 4:
if (argc == 3)
{
ifNum = atoi(argv[2]);
ip6RtrRadvMaxAdvIntGet(&client_handle, ifNum);
show_help = 0;
}
break;
case 5:
if (argc == 4)
{
ifNum = atoi(argv[2]);
val = atoi(argv[3]);
ip6RtrRadvAdvLifetimeSet(&client_handle, ifNum, val);
show_help = 0;
}
break;
case 6:
if (argc == 3)
{
ifNum = atoi(argv[2]);
ip6RtrRadvAdvLifetimeGet(&client_handle, ifNum);
show_help = 0;
}
break;
case 7:
if (argc == 4)
{
ifNum = atoi(argv[2]);
val = atoi(argv[3]);
ip6RtrRadvAdvMtuSet(&client_handle, ifNum, val);
show_help = 0;
}
break;
case 8:
if (argc == 3)
{
ifNum = atoi(argv[2]);
ip6RtrRadvAdvMtuGet(&client_handle, ifNum);
show_help = 0;
}
break;
case 9:
if (argc == 4)
{
ifNum = atoi(argv[2]);
val = atoi(argv[3]);
ip6RtrRadvRtrPrefSet(&client_handle, ifNum, val);
show_help = 0;
}
break;
case 10:
if (argc == 3)
{
ifNum = atoi(argv[2]);
ip6RtrRadvRtrPrefGet(&client_handle, ifNum);
show_help = 0;
}
break;
case 11:
if (argc == 4)
{
ifNum = atoi(argv[2]);
val = atoi(argv[3]);
ip6RtrRadvManagedFlagSet(&client_handle, ifNum, val);
show_help = 0;
}
break;
case 12:
if (argc == 3)
{
ifNum = atoi(argv[2]);
ip6RtrRadvManagedFlagGet(&client_handle, ifNum);
show_help = 0;
}
break;
case 13:
if (argc == 4)
{
ifNum = atoi(argv[2]);
val = atoi(argv[3]);
ip6RtrRadvOtherCfgFlagSet(&client_handle, ifNum, val);
show_help = 0;
}
break;
case 14:
if (argc == 3)
{
ifNum = atoi(argv[2]);
ip6RtrRadvOtherCfgFlagGet(&client_handle, ifNum);
show_help = 0;
}
break;
case 15:
if (argc == 4)
{
ifNum = atoi(argv[2]);
val = atoi(argv[3]);
ip6RtrRadvHopLimitUnspec(&client_handle, ifNum, val);
show_help = 0;
}
break;
case 16:
if (argc == 3)
{
ifNum = atoi(argv[2]);
ip6RtrRadvHopLimitUnspecGet(&client_handle, ifNum);
show_help = 0;
}
break;
case 17:
if (argc == 4)
{
ifNum = atoi(argv[2]);
val = atoi(argv[3]);
ip6RtrRadvSuppressSet(&client_handle, ifNum, val);
show_help = 0;
}
break;
case 18:
if (argc == 3)
{
ifNum = atoi(argv[2]);
ip6RtrRadvSuppressGet(&client_handle, ifNum);
show_help = 0;
}
break;
case 19:
if (argc == 10)
{
ifNum = atoi(argv[2]);
plen = atoi(argv[4]);
prefLife = atoi(argv[5]);
validLife = atoi(argv[6]);
lifeDecrFlags = atoi(argv[7]);
onLink = atoi(argv[8]);
autonomous = atoi(argv[9]);
ip6RtrRadvPrefixSet(&client_handle, ifNum, argv[3], plen, prefLife, validLife, lifeDecrFlags, onLink, autonomous);
show_help = 0;
}
break;
case 20:
if (argc == 5)
{
ifNum = atoi(argv[2]);
plen = atoi(argv[4]);
ip6RtrRadvPrefixGet(&client_handle, ifNum, argv[3], plen);
show_help = 0;
}
break;
default:
break;
}
if (show_help == 1)
{
printAppMenu(argv[0]);
}
L7PROC_LOGF(L7PROC_LOG_SEVERITY_INFO, 0, "Stopping IP6RADV API example application");
return 0;
}