X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flibsystemd-network%2Fsd-dhcp-lease.c;fp=src%2Flibsystemd-network%2Fsd-dhcp-lease.c;h=f6b572a996f8f324cbd800ae333c8ee92393801a;hp=f4979f7da73e4a5dc66a0f11c5f65d6041b0139d;hb=1caa12d0a8a818d5f2545aab809b3fdfec73871d;hpb=bab47929613f9e930dd241a01483b37d14b59c69 diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c index f4979f7da..f6b572a99 100644 --- a/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/libsystemd-network/sd-dhcp-lease.c @@ -310,23 +310,6 @@ static int lease_parse_in_addrs_pairs(const uint8_t *option, size_t len, struct return lease_parse_in_addrs_aux(option, len, ret, ret_size, 2); } -static int class_prefixlen(uint8_t msb_octet, uint8_t *ret) { - if (msb_octet < 128) - /* Class A */ - *ret = 8; - else if (msb_octet < 192) - /* Class B */ - *ret = 16; - else if (msb_octet < 224) - /* Class C */ - *ret = 24; - else - /* Class D or E -- no subnet mask */ - return -ERANGE; - - return 0; -} - static int lease_parse_routes(const uint8_t *option, size_t len, struct sd_dhcp_route **routes, size_t *routes_size, size_t *routes_allocated) { @@ -348,8 +331,10 @@ static int lease_parse_routes(const uint8_t *option, size_t len, struct sd_dhcp_ while (len >= 8) { struct sd_dhcp_route *route = *routes + *routes_size; + int r; - if (class_prefixlen(*option, &route->dst_prefixlen) < 0) { + r = in_addr_default_prefixlen((struct in_addr*) option, &route->dst_prefixlen); + if (r < 0) { log_error("Failed to determine destination prefix length from class based IP, ignoring"); continue; }