#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "rpcclt_openapi.h"
#include "proc_util.h"
void printAppMenu(char *name)
{
printf("Usage: %s <test#> <arg1> <arg2> ... \n", name);
printf("Usage: For arguments defaultRouters, dnsServers, netBiosNameServers, "
"ntpServers provide mulitple addresses seperated by \",\"\n");
printf("Test 1: Get lease data for ipaddr in default VRF: %s 1 <ipaddr>\n", name);
printf("Test 2: Get lease data for VRF and ipaddr: %s 2 <vrf-name> <ipaddr>\n", name);
printf("Test 3: Get pool entries: %s 3\n", name);
printf("Test 4: Given a pool name, get lease entries: %s 4 <pool name>\n", name);
printf("Test 5: Given a pool name, get pool type: %s 5 <pool name>\n", name);
printf("Test 6: Display DHCP server statistics: %s 6\n", name);
printf("Test 7: Test DHCP server OpEN API Sanity: %s 7\n", name);
printf("Test 8: Add an excluded IP-address range for a VRF: %s 8 <low-ipaddr> <high-ipaddr> <vrf-name>\n", name);
printf("Test 9: Delete an excluded IP-address range for a VRF: %s 9 <low-ipaddr> <high-ipaddr> <vrf-name>\n", name);
printf("Test 10: Set the VRF name for a DHCP Server Pool: %s 10 <pool-name> <vrf-name>\n", name);
printf("Test 11: Reset the VRF name to default VRF's name for a DHCP Server Pool: %s 11 <pool-name>\n", name);
printf("Test 12: Get excluded addresses range entries: %s 12\n", name);
printf("Test 13: Clear all lease data of a VRF: %s 13 <vrf-name>\n", name);
printf("Test 14: Clear lease data for VRF and ipaddr: %s 14 <vrf-name> <ipaddr>\n", name);
printf("Test 15: Clear all lease data of a Pool: %s 15 <pool-name>\n", name);
printf("Test 16: Clear lease data for Pool and ipaddr: %s 16 <pool-name> <ipaddr>\n", name);
printf("Test 17: Clear all lease data across all VRFs: %s 17\n", name);
printf("Test 18: Set the DHCP server admin mode: %s 18 <mode>\n", name);
printf("Test 19: Get the DHCP server admin mode: %s 19\n", name);
printf("Test 20: Set the Bootp client allocation mode: %s 20 <mode>\n", name);
printf("Test 21: Get the Bootp client allocation mode: %s 21\n", name);
printf("Test 22: Set the number of pings to be sent out by DHCP server before assigning the address: %s 22 <pingPacketCount>\n", name);
printf("Test 23: Get the number of pings to be sent out by DHCP server before assigning the address: %s 23 \n", name);
printf("Test 24: Set the number of pings to be sent out by DHCP server before assigning the address, to default count: %s 24 \n", name);
printf("Test 25: Create a DHCP server address pool: %s 25 <poolName>\n", name);
printf("Test 26: Delete a DHCP server address pool: %s 26 <poolName>\n", name);
printf("Test 27: Set the default routers for DHCP hosts in a given pool: %s 27 <poolName> <defaultRouters>\n", name);
printf("Test 28: Get the default routers for DHCP hosts in a given pool: %s 28 <poolName>\n", name);
printf("Test 29: Reset the default routers for DHCP hosts in a given pool: %s 29 <poolName>\n", name);
printf("Test 30: Set the DHCP Host network for a pool: %s 30 <poolName> <networkAddr> <prefixLen>\n", name);
printf("Test 31: Get the DHCP Host network for a pool: %s 31 <poolName>\n", name);
printf("Test 32: Delete the DHCP Host network for a pool: %s 32 <poolName>\n", name);
printf("Test 33: Set the DNS servers for DHCP hosts in a given pool: %s 33 <poolName> <dnsServers>\n", name);
printf("Test 34: Get the DNS servers for DHCP hosts in a given pool: %s 34 <poolName>\n", name);
printf("Test 35: Reset the DNS servers for DHCP hosts in a given pool: %s 35 <poolName>\n", name);
printf("Test 36: Set the Netbios name server addresses in given pool: %s 36 <poolName> <netBiosNameServers>\n", name);
printf("Test 37: Get the Netbios name server addresses in given pool: %s 37 <poolName>\n", name);
printf("Test 38: Delete the Netbios name server addresses in given pool: %s 38 <poolName>\n", name);
printf("Test 39: Set the type of Netbios node: %s 39 <poolName> <nodeType>\n", name);
printf("Test 40: Get the type of Netbios node: %s 40 <poolName>\n", name);
printf("Test 41: Delete the type of Netbios node: %s 41 <poolName>\n", name);
printf("Test 42: Set the DHCP lease time: %s 42 <poolName> <leaseTime>\n", name);
printf("Test 43: Get the DHCP lease time: %s 43 <poolName>\n", name);
printf("Test 44: Reset the DHCP lease time: %s 44 <poolName>\n", name);
printf("Test 45: Set the domain name of a DHCP client: %s 45 <poolName> <domainName>\n", name);
printf("Test 46: Get the domain name of a DHCP client: %s 46 <poolName>\n", name);
printf("Test 47: Delete the domain name of a DHCP client: %s 47 <poolName>\n", name);
printf("Test 48: Set the next server IP address: %s 48 <poolName> <nextAddress>\n", name);
printf("Test 49: Get the next server IP address: %s 49 <poolName>\n", name);
printf("Test 50: Delete the next server IP address: %s 50 <poolName>\n", name);
printf("Test 51: Set the DHCP host hardware address for a manual pool: %s 51 <poolName> <hwAddr> <hwType>\n", name);
printf("Test 52: Get the DHCP host hardware address for a manual pool: %s 52 <poolName>\n", name);
printf("Test 53: Delete the DHCP host hardware address for a manual pool: %s 53 <poolName>\n", name);
printf("Test 54: Set the DHCP Host network for a manual pool: %s 54 <poolName> <hostAddr> <prefixLen>\n", name);
printf("Test 55: Get the DHCP Host network for a manual pool: %s 55 <poolName>\n", name);
printf("Test 56: Delete the DHCP Host address and mask for a pool: %s 56 <poolName>\n", name);
printf("Test 57: Set the boot file name: %s 57 <poolName>\n", name);
printf("Test 58: Get the boot file name: %s 58 <poolName> <fileName>\n", name);
printf("Test 59: Delete the boot file name: %s 59 <poolName>\n", name);
printf("Test 60: Set the NTP server addresses for a given pool: %s 60 <poolName> <ntpServers>\n", name);
printf("Test 61: Get the NTP server addresses for a given pool: %s 61 <poolName>\n", name);
printf("Test 62: Delete the NTP server addresses for a given pool: %s 62 <poolName>\n", name);
printf("Test 63: Clear the DHCP server statistics: %s 63 \n", name);
printf("Test 64: Set the client id of a DHCP client: %s 64 <poolName> <clientId>\n", name);
printf("Test 65: Get the client id of a DHCP client: %s 65 <poolName>\n", name);
printf("Test 66: Delete the client id of a DHCP client: %s 66 <poolName>\n", name);
printf("Test 67: Set the client name of a DHCP client: %s 67 <poolName> <clientName>\n", name);
printf("Test 68: Get the client name of a DHCP client: %s 68 <poolName>\n", name);
printf("Test 69: Delete the client name of a DHCP client: %s 69 <poolName>\n", name);
return;
}
{
uint32_t mask;
uint32_t remaining;
unsigned char buffer[OPEN_MAC_ADDR_LEN];
hwaddr.
size =
sizeof(buffer);
memset(&ipAddr, 0, sizeof(ipAddr));
inet_pton(AF_INET, ipaddr, (
void*)&(ipAddr.
addr.
ipv4));
ipAddr.addr.ipv4 = htonl(ipAddr.addr.ipv4);
if (ipAddr.addr.ipv4 == INADDR_NONE)
{
printf("Invalid IP address string '%s', IPv4 address string required\n",
ipaddr);
}
else
{
&ipAddr,
&mask,
&hwaddr,
&clientId,
&poolName,
&remaining);
{
printf("Bad return code trying to get lease data. (result = %d)\n", result);
}
else
{
printf("IP Addr IP Mask hwaddr Pool Name Remaining Client ID\n");
printf("-------------------------------------------------------------------------------------------------------\n");
printf("%-16s %03d.%03d.%03d.%03d %02x:%02x:%02x:%02x:%02x:%02x %-32s%5d %s\n",
ipaddr, (mask & 0xff000000) >> 24, (mask & 0x00ff0000) >> 16,
(mask & 0x0000ff00) >> 8, mask & 0x000000ff,
buffer[0], buffer[1], buffer[2], buffer[3], buffer[4],
}
}
}
{
uint32_t mask;
uint32_t remaining;
unsigned char buffer[OPEN_MAC_ADDR_LEN];
hwaddr.pstart = buffer;
hwaddr.size = sizeof(buffer);
memset(&ipAddr, 0, sizeof(ipAddr));
inet_pton(AF_INET, ipaddr, (void*)&(ipAddr.addr.ipv4));
ipAddr.addr.ipv4 = htonl(ipAddr.addr.ipv4);
if (ipAddr.addr.ipv4 == INADDR_NONE)
{
printf("Invalid IP address string '%s', IPv4 address string required\n",
ipaddr);
}
else
{
strncpy(strVrfName.
name, vrfName,
sizeof(strVrfName.
name));
&strVrfName,
&ipAddr,
&mask,
&hwaddr,
&clientId,
&poolName,
&remaining);
{
printf("Bad return code trying to get lease data. (result = %d)\n", result);
}
else
{
printf("IP Addr IP Mask hwaddr Pool Name Remaining Client ID\n");
printf("-------------------------------------------------------------------------------------------------------\n");
printf("%-16s %03d.%03d.%03d.%03d %02x:%02x:%02x:%02x:%02x:%02x %-32s%5d %s\n",
ipaddr, (mask & 0xff000000) >> 24, (mask & 0x00ff0000) >> 16,
(mask & 0x0000ff00) >> 8, mask & 0x000000ff,
buffer[0], buffer[1], buffer[2], buffer[3], buffer[4],
}
}
}
void clearDhcpServerVrfIpAddrLeaseData(
openapiClientHandle_t *clientHandle,
char *vrfName,
char *ipaddr)
{
memset(&ipAddr, 0, sizeof(ipAddr));
inet_pton(AF_INET, ipaddr, (void*)&(ipAddr.addr.ipv4));
ipAddr.addr.ipv4 = htonl(ipAddr.addr.ipv4);
if (ipAddr.addr.ipv4 == INADDR_NONE)
{
printf("Invalid IP address string '%s', IPv4 address string required\n", ipaddr);
}
else
{
strncpy(strVrfName.
name, vrfName,
sizeof(strVrfName.
name));
&strVrfName,
&ipAddr);
{
printf("Bad return code trying to clear lease data. (result = %d)\n", result);
}
else
{
printf("Cleared successfully.\n");
}
}
}
{
strncpy(strVrfName.
name, vrfName,
sizeof(strVrfName.
name));
&strVrfName);
{
printf("Bad return code trying to clear lease data. (result = %d)\n", result);
}
else
{
printf("Cleared successfully.\n");
}
}
void clearDhcpServerPoolIpAddrLeaseData(
openapiClientHandle_t *clientHandle,
char *poolName,
char *ipaddr)
{
memset(&ipAddr, 0, sizeof(ipAddr));
inet_pton(AF_INET, ipaddr, (void*)&(ipAddr.addr.ipv4));
ipAddr.addr.ipv4 = htonl(ipAddr.addr.ipv4);
if (ipAddr.addr.ipv4 == INADDR_NONE)
{
printf("Invalid IP address string '%s', IPv4 address string required\n", ipaddr);
}
else
{
strncpy(strPoolName.
name, poolName,
sizeof(strPoolName.
name));
&strPoolName,
&ipAddr);
{
printf("Bad return code trying to clear lease data. (result = %d)\n", result);
}
else
{
printf("Cleared successfully.\n");
}
}
}
{
strncpy(strPoolName.
name, poolName,
sizeof(strPoolName.
name));
&strPoolName);
{
printf("Bad return code trying to clear lease data. (result = %d)\n", result);
}
else
{
printf("Cleared successfully.\n");
}
}
{
{
printf("Bad return code trying to clear lease data. (result = %d)\n", result);
}
else
{
printf("Cleared successfully.\n");
}
}
{
uint32_t index;
{
{
printf("Non-success return code from openapiDhcpServerPoolVrfNameGet(result = %d).\n", result);
return;
}
printf("Pool-Index Pool-Name VRF-Name \n");
printf("---------------------------------------------------------------\n");
{
printf(
"%10d %31s %s\n", index, name.
name, vrfName.
name);
{
printf("Non-success return code from openapiDhcpServerPoolEntryNextGet(result = %d).\n", result);
}
{
{
printf("Non-success return code from openapiDhcpServerPoolVrfNameGet(result = %d).\n", result);
}
}
}
}
else
{
printf("Non-success return code from openapiDhcpServerPoolEntryFirstGet (result = %d).\n", result);
}
}
{
char *ret = "Unknown lease state";
switch(state)
{
ret = "free";
break;
ret = "active";
break;
ret = "offered";
break;
ret = "expired";
break;
ret = "abandoned";
break;
}
return ret;
}
{
uint32_t index;
char ipStr[INET_ADDRSTRLEN];
strncpy(poolName.
name, name,
sizeof(poolName.
name));
&addr, &state);
{
printf("Pool name Lease index IPv4 Addr State\n");
printf("-----------------------------------------------------\n");
{
addr.addr.ipv4=ntohl(addr.addr.ipv4);
inet_ntop(AF_INET, &(addr.addr.ipv4), ipStr, sizeof(ipStr));
printf(
"%-16s %05d %-16s %s\n", poolName.
name, index, ipStr, stateToStr(state));
{
printf("Non-success return code from openapiDhcpServerPoolEntryNextGet(result = %d)\n", result);
}
}
}
else
{
printf("Non-success return code from openapiDhcpServerLeaseEntryFirstGet (result = %d)\n", result);
}
}
{
char *ret = "Unknown type";
switch(type)
{
ret = "inactive";
break;
ret = "dynamic";
break;
ret = "manual";
break;
}
return ret;
}
{
strncpy(poolName.
name, name,
sizeof(poolName.
name));
{
printf("Bad return code from openapiDhcpServerPoolTypeGet. (result = %d)\n", result);
}
else
{
printf("Type for pool %s is %s\n", name, poolTypeToStr(type));
}
}
{
strncpy(poolName.
name, pool_name,
sizeof(poolName.
name));
strncpy(vrfName.
name, vrf_name,
sizeof(vrfName.
name));
{
printf("Bad return code from openapiDhcpServerPoolVrfNameSet. (result = %d)\n", result);
}
else
{
printf("Successfully set. \n");
}
}
{
strncpy(poolName.
name, pool_name,
sizeof(poolName.
name));
{
printf("Bad return code from resetDhcpServerPoolVrfNameToDefaultVrf. (result = %d)\n", result);
}
else
{
printf("Successfully reset. \n");
}
}
{
char startIpStr[INET_ADDRSTRLEN];
char endIpStr[INET_ADDRSTRLEN];
uint32_t index;
&index,
&strVrfName,
&startIpAddr,
&endIpAddr);
{
printf("Index Start-IPaddress End-IPaddress VRF-Name \n");
printf("---------------------------------------------------------------\n");
{
startIpAddr.addr.ipv4=ntohl(startIpAddr.addr.ipv4);
inet_ntop(AF_INET, &(startIpAddr.addr.ipv4), startIpStr, sizeof(startIpStr));
endIpAddr.addr.ipv4=ntohl(endIpAddr.addr.ipv4);
inet_ntop(AF_INET, &(endIpAddr.addr.ipv4), endIpStr, sizeof(endIpStr));
printf(
"%05d %-16s %-16s %s\n", index, startIpStr, endIpStr, strVrfName.
name);
{
printf("Non-success return code from openapiDhcpServerExcludedAddressRangeEntryNextGet(result = %d).\n", result);
}
}
}
else
{
printf("Non-success return code from openapiDhcpServerExcludedAddressRangeEntryFirstGet(result = %d).\n", result);
}
}
void addDhcpServerExcludedAddressRangeForVrf(
openapiClientHandle_t *clientHandle,
char *lowIpAddr,
char *highIpAddr,
char *vrfName)
{
memset(&startIpAddr, 0, sizeof(startIpAddr));
inet_pton(AF_INET, lowIpAddr, (void*)&(startIpAddr.addr.ipv4));
startIpAddr.addr.ipv4 = htonl(startIpAddr.addr.ipv4);
if (startIpAddr.addr.ipv4 == INADDR_NONE)
{
printf("Invalid low IP address string '%s', IPv4 address string required\n", lowIpAddr);
return;
}
memset(&endIpAddr, 0, sizeof(endIpAddr));
inet_pton(AF_INET, highIpAddr, (void*)&(endIpAddr.addr.ipv4));
endIpAddr.addr.ipv4 = htonl(endIpAddr.addr.ipv4);
if (endIpAddr.addr.ipv4 == INADDR_NONE)
{
printf("Invalid high IP address string '%s', IPv4 address string required\n", highIpAddr);
return;
}
strncpy(strVrfName.
name, vrfName,
sizeof(strVrfName.
name));
&strVrfName,
&startIpAddr,
&endIpAddr);
{
printf("Bad return code trying to add an excluded-address range. (result = %d).\n", result);
}
else
{
printf("Successfully added. \n");
}
}
void deleteDhcpServerExcludedAddressRangeForVrf(
openapiClientHandle_t *clientHandle,
char *lowIpAddr,
char *highIpAddr,
char *vrfName)
{
memset(&startIpAddr, 0, sizeof(startIpAddr));
inet_pton(AF_INET, lowIpAddr, (void*)&(startIpAddr.addr.ipv4));
startIpAddr.addr.ipv4 = htonl(startIpAddr.addr.ipv4);
if (startIpAddr.addr.ipv4 == INADDR_NONE)
{
printf("Invalid low IP address string '%s', IPv4 address string required\n", lowIpAddr);
return;
}
memset(&endIpAddr, 0, sizeof(endIpAddr));
inet_pton(AF_INET, highIpAddr, (void*)&(endIpAddr.addr.ipv4));
endIpAddr.addr.ipv4 = htonl(endIpAddr.addr.ipv4);
if (endIpAddr.addr.ipv4 == INADDR_NONE)
{
printf("Invalid high IP address string '%s', IPv4 address string required\n", highIpAddr);
return;
}
strncpy(strVrfName.
name, vrfName,
sizeof(strVrfName.
name));
&strVrfName,
&startIpAddr,
&endIpAddr);
{
printf("Bad return code trying to delete an excluded-address range. (result = %d).\n", result);
}
else
{
printf("Successfully deleted. \n");
}
}
{
{
"Reserved",
"Active Leases",
"Expired Leases",
"Malformed Messages",
"Discover Dropped",
"Discover Received",
"Request Received",
"Decline Received",
"Release Received",
"Inform Received",
"Offer Sent",
"Ack Sent",
"Nack Sent"
};
uint32_t value;
{
{
printf("Bad return code from openapiDhcpServerStatGet for ID %u. (result = %d)\n", id, result);
}
else
{
printf("%-20s: %u\n", statLabel[id], value);
}
}
}
{
{
printf("Bad return code trying to set the DHCP server admin mode. (result = %d)\n", result);
}
else
{
printf(
"\nDHCP sever admin mode is now %s\n", ((
OPEN_ENABLE == mode) ?
"ENABLED" :
"DISABLED"));
}
return;
}
{
{
printf("Bad return code trying to get the DHCP server admin mode. (result = %d)\n", result);
}
else
{
printf(
"\nDHCP sever admin mode is %s\n", ((
OPEN_ENABLE == mode) ?
"ENABLED" :
"DISABLED"));
}
return;
}
{
{
printf("Bad return code trying to set the Bootp client allocation mode. (result = %d)\n", result);
}
else
{
printf(
"\nDHCP Bootp automatic allocation is now %s\n", ((
OPEN_ENABLE == mode) ?
"ENABLED" :
"DISABLED"));
}
return;
}
{
{
printf ("Bad return code trying to get the Bootp client allocation mode. (result = %d)\n", result);
}
else
{
printf (
"\nDHCP Bootp automatic allocation is %s\n", ((
OPEN_ENABLE == mode) ?
"ENABLED" :
"DISABLED"));
}
return;
}
{
{
printf("Bad return code trying to set the number of pings to be sent out by DHCP server before assigning the address. (result = %d)\n", result);
}
else
{
printf("\nThe number of pings sent out by DHCP server is now %u\n", pingPacketCount);
}
return;
}
{
uint32_t pingPacketCount = 0;
{
printf("Bad return code trying to get the number of pings to be sent out by DHCP server before assigning the address. (result = %d)\n", result);
}
else
{
printf("\nThe number of pings sent out by DHCP server is %u\n", pingPacketCount);
}
return;
}
{
{
printf("Bad return code trying to set the number of pings to be sent out by DHCP server before assigning the address, to default count. (result = %d)\n", result);
}
else
{
printf ("\nThe number of ping packets sent out by DHCP server is now set to defaults\n");
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to create a DHCP server address pool. (result = %d)\n", result);
}
else
{
printf("\nDHCP server Pool \"%s\" is created\n", poolNameStr);
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to delete a DHCP server address pool. (result = %d)\n", result);
}
else
{
printf("\nDHCP server Pool \"%s\" is deleted\n", poolNameStr);
}
return;
}
char *poolName, char *defRtrs)
{
char *str_ptr = NULL;
char *ptr = NULL;
uint32_t i = 0;
char str[40];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (&defaultRouters, 0, sizeof (defaultRouters));
ptr = strtok_r (defRtrs, ",", &(str_ptr));
while (NULL != ptr)
{
memset(str, 0, sizeof(str));
strncpy(str, ptr, sizeof(str) - 1);
ipBuffdesc.pstart = str;
ipBuffdesc.size = strlen(str) + 1;
memset(&ipAddr, 0, sizeof(ipAddr));
{
printf("Bad return code trying to convert IP address. (result = %d)\n", result);
return;
}
{
printf("Invalid IPv4 address. \n");
return;
}
defaultRouters.
routers[i] = ipAddr.addr.ipv4;
ptr = strtok_r (NULL, ",", &(str_ptr));
i++;
}
{
printf("Bad return code trying to set the default routers for DHCP hosts in a given pool. (result = %d)\n", result);
}
else
{
printf("\nConfigured the pool \"%s\" with default routers\n", poolNameStr);
}
return;
}
char *poolName)
{
uint32_t i = 0;
char ipStr[16];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (&defaultRouters, 0, sizeof (defaultRouters));
{
printf("Bad return code trying to get the default routers for DHCP hosts in a given pool. (result = %d)\n", result);
}
else
{
printf ("\nDefault routers configured for the pool \"%s\" :", poolNameStr);
for (i = 0; i < OPEN_DHCPS_DEFAULT_ROUTER_MAX; i++)
{
if (0 == defaultRouters.routers[i])
{
continue;
}
defaultRouters.routers[i] = ntohl (defaultRouters.routers[i]);
memset (ipStr, 0, sizeof (ipStr));
inet_ntop (AF_INET, &defaultRouters.routers[i],
ipStr, 16);
printf ("\n %s", ipStr);
}
printf ("\n");
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to reset the default routers for DHCP hosts in a given pool. (result = %d)\n", result);
}
else
{
printf ("\nCleared the default routers configuration for the pool \"%s\"\n", poolNameStr);
}
return;
}
char *poolName, char *nwAddr, uint32_t prefixLen)
{
char str[40];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (str, 0, sizeof (str));
strncpy (str, nwAddr, sizeof (str) - 1);
ipBuffdesc.pstart = str;
ipBuffdesc.size = strlen(str) + 1;
memset (&networkAddr, 0, sizeof (networkAddr));
{
printf ("Bad return code trying to convert IP address. (result = %d)\n", result);
return;
}
networkAddr.
pfxLen = prefixLen;
{
printf("Bad return code trying to set the DHCP Host network for a pool. (result = %d)\n", result);
}
else
{
printf ("\nNetwork configured for the pool \"%s\"\n", poolNameStr);
}
return;
}
{
char ipStr[16];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to get the DHCP Host network for a pool. (result = %d)\n", result);
}
else
{
networkAddr.ipAddr.addr.ipv4 = ntohl (networkAddr.ipAddr.addr.ipv4);
memset (ipStr, 0, sizeof (ipStr));
inet_ntop (AF_INET, &(networkAddr.ipAddr.addr.ipv4), ipStr, 16);
printf ("\nNetwork configured for the pool \"%s\" : %s/%u\n",
poolNameStr, ipStr, networkAddr.pfxLen);
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to delete the DHCP Host network for a pool. (result = %d)\n", result);
}
else
{
printf ("\nCleared the network configuration for the pool \"%s\"\n", poolNameStr);
}
return;
}
{
char *str_ptr = NULL;
char *ptr = NULL;
uint32_t i = 0;
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (&dnsServers, 0, sizeof (dnsServers));
ptr = strtok_r (dnsSrvs, ",", &(str_ptr));
while (NULL != ptr)
{
inet_pton (AF_INET, ptr, &dnsServers.
dns_servers[i]);
dnsServers.dns_servers[i] = htonl (dnsServers.dns_servers[i]);
ptr = strtok_r (NULL, ",", &(str_ptr));
i++;
}
{
printf("Bad return code trying to set the DNS servers for DHCP hosts in a given pool. (result = %d)\n", result);
}
else
{
printf("\nConfigured the pool \"%s\" with DNS servers\n", poolNameStr);
}
return;
}
{
uint32_t i = 0;
char ipStr[16];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to get the DNS servers for DHCP hosts in a given pool. (result = %d)\n", result);
}
else
{
printf ("\nDNS servers configured for the pool \"%s\" :", poolNameStr);
for (i = 0; i < OPEN_DHCPS_DNS_SERVER_MAX; i++)
{
if (0 == dnsServers.dns_servers[i])
{
continue;
}
dnsServers.dns_servers[i] = ntohl (dnsServers.dns_servers[i]);
memset (ipStr, 0, sizeof (ipStr));
inet_ntop (AF_INET, &dnsServers.dns_servers[i],
ipStr, 16);
printf ("\n %s", ipStr);
}
printf ("\n");
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to reset the DNS servers for DHCP hosts in a given pool. (result = %d)\n", result);
}
else
{
printf ("\nCleared the DNS server configuration for the pool \"%s\"\n", poolNameStr);
}
return;
}
char *poolName, char *netbiosNameSrvs)
{
char *str_ptr = NULL;
char *ptr = NULL;
uint32_t i = 0;
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (&netBiosNameServers, 0, sizeof (netBiosNameServers));
ptr = strtok_r (netbiosNameSrvs, ",", &(str_ptr));
while (NULL != ptr)
{
inet_pton (AF_INET, ptr, &netBiosNameServers.
servers[i]);
netBiosNameServers.servers[i] = htonl (netBiosNameServers.servers[i]);
ptr = strtok_r (NULL, ",", &(str_ptr));
i++;
}
{
printf("Bad return code trying to set the Netbios name server addresses in given pool. (result = %d)\n", result);
}
else
{
printf("\nConfigured the pool \"%s\" with netbios name servers\n", poolNameStr);
}
return;
}
{
uint32_t i = 0;
char ipStr[16];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to get the Netbios name server addresses in given pool. (result = %d)\n", result);
}
else
{
printf ("\nNetbios name servers configured for the pool \"%s\" :", poolNameStr);
for (i = 0; i < OPEN_DHCPS_NETBIOS_NAME_SERVER_MAX; i++)
{
if (0 == netBiosNameServers.servers[i])
{
continue;
}
netBiosNameServers.servers[i] = ntohl (netBiosNameServers.servers[i]);
memset (ipStr, 0, sizeof (ipStr));
inet_ntop (AF_INET, &netBiosNameServers.servers[i],
ipStr, 16);
printf ("\n %s", ipStr);
}
printf ("\n");
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to delete the Netbios name server addresses in given pool. (result = %d)\n", result);
}
else
{
printf ("\nCleared the netbios name server configuration for the pool \"%s\"\n", poolNameStr);
}
return;
}
char *poolName, uint32_t nodeType)
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to set the type of Netbios node. (result = %d)\n", result);
}
else
{
printf("\nConfigured the pool \"%s\" with node type %u\n", poolNameStr, nodeType);
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to get the type of Netbios node. (result = %d)\n", result);
}
else
{
printf("\nThe node type of the pool \"%s\" is set to %u\n", poolNameStr, (uint32_t)nodeType);
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to delete the type of Netbios node. (result = %d)\n", result);
}
else
{
printf ("\nCleared the node type configuration for the pool \"%s\"\n", poolNameStr);
}
return;
}
char *poolName, uint32_t leaseTime)
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to set the DHCP lease time. (result = %d)\n", result);
}
else
{
printf("\nConfigured the pool \"%s\" with lease time %u\n", poolNameStr, leaseTime);
}
return;
}
{
uint32_t leaseTime;
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to get the DHCP lease time. (result = %d)\n", result);
}
else
{
printf("\nLease time for the pool \"%s\" is %u\n", poolNameStr, leaseTime);
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to reset the DHCP lease time. (result = %d)\n", result);
}
else
{
printf ("\nCleared the lease time configuration for the pool \"%s\"\n", poolNameStr);
}
return;
}
{
char domainNameStr[OPEN_DHCPS_DOMAIN_NAME_MAXLEN];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (domainNameStr, 0, sizeof (domainNameStr));
memcpy (domainNameStr, domainName, strlen (domainName));
domainNameBuf.pstart = domainNameStr;
domainNameBuf.size = sizeof (domainNameStr);
{
printf("Bad return code trying to set the domain name of a DHCP client. (result = %d)\n", result);
}
else
{
printf("\nConfigured the pool \"%s\" with domain name %s\n", poolNameStr, domainNameStr);
}
return;
}
{
char domainNameStr[OPEN_DHCPS_DOMAIN_NAME_MAXLEN];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (domainNameStr, 0, sizeof (domainNameStr));
domainNameBuf.pstart = domainNameStr;
domainNameBuf.size = sizeof (domainNameStr);
{
printf("Bad return code trying to get the domain name of a DHCP client. (result = %d)\n", result);
}
else
{
printf("\nDomain name for the pool \"%s\" is %s\n", poolNameStr, domainNameStr);
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to delete the domain name of a DHCP client. (result = %d)\n", result);
}
else
{
printf ("\nCleared the domain name configuration for the pool \"%s\"\n", poolNameStr);
}
return;
}
char *poolName, char *nextAddress)
{
char str[40];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (str, 0, sizeof (str));
strncpy (str, nextAddress, sizeof (str) - 1);
ipBuffdesc.pstart = str;
ipBuffdesc.size = strlen(str) + 1;
memset (&nextServerAddr, 0, sizeof (nextServerAddr));
{
printf ("Bad return code trying to convert IP address. (result = %d)\n", result);
return;
}
{
printf("Bad return code trying to set the next server IP address. (result = %d)\n", result);
}
else
{
printf ("\nNext server address configured for the pool \"%s\"\n", poolNameStr);
}
return;
}
{
char ipStr[16];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to get the next server IP address. (result = %d)\n", result);
}
else
{
nextServerAddr.addr.ipv4 = ntohl (nextServerAddr.addr.ipv4);
memset (ipStr, 0, sizeof (ipStr));
inet_ntop (AF_INET, &(nextServerAddr.addr.ipv4), ipStr, 16);
printf ("\nNext server configured for the pool \"%s\" : %s\n",
poolNameStr, ipStr);
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to delete the next server IP address. (result = %d)\n", result);
}
else
{
printf ("\nCleared the next server configuration for the pool \"%s\"\n", poolNameStr);
}
return;
}
char *hwAddr, uint32_t hwType)
{
char hwAddrStr[OPEN_MAC_ADDR_STR_LEN];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (hwAddrStr, 0, sizeof (hwAddrStr));
memcpy (hwAddrStr, hwAddr, strlen (hwAddr));
hwAddrBuf.pstart = hwAddrStr;
hwAddrBuf.size = sizeof (hwAddrStr);
{
printf("Bad return code trying to set the DHCP host hardware address for a manual pool. (result = %d)\n", result);
}
else
{
printf ("\nClient Hardware address configured for the manual pool \"%s\"\n", poolNameStr);
}
return;
}
{
char hwAddrStr[OPEN_MAC_ADDR_STR_LEN];
OPEN_DHCPS_HW_TYPES_t hwType;
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (hwAddrStr, 0, sizeof (hwAddrStr));
hwAddrBuf.pstart = hwAddrStr;
hwAddrBuf.size = sizeof (hwAddrStr);
{
printf("Bad return code trying to get the DHCP host hardware address for a manual pool. (result = %d)\n", result);
}
else
{
printf ("\nClient Hardware address configured for the manual pool \"%s\" is %s and type is %u\n",
poolNameStr, hwAddrStr, hwType);
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to delete the DHCP host hardware address for a manual pool. (result = %d)\n", result);
}
else
{
printf ("\nCleared the hardware address configuration for the pool \"%s\"\n", poolNameStr);
}
return;
}
char *ipAddr, uint32_t prefixLen)
{
char str[40];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (str, 0, sizeof (str));
strncpy (str, ipAddr, sizeof (str) - 1);
ipBuffdesc.pstart = str;
ipBuffdesc.size = strlen(str) + 1;
memset (&hostAddr, 0, sizeof (hostAddr));
{
printf ("Bad return code trying to convert IP address. (result = %d)\n", result);
return;
}
hostAddr.pfxLen = prefixLen;
{
printf("Bad return code trying to set the DHCP Host network for a manual pool. (result = %d)\n", result);
}
else
{
printf ("\nHost address configured for the manual pool \"%s\"\n", poolNameStr);
}
return;
}
{
char ipStr[16];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to get the DHCP Host network for a manual pool. (result = %d)\n", result);
}
else
{
hostAddr.ipAddr.addr.ipv4 = ntohl (hostAddr.ipAddr.addr.ipv4);
memset (ipStr, 0, sizeof (ipStr));
inet_ntop (AF_INET, &(hostAddr.ipAddr.addr.ipv4), ipStr, 16);
printf ("\nNetwork configured for the manual pool \"%s\" : %s/%u\n",
poolNameStr, ipStr, hostAddr.pfxLen);
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to delete the DHCP Host address and mask for a pool. (result = %d)\n", result);
}
else
{
printf ("\nCleared the host configuration for the pool \"%s\"\n", poolNameStr);
}
return;
}
{
char fileNameStr[OPEN_DHCPS_BOOT_FILE_NAME_MAXLEN];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (fileNameStr, 0, sizeof (fileNameStr));
memcpy (fileNameStr, fileName, strlen (fileName));
fileNameBuf.pstart = fileNameStr;
fileNameBuf.size = sizeof (fileNameStr);
{
printf("Bad return code trying to set the boot file name. (result = %d)\n", result);
}
else
{
printf("\nConfigured the pool \"%s\" with bootp file name %s\n", poolNameStr, fileNameStr);
}
return;
}
{
char fileNameStr[OPEN_DHCPS_BOOT_FILE_NAME_MAXLEN];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (fileNameStr, 0, sizeof (fileNameStr));
fileNameBuf.pstart = fileNameStr;
fileNameBuf.size = sizeof (fileNameStr);
{
printf("Bad return code trying to get the boot file name. (result = %d)\n", result);
}
else
{
printf("\nBootp filename configured for the pool \"%s\" is %s\n", poolNameStr, fileNameStr);
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to delete the boot file name. (result = %d)\n", result);
}
else
{
printf ("\nCleared the bootp file name configuration for the pool \"%s\"\n", poolNameStr);
}
return;
}
{
char *str_ptr = NULL;
char *ptr = NULL;
uint32_t i = 0;
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (&ntpServers, 0, sizeof (ntpServers));
ptr = strtok_r (ntpSrvs, ",", &(str_ptr));
while (NULL != ptr)
{
inet_pton (AF_INET, ptr, &ntpServers.
ntp_servers[i]);
ntpServers.ntp_servers[i] = htonl (ntpServers.ntp_servers[i]);
ptr = strtok_r (NULL, ",", &(str_ptr));
i++;
}
{
printf("Bad return code trying to set the NTP server addresses for a given pool. (result = %d)\n", result);
}
else
{
printf("\nConfigured the pool \"%s\" with ntp servers\n", poolNameStr);
}
return;
}
{
uint32_t i = 0;
char ipStr[16];
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to get the NTP server addresses for a given pool. (result = %d)\n", result);
}
else
{
printf ("\nNTP servers configured for the pool \"%s\" :", poolNameStr);
for (i = 0; i < OPEN_DHCPS_NTP_SERVER_MAX; i++)
{
if (0 == ntpServers.ntp_servers[i])
{
continue;
}
ntpServers.ntp_servers[i] = ntohl (ntpServers.ntp_servers[i]);
memset (ipStr, 0, sizeof (ipStr));
inet_ntop (AF_INET, &ntpServers.ntp_servers[i],
ipStr, 16);
printf ("\n %s", ipStr);
}
printf ("\n");
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to delete the NTP server addresses for a given pool. (result = %d)\n", result);
}
else
{
printf ("\nCleared the ntp server configuration for the pool \"%s\"\n", poolNameStr);
}
return;
}
{
{
printf("Bad return code trying to delete the NTP server addresses for a given pool. (result = %d)\n", result);
}
else
{
printf ("\nCleared the DHCP server statistics.\n");
}
return;
}
{
uint32_t clientIdLen = 0;
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (clientIdStr, 0, sizeof (clientIdStr));
memcpy (clientIdStr, clientId, strlen (clientId));
clientIdBuf.pstart = clientIdStr;
{
printf("Bad return code trying to convert the client id. (result = %d)\n", result);
}
{
printf("Bad return code trying to set the client id of a DHCP client. (result = %d)\n", result);
}
else
{
printf("\nConfigured the pool \"%s\" with client id %s\n", poolNameStr, clientIdStr);
}
return;
}
{
uint32_t clientIdLen = 0;
uint32_t i = 0;
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf ("Bad return code trying to get the client id. (result = %d)\n", result);
}
else
{
printf ("\nClient id for the pool \"%s\" is : ", poolNameStr);
for (i = 0; i < clientIdLen; i++)
{
if (i == 0)
{
printf (
"%02x", (uint8_t)clientIdArray.
clientid[i]);
}
else
{
printf (
":%02x", (uint8_t)clientIdArray.
clientid[i]);
}
}
printf ("\n");
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to delete the client name of a DHCP client. (result = %d)\n", result);
}
else
{
printf ("\nCleared the client id configuration for the pool \"%s\"\n", poolNameStr);
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (clientNameStr, 0, sizeof (clientNameStr));
memcpy (clientNameStr, clientName, strlen (clientName));
clientNameBuf.pstart = clientNameStr;
clientNameBuf.size = sizeof (clientNameStr);
{
printf("Bad return code trying to set the client name of a DHCP client. (result = %d)\n", result);
}
else
{
printf("\nConfigured the pool \"%s\" with client name %s\n", poolNameStr, clientNameStr);
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
memset (clientNameStr, 0, sizeof (clientNameStr));
clientNameBuf.pstart = clientNameStr;
clientNameBuf.size = sizeof (clientNameStr);
{
printf("Bad return code trying to get the client name of a DHCP client. (result = %d)\n", result);
}
else
{
printf("\nClient name for the pool \"%s\" is %s\n", poolNameStr, clientNameStr);
}
return;
}
{
memset (poolNameStr, 0, sizeof (poolNameStr));
memcpy (poolNameStr, poolName, strlen (poolName));
poolNameBuf.pstart = poolNameStr;
poolNameBuf.size = sizeof (poolNameStr);
{
printf("Bad return code trying to delete the client name of a DHCP client. (result = %d)\n", result);
}
else
{
printf ("\nCleared the client name configuration for the pool \"%s\"\n", poolNameStr);
}
return;
}
{
uint32_t mask;
uint32_t poolIndex;
uint32_t leaseIndex;
uint32_t val1;
uint32_t remaining;
char buf[OPEN_MAC_ADDR_LEN];
hwaddr.pstart = buf;
hwaddr.size = sizeof(buf);
printf("\nTesting openapiDhcpServerLeaseDataGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("NULL ipaddr. (result = %d)\n", result);
printf("NULL mask. (result = %d)\n", result);
printf("NULL hwaddr. (result = %d)\n", result);
printf("NULL client ID. (result = %d)\n", result);
printf("NULL pool name pointer. (result = %d)\n", result);
printf("NULL remaining pointer. (result = %d)\n", result);
hwaddr.pstart = buf;
hwaddr.size = 1;
printf("hwaddr size too small. (result = %d)\n", result);
hwaddr.pstart = NULL;
hwaddr.size = sizeof(buf);
printf("NULL hwaddr pstart. (result = %d)\n", result);
printf("openapiDhcpServerLeaseDataGet() sanity successful. \n");
printf("\nTesting openapiDhcpServerPoolEntryFirstGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("NULL pool index. (result = %d)\n", result);
printf("NULL pool name. (result = %d)\n", result);
printf("openapiDhcpServerPoolEntryFirstGet() sanity successful. \n");
printf("\nTesting openapiDhcpServerPoolEntryNextGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("NULL pool index. (result = %d)\n", result);
printf("NULL pool name. (result = %d)\n", result);
printf("openapiDhcpServerPoolEntryNextGet() sanity successful. \n");
printf("\nTesting openapiDhcpServerPoolTypeGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("NULL pool name. (result = %d)\n", result);
printf("NULL type. (result = %d)\n", result);
printf("openapiDhcpServerPoolTypeGet() sanity successful. \n");
printf("\nTesting openapiDhcpServerLeaseEntryFirstGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("NULL pool name. (result = %d)\n", result);
printf("NULL lease index. (result = %d)\n", result);
printf("NULL IP addr. (result = %d)\n", result);
printf("NULL state. (result = %d)\n", result);
printf("openapiDhcpServerLeaseEntryFirstGet() sanity successful. \n");
printf("\nTesting openapiDhcpServerLeaseEntryNextGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("NULL pool name. (result = %d)\n", result);
printf("NULL lease index. (result = %d)\n", result);
printf("NULL IP addr. (result = %d)\n", result);
printf("NULL state. (result = %d)\n", result);
printf("openapiDhcpServerLeaseEntryNextGet() sanity successful. \n");
printf("\nTesting openapiDhcpServerStatGet(): \n");
printf("NULL Client Handle. (result = %d)\n", result);
printf("Invalid statistic ID (too low). (result = %d)\n", result);
printf("Invalid statistic ID (too high). (result = %d)\n", result);
printf("NULL statistic output value pointer. (result = %d)\n", result);
printf("openapiDhcpServerStatGet() sanity successful. \n");
}
int main(int argc, char **argv)
{
uint32_t testNum;
char switch_os_revision_string[100];
if (argc < 2)
{
printAppMenu(argv[0]);
exit(1);
}
testNum = atoi(argv[1]);
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 DHCP Server 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 != 3)
{
printAppMenu(argv[0]);
exit(1);
}
getDhcpServerLeaseData(&clientHandle, argv[2]);
break;
case 2:
if (argc != 4)
{
printAppMenu(argv[0]);
exit(1);
}
getDhcpServerVrfIpAddrLeaseData(&clientHandle, argv[2], argv[3]);
break;
case 3:
if (argc != 2)
{
printAppMenu(argv[0]);
exit(1);
}
getDhcpServerPoolEntries(&clientHandle);
break;
case 4:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
getDhcpServerLeaseEntries(&clientHandle, argv[2]);
break;
case 5:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
getDhcpServerPoolTypeForName(&clientHandle, argv[2]);
break;
case 6:
if (argc != 2)
{
printAppMenu(argv[0]);
exit(1);
}
displayDhcpServerStats(&clientHandle);
break;
case 7:
if (argc != 2)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpServerOpENAPIsSanity(&clientHandle);
break;
case 8:
if (argc != 5)
{
printAppMenu(argv[0]);
exit(1);
}
addDhcpServerExcludedAddressRangeForVrf(&clientHandle, argv[2], argv[3], argv[4]);
break;
case 9:
if (argc != 5)
{
printAppMenu(argv[0]);
exit(1);
}
deleteDhcpServerExcludedAddressRangeForVrf(&clientHandle, argv[2], argv[3], argv[4]);
break;
case 10:
if (argc != 4)
{
printAppMenu(argv[0]);
exit(1);
}
setDhcpServerPoolVrfName(&clientHandle, argv[2], argv[3]);
break;
case 11:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
resetDhcpServerPoolVrfNameToDefaultVrf(&clientHandle, argv[2]);
break;
case 12:
if (argc != 2)
{
printAppMenu(argv[0]);
exit(1);
}
getDhcpServerExcludedAddressesRangeEntries(&clientHandle);
break;
case 13:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
clearDhcpServerVrfLeaseData(&clientHandle, argv[2]);
break;
case 14:
if (argc != 4)
{
printAppMenu(argv[0]);
exit(1);
}
clearDhcpServerVrfIpAddrLeaseData(&clientHandle, argv[2], argv[3]);
break;
case 15:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
clearDhcpServerPoolLeaseData(&clientHandle, argv[2]);
break;
case 16:
if (argc != 4)
{
printAppMenu(argv[0]);
exit(1);
}
clearDhcpServerPoolIpAddrLeaseData(&clientHandle, argv[2], argv[3]);
break;
case 17:
if (argc != 2)
{
printAppMenu(argv[0]);
exit(1);
}
clearDhcpServerAllLeaseData(&clientHandle);
break;
case 18:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsAdminModeSet (&clientHandle, atoi(argv[2]));
break;
case 19:
if (argc != 2)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsAdminModeGet (&clientHandle);
break;
case 20:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsBootpAutomaticSet (&clientHandle, atoi(argv[2]));
break;
case 21:
if (argc != 2)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsBootpAutomaticGet (&clientHandle);
break;
case 22:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNoOfPingPktSet (&clientHandle, atoi(argv[2]));
break;
case 23:
if (argc != 2)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNoOfPingPktGet (&clientHandle);
break;
case 24:
if (argc != 2)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNoOfPingPktReset (&clientHandle);
break;
case 25:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsPoolCreate (&clientHandle, argv[2]);
break;
case 26:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsPoolDelete (&clientHandle, argv[2]);
break;
case 27:
if (argc != 4)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsDefaultRoutersSet (&clientHandle, argv[2], argv[3]);
break;
case 28:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsDefaultRoutersGet (&clientHandle, argv[2]);
break;
case 29:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsDefaultRoutersIpReset (&clientHandle, argv[2]);
break;
case 30:
if (argc != 5)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNetworkSet (&clientHandle, argv[2], argv[3], atoi(argv[4]));
break;
case 31:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNetworkGet (&clientHandle, argv[2]);
break;
case 32:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNetworkDelete (&clientHandle, argv[2]);
break;
case 33:
if (argc != 4)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsDnsServersSet (&clientHandle, argv[2], argv[3]);
break;
case 34:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsDnsServersGet (&clientHandle, argv[2]);
break;
case 35:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsDnsServersReset (&clientHandle, argv[2]);
break;
case 36:
if (argc != 4)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNetbiosNameServerAddressSet (&clientHandle, argv[2], argv[3]);
break;
case 37:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNetbiosNameServerAddressGet (&clientHandle, argv[2]);
break;
case 38:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNetbiosNameServerAddressDelete (&clientHandle, argv[2]);
break;
case 39:
if (argc != 4)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNetbiosNodeTypeSet (&clientHandle, argv[2], atoi (argv[3]));
break;
case 40:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNetbiosNodeTypeGet (&clientHandle, argv[2]);
break;
case 41:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNetbiosNodeTypeDelete (&clientHandle, argv[2]);
break;
case 42:
if (argc != 4)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsLeaseTimeSet (&clientHandle, argv[2], atoi (argv[3]));
break;
case 43:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsLeaseTimeGet (&clientHandle, argv[2]);
break;
case 44:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsLeaseTimeReset (&clientHandle, argv[2]);
break;
case 45:
if (argc != 4)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsDomainNameSet (&clientHandle, argv[2], argv[3]);
break;
case 46:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsDomainNameGet (&clientHandle, argv[2]);
break;
case 47:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsDomainNameDelete (&clientHandle, argv[2]);
break;
case 48:
if (argc != 4)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNextServerSet (&clientHandle, argv[2], argv[3]);
break;
case 49:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNextServerGet (&clientHandle, argv[2]);
break;
case 50:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNextServerDelete (&clientHandle, argv[2]);
break;
case 51:
if (argc != 5)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsHwAddressSet (&clientHandle, argv[2], argv[3], atoi(argv[4]));
break;
case 52:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsHwAddressGet (&clientHandle, argv[2]);
break;
case 53:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsHwAddressDelete (&clientHandle, argv[2]);
break;
case 54:
if (argc != 5)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsHostSet (&clientHandle, argv[2], argv[3], atoi(argv[4]));
break;
case 55:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsHostGet (&clientHandle, argv[2]);
break;
case 56:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsHostDelete (&clientHandle, argv[2]);
break;
case 57:
if (argc != 4)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsBootfileSet (&clientHandle, argv[2], argv[3]);
break;
case 58:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsBootfileGet (&clientHandle, argv[2]);
break;
case 59:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsBootfileDelete (&clientHandle, argv[2]);
break;
case 60:
if (argc != 4)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNTPServerSet (&clientHandle, argv[2], argv[3]);
break;
case 61:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNTPServerGet (&clientHandle, argv[2]);
break;
case 62:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsNTPServerDelete (&clientHandle, argv[2]);
break;
case 63:
if (argc != 2)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsClearStatistics (&clientHandle);
break;
case 64:
if (argc != 4)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsClientIdSet (&clientHandle, argv[2], argv[3]);
break;
case 65:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsClientIdGet (&clientHandle, argv[2]);
break;
case 66:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsClientIdDelete (&clientHandle, argv[2]);
break;
case 67:
if (argc != 4)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsClientNameSet (&clientHandle, argv[2], argv[3]);
break;
case 68:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsClientNameGet (&clientHandle, argv[2]);
break;
case 69:
if (argc != 3)
{
printAppMenu(argv[0]);
exit(1);
}
dhcpsClientNameDelete (&clientHandle, argv[2]);
break;
default:
printAppMenu(argv[0]);
break;
}
L7PROC_LOGF(L7PROC_LOG_SEVERITY_INFO, 0, "Stopping DHCP Server API example application");
return 0;
}