summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Härdeman2025-11-20 12:47:13 +0000
committerÁlvaro Fernández Rojas2025-11-27 07:24:14 +0000
commitab8b1572247d6cfede311fe16433db1b36bfb059 (patch)
tree813ee53652b6e3dcee9b36876d94b14659180096
parent558fb499c8c2f48d1cff9bc339e118c0220b4a1f (diff)
downloadodhcpd-ab8b1572247d6cfede311fe16433db1b36bfb059.tar.gz
dhcpv4: remove iface->dhcpv4_mask
This is already covered by iface->dhcpv4_own_ip Signed-off-by: David Härdeman <david@hardeman.nu> Link: https://github.com/openwrt/odhcpd/pull/320 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
-rw-r--r--src/dhcpv4.c13
-rw-r--r--src/odhcpd.h1
2 files changed, 5 insertions, 9 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c
index 49d3c78..194959b 100644
--- a/src/dhcpv4.c
+++ b/src/dhcpv4.c
@@ -603,8 +603,8 @@ dhcpv4_lease(struct interface *iface, enum dhcpv4_msg req_msg, const uint8_t *re
return NULL;
/* Old lease, but with an address that is out-of-scope? */
- if (lease && ((lease->ipv4.s_addr & iface->dhcpv4_mask.s_addr) !=
- (iface->dhcpv4_start_ip.s_addr & iface->dhcpv4_mask.s_addr)) &&
+ if (lease && ((lease->ipv4.s_addr & iface->dhcpv4_local.netmask) !=
+ (iface->dhcpv4_start_ip.s_addr & iface->dhcpv4_local.netmask)) &&
!(lease->flags & OAF_STATIC)) {
/* Try to reassign to an address that is in-scope */
avl_delete(&iface->dhcpv4_leases, &lease->iface_avl);
@@ -1073,8 +1073,8 @@ void dhcpv4_handle_msg(void *src_addr, void *data, size_t len,
reply_serverid.data = fr_serverid;
if (req->ciaddr.s_addr &&
- ((iface->dhcpv4_start_ip.s_addr & iface->dhcpv4_mask.s_addr) !=
- (req->ciaddr.s_addr & iface->dhcpv4_mask.s_addr)))
+ ((iface->dhcpv4_start_ip.s_addr & iface->dhcpv4_local.netmask) !=
+ (req->ciaddr.s_addr & iface->dhcpv4_local.netmask)))
req->ciaddr.s_addr = INADDR_ANY;
}
break;
@@ -1088,7 +1088,7 @@ void dhcpv4_handle_msg(void *src_addr, void *data, size_t len,
case DHCPV4_OPT_NETMASK:
if (!lease)
break;
- reply_netmask.data = iface->dhcpv4_mask.s_addr;
+ reply_netmask.data = iface->dhcpv4_local.netmask;
iov[IOV_NETMASK].iov_len = sizeof(reply_netmask);
break;
@@ -1361,7 +1361,6 @@ static bool dhcpv4_setup_addresses(struct interface *iface)
iface->dhcpv4_end_ip.s_addr = INADDR_ANY;
iface->dhcpv4_own_ip = (struct odhcpd_ipaddr){ .addr.in.s_addr = INADDR_ANY };
iface->dhcpv4_bcast.s_addr = INADDR_ANY;
- iface->dhcpv4_mask.s_addr = INADDR_ANY;
if (iface->no_dynamic_dhcp) {
if (!iface->oaddrs4_cnt)
@@ -1369,7 +1368,6 @@ static bool dhcpv4_setup_addresses(struct interface *iface)
iface->dhcpv4_own_ip = iface->oaddrs4[0];
iface->dhcpv4_bcast = iface->oaddrs4[0].broadcast;
- iface->dhcpv4_mask.s_addr = iface->oaddrs4[0].netmask;
info("DHCPv4: providing static leases on interface '%s'", iface->name);
return true;
@@ -1428,7 +1426,6 @@ static bool dhcpv4_setup_addresses(struct interface *iface)
iface->dhcpv4_end_ip.s_addr = (oaddr->addr.in.s_addr & oaddr->netmask) | htonl(pool_end);
iface->dhcpv4_own_ip = *oaddr;
iface->dhcpv4_bcast = oaddr->broadcast;
- iface->dhcpv4_mask.s_addr = oaddr->netmask;
info("DHCPv4: providing dynamic/static leases on interface '%s', pool: %s - %s", iface->name,
inet_ntop(AF_INET, &iface->dhcpv4_start_ip, pool_start_str, sizeof(pool_start_str)),
diff --git a/src/odhcpd.h b/src/odhcpd.h
index 735bd6f..1de9ffd 100644
--- a/src/odhcpd.h
+++ b/src/odhcpd.h
@@ -448,7 +448,6 @@ struct interface {
struct in_addr dhcpv4_end_ip;
struct odhcpd_ipaddr dhcpv4_own_ip;
struct in_addr dhcpv4_bcast;
- struct in_addr dhcpv4_mask;
struct in_addr *dhcpv4_router;
size_t dhcpv4_router_cnt;
struct in_addr *dhcpv4_dns;