This document provides a brief description of the DHCP Server OpEN APIs. It provides the following services:
- Get lease data for a specific IP address in default VRF.
- Get lease data for a specific VRF and IP address.
- Get pool entries.
- Given a pool name, get lease entries.
- Given a pool name, get pool type.
- Display DHCP server statistics.
- Test DHCP server OpEN API Sanity.
- Add an excluded IP-address range for a specific VRF.
- Delete an excluded IP-address range for a specific VRF.
- Set the VRF name for a DHCP server pool.
- Reset the VRF name to default VRF's name for a DHCP server pool.
- Get excluded addresses range entries.
- Clear all lease data of a VRF.
- Clear lease data for VRF and ipaddr.
- Clear all lease data of a pool.
- Clear lease data for a specific pool and IP address.
- Clear all lease data across all VRFs.
- Set the DHCP server admin mode.
- Get the DHCP server admin mode.
- Set the Bootp client allocation mode.
- Get the Bootp client allocation mode.
- Set the number of pings to be sent out by DHCP server before assigning the address.
- Get the number of pings to be sent out by DHCP server before assigning the address.
- Set the number of pings to be sent out by DHCP server before assigning the address, to default count.
- Create a DHCP server address pool.
- Delete a DHCP server address pool.
- Set the default routers for DHCP hosts in a given pool.
- Get the default routers for DHCP hosts in a given pool.
- Reset the default routers for DHCP hosts in a given pool.
- Set the DHCP Host network for a pool.
- Get the DHCP Host network for a pool.
- Delete the DHCP Host network for a pool.
- Set the DNS servers for DHCP hosts in a given pool.
- Get the DNS servers for DHCP hosts in a given pool.
- Reset the DNS servers for DHCP hosts in a given pool.
- Set the Netbios name server addresses in given pool.
- Get the Netbios name server addresses in given pool.
- Delete the Netbios name server addresses in given pool.
- Set the type of Netbios node.
- Get the type of Netbios node.
- Delete the type of Netbios node.
- Set the DHCP lease time.
- Get the DHCP lease time.
- Reset the DHCP lease time.
- Set the domain name of a DHCP client.
- Get the domain name of a DHCP client.
- Delete the domain name of a DHCP client.
- Set the next server IP address.
- Get the next server IP address.
- Delete the next server IP address.
- Set the DHCP host hardware address for a manual pool.
- Get the DHCP host hardware address for a manual pool.
- Delete the DHCP host hardware address for a manual pool.
- Set the DHCP Host network for a manual pool.
- Get the DHCP Host network for a manual pool.
- Delete the DHCP Host address and mask for a pool.
- Set the boot file name.
- Get the boot file name.
- Delete the boot file name.
- Set the NTP server addresses for a given pool.
- Get the NTP server addresses for a given pool.
- Delete the NTP server addresses for a given pool.
- Clear the DHCP server statistics.
- Configure the client identifier of the DHCP client.
- Get the client identifier of the DHCP client.
- Delete the client identifier of the DHCP client.
- Configure the client name of the DHCP client.
- Get the client name of the DHCP client.
- Delete the client name of the DHCP client.
Example C Application dhcp_server_example
Initialization
In the main function, the sample application initializes the OpEN API RPC service by calling openapiClientRegister() and waits for the RPC service in switchdrvr to start. A Client Handle is returned by openapiClientRegister() which is used while invoking the OpEN APIs. The application then exercises the associated OpEN APIs and logs informational and/or error messages on the console. The example application runs to its completion and exits.
dhcp_server_example
dhcp_server_example.c is a sample application that demonstrates the use of OpEN's DHCP Server APIs. dhcp_server_example is started from the command line and can be used to exercise the various APIs by specifying arguments on the command line.
Sample Output
- Usage: dhcps_example <test#> <arg1> <arg2> ...
- Usage: For arguments defaultRouters, dnsServers, netBiosNameServers, ntpServers provide mulitple addresses seperated by a comma
- Test 1: Get lease data for ipaddr in default VRF: dhcps_example 1 <ipaddr>
- Test 2: Get lease data for VRF and ipaddr: dhcps_example 2 <vrf-name> <ipaddr>
- Test 3: Get pool entries: dhcps_example 3
- Test 4: Given a pool name, get lease entries: dhcps_example 4 <pool name>="">
- Test 5: Given a pool name, get pool type: dhcps_example 5 <pool name>="">
- Test 6: Display DHCP server statistics: dhcps_example 6
- Test 7: Test DHCP server OpEN API Sanity: dhcps_example 7
- Test 8: Add an excluded IP-address range for a VRF: dhcps_example 8 <low-ipaddr> <high-ipaddr> <vrf-name>
- Test 9: Delete an excluded IP-address range for a VRF: dhcps_example 9 <low-ipaddr> <high-ipaddr> <vrf-name>
- Test 10: Set the VRF name for a DHCP server pool: dhcps_example 10 <pool-name> <vrf-name>
- Test 11: Reset the VRF name to default VRF's name for a DHCP server pool: dhcps_example 11 <pool-name>
- Test 12: Get excluded addresses range entries: dhcps_example 12
- Test 13: Clear all lease data of a VRF: dhcps_example 13 <vrf-name>
- Test 14: Clear lease data for VRF and ipaddr: dhcps_example 14 <vrf-name> <ipaddr>
- Test 15: Clear all lease data of a pool: dhcps_example 15 <pool-name>
- Test 16: Clear lease data for pool and ipaddr: dhcps_example 16 <pool-name> <ipaddr>
- Test 17: Clear all lease data across all VRFs: dhcps_example 17
- Test 18: Set the DHCP server admin mode: dhcpserver_example 18 <mode>
- Test 19: Get the DHCP server admin mode: dhcpserver_example 19
- Test 20: Set the Bootp client allocation mode: dhcpserver_example 20 <mode>
- Test 21: Get the Bootp client allocation mode: dhcpserver_example 21
- Test 22: Set the number of pings to be sent out by DHCP server before assigning the address: dhcpserver_example 22 <pingPacketCount>
- Test 23: Get the number of pings to be sent out by DHCP server before assigning the address: dhcpserver_example 23
- Test 24: Set the number of pings to be sent out by DHCP server before assigning the address, to default count: dhcpserver_example 24
- Test 25: Create a DHCP server address pool: dhcpserver_example 25 <poolName>
- Test 26: Delete a DHCP server address pool: dhcpserver_example 26 <poolName>
- Test 27: Set the default routers for DHCP hosts in a given pool: dhcpserver_example 27 <poolName> <defaultRouters>
- Test 28: Get the default routers for DHCP hosts in a given pool: dhcpserver_example 28 <poolName>
- Test 29: Reset the default routers for DHCP hosts in a given pool: dhcpserver_example 29 <poolName>
- Test 30: Set the DHCP Host network for a pool: dhcpserver_example 30 <poolName> <networkAddr> <prefixLen>
- Test 31: Get the DHCP Host network for a pool: dhcpserver_example 31 <poolName>
- Test 32: Delete the DHCP Host network for a pool: dhcpserver_example 32 <poolName>
- Test 33: Set the DNS servers for DHCP hosts in a given pool: dhcpserver_example 33 <poolName> <dnsServers>
- Test 34: Get the DNS servers for DHCP hosts in a given pool: dhcpserver_example 34 <poolName>
- Test 35: Reset the DNS servers for DHCP hosts in a given pool: dhcpserver_example 35 <poolName>
- Test 36: Set the Netbios name server addresses in given pool: dhcpserver_example 36 <poolName> <netBiosNameServers>
- Test 37: Get the Netbios name server addresses in given pool: dhcpserver_example 37 <poolName>
- Test 38: Delete the Netbios name server addresses in given pool: dhcpserver_example 38 <poolName>
- Test 39: Set the type of Netbios node: dhcpserver_example 39 <poolName> <nodeType>
- Test 40: Get the type of Netbios node: dhcpserver_example 40 <poolName>
- Test 41: Delete the type of Netbios node: dhcpserver_example 41 <poolName>
- Test 42: Set the DHCP lease time: dhcpserver_example 42 <poolName> <leaseTime>
- Test 43: Get the DHCP lease time: dhcpserver_example 43 <poolName>
- Test 44: Reset the DHCP lease time: dhcpserver_example 44 <poolName>
- Test 45: Set the domain name of a DHCP client: dhcpserver_example 45 <poolName> <domainName>
- Test 46: Get the domain name of a DHCP client: dhcpserver_example 46 <poolName>
- Test 47: Delete the domain name of a DHCP client: dhcpserver_example 47 <poolName>
- Test 48: Set the next server IP address: dhcpserver_example 48 <poolName> <nextAddress>
- Test 49: Get the next server IP address: dhcpserver_example 49 <poolName>
- Test 50: Delete the next server IP address: dhcpserver_example 50 <poolName>
- Test 51: Set the DHCP host hardware address for a manual pool: dhcpserver_example 51 <poolName> <hwAddr> <hwType>
- Test 52: Get the DHCP host hardware address for a manual pool: dhcpserver_example 52 <poolName>
- Test 53: Delete the DHCP host hardware address for a manual pool: dhcpserver_example 53 <poolName>
- Test 54: Set the DHCP Host network for a manual pool: dhcpserver_example 54 <poolName> <hostAddr> <prefixLen>
- Test 55: Get the DHCP Host network for a manual pool: dhcpserver_example 55 <poolName>
- Test 56: Delete the DHCP Host address and mask for a pool: dhcpserver_example 56 <poolName>
- Test 57: Set the boot file name: dhcpserver_example 57 <poolName>
- Test 58: Get the boot file name: dhcpserver_example 58 <poolName> <fileName>
- Test 59: Delete the boot file name: dhcpserver_example 59 <poolName>
- Test 60: Set the NTP server addresses for a given pool: dhcpserver_example 60 <poolName> <ntpServers>
- Test 61: Get the NTP server addresses for a given pool: dhcpserver_example 61 <poolName>
- Test 62: Delete the NTP server addresses for a given pool: dhcpserver_example 62 <poolName>
- Test 63: Clear the DHCP server statistics: s 63
- Test 64: Set the client id of a DHCP client: s 64 <poolName> <clientId>
- Test 65: Get the client id of a DHCP client: s 65 <poolName>
- Test 66: Delete the client id of a DHCP client: s 66 <poolName>
- Test 67: Set the client name of a DHCP client: s 67 <poolName> <clientName>
- Test 68: Get the client name of a DHCP client: s 68 <poolName>
- Test 69: Delete the client name of a DHCP client: s 69 <poolName>
It exercises all the DHCP Server OpEN APIs with appropriate arguments to manage the DHCP-Server component in the EFOS main process (switchdrvr).
DHCP Server CLI/API Cross Reference
CLI Command | OpEN API Reference ---------— | ---------------— (Priv-User Mode)##
show ip dhcp pool configuration all | openapiDhcpServerPoolEntryFirstGet() | openapiDhcpServerPoolEntryNextGet (Priv-User Mode)##
show ip dhcp binding all | openapiDhcpServerLeaseEntryFirstGet
openapiDhcpServerLeaseEntryNextGet()
openapiDhcpServerLeaseDataGet() (Priv-User Mode)##
show ip dhcp binding vrf <vrf-name> <ipaddress> | openapiDhcpServerVrfIpAddrLeaseDataGet() (Priv-User Mode)##
show ip dhcp server statistics | openapiDhcpServerStatGet() (Priv-User Mode)##
show ip dhcp pool configuration <pool-name> | openapiDhcpServerPoolVrfNameGet()
openapiDhcpServerPoolTypeGet()
openapiDhcpsLeaseTimeGet()
openapiDhcpsNetworkGet()
openapiDhcpsDnsServersGet()
openapiDhcpsDefaultRoutersGet()
openapiDhcpsHostGet()
openapiDhcpsHwAddressGet()
openapiDhcpsNetbiosNameServerAddressGet()
openapiDhcpsNetbiosNodeTypeGet()
openapiDhcpsNextServerGet()
openapiDhcpsDomainNameGet()
openapiDhcpsBootfileGet()
openapiDhcpsNTPServerGet()
openapiDhcpsClientIdGet()
openapiDhcpsClientNameGet() (Config-dhcp-pool)##
vrf <vrf-name> | openapiDhcpServerPoolVrfNameSet() (Config-dhcp-pool)##
no vrf | openapiDhcpServerPoolVrfNameSetToDefaultVrf() (Priv-User Mode)##
show ip dhcp global configuration | openapiDhcpServerExcludedAddressRangeEntryFirstGet()
openapiDhcpServerExcludedAddressRangeEntryNextGet()
openapiDhcpsNoOfPingPktGet()
openapiDhcpsAdminModeGet()
openapiDhcpsBootpAutomaticGet() (Config)##
ip dhcp excluded-address vrf <vrf-name> <low-address> <high-address> | openapiDhcpServerExcludedAddressRangeAdd() (Config)##
no ip dhcp excluded-address vrf <vrf-name> <low-address> <high-address> | openapiDhcpServerExcludedAddressRangeDelete() (Priv-User Mode)##
openapiDhcpServerVrfIpAddrLeaseDataGet() (Priv-User Mode)##
clear ip dhcp binding vrf <vrf-name> <ipaddress> | openapiDhcpServerVrfIpAddrLeaseDataClear() (Priv-User Mode)##
clear ip dhcp binding pool <pool-name> | <ipaddress> | openapiDhcpServerPoolIpAddrLeaseDataClear() (Priv-User Mode)##
clear ip dhcp binding vrf <vrf-name> | openapiDhcpServerVrfLeaseDataClear() (Priv-User Mode)##
clear ip dhcp binding pool <pool-name> | openapiDhcpServerPoolLeaseDataClear() (Priv-User Mode)##
clear ip dhcp binding * | openapiDhcpServerAllLeaseDataClear() (Config-dhcp-pool)##
[no] lease <days> [hours] [minutes] | openapiDhcpsLeaseTimeSet()
openapiDhcpsLeaseTimeReset() (Config-dhcp-pool)##
[no] network network-prefix [mask|prefix-length] | openapiDhcpsNetworkSet()
openapiDhcpsNetworkDelete() (Config-dhcp-pool)##
[no] dns-server <address1> [<address2>...<address8>] | openapiDhcpsDnsServersSet()
openapiDhcpsDnsServersReset() (Config-dhcp-pool)##
[no] default-router <address1> [<address2>...<address8>] | openapiDhcpsDefaultRoutersSet()
openapiDhcpsDefaultRoutersReset() (Config-dhcp-pool)##
[no] host <address> [mask | prefix-length] | openapiDhcpsHostSet()
openapiDhcpsHostDelete() (Config-dhcp-pool)##
[no] hardware-address <hardware-address> [type] | openapiDhcpsHwAddressSet()
openapiDhcpsHwAddressDelete() (Config-dhcp-pool)##
[no] netbios-name-server <address1> [<address2>...<address8>] | openapiDhcpsNetbiosNameServerAddressSet()
openapiDhcpsNetbiosNameServerAddressDelete() (Config-dhcp-pool)##
[no] netbios-node-type <type> | openapiDhcpsNetbiosNodeTypeSet()
openapiDhcpsNetbiosNodeTypeDelete() (Config-dhcp-pool)##
[no] next-server <ip-address> | openapiDhcpsNextServerSet()
openapiDhcpsNextServerDelete() (Config-dhcp-pool)##
[no] domain-name <domain> | openapiDhcpsDomainNameSet()
openapiDhcpsDomainNameDelete() (Config-dhcp-pool)##
[no] bootfile <filename> | openapiDhcpsBootfileSet()
openapiDhcpsBootfileDelete() (Config-dhcp-pool)##
[no] ntp <ip-address1> [<ip-address2>...<address8>] | openapiDhcpsNTPServerSet()
openapiDhcpsNTPServerDelete() (Config)##
[no] service dhcp | openapiDhcpsAdminModeSet() (Config)##
[no] ip dhcp pool <name> | openapiDhcpsPoolCreate()
openapiDhcpsPoolDelete() (Config)##
[no] ip dhcp bootp automatic | openapiDhcpsNoOfPingPktSet()
openapiDhcpsNoOfPingPktReset() (Config)##
[no] ip dhcp ping packets <0, 2-10> | openapiDhcpsBootpAutomaticSet() (Priv-User Mode)##
clear ip dhcp server statistics | openapiDhcpsStatisticsClear() (Config-dhcp-pool)##
[no] client-identifier <identifier> | openapiDhcpsClientIdSet()
openapiDhcpsClientIdDelete() (Config-dhcp-pool)##
[no] client-name <name> | openapiDhcpsClientNameSet()
openapiDhcpsClientNameDelete()