From 9f0b6a1f700187468a0e7291d67c6c5e36cb92c1 Mon Sep 17 00:00:00 2001 From: huangxin Date: Mon, 27 Feb 2023 14:28:07 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20=E5=A4=9A=E7=94=A8=E6=88=B7=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E7=94=A8=E6=88=B7=E4=BD=BF=E7=94=A8=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E7=9A=84opendhcp.state=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/opendhcp183/opendhcpd.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/srcs/opendhcp183/opendhcpd.cpp b/srcs/opendhcp183/opendhcpd.cpp index e479332..878f1ac 100644 --- a/srcs/opendhcp183/opendhcpd.cpp +++ b/srcs/opendhcp183/opendhcpd.cpp @@ -39,6 +39,7 @@ using namespace std; #include "opendhcpd.h" #include "user_errno.h" #include "task_manager.h" +#include "config.h" void on_system_exit(void *p); @@ -305,10 +306,15 @@ int dhcpd_main(int daemon, const char *pInifile, const char *pStatusFile, const strcpy(iniFile, "/etc/opendhcp.ini"); } + memset(leaFile, 0, PATH_MAX); if (pStatusFile && strlen(pStatusFile) > 0) { strcpy(leaFile, pStatusFile); } else { +#ifdef USERVNI_ON + sprintf(leaFile, "/tmp/opendhcp.%d.state", cfg_get_user_vni_id()); +#else strcpy(leaFile, "/tmp/opendhcp.state"); +#endif } if (pIfName && strlen(pIfName) > 0) { @@ -741,8 +747,8 @@ int prepareUserHtmlRespStatus(const char **pRsps) { data7 *dhcpEntry = nullptr; //data7 *cache = nullptr; //printf("%d=%d\n", dhcpCache.size(), cfig.dhcpSize); - int memSize = (int)(2048 + (135 * dhcpCache.size()) + (cfig.dhcpSize * 26)); - char *pRsp = (char *)calloc(1, memSize); + int memSize = (int)(2048 + (135 * dhcpCache.size()) + (cfig.dhcpSize * 26)); + char *pRsp = (char *)calloc(1, memSize); if (!pRsp) { return -ERR_MALLOC_MEMORY; @@ -881,7 +887,7 @@ int prepareUserHtmlRespStatus(const char **pRsps) { fp += sprintf(fp, "\n"); } - fp += sprintf(fp, "\n\n"); + fp += sprintf(fp, "\n\n"); //MYBYTE x = sprintf(tempbuff, "%u", (fp - contentStart)); //memcpy((contentStart - 12), tempbuff, x); //pRsp->bytes = (int)(fp - pRsp->dp); @@ -4424,7 +4430,11 @@ void *init(void *lparam) { } if (!leaFile[0]) { +#ifdef USERVNI_ON + sprintf(leaFile, "%s%d/%s", filePATH, cfg_get_user_vni_id(), "opendhcp.state"); +#else sprintf(leaFile, "%s%s", filePATH, "opendhcp.state"); +#endif } if (!icoFile[0]) {