diff --git a/srcs/libs/include/proto.h b/srcs/libs/include/proto.h index aa5d56c..33fbc4a 100644 --- a/srcs/libs/include/proto.h +++ b/srcs/libs/include/proto.h @@ -18,12 +18,6 @@ typedef enum { CRYPTO_AES256 = 4, } PROTO_CRYPTO_TYPE; -typedef enum { - TYPE_ADD_RNG = 0, - TYPE_DEL_RNG = 1, - TYPE_QUE_USR = 2, -} PROTO_POST_TYPE; - const char *proto_msg_validation(const char *pJsonStr, const char *msgJson, const char *errMsg); const char *proto_create_new(cJSON *pMsgCtx, int httpCode); const char *proto_decode_context(const char *pString, unsigned int *pVer, unsigned long long *pTm, int *pErrCode); diff --git a/srcs/opendhcp183/query.cpp b/srcs/opendhcp183/query.cpp index 67d20e1..f75ecac 100644 --- a/srcs/opendhcp183/query.cpp +++ b/srcs/opendhcp183/query.cpp @@ -54,20 +54,20 @@ typedef struct { } JSON_POST_CTX; static JSON_POST_CTX g_add_msg[] = { - {R"({"type":"object","required":["rangeSet"]})", "Missing required field [rangeSet]"}, - {R"({"properties":{"rangeSet":{"type":"array","minItems":1}}})", "No content in field [rangeSet]"}, + {R"({"type":"object","required":["rangeSet"]})", "Missing required field [rangeSet]"}, + {R"({"properties":{"rangeSet":{"type":"array","minItems":1}}})", "No content in field [rangeSet]"}, {R"({"properties":{"rangeSet":{"items":{"type":"object","required":["dhcpRange"]}}}})", "Missing required field [dhcpRange]"}, // {R"({"properties":{"rangeSet":{"items":{"properties":{"dhcpRange":{"type":"string","minLength":15}}}}}})", "Error in field [dhcpRange]"} }; static JSON_POST_CTX g_del_msg[] = { - {R"({"type":"object","required":["dhcpRange"]})", "Missing required field [dhcpRange]"}, + {R"({"type":"object","required":["dhcpRange"]})", "Missing required field [dhcpRange]"}, {R"({"properties":{"dhcpRange":{"type":"array","minItems":1}}})", "No content in field [dhcpRange]"}, // {R"({"properties":{"dhcpRange":{"items":{"type":"string","minLength":15}}}})", "Error in field [dhcpRange]"} }; static JSON_POST_CTX g_que_msg[] = { - {R"({"type":"object","required":["userMac"]})", "Missing required field [userMac]"}, + {R"({"type":"object","required":["userMac"]})", "Missing required field [userMac]"}, {R"({"properties":{"userMac":{"type":"array","minItems":1}}})", "No content in field [userMac]"}, // {R"({"properties":{"userMac":{"items":{"type":"string","minLength":17,"maxLength":17}}}})", "Error in field [userMac]"} }; @@ -543,16 +543,25 @@ static int delete_dhcpd_rangeset(const char **pRsp, const char *pRequest) { MYDWORD st_addr; MYDWORD en_addr; mySplit(start, end, del_range, '-'); - st_addr = htonl(inet_addr(start)); - en_addr = htonl(inet_addr(end)); - PHASH_MAP s; - HASH_FIND_INT(delMap, &st_addr, s); - if (s == nullptr) { - s = (PHASH_MAP)malloc(sizeof(HASH_MAP)); - s->key = st_addr; - s->value = en_addr; - HASH_ADD_INT(delMap, key, s); + if(isIP(start) && isIP(end)) { + st_addr = htonl(inet_addr(start)); + en_addr = htonl(inet_addr(end)); + + PHASH_MAP s; + HASH_FIND_INT(delMap, &st_addr, s); + if (s == nullptr) { + s = (PHASH_MAP)malloc(sizeof(HASH_MAP)); + s->key = st_addr; + s->value = en_addr; + HASH_ADD_INT(delMap, key, s); + } + } else { + cJSON *pdel_Item = cJSON_CreateObject(); + 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); } }