summaryrefslogtreecommitdiff
path: root/src/shared/in-addr-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/in-addr-util.c')
-rw-r--r--src/shared/in-addr-util.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/shared/in-addr-util.c b/src/shared/in-addr-util.c
index 459f846173..457eedd6d8 100644
--- a/src/shared/in-addr-util.c
+++ b/src/shared/in-addr-util.c
@@ -242,3 +242,9 @@ int in_addr_from_string_auto(const char *s, int *family, union in_addr_union *re
return -EINVAL;
}
+
+unsigned in_addr_netmask_to_prefixlen(const struct in_addr *addr) {
+ assert(addr);
+
+ return 32 - u32ctz(be32toh(addr->s_addr));
+}