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](GUID-90A7B2F8-7623-4629-99D5-AC3CF1A5C39D-low.png)
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
Name | Description |
---|---|
Macros | |
TCPIP_DHCPS_DEFAULT_IP_ADDRESS_RANGE_START | These 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_ADDRESS | DHCP server Address per interface. DHCP server Address selection should be in the same subnet. |
TCPIP_DHCPS_DEFAULT_SERVER_NETMASK_ADDRESS | DHCP server subnet Address per interface. |
TCPIP_DHCPS_DEFAULT_SERVER_PRIMARY_DNS_ADDRESS | DHCP server DNS primary Address |
TCPIP_DHCPS_DEFAULT_SERVER_SECONDARY_DNS_ADDRESS | DHCP server DNS Secondary Address |
TCPIP_DHCPS_LEASE_DURATION | Timeout 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_DEFAULT | The Maximum Number of entries in the lease table Default total number of entries for all the the interface |
TCPIP_DHCPS_LEASE_REMOVED_BEFORE_ACK | Timeout 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_TMO | Timeout 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_RATE | DHCPS 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. |
###Configuration | Functions |
TCPIP_DHCPS_Disable | Disables the DHCP Server for the specified interface. |
TCPIP_DHCPS_Enable | Enables the DHCP Server for the specified interface. |
TCPIP_DHCPS_RemovePoolEntries | Removes all the entries or only used entries of a certain type belonging to a network interface. |
Status Functions | |
TCPIP_DHCPS_IsEnabled | Determines if the DHCP Server is enabled on the specified interface. |
TCPIP_DHCPS_GetPoolEntries | Get all the entries or only used entries of a certain type belonging to a network interface. |
TCPIP_DHCPS_LeaseEntryGet | Get the lease entry details as per TCPIP_DHCPS_LEASE_HANDLE and per interface. |
Data Types and Constants | |
TCPIP_DHCPS_LEASE_ENTRY | DHCP Server module lease data. |
TCPIP_DHCPS_LEASE_HANDLE | DHCP Server Lease Handle |
TCPIP_DHCPS_POOL_ENTRY_TYPE | DHCP server pool types are used to get and remove the leased IP address details. |
TCPIP_DHCPS_ADDRESS_CONFIG | DHCP server configuration and IP address range. |
TCPIP_DHCPS_MODULE_CONFIG | DHCP Server module runtime and initialization configuration data. |
TCPIP_DHCPS_LeaseEntryRemove | Remove one entry from the DHCP server leased entry. |
TCPIP_DHCPS_Task | Standard TCP/IP stack module task function. |