#include <stdlib.h>
#include <unistd.h>
#include "rpcclt_openapi.h"
#include "proc_util.h"
{
char *str = NULL;
char *testSysName="DummyName";
char *testSysLocation="DummyLocation";
char *testSysContact="DummyContact";
if ((str = (char *)malloc(OPEN_RFC1213_PARAM_SIZE)) == NULL)
{
printf("Could not allocate memory.\n");
return;
}
buffdesc.
size = OPEN_RFC1213_PARAM_SIZE;
{
printf("Bad return code trying to get system description. (result = %d)\n", result);
printf("System Description Get test -- FAIL\n\n");
}
else
{
printf("System description retrieved successfully. system_descr=\"%s\" size=%d (result = %d)\n",
(char *) buffdesc.pstart, buffdesc.size, result);
printf("System Description Get test -- PASS\n\n");
}
buffdesc.size = OPEN_RFC1213_PARAM_SIZE;
{
printf("Bad return code trying to get system name. (result = %d)\n", result);
}
else
{
printf("System name retrieved successfully. Configured system name=\"%s\" size=%d (result = %d)\n",
(char *) buffdesc.pstart, buffdesc.size, result);
}
printf("Trying to set the system name to %s\n", testSysName);
memset(buffdesc.pstart, 0, OPEN_RFC1213_PARAM_SIZE);
strncpy ((char *) buffdesc.pstart, testSysName, OPEN_RFC1213_PARAM_SIZE-1);
buffdesc.size = strlen(testSysName)+1;
{
printf("Bad return code trying to set system name. (result = %d)\n", result);
}
else
{
printf("System name set is successful. (result = %d)\n", result);
}
memset(buffdesc.pstart, 0, OPEN_RFC1213_PARAM_SIZE);
buffdesc.size = OPEN_RFC1213_PARAM_SIZE;
{
printf("Bad return code trying to get system name. (result = %d)\n", result);
}
else
{
printf("System name retrieved successfully. system name=%s size=%d (result = %d)\n",
(char *) buffdesc.pstart, buffdesc.size, result);
}
if (0 == memcmp (buffdesc.pstart, testSysName, strlen(testSysName)))
{
printf("System Name Set test -- PASS\n\n");
}
else
{
printf("System Name Set test -- FAIL (New: %s Org: %s)\n\n", (char *)buffdesc.pstart, testSysName);
}
buffdesc.size = OPEN_RFC1213_PARAM_SIZE;
{
printf("Bad return code trying to get system location. (result = %d)\n", result);
}
else
{
printf("System location retrieved successfully. Configured system location=\"%s\" size=%d (result = %d)\n",
(char *) buffdesc.pstart, buffdesc.size, result);
}
printf("Trying to set the system location to %s\n", testSysLocation);
memset(buffdesc.pstart, 0, OPEN_RFC1213_PARAM_SIZE);
strncpy ((char *) buffdesc.pstart, testSysLocation, OPEN_RFC1213_PARAM_SIZE-1);
buffdesc.size = strlen(testSysLocation)+1;
{
printf("Bad return code trying to set system location. (result = %d)\n", result);
}
else
{
printf("System location set is successful. (result = %d)\n", result);
}
memset(buffdesc.pstart, 0, OPEN_RFC1213_PARAM_SIZE);
buffdesc.size = OPEN_RFC1213_PARAM_SIZE;
{
printf("Bad return code trying to get system location. (result = %d)\n", result);
}
else
{
printf("System location retrieved successfully. system location=\"%s\" size=%d (result = %d)\n",
(char *) buffdesc.pstart, buffdesc.size, result);
}
if (0 == memcmp (buffdesc.pstart, testSysLocation, strlen(testSysLocation)))
{
printf("System Location Set test -- PASS\n\n");
}
else
{
printf("System Location Set test -- FAIL (New: %s Org: %s)\n\n", (char *)buffdesc.pstart, testSysLocation);
}
buffdesc.size = OPEN_RFC1213_PARAM_SIZE;
{
printf("Bad return code trying to get system contact. (result = %d)\n", result);
}
else
{
printf("System contact retrieved successfully. Configured system contact=\"%s\" size=%d (result = %d)\n",
(char *) buffdesc.pstart, buffdesc.size, result);
}
printf("Trying to set the system contact to %s\n", testSysContact);
memset(buffdesc.pstart, 0, OPEN_RFC1213_PARAM_SIZE);
strncpy ((char *) buffdesc.pstart, testSysContact, OPEN_RFC1213_PARAM_SIZE-1);
buffdesc.size = strlen(testSysContact)+1;
{
printf("Bad return code trying to set system contact. (result = %d)\n", result);
}
else
{
printf("System contact set is successful. (result = %d)\n", result);
}
memset(buffdesc.pstart, 0, OPEN_RFC1213_PARAM_SIZE);
buffdesc.size = OPEN_RFC1213_PARAM_SIZE;
{
printf("Bad return code trying to get system contact. (result = %d)\n", result);
}
else
{
printf("System contact retrieved successfully. system contact=\"%s\" size=%d (result = %d)\n",
(char *) buffdesc.pstart, buffdesc.size, result);
}
if (0 == memcmp (buffdesc.pstart, testSysContact, strlen(testSysContact)))
{
printf("System Contact Set test -- PASS\n");
}
else
{
printf("System Contact Set test -- FAIL (New: %s Org: %s)\n", (char *)buffdesc.pstart, testSysContact);
}
free(str);
return;
}
int main(int argc, char **argv)
{
char switch_os_revision_string[100];
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 System 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");
rfc1213SystemSanityTest (&clientHandle);
L7PROC_LOGF(L7PROC_LOG_SEVERITY_INFO, 0, "Stopping System API example application");
return 0;
}