mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 05:16:47 +08:00
nuttx/net: Expose the net_ipv6addr_maskcmp interface to user-mode calls
This interface needs to be called in the libc library, but the interface is implemented in the kernel, so this interface needs to be exposed Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
This commit is contained in:
+24
-3
@@ -592,9 +592,30 @@ extern "C"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
|
||||
const net_ipv6addr_t addr2,
|
||||
const net_ipv6addr_t mask);
|
||||
static inline_function bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
|
||||
const net_ipv6addr_t addr2,
|
||||
const net_ipv6addr_t mask)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Start from the "bottom" where the addresses will most likely differ */
|
||||
|
||||
for (i = 7; i >= 0; i--)
|
||||
{
|
||||
/* Same? */
|
||||
|
||||
if ((addr1[i] & mask[i]) != (addr2[i] & mask[i]))
|
||||
{
|
||||
/* No.. the addresses are different */
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* The addresses are the same */
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user