From 772e9c6627efdb3876a9be5f529bf7a61c229055 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 13 Sep 2023 16:27:58 +0800 Subject: [PATCH] update test case --- source/libs/transport/src/transComm.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index b9683ec487..c0fe41b8ca 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -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; } }