From d727cbf66140f961abe68706b6066ed10d0c9496 Mon Sep 17 00:00:00 2001 From: huangxin Date: Thu, 24 Nov 2022 15:01:06 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20OpenDHCPD=20=E6=94=AF=E6=8C=81=20vcp?= =?UTF-8?q?e.cfg=20=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E7=9B=91=E5=90=AC=E6=8E=A5=E5=8F=A3=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/open_dhcp/opendhcpd.cpp | 3 +++ srcs/open_dhcp/opendhcpd.h | 1 + srcs/open_dhcp/query.cpp | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/srcs/open_dhcp/opendhcpd.cpp b/srcs/open_dhcp/opendhcpd.cpp index 507c865..2362969 100644 --- a/srcs/open_dhcp/opendhcpd.cpp +++ b/srcs/open_dhcp/opendhcpd.cpp @@ -4388,6 +4388,9 @@ void *init(void *lparam) { } } + // 合并 vcpe.cfg 配置文件配置内容 + opendhcp_add_listener(); + /* for (int i = 0; i < cfig.rangeCount; i++) { diff --git a/srcs/open_dhcp/opendhcpd.h b/srcs/open_dhcp/opendhcpd.h index 710aef5..815d2e3 100644 --- a/srcs/open_dhcp/opendhcpd.h +++ b/srcs/open_dhcp/opendhcpd.h @@ -609,6 +609,7 @@ MYWORD qLen(char *); const char *getRequestMethod(const char *buffer); void prepareUserHtmlRespStatus(data19 *req); void opendhcp_init_http_server(); +int opendhcp_add_listener(); void sendUserList(data19 *req, const char *pRequest, dhcpMap *dhcpCache, data2 *cfig, time_t t); void sendAllLists(data19 *req, bool kRunning, dhcpMap *dhcpCache, data2 *cfig); int getHwAddr(char *buff, char *mac); diff --git a/srcs/open_dhcp/query.cpp b/srcs/open_dhcp/query.cpp index 6a3dd3e..64e444c 100644 --- a/srcs/open_dhcp/query.cpp +++ b/srcs/open_dhcp/query.cpp @@ -593,6 +593,28 @@ static void opendhcp_http_expand_rangeset(http_request *request, hw_http_respons hw_http_response_send(response, req, response_complete); } +/** + * 添加配置文件监听接口 + * @return + */ +int opendhcp_add_listener() { + int i; + vector listen_ip = config_get_dhcp_listen_on(); + + for (i = 0; listen_ip && i < vect_size(listen_ip); i++) { + const char *pIp = (const char *)vect_get_at(listen_ip, i); + if (pIp && strlen(pIp) > 0) { + MYDWORD addr = inet_addr(pIp); + addServer(cfig.specifiedServers, MAX_SERVERS, addr); + } + } + + return i; +} + +/** + * 增加 DHCP Server HTTP服务接口 + */ void opendhcp_init_http_server() { static int added = FALSE;