Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
5967e43519
|
@ -245,6 +245,7 @@ static void expand_range_set(data19 *req, const char *pRequest) {
|
|||
OBJ_DHCP_RNG pRange;
|
||||
char *fp;
|
||||
cJSON *pRspRoot;
|
||||
cJSON *pExpandArray;
|
||||
|
||||
dzlog_debug("Input: %s\n", pRequest);
|
||||
|
||||
|
@ -259,17 +260,7 @@ static void expand_range_set(data19 *req, const char *pRequest) {
|
|||
return;
|
||||
}
|
||||
|
||||
cJSON *pdhcp_range = cJSON_GetObjectItem(pRoot, "dhcp_range");
|
||||
|
||||
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");
|
||||
cJSON *prange_set = cJSON_GetObjectItem(pRoot, "range_set");
|
||||
|
||||
req->memSize = (int)(2048 + (135 * dhcpCache.size()) + (cfig.dhcpSize * 26));
|
||||
req->dp = (char *)calloc(1, req->memSize);
|
||||
|
@ -283,11 +274,28 @@ static void expand_range_set(data19 *req, const char *pRequest) {
|
|||
|
||||
fp = req->dp;
|
||||
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));
|
||||
|
||||
strcpy(pRange.rangAddr, pdhcp_range->valuestring);
|
||||
|
||||
if (psubnet_mask) {
|
||||
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);
|
||||
|
||||
cJSON_AddNumberToObject(pRspRoot, "expand_start", cfig.dhcpRanges[m].rangeStart);
|
||||
cJSON_AddNumberToObject(pRspRoot, "expand_end", cfig.dhcpRanges[m].rangeEnd);
|
||||
cJSON_AddNumberToObject(pEx_range, "expand_start", cfig.dhcpRanges[m].rangeStart);
|
||||
cJSON_AddNumberToObject(pEx_range, "expand_end", cfig.dhcpRanges[m].rangeEnd);
|
||||
cJSON_AddItemToArray(pExpandArray, pEx_range);
|
||||
}
|
||||
|
||||
fp += sprintf(fp, "%s", cJSON_Print(pRspRoot));
|
||||
|
||||
|
|
Loading…
Reference in New Issue