MCPcopy Create free account
hub / github.com/F-Stack/f-stack / in6_are_prefix_equal

Function in6_are_prefix_equal

freebsd/netinet6/in6.c:1828–1851  ·  view source on GitHub ↗

XXX: to be scope conscious */

Source from the content-addressed store, hash-verified

1826
1827/* XXX: to be scope conscious */
1828int
1829in6_are_prefix_equal(struct in6_addr *p1, struct in6_addr *p2, int len)
1830{
1831 int bytelen, bitlen;
1832
1833 /* sanity check */
1834 if (0 > len || len > 128) {
1835 log(LOG_ERR, "in6_are_prefix_equal: invalid prefix length(%d)\n",
1836 len);
1837 return (0);
1838 }
1839
1840 bytelen = len / 8;
1841 bitlen = len % 8;
1842
1843 if (bcmp(&p1->s6_addr, &p2->s6_addr, bytelen))
1844 return (0);
1845 if (bitlen != 0 &&
1846 p1->s6_addr[bytelen] >> (8 - bitlen) !=
1847 p2->s6_addr[bytelen] >> (8 - bitlen))
1848 return (0);
1849
1850 return (1);
1851}
1852
1853void
1854in6_prefixlen2mask(struct in6_addr *maskp, int len)

Callers 3

nd6_prefix_lookup_lockedFunction · 0.85
nd6_prefix_onlinkFunction · 0.85
nd6_prefix_offlinkFunction · 0.85

Calls 1

logFunction · 0.50

Tested by

no test coverage detected