aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/leases.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/leases.c')
-rw-r--r--networking/udhcp/leases.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/networking/udhcp/leases.c b/networking/udhcp/leases.c
index c5b60b108..745340ad3 100644
--- a/networking/udhcp/leases.c
+++ b/networking/udhcp/leases.c
@@ -112,7 +112,7 @@ struct dyn_lease* FAST_FUNC find_lease_by_nip(uint32_t nip)
112} 112}
113 113
114/* Check if the IP is taken; if it is, add it to the lease table */ 114/* Check if the IP is taken; if it is, add it to the lease table */
115static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac) 115static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac, unsigned arpping_ms)
116{ 116{
117 struct in_addr temp; 117 struct in_addr temp;
118 int r; 118 int r;
@@ -120,7 +120,8 @@ static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac)
120 r = arpping(nip, safe_mac, 120 r = arpping(nip, safe_mac,
121 server_config.server_nip, 121 server_config.server_nip,
122 server_config.server_mac, 122 server_config.server_mac,
123 server_config.interface); 123 server_config.interface,
124 arpping_ms);
124 if (r) 125 if (r)
125 return r; 126 return r;
126 127
@@ -132,7 +133,7 @@ static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac)
132} 133}
133 134
134/* Find a new usable (we think) address */ 135/* Find a new usable (we think) address */
135uint32_t FAST_FUNC find_free_or_expired_nip(const uint8_t *safe_mac) 136uint32_t FAST_FUNC find_free_or_expired_nip(const uint8_t *safe_mac, unsigned arpping_ms)
136{ 137{
137 uint32_t addr; 138 uint32_t addr;
138 struct dyn_lease *oldest_lease = NULL; 139 struct dyn_lease *oldest_lease = NULL;
@@ -177,7 +178,7 @@ uint32_t FAST_FUNC find_free_or_expired_nip(const uint8_t *safe_mac)
177 lease = find_lease_by_nip(nip); 178 lease = find_lease_by_nip(nip);
178 if (!lease) { 179 if (!lease) {
179//TODO: DHCP servers do not always sit on the same subnet as clients: should *ping*, not arp-ping! 180//TODO: DHCP servers do not always sit on the same subnet as clients: should *ping*, not arp-ping!
180 if (nobody_responds_to_arp(nip, safe_mac)) 181 if (nobody_responds_to_arp(nip, safe_mac, arpping_ms))
181 return nip; 182 return nip;
182 } else { 183 } else {
183 if (!oldest_lease || lease->expires < oldest_lease->expires) 184 if (!oldest_lease || lease->expires < oldest_lease->expires)
@@ -194,7 +195,7 @@ uint32_t FAST_FUNC find_free_or_expired_nip(const uint8_t *safe_mac)
194 195
195 if (oldest_lease 196 if (oldest_lease
196 && is_expired_lease(oldest_lease) 197 && is_expired_lease(oldest_lease)
197 && nobody_responds_to_arp(oldest_lease->lease_nip, safe_mac) 198 && nobody_responds_to_arp(oldest_lease->lease_nip, safe_mac, arpping_ms)
198 ) { 199 ) {
199 return oldest_lease->lease_nip; 200 return oldest_lease->lease_nip;
200 } 201 }