Lines Matching defs:addr
27 #include "in-addr-util.h"
264 unsigned char in_addr_netmask_to_prefixlen(const struct in_addr *addr) {
265 assert(addr);
267 return 32 - u32ctz(be32toh(addr->s_addr));
270 struct in_addr* in_addr_prefixlen_to_netmask(struct in_addr *addr, unsigned char prefixlen) {
271 assert(addr);
276 addr->s_addr = 0;
278 addr->s_addr = htobe32((0xffffffff << (32 - prefixlen)) & 0xffffffff);
280 return addr;
283 int in_addr_default_prefixlen(const struct in_addr *addr, unsigned char *prefixlen) {
284 uint8_t msb_octet = *(uint8_t*) addr;
286 /* addr may not be aligned, so make sure we only access it byte-wise */
288 assert(addr);
307 int in_addr_default_subnet_mask(const struct in_addr *addr, struct in_addr *mask) {
311 assert(addr);
314 r = in_addr_default_prefixlen(addr, &prefixlen);
322 int in_addr_mask(int family, union in_addr_union *addr, unsigned char prefixlen) {
323 assert(addr);
331 addr->in.s_addr &= mask.s_addr;
349 addr->in6.s6_addr[i] &= mask;