diff options
author | Tom Gundersen <teg@jklm.no> | 2014-01-28 23:23:31 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-01-30 14:30:39 +0100 |
commit | 377a218f876507fb8be9c21ef4121fa2576ec317 (patch) | |
tree | e5da9ac8c900e9150b752cf0b75f027c748424b5 /src/network | |
parent | eb0ea358b688a6f83ff305c6b825c61f12b6dcb8 (diff) |
sd-dhcp-client/net-util: make netmask_to_prefixlen generic
This was originally included in the dhcp-client at my request, but it is not
really dhcp-specific and useful outside of it, so let's pull it out.
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkd-link.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index dec33e88ee..f021918311 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -26,6 +26,7 @@ #include "libudev-private.h" #include "util.h" #include "bus-util.h" +#include "net-util.h" int link_new(Manager *manager, struct udev_device *device, Link **ret) { _cleanup_link_free_ Link *link = NULL; @@ -422,7 +423,7 @@ static void dhcp_handler(sd_dhcp_client *client, int event, void *userdata) { struct in_addr address; struct in_addr netmask; struct in_addr gateway; - int prefixlen; + unsigned prefixlen; int r; assert(link); @@ -496,12 +497,7 @@ static void dhcp_handler(sd_dhcp_client *client, int event, void *userdata) { return; } - prefixlen = sd_dhcp_client_prefixlen(&netmask); - if (prefixlen < 0) { - log_warning_link(link, "DHCP error: no prefixlen"); - link_enter_failed(link); - return; - } + prefixlen = net_netmask_to_prefixlen(&netmask); r = sd_dhcp_client_get_router(client, &gateway); if (r < 0) { |