mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-19 19:44:35 +08:00
Fix dhcpd #17
apps/netutils/dhcpd/dhcpd.c: Fix unused const variable dhcpd.c:273:29: warning: 'g_anyipaddr' defined but not used [-Wunused-const-variable=] static const uint8_t g_anyipaddr[4] = {0, 0, 0, 0}; apps/netutils/dhcpd: Make dhcpd interface configurable apps/netutils/dhcpd: Lease address directly if hit in address range apps/netutils/netinit: Initialize dhcpc_state update the addresses only on request success
This commit is contained in:
@@ -439,29 +439,35 @@ static void netinit_net_bringup(void)
|
||||
|
||||
handle = dhcpc_open(NET_DEVNAME, &mac, IFHWADDRLEN);
|
||||
|
||||
/* Get an IP address. Note that there is no logic for renewing the IP address in this
|
||||
* example. The address should be renewed in ds.lease_time/2 seconds.
|
||||
/* Get an IP address. Note that there is no logic for renewing the IP
|
||||
* address in this example. The address should be renewed in
|
||||
* ds.lease_time/2 seconds.
|
||||
*/
|
||||
|
||||
if (handle != NULL)
|
||||
{
|
||||
struct dhcpc_state ds;
|
||||
dhcpc_request(handle, &ds);
|
||||
netlib_set_ipv4addr(NET_DEVNAME, &ds.ipaddr);
|
||||
struct dhcpc_state ds =
|
||||
{
|
||||
};
|
||||
|
||||
if (ds.netmask.s_addr != 0)
|
||||
if (dhcpc_request(handle, &ds) == OK)
|
||||
{
|
||||
netlib_set_ipv4netmask(NET_DEVNAME, &ds.netmask);
|
||||
}
|
||||
netlib_set_ipv4addr(NET_DEVNAME, &ds.ipaddr);
|
||||
|
||||
if (ds.default_router.s_addr != 0)
|
||||
{
|
||||
netlib_set_dripv4addr(NET_DEVNAME, &ds.default_router);
|
||||
}
|
||||
if (ds.netmask.s_addr != 0)
|
||||
{
|
||||
netlib_set_ipv4netmask(NET_DEVNAME, &ds.netmask);
|
||||
}
|
||||
|
||||
if (ds.dnsaddr.s_addr != 0)
|
||||
{
|
||||
netlib_set_ipv4dnsaddr(&ds.dnsaddr);
|
||||
if (ds.default_router.s_addr != 0)
|
||||
{
|
||||
netlib_set_dripv4addr(NET_DEVNAME, &ds.default_router);
|
||||
}
|
||||
|
||||
if (ds.dnsaddr.s_addr != 0)
|
||||
{
|
||||
netlib_set_ipv4dnsaddr(&ds.dnsaddr);
|
||||
}
|
||||
}
|
||||
|
||||
dhcpc_close(handle);
|
||||
|
Reference in New Issue
Block a user