diff options
author | Patrick Grimm <stargieg@gmail.com> | 2015-06-15 00:39:32 +0200 |
---|---|---|
committer | Patrick Grimm <stargieg@gmail.com> | 2015-06-15 00:39:32 +0200 |
commit | 6e6d58c2389c7610e75b5a766af873deb77377b0 (patch) | |
tree | 8134edf0743ed8bd7bc717f00ad25478aaa304e3 | |
parent | cc0763d6edff3ec43a025067f1c8f13a42821a8d (diff) |
dhcpv4: use ubus for ipv4 dhcp range calculation
Signed-off-by: Patrick Grimm <patrick@lunatiki.de>
-rw-r--r-- | src/dhcpv4.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c index a657e13..bc3ee31 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -119,18 +119,22 @@ int setup_dhcpv4_interface(struct interface *iface, bool enable) } // Create a range if not specified - struct ifreq ifreq; - strncpy(ifreq.ifr_name, iface->ifname, sizeof(ifreq.ifr_name)); - - struct sockaddr_in *saddr = (struct sockaddr_in*)&ifreq.ifr_addr; - struct sockaddr_in *smask = (struct sockaddr_in*)&ifreq.ifr_netmask; + //struct ifreq ifreq; + //strncpy(ifreq.ifr_name, iface->ifname, sizeof(ifreq.ifr_name)); + + //struct sockaddr_in *saddr = (struct sockaddr_in*)&ifreq.ifr_addr; + //struct sockaddr_in *smask = (struct sockaddr_in*)&ifreq.ifr_netmask; + //if (!(iface->dhcpv4_start.s_addr & htonl(0xffff0000)) && + // !(iface->dhcpv4_end.s_addr & htonl(0xffff0000)) && + // !ioctl(sock, SIOCGIFADDR, &ifreq)) { if (!(iface->dhcpv4_start.s_addr & htonl(0xffff0000)) && - !(iface->dhcpv4_end.s_addr & htonl(0xffff0000)) && - !ioctl(sock, SIOCGIFADDR, &ifreq)) { - struct in_addr addr = saddr->sin_addr; + !(iface->dhcpv4_end.s_addr & htonl(0xffff0000))) { + //struct in_addr addr = saddr->sin_addr; + struct in_addr addr = ubus_get_address4(iface->ifname); - ioctl(sock, SIOCGIFNETMASK, &ifreq); - struct in_addr mask = smask->sin_addr; + //ioctl(sock, SIOCGIFNETMASK, &ifreq); + //struct in_addr mask = smask->sin_addr; + struct in_addr mask = ubus_get_mask4(iface->ifname); uint32_t start = ntohl(iface->dhcpv4_start.s_addr); uint32_t end = ntohl(iface->dhcpv4_end.s_addr); |