summaryrefslogtreecommitdiff
path: root/src/shared/net-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/net-util.c')
-rw-r--r--src/shared/net-util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/net-util.c b/src/shared/net-util.c
index 887dae5125..630be18e56 100644
--- a/src/shared/net-util.c
+++ b/src/shared/net-util.c
@@ -58,6 +58,21 @@ bool net_match_config(const struct ether_addr *match_mac,
return 1;
}
+unsigned net_netmask_to_prefixlen(const struct in_addr *addr) {
+ unsigned len = 0;
+ uint32_t mask;
+
+ assert(addr);
+
+ mask = be32toh(addr->s_addr);
+ while (mask) {
+ len++;
+ mask = mask << 1;
+ }
+
+ return len;
+}
+
int config_parse_ifname(const char *unit,
const char *filename,
unsigned line,