mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 01:37:53 +00:00
Revert "lib: optimize apply_mask_ipv6()"
Experience with IPv4 counterpart of this function suggests, that this way of type-punning is likely to cause errors.
This commit is contained in:
parent
223da1a912
commit
8c7f49d277
24
lib/prefix.c
24
lib/prefix.c
@ -660,13 +660,23 @@ masklen2ip6 (const int masklen, struct in6_addr *netmask)
|
|||||||
void
|
void
|
||||||
apply_mask_ipv6 (struct prefix_ipv6 *p)
|
apply_mask_ipv6 (struct prefix_ipv6 *p)
|
||||||
{
|
{
|
||||||
assert (p->prefixlen >= 0 && p->prefixlen <= IPV6_MAX_BITLEN);
|
u_char *pnt;
|
||||||
u_int32_t *addr_word = (u_int32_t *) &p->prefix;
|
int index;
|
||||||
u_int32_t *mask_word = (u_int32_t *) (maskbytes6 + p->prefixlen);
|
int offset;
|
||||||
*addr_word++ &= *mask_word++;
|
|
||||||
*addr_word++ &= *mask_word++;
|
index = p->prefixlen / 8;
|
||||||
*addr_word++ &= *mask_word++;
|
|
||||||
*addr_word &= *mask_word;
|
if (index < 16)
|
||||||
|
{
|
||||||
|
pnt = (u_char *) &p->prefix;
|
||||||
|
offset = p->prefixlen % 8;
|
||||||
|
|
||||||
|
pnt[index] &= maskbit[offset];
|
||||||
|
index++;
|
||||||
|
|
||||||
|
while (index < 16)
|
||||||
|
pnt[index++] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user