From 513951e56d71fded79b2e299e253f9b2154b9483 Mon Sep 17 00:00:00 2001 From: Patrick Grimm Date: Mon, 15 Jun 2015 03:36:15 +0200 Subject: [PATCH] dhcpv4: use iface-name Signed-off-by: Patrick Grimm --- src/dhcpv4.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/dhcpv4.c b/src/dhcpv4.c index 0f613b2..99ad658 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -121,9 +121,11 @@ int setup_dhcpv4_interface(struct interface *iface, bool enable) // Create a range if not specified if (!(iface->dhcpv4_start.s_addr & htonl(0xffff0000)) && !(iface->dhcpv4_end.s_addr & htonl(0xffff0000))) { - struct in_addr addr = ubus_get_address4(iface->ifname); - struct in_addr mask = ubus_get_mask4(iface->ifname); + struct in_addr *saddr = ubus_get_address4(iface->name); + struct in_addr addr = { .s_addr = saddr->s_addr } ; + struct in_addr *smask = ubus_get_mask4(iface->name); + struct in_addr mask = { .s_addr = smask->s_addr } ; uint32_t start = ntohl(iface->dhcpv4_start.s_addr); uint32_t end = ntohl(iface->dhcpv4_end.s_addr); @@ -195,9 +197,11 @@ int setup_dhcpv4_interface(struct interface *iface, bool enable) // Clean invalid assignments struct dhcpv4_assignment *a, *n; + struct in_addr *smask = ubus_get_mask4(iface->name); + struct in_addr mask = { .s_addr = smask->s_addr } ; list_for_each_entry_safe(a, n, &iface->dhcpv4_assignments, head) { - if ((htonl(a->addr) & smask->sin_addr.s_addr) != - (iface->dhcpv4_start.s_addr & smask->sin_addr.s_addr)) { + if ((htonl(a->addr) & mask.s_addr) != + (iface->dhcpv4_start.s_addr & mask.s_addr)) { list_del(&a->head); free(a); } -- 2.25.1