Merge remote-tracking branch 'origin/master'

This commit is contained in:
huangxin 2022-11-28 10:35:52 +08:00
commit 5967e43519
1 changed files with 63 additions and 53 deletions

View File

@ -245,6 +245,7 @@ static void expand_range_set(data19 *req, const char *pRequest) {
OBJ_DHCP_RNG pRange; OBJ_DHCP_RNG pRange;
char *fp; char *fp;
cJSON *pRspRoot; cJSON *pRspRoot;
cJSON *pExpandArray;
dzlog_debug("Input: %s\n", pRequest); dzlog_debug("Input: %s\n", pRequest);
@ -259,17 +260,7 @@ static void expand_range_set(data19 *req, const char *pRequest) {
return; return;
} }
cJSON *pdhcp_range = cJSON_GetObjectItem(pRoot, "dhcp_range"); cJSON *prange_set = cJSON_GetObjectItem(pRoot, "range_set");
if (!pdhcp_range) {
cJSON_Delete(pRoot);
return;
}
cJSON *psubnet_mask = cJSON_GetObjectItem(pRoot, "subnet_mask");
cJSON *pdomain_server = cJSON_GetObjectItem(pRoot, "domain_server");
cJSON *pgateway = cJSON_GetObjectItem(pRoot, "gateway");
cJSON *please_time = cJSON_GetObjectItem(pRoot, "lease_time");
req->memSize = (int)(2048 + (135 * dhcpCache.size()) + (cfig.dhcpSize * 26)); req->memSize = (int)(2048 + (135 * dhcpCache.size()) + (cfig.dhcpSize * 26));
req->dp = (char *)calloc(1, req->memSize); req->dp = (char *)calloc(1, req->memSize);
@ -283,11 +274,28 @@ static void expand_range_set(data19 *req, const char *pRequest) {
fp = req->dp; fp = req->dp;
pRspRoot = cJSON_CreateObject(); pRspRoot = cJSON_CreateObject();
pExpandArray = cJSON_CreateArray();
cJSON_AddItemToObject(pRspRoot, "expansion", pExpandArray);
for (int i = 0; i < cJSON_GetArraySize(prange_set); i++) {
char tempbuff[512];
cJSON *pItem = cJSON_GetArrayItem(prange_set, i);
cJSON *pdhcp_range = cJSON_GetObjectItem(pItem, "dhcp_range");
cJSON *pEx_range = cJSON_CreateObject();
if (!pdhcp_range) {
cJSON_Delete(pRoot);
return;
}
cJSON *psubnet_mask = cJSON_GetObjectItem(pItem, "subnet_mask");
cJSON *pdomain_server = cJSON_GetObjectItem(pItem, "domain_server");
cJSON *pgateway = cJSON_GetObjectItem(pItem, "gateway");
cJSON *please_time = cJSON_GetObjectItem(pItem, "lease_time");
memset(&pRange, 0, sizeof(OBJ_DHCP_RNG)); memset(&pRange, 0, sizeof(OBJ_DHCP_RNG));
strcpy(pRange.rangAddr, pdhcp_range->valuestring); strcpy(pRange.rangAddr, pdhcp_range->valuestring);
if (psubnet_mask) { if (psubnet_mask) {
strcpy(pRange.subnet, psubnet_mask->valuestring); strcpy(pRange.subnet, psubnet_mask->valuestring);
} }
@ -327,8 +335,10 @@ static void expand_range_set(data19 *req, const char *pRequest) {
} }
cfig.rangeCount = (char)(m + 1); cfig.rangeCount = (char)(m + 1);
cJSON_AddNumberToObject(pRspRoot, "expand_start", cfig.dhcpRanges[m].rangeStart); cJSON_AddNumberToObject(pEx_range, "expand_start", cfig.dhcpRanges[m].rangeStart);
cJSON_AddNumberToObject(pRspRoot, "expand_end", cfig.dhcpRanges[m].rangeEnd); cJSON_AddNumberToObject(pEx_range, "expand_end", cfig.dhcpRanges[m].rangeEnd);
cJSON_AddItemToArray(pExpandArray, pEx_range);
}
fp += sprintf(fp, "%s", cJSON_Print(pRspRoot)); fp += sprintf(fp, "%s", cJSON_Print(pRspRoot));