mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-10-05 05:07:49 +00:00
dhcpd: Supports kernel mode compilation
The previous method of terminating the dhcp daemon via a global variable has been removed; instead, the `kill pid` command is used. Also, because the original `dhcp_start` method creates tasks via `task_create`, which is not supported in kernel mode, `dhcp_start` is not compiled in kernel mode. The daemon can be started in kernel mode using `dhcpd xxx &`. Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
This commit is contained in:
parent
9ad4c3c395
commit
6830e297cf
4 changed files with 135 additions and 77 deletions
|
|
@ -30,23 +30,27 @@ if(CONFIG_EXAMPLES_DHCPD)
|
|||
STACKSIZE
|
||||
${CONFIG_DEFAULT_TASK_STACKSIZE})
|
||||
|
||||
nuttx_add_application(
|
||||
NAME
|
||||
dhcpd_start
|
||||
SRCS
|
||||
dhcpd_start.c
|
||||
dhcpd_daemon.c
|
||||
STACKSIZE
|
||||
${CONFIG_DEFAULT_TASK_STACKSIZE})
|
||||
if(NOT CONFIG_BUILD_KERNEL)
|
||||
nuttx_add_application(
|
||||
NAME
|
||||
dhcpd_start
|
||||
SRCS
|
||||
dhcpd_start.c
|
||||
dhcpd_daemon.c
|
||||
STACKSIZE
|
||||
${CONFIG_DEFAULT_TASK_STACKSIZE})
|
||||
endif()
|
||||
|
||||
nuttx_add_application(
|
||||
NAME
|
||||
dhcpd_stop
|
||||
SRCS
|
||||
dhcpd_stop.c
|
||||
dhcpd_daemon.c
|
||||
STACKSIZE
|
||||
${CONFIG_DEFAULT_TASK_STACKSIZE})
|
||||
if(CONFIG_SCHED_WAITPID)
|
||||
nuttx_add_application(
|
||||
NAME
|
||||
dhcpd_stop
|
||||
SRCS
|
||||
dhcpd_stop.c
|
||||
dhcpd_daemon.c
|
||||
STACKSIZE
|
||||
${CONFIG_DEFAULT_TASK_STACKSIZE})
|
||||
endif()
|
||||
|
||||
add_definitions(-DCONFIG_NETUTILS_DHCPD_HOST=1 -DHAVE_SO_REUSEADDR=1
|
||||
-DHAVE_SO_BROADCAST=1)
|
||||
|
|
|
|||
|
|
@ -26,13 +26,23 @@ include $(APPDIR)/Make.defs
|
|||
|
||||
CSRCS = dhcpd_daemon.c
|
||||
|
||||
MAINSRC = dhcpd_start.c dhcpd_stop.c target.c
|
||||
MAINSRC = target.c
|
||||
|
||||
# DHCPD built-in application info
|
||||
|
||||
PROGNAME = dhcpd_start dhcpd_stop dhcpd
|
||||
PROGNAME = dhcpd
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE)
|
||||
MODULE = $(CONFIG_EXAMPLES_DHCPD)
|
||||
|
||||
ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||
MAINSRC += dhcpd_start.c
|
||||
PROGNAME += dhcpd_start
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SCHED_WAITPID),y)
|
||||
MAINSRC += dhcpd_stop.c
|
||||
PROGNAME += dhcpd_stop
|
||||
endif
|
||||
|
||||
include $(APPDIR)/Application.mk
|
||||
|
|
|
|||
|
|
@ -128,10 +128,12 @@ int dhcpd_daemon(int argc, FAR char *argv[], bool daemon)
|
|||
|
||||
/* Then start the dhcpd */
|
||||
|
||||
if (daemon)
|
||||
#ifndef CONFIG_BUILD_KERNEL
|
||||
if (!daemon)
|
||||
{
|
||||
return dhcpd_run(devname);
|
||||
return dhcpd_start(devname);
|
||||
}
|
||||
#endif
|
||||
|
||||
return dhcpd_start(devname);
|
||||
return dhcpd_run(devname);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue