diff --git a/srcs/open_dhcp/opendhcpd.cpp b/srcs/open_dhcp/opendhcpd.cpp index d4f8ca2..2362969 100644 --- a/srcs/open_dhcp/opendhcpd.cpp +++ b/srcs/open_dhcp/opendhcpd.cpp @@ -41,8 +41,6 @@ using namespace std; #include "dhcpd.h" #include "task_manager.h" -#define STR2INT(val) ((int)strtol((val), nullptr, 10)) - void on_system_exit(void *p); //Global Variables timeval tv; @@ -4390,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 8544504..815d2e3 100644 --- a/srcs/open_dhcp/opendhcpd.h +++ b/srcs/open_dhcp/opendhcpd.h @@ -70,6 +70,8 @@ typedef struct in_pktinfo IN_PKTINFO; #define LPSOCKADDR sockaddr * #define closesocket close +#define STR2INT(val) ((int)strtol((val), nullptr, 10)) + struct data7//cache { char *mapname; @@ -607,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 314993a..f626a51 100644 --- a/srcs/open_dhcp/query.cpp +++ b/srcs/open_dhcp/query.cpp @@ -603,6 +603,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;