chiark / gitweb /
networkd: monopolize in_addr utility functions in shared/in-addr-util.h
[elogind.git] / src / shared / in-addr-util.c
index 459f8461738f935fc0c09af5ce6e70e00af3c5d6..457eedd6d81825f519984f06884cc0c91ab4c6c0 100644 (file)
@@ -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));
+}