From da06daecd676d1f456fa6895f6090ace1bf20042 Mon Sep 17 00:00:00 2001 From: huangxin Date: Wed, 16 Nov 2022 10:36:28 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20=E5=A2=9E=E5=8A=A0DHCP=20Server?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E5=AE=8F=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 16 ++++++++++++++++ srcs/CMakeLists.txt | 13 ++----------- srcs/libs/CMakeLists.txt | 3 ++- srcs/libs/cmdline/cmd_menu.c | 8 +++++++- srcs/vcpe_main.c | 4 +--- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73627df..1b6a0ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,18 @@ endif () MESSAGE("Version: " ${GIT_VERSION}) +if (USED_LWIP) + LIST(APPEND COMMON_DEFINE "-DLWIP_ON") +endif () + +if (USED_OPENDHCPD) + LIST(APPEND COMMON_DEFINE "-DOPENDHCPD_ON") +endif () + +if (USED_OPENDHCPDDNS) + LIST(APPEND COMMON_DEFINE "-DOPENDHCPDDNS_ON") +endif () + ADD_SUBDIRECTORY(srcs) ADD_SUBDIRECTORY(srcs/libs) @@ -49,3 +61,7 @@ if (USED_LWIP OR VCPE_AGENT) endif () ADD_SUBDIRECTORY(srcs/httpserver) + + + +MESSAGE("COMMON_DEFINE: " ${COMMON_DEFINE}) \ No newline at end of file diff --git a/srcs/CMakeLists.txt b/srcs/CMakeLists.txt index 7cfe382..7e2a354 100644 --- a/srcs/CMakeLists.txt +++ b/srcs/CMakeLists.txt @@ -19,6 +19,8 @@ LIST(APPEND COMMON_LIBS "-ldl -lpthread -lzlog -lm -luv -lzmq -luuid -lconfig") LIST(APPEND COMMON_LIBS "-lpthread") +ADD_DEFINITIONS(${COMMON_DEFINE}) + INCLUDE_DIRECTORIES(include ./ ./include ./libs/include ./lwip/src/include ./lwip/src/arch_linux/include ./httpserver/include ${COMMON_INCLUDE}) @@ -32,17 +34,6 @@ if (USED_LWIP) AUX_SOURCE_DIRECTORY(user VCPE_SRC) endif () -if (USED_LWIP) - ADD_DEFINITIONS(-DLWIP_ON) -endif () - -if (USED_OPENDHCPD) - ADD_DEFINITIONS(-DOPENDHCPD_ON) -endif () - -if (USED_OPENDHCPDDNS) - ADD_DEFINITIONS(-DOPENDHCPDDNS_ON) -endif () ADD_EXECUTABLE(${PROJECT_TARGET} ${VCPE_SRC} ${VCPE_HEADS} vcpe_main.c) diff --git a/srcs/libs/CMakeLists.txt b/srcs/libs/CMakeLists.txt index 48ffae8..7acbff6 100644 --- a/srcs/libs/CMakeLists.txt +++ b/srcs/libs/CMakeLists.txt @@ -27,7 +27,8 @@ AUX_SOURCE_DIRECTORY(hardware C_SRC) SET(CMAKE_C_STANDARD 99) -ADD_DEFINITIONS(-DBUILD_VERSION="${GIT_VERSION}") +ADD_DEFINITIONS(-DBUILD_VERSION="${GIT_VERSION}" ${COMMON_DEFINE}) + LINK_LIBRARIES(${COMMON_LIBS}) ADD_LIBRARY(${LIB_PROJECT_TARGET} ${C_SRC} ${C_HEADS}) diff --git a/srcs/libs/cmdline/cmd_menu.c b/srcs/libs/cmdline/cmd_menu.c index f5a0f17..d73a6ea 100644 --- a/srcs/libs/cmdline/cmd_menu.c +++ b/srcs/libs/cmdline/cmd_menu.c @@ -388,6 +388,7 @@ static void dhcpd_task(void *pArg) { } } +#if OPENDHCPD_ON static int on_cmd7(void *pTbl[], const char *pName, void *pInfo) { int ret; PDHCPD_SETUP p; @@ -424,11 +425,12 @@ static int on_cmd7(void *pTbl[], const char *pName, void *pInfo) { return ERR_SUCCESS; } +#endif static int on_cmd_(void *pTbl[], const char *pName, void *pInfo) { PARG_TBL_INFO pArg = (PARG_TBL_INFO)pInfo; int help = get_help_cmd(pTbl, pArg)->count; - int version = ((arg_lit_t *)pTbl[0])->count; + //int version = ((arg_lit_t *)pTbl[0])->count; if (help > 0) { show_help(pName); @@ -545,6 +547,7 @@ int menu_run(int argc, char **argv) { void *pArgTbl6[] = {cmd6, keyGen, helpCmd6, end6}; int errCode6 = 0; +#if OPENDHCPD_ON arg_rex_t *cmd7 = arg_rex1(NULL, NULL, "dhcpd", NULL, REG_ICASE, NULL); arg_lit_t *operate7 = arg_lit0("m", "mode", "\tService works on verbatim mode."); arg_file_t *cfgfile7 = arg_file1("c", "config", "", "\tSpecify the current application configuration file path"); @@ -557,6 +560,7 @@ int menu_run(int argc, char **argv) { arg_end_t *end7 = arg_end(20); void *pArgTbl7[] = {cmd7, operate7, cfgfile7, cfgdir7, inifile, statfile, ifname, key7, helpCmd7, end7}; int errCode7 = 0; +#endif /***************************************************************** * 系统帮助参数定义 @@ -569,7 +573,9 @@ int menu_run(int argc, char **argv) { ARG_TBL_INFO argTblInfo[] = { {pArgTbl1, ARRAY_SIZE(pArgTbl1), &errCode1, on_cmd1, cmdn_help, "\r \033[1;4;36mstart\033[0m: \033[1mRun agent service normally.\033[0m\n"}, +#if OPENDHCPD_ON {pArgTbl7, ARRAY_SIZE(pArgTbl7), &errCode7, on_cmd7, cmdn_help, "\n \033[1;4;36mdhcpd\033[0m: \033[1mRun DHCP service normally.\033[0m\n"}, +#endif {pArgTbl2, ARRAY_SIZE(pArgTbl2), &errCode2, on_cmd2, cmd2_help, "\n \033[1;4;36mif\033[0m: \033[1mRun agent interface tools.\033[0m\n"}, {pArgTbl3, ARRAY_SIZE(pArgTbl3), &errCode3, on_cmd3, cmdn_help, "\n \033[1;4;36mbase64\033[0m: \033[1mString base64 encode/decode.\033[0m\n"}, {pArgTbl4, ARRAY_SIZE(pArgTbl4), &errCode4, on_cmd4, cmdn_help, "\n \033[1;4;36mhash\033[0m: \033[1mCalculate file's hash value.\033[0m\n"}, diff --git a/srcs/vcpe_main.c b/srcs/vcpe_main.c index 6d5aedb..7006f10 100644 --- a/srcs/vcpe_main.c +++ b/srcs/vcpe_main.c @@ -49,9 +49,7 @@ int main(int argc, char **argv) { #ifdef OPENDHCPDDNS_ON return dual_server_main(argc, argv); -#elif OPENDHCPD_ON - // return dhcpd_main(argc, argv); - //#else +#else uv_setup_args(argc, argv); setvbuf(stdout, NULL, _IONBF, 0);