From 8dbab1019eac2f9f35c1b0c688441f2e1cd754a5 Mon Sep 17 00:00:00 2001 From: dongwenze Date: Thu, 8 Dec 2022 15:18:18 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=E5=A2=9E=E5=8A=A0=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E6=B1=A0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/open_dhcp/query.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/srcs/open_dhcp/query.cpp b/srcs/open_dhcp/query.cpp index b261338..e4d0249 100644 --- a/srcs/open_dhcp/query.cpp +++ b/srcs/open_dhcp/query.cpp @@ -458,13 +458,16 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest){ if(!deleted_flag){ if((st_addr == cfig.dhcpRanges[m].rangeStart) && (en_addr == cfig.dhcpRanges[m].rangeEnd)){ deleted_flag = true; - memset(&cfig.dhcpRanges[m], 0, sizeof(struct data19)); + if(m == cfig.rangeCount-1){ + memset(&cfig.dhcpRanges[m], 0, sizeof(struct data19)); + } continue; }else if(st_addr == cfig.dhcpRanges[m].rangeStart||en_addr == cfig.dhcpRanges[m].rangeEnd){ deleted_flag = false; break; } }else{ + cfig.dhcpRanges[m].rangeSetInd = m-1; memcpy(&(cfig.dhcpRanges[m-1]), &(cfig.dhcpRanges[m]), sizeof(struct data19)); } } @@ -560,6 +563,8 @@ static int query_dhcpd_rangeset(data19 *req){ opPointer++; memcpy(op.value, opPointer, op.size); + printf("***op->addr=%X***\n", cfig.dhcpRanges[rangeInd].options); + printf("op.opt_code=%d\n", op.opt_code); if(op.opt_code == DHCP_OPTION_DNS){ dnsSize = op.size; do { @@ -582,6 +587,7 @@ static int query_dhcpd_rangeset(data19 *req){ cJSON_AddStringToObject(pRangeItem, "gateway", gateway); }else if(op.opt_code == DHCP_OPTION_IPADDRLEASE){ + printf("***flag!!!***\n"); lease = fUInt(op.value); cJSON_AddNumberToObject(pRangeItem, "lease", lease);