update test case

This commit is contained in:
yihaoDeng 2023-09-13 16:27:58 +08:00
parent 4faa791ffd
commit 772e9c6627
1 changed files with 4 additions and 11 deletions

View File

@ -679,15 +679,8 @@ void subnetIp2int(const char* const ip_addr, uint8_t* dst) {
}
uint32_t subnetIpRang2Int(SIpV4Range* pRange) {
SIpV4Range range = {.ip = pRange->ip, .mask = 32};
uint8_t el[4] = {0};
el[0] = range.ip & 0xFF;
el[1] = (range.ip >> 8) & 0xFF;
el[2] = (range.ip >> 16) & 0xFF;
el[3] = (range.ip >> 24) & 0xFF;
return (el[0] << 24) | (el[1] << 16) | (el[2] << 8) | (el[3]);
uint32_t ip = pRange->ip;
return ((ip & 0xFF) << 24) | ((ip & 0xFF00) << 8) | ((ip & 0xFF0000) >> 8) | ((ip >> 24) & 0xFF);
}
int32_t subnetInit(SubnetUtils* pUtils, SIpV4Range* pRange) {
if (pRange->mask == 32) {
@ -720,8 +713,8 @@ int32_t subnetCheckIp(SubnetUtils* pUtils, uint32_t ip) {
} else {
SIpV4Range range = {.ip = ip, .mask = 32};
uint32_t ip = subnetIpRang2Int(&range);
return ip >= pUtils->network && ip <= pUtils->broadcast;
uint32_t t = subnetIpRang2Int(&range);
return t >= pUtils->network && t <= pUtils->broadcast;
}
}