OCT 修改删除地址池接口部分实现细节

This commit is contained in:
dongwenze 2023-02-10 11:06:16 +08:00
parent 445a82aa8f
commit a56fa29378
1 changed files with 12 additions and 12 deletions

View File

@ -473,11 +473,11 @@ static int add_dhcpd_rangeset(data19 *req, const char *pRequest) {
return ERR_SUCCESS;
}
struct hash_map {
typedef struct {
unsigned int key;
unsigned int value;
UT_hash_handle hh;
};
}HASH_MAP, *PHASH_MAP;
static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
char logBuff[512];
@ -486,7 +486,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
cJSON *pRspRoot;
cJSON *pdelArray;
data13 dhcpRanges[MAX_DHCP_RANGES];
hash_map *delMap = nullptr;
PHASH_MAP delMap = nullptr;
int resCount = 0;
LOG_MOD(debug, ZLOG_MOD_OPENDHCPD, "Input: %s\n", pRequest);
@ -531,7 +531,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
cJSON *pdel_Item = cJSON_CreateObject();
cJSON *pdelRange = cJSON_GetArrayItem(pdhcp_range, i);
char del_range[256];
auto *delItem = (struct hash_map *)malloc(sizeof(hash_map));
auto *delItem = (PHASH_MAP)malloc(sizeof(HASH_MAP));
if (!pdelRange) {
continue;
@ -556,7 +556,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
HASH_FIND_INT(delMap, &st_addr, delItem);
if (delItem == nullptr) {
auto *s = (struct hash_map *)malloc(sizeof(struct hash_map));
auto *s = (PHASH_MAP)malloc(sizeof(HASH_MAP));
s->key = st_addr;
s->value = en_addr;
HASH_ADD_INT(delMap, key, s);
@ -565,7 +565,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
for (int i = 0; i < cfig.rangeCount; i++) {
cJSON *pdel_Item = cJSON_CreateObject();
hash_map *delRange;
PHASH_MAP delRange;
char del_range[256];
char saddr[128];
char eaddr[128];
@ -578,7 +578,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
sprintf(del_range, "%s-%s", saddr, eaddr);
cJSON_AddStringToObject(pdel_Item, "dhcpRange", del_range);
//judge whether the input has error
//Determine whether the input is correct or not
if (delRange->value == cfig.dhcpRanges[i].rangeEnd) {
cJSON_AddNumberToObject(pdel_Item, "status", ERR_SUCCESS);
cJSON_AddStringToObject(pdel_Item, "message", getErrorEnumDesc(ERR_SUCCESS));
@ -594,17 +594,17 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
HASH_DEL(delMap, delRange);
} else {
//write to dhcpRanges
//Write dhcpRanges
memcpy(&dhcpRanges[resCount], &cfig.dhcpRanges[i], sizeof(struct data13));
resCount++;
}
}
//输入参数不存在的情况
//The input parameter does not exist
if (resCount > cfig.rangeCount - cJSON_GetArraySize(pdhcp_range)) {
cJSON *pdel_Item = cJSON_CreateObject();
auto *s = (struct hash_map *)malloc(sizeof(struct hash_map));
hash_map *tmp;
auto *s = (PHASH_MAP)malloc(sizeof(HASH_MAP));
PHASH_MAP tmp;
char saddr[128];
char eaddr[128];
char del_range[256];
@ -623,7 +623,7 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
}
}
//rewite cfig.dhcpRanges
//Rewrite cfig.dhcpRanges
for (int i = 0; i < cfig.rangeCount; i++) {
if (i < resCount) {
memcpy(&cfig.dhcpRanges[i], &dhcpRanges[i], sizeof(struct data13));