OCT 修改接口的部分实现细节

This commit is contained in:
dongwenze 2022-12-12 15:45:25 +08:00
parent 3ef2b0672c
commit ec5dc9e900
1 changed files with 7 additions and 16 deletions

View File

@ -104,17 +104,16 @@ static int dhcp_get_user_info(data19 *req, const char *pRequest) {
} else {
cJSON_AddStringToObject(pRspItem, "leaseExpiry", "Expiry");
}
cJSON_AddNumberToObject(pRspItem, "status", ERR_SUCCESS);
cJSON_AddStringToObject(pRspItem, "message", getErrorEnumDesc(ERR_SUCCESS));
} else {
cJSON_AddStringToObject(pRspItem, "ip", "");
cJSON_AddStringToObject(pRspItem, "hostname", "");
cJSON_AddNumberToObject(pRspItem, "status", ERR_ITEM_UNEXISTS);
cJSON_AddStringToObject(pRspItem, "message", getErrorEnumDesc(ERR_ITEM_UNEXISTS));
}
cJSON_AddItemToArray(pMsgArray, pRspItem);
}
cJSON_AddNumberToObject(pRspMsg, "status", ERR_SUCCESS);
cJSON_AddStringToObject(pRspMsg, "message", getErrorEnumDesc(ERR_SUCCESS));
const char *pStrPro = proto_create_new(pRspMsg, 200);
//cJSON_AddItemToObject(pRspRoot, "msgContent", pRspMsg);
@ -564,12 +563,6 @@ static int delete_dhcpd_rangeset(data19 *req, const char *pRequest) {
return ERR_SUCCESS;
}
static void revert(unsigned int *num) {
unsigned int v = *num;
v = ((v & 0x000000FF) << 24) | ((v & 0x0000FF00) << 8) | ((v & 0x00FF0000) >> 8) | ((v & 0xFF000000) >> 24);
*num = v;
}
static int query_dhcpd_rangeset(data19 *req) {
char logBuff[512];
req->memSize = (int)(2048 + (135 * dhcpCache.size()) + (cfig.dhcpSize * 26));
@ -627,8 +620,7 @@ static int query_dhcpd_rangeset(data19 *req) {
dnsSize = op.size;
do {
tmpVal = fIP(op.value + offset);
revert(&tmpVal);
IP2String(dns_op, ntohl(tmpVal));
IP2String(dns_op, htonl(ntohl(tmpVal)));
sprintf(domainServer, "%s%s", domainServer, dns_op);
if (dnsSize != 4) {
sprintf(domainServer, "%s,", domainServer);
@ -640,14 +632,13 @@ static int query_dhcpd_rangeset(data19 *req) {
cJSON_AddStringToObject(pRangeItem, "domainServer", domainServer);
} else if (op.opt_code == DHCP_OPTION_ROUTER) {
tmpVal = fIP(op.value);
revert(&tmpVal);
IP2String(gateway, ntohl(tmpVal));
IP2String(gateway, htonl(ntohl(tmpVal)));
cJSON_AddStringToObject(pRangeItem, "gateway", gateway);
} else if (op.opt_code == DHCP_OPTION_IPADDRLEASE) {
lease = fUInt(op.value);
cJSON_AddNumberToObject(pRangeItem, "lease", lease);
cJSON_AddNumberToObject(pRangeItem, "leaseTime", lease);
}
opPointer += op.size;
}