1.2.1.4 DHCP Server Module

The DHCP Server module is used to assign IP addresses to DHCP clients from the configured IP address database. When the server receives a request from a client, the DHCP server determines the network to which the DHCP client is connected, and then allocates an IP address that is appropriate for the client, and sends configuration information appropriate for that client. DHCP servers typically grant IP addresses to clients only for a limited interval. DHCP clients are responsible for renewing their IP address before that interval has expired, and must stop using the address once the interval has expired, if they have not been able to renew it.

Abstraction Model

This module provides software abstraction of the DHCP Server module existent in any TCP/IP Stack implementation. It removes the overhead of address resolution from all other modules in the stack

dhcp_diagram1

How the Library Works

To use DHCP Server, include the files dhcps.c, and dhcps.h in your project, and add or uncomment the definition "#define TCPIP_STACK_USE_DHCP_SERVER" to tcpip_config.h.

The DHCP Server module will assign IP addresses to DHCP clients from the configured IP address database.

When the server receives a request from a client, the DHCP server allocates an IP address that is appropriate for the client, and sends configuration information appropriate for that client.

The IP addresses will be granted for a limited interval. DHCP clients are responsible for renewing their IP address before that interval has expired.

A DHCP client must stop using the leased address once the interval has expired, if they have not been able to renew it.

Library Interface

NameDescription
Macros
TCPIP_DHCPS_DEFAULT_IP_ADDRESS_RANGE_STARTThese below IPv4 DHCP server address details are default address and it is assigned to the network default network interface. for Other interfaces , tcpip_stack_init.c file should be use to configure DHCP_POOL_CONFIG. IPv4 Address range is starting from 100, because the from 1 to 100 is reserved. Reserved Address will be used for the gateway address. Start of IP address Range , network_config.h ipaddress and this start of IP address should be in same SUBNET RECOMENDED - network_config.h ipaddress should be 192.168.1.1 if DHCP server ip address range starts from 192.168.1.100.
TCPIP_DHCPS_DEFAULT_SERVER_IP_ADDRESSDHCP server Address per interface. DHCP server Address selection should be in the same subnet.
TCPIP_DHCPS_DEFAULT_SERVER_NETMASK_ADDRESSDHCP server subnet Address per interface.
TCPIP_DHCPS_DEFAULT_SERVER_PRIMARY_DNS_ADDRESSDHCP server DNS primary Address
TCPIP_DHCPS_DEFAULT_SERVER_SECONDARY_DNS_ADDRESSDHCP server DNS Secondary Address
TCPIP_DHCPS_LEASE_DURATIONTimeout for a solved entry in the cache, in seconds the entry will be removed if the TMO elapsed and the entry has not been referenced again
TCPIP_DHCPS_LEASE_ENTRIES_DEFAULTThe Maximum Number of entries in the lease table Default total number of entries for all the the interface
TCPIP_DHCPS_LEASE_REMOVED_BEFORE_ACKTimeout for a unsolved entry , in seconds and should be removed from the entry if there is no REQUEST after OFFER
TCPIP_DHCPS_LEASE_SOLVED_ENTRY_TMOTimeout for a solved entry in the cache, in seconds. The entry will be removed if the TMO lapsed and the entry has not been referenced again
TCPIP_DHCPS_TASK_PROCESS_RATEDHCPS task processing rate, in milliseconds. The DHCPS module will process a timer event with this rate for maintaining its own queues, processing timeouts, etc. Choose it so that the other TMO are multiple of this The default value is 200 milliseconds. The lower the rate (higher the frequency) the higher the module priority and higher module performance can be obtained The value cannot be lower than the TCPIP_STACK_TICK_RATE.
###ConfigurationFunctions
TCPIP_DHCPS_DisableDisables the DHCP Server for the specified interface.
TCPIP_DHCPS_EnableEnables the DHCP Server for the specified interface.
TCPIP_DHCPS_RemovePoolEntriesRemoves all the entries or only used entries of a certain type belonging to a network interface.
Status Functions
TCPIP_DHCPS_IsEnabledDetermines if the DHCP Server is enabled on the specified interface.
TCPIP_DHCPS_GetPoolEntriesGet all the entries or only used entries of a certain type belonging to a network interface.
TCPIP_DHCPS_LeaseEntryGetGet the lease entry details as per TCPIP_DHCPS_LEASE_HANDLE and per interface.
Data Types and Constants
TCPIP_DHCPS_LEASE_ENTRYDHCP Server module lease data.
TCPIP_DHCPS_LEASE_HANDLEDHCP Server Lease Handle
TCPIP_DHCPS_POOL_ENTRY_TYPEDHCP server pool types are used to get and remove the leased IP address details.
TCPIP_DHCPS_ADDRESS_CONFIGDHCP server configuration and IP address range.
TCPIP_DHCPS_MODULE_CONFIGDHCP Server module runtime and initialization configuration data.
TCPIP_DHCPS_LeaseEntryRemoveRemove one entry from the DHCP server leased entry.
TCPIP_DHCPS_TaskStandard TCP/IP stack module task function.