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);