Lines Matching defs:prefixlen
146 int in_addr_prefix_next(int family, union in_addr_union *u, unsigned prefixlen) {
152 if (prefixlen <= 0)
158 if (prefixlen > 32)
159 prefixlen = 32;
162 n = c + (1UL << (32 - prefixlen));
165 n &= 0xFFFFFFFFUL << (32 - prefixlen);
176 if (prefixlen > 128)
177 prefixlen = 128;
180 add.s6_addr[(prefixlen-1) / 8] = 1 << (7 - (prefixlen-1) % 8);
270 struct in_addr* in_addr_prefixlen_to_netmask(struct in_addr *addr, unsigned char prefixlen) {
272 assert(prefixlen <= 32);
275 if (prefixlen == 0)
278 addr->s_addr = htobe32((0xffffffff << (32 - prefixlen)) & 0xffffffff);
283 int in_addr_default_prefixlen(const struct in_addr *addr, unsigned char *prefixlen) {
289 assert(prefixlen);
293 *prefixlen = 8;
296 *prefixlen = 16;
299 *prefixlen = 24;
301 /* class D or E, no default prefixlen */
308 unsigned char prefixlen;
314 r = in_addr_default_prefixlen(addr, &prefixlen);
318 in_addr_prefixlen_to_netmask(mask, prefixlen);
322 int in_addr_mask(int family, union in_addr_union *addr, unsigned char prefixlen) {
328 if (!in_addr_prefixlen_to_netmask(&mask, prefixlen))
341 if (prefixlen >= 8) {
343 prefixlen -= 8;
345 mask = 0xFF << (8 - prefixlen);
346 prefixlen = 0;