This chapter contains a description of all NetX Duo DHCP Server services (listed below) in alphabetic order.
Note: In the Return Values section in the following API descriptions, values in BOLD are not affected by the NX_DISABLE_ERROR_CHECKING define that is used to disable API error checking, while non-bold values are completely disabled.
Create a DHCP Server instance
UINT nx_dhcp_server_create(
NX_DHCP_SERVER *dhcp_ptr,
NX_IP *ip_ptr,
VOID *stack_ptr,
ULONG stack_size,
CHAR *input_address_list,
CHAR *name_ptr,
NX_PACKET_POOL *packet_pool_ptr);
This service creates a DHCP Server instance with a previously created IP instance.
Important: The application must make sure the packet pool created for the IP create service has a minimum 548 byte payload, not including the UDP, IP and Ethernet headers.
Application
/* Create a DHCP Server instance. */
status = nx_dhcp_server_create(&dhcp_server, &server_ip, pointer,
DEMO_SERVER_STACK_SIZE, SERVER_IP_ADDRESS_LIST, "DHCP server", &server_pool);
/* If status is NX_SUCCESS a DHCP Server instance was successfully created. */
Create a IP address pool
UINT nx_dhcp_create_server_ip_address_list(
NX_DHCP_SERVER *dhcp_ptr,
UINT iface_index,
ULONG start_ip_address,
ULONG end_ip_address,
UINT *addresses_added);
This service creates a network interface specific pool of available IP addresses for the specified DHCP server to assign. The start and end IP addresses must match the specified network interface. The actual number of IP addresses added may be less than the total addresses if the IP address list is not large enough (which is set in the user configurable NX_DHCP_IP_ADDRESS_MAX_LIST_SIZE parameter).
Application
/* Create a pool of available IP addresses to assign. */
status = nx_dhcp_create_server_ip_list(&dhcp_server, iface_index,
START_IP_ADDRESS_LIST, END_IP_ADDRESS_LIST, &addresses_added);
/* If status is NX_SUCCESS a IP address list was successfully created.
addresses_added indicates how many IP addresses were actually added to the
list. */
Remove Client record from Server database
UINT nx_dhcp_clear_client_record(
NX_DHCP_SERVER *dhcp_ptr,
NX_DHCP_CLIENT *dhcp_client_ptr);
This service clears the Client record from the Server database.
Application
/* Remove Client record from the server database. */
status = nx_dhcp_clear_client_record(&dhcp_server, &dhcp_client_ptr);
/* If status is NX_SUCCESS the specified Client was removed from the database. */
Set network parameters for DHCP options
UINT nx_dhcp_set_interface_network_parameters(
NX_DHCP_SERVER *dhcp_ptr,
UINT iface_index,
ULONG subnet_mask,
ULONG default_gateway_address,
ULONG dns_server_address);
This service sets default values for network critical parameters for the specified interface. The DHCP server will include these options in its OFFER and ACK replies to the DHCP Client. If the host set interface parameters on which a DHCP server is running, the parameters will defaulted as follows: the router set to the primary interface gateway for the DHCP server itself, the DNS server address to the DHCP server itself, and the subnet mask to the same as the DHCP server interface is configured with.
Application
/* Set network parameters for a specific interface. */
status = nx_dhcp_set_interface_network_parameters(&dhcp_server, iface_index,
NX_DHCP_SUBNET_MASK, NX_DHCP_DEFAULT_GATEWAY,
NX_DHCP_DNS_SERVER);
/* If status is NX_SUCCESS network parameters were successfully set. */
Delete a DHCP Server instance
UINT nx_dhcp_server_delete(NX_DHCP_SERVER *dhcp_ptr);
This service deletes a previously created DHCP Server instance.
Threads
/* Delete a DHCP Server instance. */
status = nx_dhcp_server_delete(&dhcp_server);
/* If status is NX_SUCCESS the DHCP Server instance was successfully deleted. */
Start DHCP Server processing
UINT nx_dhcp_server_start(NX_DHCP_SERVER *dhcp_ptr);
This service starts DHCP Server processing, which includes creating a server UDP socket, binding the DHCP port and waiting to receive Client DHCP requests.
Threads
/* Start the DHCP Server processing for this IP instance. */
status = nx_dhcp_server_start(&dhcp_server);
/* If status is NX_SUCCESS the DHCP Server was successfully started. */
Stops DHCP Server processing
UINT nx_dhcp_server_stop(NX_DHCP_SERVER *dhcp_ptr);
This service stops DHCP Server processing, which includes of receiving DHCP Client requests.
Threads
/* Stop the DHCP Server processing for this IP instance. */
status = nx_dhcp_server_stop(&dhcp_server);
/* If status is NX_SUCCESS the DHCP Server was successfully stopped. */