diff options
author | Jan Kiszka <jan.kiszka@web.de> | 2009-05-21 22:43:39 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-05-22 10:50:34 -0500 |
commit | d41c451bbc4aae98e51bebe44274b30c7c2511b4 (patch) | |
tree | 58db065c228344f557a544bf5b91123e307cb330 /bootp.c | |
parent | 6618b7dae6f1588c25f1bddcefc083fbc8321e9d (diff) | |
download | slirp-d41c451bbc4aae98e51bebe44274b30c7c2511b4.zip slirp-d41c451bbc4aae98e51bebe44274b30c7c2511b4.tar.gz slirp-d41c451bbc4aae98e51bebe44274b30c7c2511b4.tar.bz2 |
slirp: Reassign same address to same DHCP client
In case a client restarts a DHCP recovery without releasing its old
address, reassign the same address to prevent consuming free addresses
and moving away from the standard client address.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Diffstat (limited to 'bootp.c')
-rw-r--r-- | bootp.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -52,13 +52,14 @@ static const uint8_t rfc1533_cookie[] = { RFC1533_COOKIE }; #define dprintf(fmt, ...) #endif -static BOOTPClient *get_new_addr(struct in_addr *paddr) +static BOOTPClient *get_new_addr(struct in_addr *paddr, const uint8_t *macaddr) { BOOTPClient *bc; int i; for (i = 0; i < NB_ADDR; i++) { - if (!bootp_clients[i].allocated) + bc = &bootp_clients[i]; + if (!bc->allocated || !memcmp(macaddr, bc->macaddr, 6)) goto found; } return NULL; @@ -194,7 +195,7 @@ static void bootp_reply(const struct bootp_t *bp) } if (!bc) { new_addr: - bc = get_new_addr(&daddr.sin_addr); + bc = get_new_addr(&daddr.sin_addr, client_ethaddr); if (!bc) { dprintf("no address left\n"); return; |