OCT 修改参数异常判断
This commit is contained in:
parent
9efa161728
commit
3ef2b0672c
|
@ -448,6 +448,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
|
||||||
cJSON_AddItemToObject(pRspRoot, "rangeSet", pdelArray);
|
cJSON_AddItemToObject(pRspRoot, "rangeSet", pdelArray);
|
||||||
|
|
||||||
for (int i = 0; i < cJSON_GetArraySize(pdhcp_range); i++) {
|
for (int i = 0; i < cJSON_GetArraySize(pdhcp_range); i++) {
|
||||||
|
cJSON *pdel_Item = cJSON_CreateObject();
|
||||||
cJSON *pdelRange = cJSON_GetArrayItem(pdhcp_range, i);
|
cJSON *pdelRange = cJSON_GetArrayItem(pdhcp_range, i);
|
||||||
char del_range[256];
|
char del_range[256];
|
||||||
auto *delItem = (struct hash_map *)malloc(sizeof(hash_map));
|
auto *delItem = (struct hash_map *)malloc(sizeof(hash_map));
|
||||||
|
@ -465,6 +466,13 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
|
||||||
mySplit(start, end, del_range, '-');
|
mySplit(start, end, del_range, '-');
|
||||||
st_addr = htonl(inet_addr(start));
|
st_addr = htonl(inet_addr(start));
|
||||||
en_addr = htonl(inet_addr(end));
|
en_addr = htonl(inet_addr(end));
|
||||||
|
if(en_addr == 0) {
|
||||||
|
cJSON_AddStringToObject(pdel_Item, "dhcpRange", del_range);
|
||||||
|
|
||||||
|
cJSON_AddNumberToObject(pdel_Item, "status", ERR_INPUT_PARAMS);
|
||||||
|
cJSON_AddStringToObject(pdel_Item, "message", getErrorEnumDesc(ERR_INPUT_PARAMS));
|
||||||
|
cJSON_AddItemToArray(pdelArray, pdel_Item);
|
||||||
|
}
|
||||||
|
|
||||||
HASH_FIND_INT(delMap, &st_addr, delItem);
|
HASH_FIND_INT(delMap, &st_addr, delItem);
|
||||||
if (delItem == nullptr) {
|
if (delItem == nullptr) {
|
||||||
|
@ -491,7 +499,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
|
||||||
sprintf(del_range, "%s-%s", saddr, eaddr);
|
sprintf(del_range, "%s-%s", saddr, eaddr);
|
||||||
cJSON_AddStringToObject(pdel_Item, "dhcpRange", del_range);
|
cJSON_AddStringToObject(pdel_Item, "dhcpRange", del_range);
|
||||||
//judge whether the input has error
|
//judge whether the input has error
|
||||||
if(delRange->key && delRange->value && (delRange->value == cfig.dhcpRanges[i].rangeEnd)){
|
if(delRange->value == cfig.dhcpRanges[i].rangeEnd) {
|
||||||
cJSON_AddNumberToObject(pdel_Item, "status", ERR_SUCCESS);
|
cJSON_AddNumberToObject(pdel_Item, "status", ERR_SUCCESS);
|
||||||
cJSON_AddStringToObject(pdel_Item, "message", getErrorEnumDesc(ERR_SUCCESS));
|
cJSON_AddStringToObject(pdel_Item, "message", getErrorEnumDesc(ERR_SUCCESS));
|
||||||
cJSON_AddItemToArray(pdelArray, pdel_Item);
|
cJSON_AddItemToArray(pdelArray, pdel_Item);
|
||||||
|
@ -504,10 +512,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
|
||||||
cJSON_AddItemToArray(pdelArray, pdel_Item);
|
cJSON_AddItemToArray(pdelArray, pdel_Item);
|
||||||
}
|
}
|
||||||
|
|
||||||
hash_map *s = (struct hash_map*)malloc(sizeof(struct hash_map));
|
HASH_DEL(delMap, delRange);
|
||||||
s->key = delRange->key;
|
|
||||||
s->value = 0;
|
|
||||||
HASH_REPLACE_INT(delMap, key, s, delRange);
|
|
||||||
} else {
|
} else {
|
||||||
//write to dhcpRanges
|
//write to dhcpRanges
|
||||||
memcpy(&dhcpRanges[resCount], &cfig.dhcpRanges[i], sizeof(struct data13));
|
memcpy(&dhcpRanges[resCount], &cfig.dhcpRanges[i], sizeof(struct data13));
|
||||||
|
@ -526,7 +531,6 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
|
||||||
memset(del_range, 0, 256);
|
memset(del_range, 0, 256);
|
||||||
|
|
||||||
HASH_ITER(hh, delMap, s, tmp){
|
HASH_ITER(hh, delMap, s, tmp){
|
||||||
if(s->value != 0){
|
|
||||||
IP2String(saddr, ntohl(s->key));
|
IP2String(saddr, ntohl(s->key));
|
||||||
IP2String(eaddr, ntohl(s->value));
|
IP2String(eaddr, ntohl(s->value));
|
||||||
|
|
||||||
|
@ -538,7 +542,6 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
|
||||||
cJSON_AddItemToArray(pdelArray, pdel_Item);
|
cJSON_AddItemToArray(pdelArray, pdel_Item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//rewite cfig.dhcpRanges
|
//rewite cfig.dhcpRanges
|
||||||
for (int i = 0; i < cfig.rangeCount; i++) {
|
for (int i = 0; i < cfig.rangeCount; i++) {
|
||||||
|
|
Loading…
Reference in New Issue