
DHCPv4 Server
75
SWRU455A – February 2017 – Revised March 2017
Copyright © 2017, Texas Instruments Incorporated
Network Addresses
Example:
_i16 Status;
Status = sl_NetCfgSet(SL_NETCFG_IPV4_STA_ADDR_MODE,SL_NETCFG_IF_ENABLE_DHCP_RELEASE,0,0);
if
( Status )
{
// error
}
5.5
DHCPv4 Server
The SimpleLink device includes an internal DHCPv4 server which is supported in AP mode and Wi-Fi
Direct mode (group owner). The DHCPv4 server allocates IP addresses for connected stations. The range
and lease time of the IP address can be configured by the host driver APIs. The AP/GO IP and DHCP
server addresses range should have the same class C subnet. Station-leased IP address information is
not persistent, and all addresses are considered as available for lease after the SimpleLink device reset.
shows the DHCP server defaults.
Table 5-3. DHCP Server Defaults
DHCP Server
Default
Mode
Enabled
Gateway IP address
10.123.45.1
IP range
10.123.45.2 to 10.123.45.254
Lease time
86,400 seconds
32 Address
Maximum lease addresses
5.5.1 Enable and Disable the DHCP Server
The SimpleLink device lets users enable or disable the DHCP server. In AP mode, the DHCP server is
enabled by default. This configuration is persistent according to the system-persistent configuration.
An example of enabling the DHCP server:
_i16 Status;
Status
= sl_NetAppStart(SL_NETAPP_DHCP_SERVER_ID);
//enable the DHCP server
if
( Status )
{
// error
}
An example of disabling the DHCP server:
_i16 Status;
Status
= sl_NetAppStop(SL_NETAPP_DHCP_SERVER_ID);
//disable the DHCP server
if
( Status )
{
// error
}
5.5.2 Set DHCP Server Parameters
The SimpleLink device lets users set the DHCP server parameters. The following parameters can be set:
•
Address range
– First and last IP address for addressed allocation. The following macro can be used:
SL_IPV4_VAL(192,168,1,10)
•
Lease time
– Lease time (in seconds) of the IP address.
The range of the DHCP server addresses must be in the subnet of the AP IP address. This configuration
is persistent. The configuration should be performed when the DHCP server is down.