From 7c4d8aaf58c8e7765afb2adf41a0eb78fe269856 Mon Sep 17 00:00:00 2001 From: huangxin Date: Tue, 22 Nov 2022 16:13:42 +0800 Subject: [PATCH 1/4] =?UTF-8?q?OCT=201.=20=E4=B8=B4=E6=97=B6=E5=B1=8F?= =?UTF-8?q?=E8=94=BD=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/open_dhcp/query.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/srcs/open_dhcp/query.cpp b/srcs/open_dhcp/query.cpp index 39ac641..431c6d2 100644 --- a/srcs/open_dhcp/query.cpp +++ b/srcs/open_dhcp/query.cpp @@ -164,7 +164,7 @@ static void sendAllLists(data19 *req) { req->bytes = (int)(fp - req->dp); } - +#if 0 static void expand_range_set(data19 *req, const char *pRequest) { char logBuff[512]; @@ -267,6 +267,7 @@ static void expand_range_set(data19 *req, const char *pRequest) { req->bytes = (int)(fp - req->dp); } +#endif #pragma clang diagnostic push #pragma ide diagnostic ignored "cert-err34-c" @@ -507,7 +508,7 @@ static void opendhcp_http_expand_rangeset(http_request *request, hw_http_respons hw_set_response_header(response, &content_type_name, &content_type_value); SETSTRING(status_code, HTTP_STATUS_200); - expand_range_set(req, request->body->value); + //expand_range_set(req, request->body->value); SETSTRING(body, req->dp); hw_set_body(response, &body); hw_set_response_status_code(response, &status_code); From 814d744cebd0c7cd12c2de07e21dcd5deab78255 Mon Sep 17 00:00:00 2001 From: huangxin Date: Wed, 23 Nov 2022 09:20:38 +0800 Subject: [PATCH 2/4] =?UTF-8?q?OCT=201.=20=E7=A7=BB=E9=99=A4DHCP=20HTTP?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=AB=AF=E7=99=BD=E5=90=8D=E5=8D=95=202.=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96DHCP=20=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=8E=A5=E5=8F=A3=203.=20=E5=A2=9E=E5=8A=A0D?= =?UTF-8?q?HCP=20=E4=B8=BB=E5=A4=87=E6=9C=8D=E5=8A=A1=E5=99=A8=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/vcpe.cfg | 3 ++- srcs/libs/configure/config.c | 2 +- srcs/libs/configure/config_help.c | 8 ++++++++ srcs/libs/include/config.h | 4 +++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/config/vcpe.cfg b/config/vcpe.cfg index 51574cd..834c0cf 100644 --- a/config/vcpe.cfg +++ b/config/vcpe.cfg @@ -78,7 +78,8 @@ application: # DHCP Server Config dhcp_server: { listen_on = ["192.168.30.1", "192.168.100.1"]; - http_client = ["192.168.30.1", "192.168.30.110", "192.168.100.1", "192.168.100.110"]; + # 主备服务器设置 + # replication = ["192.168.100.211", "192.168.100.215"]; range_set: ( { dhcp_range = "192.168.30.110-192.168.30.120"; diff --git a/srcs/libs/configure/config.c b/srcs/libs/configure/config.c index 2fd6de3..7e6b006 100644 --- a/srcs/libs/configure/config.c +++ b/srcs/libs/configure/config.c @@ -67,7 +67,7 @@ do { ADD_CFG_ITEM(CFG_HTTP_SVR_PORT, "application.http_svr.listen_port", VALUE_TYPE_INTEGRAL, "6789", "Network port to listen on"); \ ADD_CFG_ITEM(CFG_HTTP_SVR_TCP_NODELAY, "application.http_svr.tcp_nodelay", VALUE_TYPE_BOOL, "1", "TCP delay switch"); \ ADD_CFG_ITEM(CFG_DHCP_LISTEN_ON, "application.dhcp_server.listen_on", VALUE_TYPE_ARRAY_STR, "", "DHCP listen interface"); \ - ADD_CFG_ITEM(CFG_DHCP_HTTP_CLIENT, "application.dhcp_server.http_client", VALUE_TYPE_ARRAY_STR, "", "DHCP http server client write list"); \ + ADD_CFG_ITEM(CFG_DHCP_REPLICATION_SVR, "application.dhcp_server.replication", VALUE_TYPE_ARRAY_STR, "", "DHCP replication server master and secondary"); \ ADD_CFG_ITEM(CFG_DHCP_RANGE_SET, "application.dhcp_server.range_set", VALUE_TYPE_ARRAY_OBJ, "", "DHCP IP pool"); \ } while (0)// clang-format on diff --git a/srcs/libs/configure/config_help.c b/srcs/libs/configure/config_help.c index e894893..9a100db 100644 --- a/srcs/libs/configure/config_help.c +++ b/srcs/libs/configure/config_help.c @@ -7,6 +7,14 @@ const vector config_get_dhcp_server_range_set() { return cfg_get_vector(CFG_DHCP_RANGE_SET); } +const vector config_get_dhcp_listen_on() { + return cfg_get_vector(CFG_DHCP_LISTEN_ON); +} + +const vector config_get_dhcp_replication_svr() { + return cfg_get_vector(CFG_DHCP_REPLICATION_SVR); +} + const char* config_get_http_server_addr() { return cfg_get_string_value(CFG_HTTP_SVR_ADDR); } diff --git a/srcs/libs/include/config.h b/srcs/libs/include/config.h index 1dc2714..f547a6e 100644 --- a/srcs/libs/include/config.h +++ b/srcs/libs/include/config.h @@ -62,7 +62,7 @@ typedef enum { CFG_HTTP_SVR_PORT = 30, CFG_HTTP_SVR_TCP_NODELAY = 31, CFG_DHCP_LISTEN_ON = 32, - CFG_DHCP_HTTP_CLIENT = 33, + CFG_DHCP_REPLICATION_SVR = 33, CFG_DHCP_RANGE_SET = 34, CONFIG_ITEM_ID_MAX } CONFIG_ITEM_ID; @@ -114,6 +114,8 @@ const char *config_get_http_server_addr(); unsigned int config_get_http_server_port(); int config_get_http_server_tcp_nodelay(); const vector config_get_dhcp_server_range_set(); +const vector config_get_dhcp_listen_on(); +const vector config_get_dhcp_replication_svr(); #ifdef __cplusplus } #endif From 28d0eb893ef7cf66ba029984f873a178afb9a462 Mon Sep 17 00:00:00 2001 From: huangxin Date: Wed, 23 Nov 2022 10:41:05 +0800 Subject: [PATCH 3/4] =?UTF-8?q?OCT=201.=20=E6=95=B4=E7=90=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=8C=E9=87=8D=E6=9E=84sds=E5=BA=93=E6=BA=90?= =?UTF-8?q?=E7=A0=81=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/libs/CMakeLists.txt | 3 +-- srcs/libs/configure/config.c | 3 +-- srcs/libs/hardware/disk.c | 2 +- srcs/libs/hardware/ipmltools.c | 2 +- srcs/libs/hardware/memory.c | 2 +- srcs/libs/include/config.h | 2 +- srcs/libs/{misc => include/sds}/alloc.h | 0 srcs/libs/include/{ => sds}/sds.h | 0 srcs/libs/{misc => include/sds}/sdsalloc.h | 0 srcs/libs/misc/sds.c | 5 ++--- srcs/libs/{vector => misc}/zvector.c | 0 srcs/libs/mq/mq_proto.c | 2 +- srcs/vcpe_main.c | 7 +++---- 13 files changed, 12 insertions(+), 16 deletions(-) rename srcs/libs/{misc => include/sds}/alloc.h (100%) rename srcs/libs/include/{ => sds}/sds.h (100%) rename srcs/libs/{misc => include/sds}/sdsalloc.h (100%) rename srcs/libs/{vector => misc}/zvector.c (100%) diff --git a/srcs/libs/CMakeLists.txt b/srcs/libs/CMakeLists.txt index 16f58b2..5f3a02e 100644 --- a/srcs/libs/CMakeLists.txt +++ b/srcs/libs/CMakeLists.txt @@ -23,11 +23,10 @@ AUX_SOURCE_DIRECTORY(mq C_SRC) AUX_SOURCE_DIRECTORY(cmdline C_SRC) AUX_SOURCE_DIRECTORY(crypto C_SRC) AUX_SOURCE_DIRECTORY(hardware C_SRC) -AUX_SOURCE_DIRECTORY(vector C_SRC) SET(CMAKE_C_STANDARD 99) -SET_SOURCE_FILES_PROPERTIES(vector/zvector.c PROPERTIES COMPILE_FLAGS "-Wall -Wextra -flto") +SET_SOURCE_FILES_PROPERTIES(misc/zvector.c PROPERTIES COMPILE_FLAGS "-Wall -Wextra -flto") ADD_DEFINITIONS(-DBUILD_VERSION="${GIT_VERSION}" ${COMMON_DEFINE}) diff --git a/srcs/libs/configure/config.c b/srcs/libs/configure/config.c index 7e6b006..af5b4c6 100644 --- a/srcs/libs/configure/config.c +++ b/srcs/libs/configure/config.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include "uthash/uthash.h" #include "config.h" @@ -14,7 +14,6 @@ #include "user_errno.h" #include "crypto.h" #include "hardware.h" -#include "zvector/zvector.h" #define CFG_INT_VALUE(p) (p->value.longValue) #define CFG_BOOL_VALUE(p) (p->value.longValue == FALSE ? FALSE : TRUE) diff --git a/srcs/libs/hardware/disk.c b/srcs/libs/hardware/disk.c index 086b8d3..7679624 100644 --- a/srcs/libs/hardware/disk.c +++ b/srcs/libs/hardware/disk.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "misc.h" #include "user_errno.h" diff --git a/srcs/libs/hardware/ipmltools.c b/srcs/libs/hardware/ipmltools.c index cbaad14..450987b 100644 --- a/srcs/libs/hardware/ipmltools.c +++ b/srcs/libs/hardware/ipmltools.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "hardware.h" #include "user_errno.h" diff --git a/srcs/libs/hardware/memory.c b/srcs/libs/hardware/memory.c index 0d31710..6f86294 100644 --- a/srcs/libs/hardware/memory.c +++ b/srcs/libs/hardware/memory.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "hardware.h" #include "task_manager.h" diff --git a/srcs/libs/include/config.h b/srcs/libs/include/config.h index f547a6e..b8acc56 100644 --- a/srcs/libs/include/config.h +++ b/srcs/libs/include/config.h @@ -2,7 +2,7 @@ // Created by xajhu on 2021/7/1 0001. // -#include "zvector/zvector.h" +#include #ifndef DAEMON_AGENT_INCLUDE_CONFIG_H #define DAEMON_AGENT_INCLUDE_CONFIG_H diff --git a/srcs/libs/misc/alloc.h b/srcs/libs/include/sds/alloc.h similarity index 100% rename from srcs/libs/misc/alloc.h rename to srcs/libs/include/sds/alloc.h diff --git a/srcs/libs/include/sds.h b/srcs/libs/include/sds/sds.h similarity index 100% rename from srcs/libs/include/sds.h rename to srcs/libs/include/sds/sds.h diff --git a/srcs/libs/misc/sdsalloc.h b/srcs/libs/include/sds/sdsalloc.h similarity index 100% rename from srcs/libs/misc/sdsalloc.h rename to srcs/libs/include/sds/sdsalloc.h diff --git a/srcs/libs/misc/sds.c b/srcs/libs/misc/sds.c index f853ad7..fe5c04a 100644 --- a/srcs/libs/misc/sds.c +++ b/srcs/libs/misc/sds.c @@ -36,9 +36,8 @@ #include #include #include -#include "sds.h" -#include "sdsalloc.h" - +#include +#include hiredisAllocFuncs hiredisAllocFns = { .mallocFn = malloc, diff --git a/srcs/libs/vector/zvector.c b/srcs/libs/misc/zvector.c similarity index 100% rename from srcs/libs/vector/zvector.c rename to srcs/libs/misc/zvector.c diff --git a/srcs/libs/mq/mq_proto.c b/srcs/libs/mq/mq_proto.c index 3839049..33d9b92 100644 --- a/srcs/libs/mq/mq_proto.c +++ b/srcs/libs/mq/mq_proto.c @@ -3,7 +3,7 @@ // #include #include -#include +#include #include "msg_queue.h" #include "s2j/s2j.h" diff --git a/srcs/vcpe_main.c b/srcs/vcpe_main.c index 32754dd..897d279 100644 --- a/srcs/vcpe_main.c +++ b/srcs/vcpe_main.c @@ -15,7 +15,6 @@ #ifdef OPENDHCPD_ON #include "user_errno.h" -#include "libs/misc/sdsalloc.h" #endif #ifdef OPENDHCPDDNS_ON @@ -59,8 +58,7 @@ int main(int argc, char **argv) { if(ret == ERR_MENU_EXIT) { user_uninit(); exit(0); - } - if (ret != ERR_SUCCESS) { + } else if (ret != ERR_SUCCESS) { printf("Application setup error(%d), please used --help to show usage, exited!!!\n", ret); user_uninit(); exit(0); @@ -79,6 +77,7 @@ int main(int argc, char **argv) { } user_uninit(); - return 0; + + return ret; #endif } From a57cf4c5d2ab9f318a91f4bced32c6f0d9eb224d Mon Sep 17 00:00:00 2001 From: huangxin Date: Wed, 23 Nov 2022 10:46:36 +0800 Subject: [PATCH 4/4] =?UTF-8?q?OCT=201.=20=E7=BB=9F=E4=B8=80=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=B0=83=E7=94=A8=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/open_dhcp/query.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/srcs/open_dhcp/query.cpp b/srcs/open_dhcp/query.cpp index 431c6d2..de25c28 100644 --- a/srcs/open_dhcp/query.cpp +++ b/srcs/open_dhcp/query.cpp @@ -31,7 +31,7 @@ static void sendUserList(data19 *req, const char *pRequest) { char logBuff[512]; dhcpMap::iterator p; - printf("Input: %s\n", pRequest); + dzlog_debug("Input: %s\n", pRequest); if (pRequest == nullptr || strlen(pRequest) == 0) { sprintf(logBuff, "Requeset Json"); @@ -293,7 +293,7 @@ int getHwAddr(char *buff, char *mac) { int arpSet(const char *ifname, char *ipStr, char *mac) { if (ifname == nullptr || ipStr == nullptr || mac == nullptr) { - printf("para is null.\n"); + dzlog_error("para is null.\n"); return -1; } @@ -311,19 +311,19 @@ int arpSet(const char *ifname, char *ipStr, char *mac) { req.arp_flags = ATF_PERM | ATF_COM; if (getHwAddr((char *)req.arp_ha.sa_data, mac) < 0) { - printf("get mac error.\n"); + dzlog_error("get mac error.\n"); return -1; } sock_fd = socket(AF_INET, SOCK_DGRAM, 0); if (sock_fd < 0) { - printf("get socket error.\n"); + dzlog_error("get socket error.\n"); return -1; } ret = ioctl(sock_fd, SIOCSARP, &req); if (ret < 0) { - printf("ioctl error.\n"); + dzlog_error("ioctl error.\n"); close(sock_fd); return -1; }