diff options
author | Steven Barth <steven@midlink.org> | 2014-07-01 10:05:30 +0200 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2014-07-01 10:06:08 +0200 |
commit | 4267915aef64aae345972c77148b11759a172b14 (patch) | |
tree | 9ca0d98d7dec5c6e9f9c87e3a698dff04ab499a7 | |
parent | 78aef4acbc692ef61169e3f26bb69d0f3574b1cd (diff) |
DHCPv4: send DHCPNAK if requested addr != leased addr
-rw-r--r-- | src/dhcpv4.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c index 1fac8a1..b8d64ce 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -331,6 +331,10 @@ static void handle_dhcpv4(void *addr, void *data, size_t len, return; } else if (reqmsg == DHCPV4_MSG_DISCOVER) { msg = DHCPV4_MSG_OFFER; + } else if (reqmsg == DHCPV4_MSG_REQUEST && reqaddr.s_addr && + reqaddr.s_addr != htonl(lease->addr)) { + msg = DHCPV4_MSG_NAK; + lease = NULL; } if (reqmsg == DHCPV4_MSG_DECLINE || reqmsg == DHCPV4_MSG_RELEASE) @@ -401,7 +405,7 @@ static void handle_dhcpv4(void *addr, void *data, size_t len, dest.sin_addr = req->ciaddr; dest.sin_port = htons(DHCPV4_CLIENT_PORT); } else if ((ntohs(req->flags) & DHCPV4_FLAG_BROADCAST) || - req->hlen != reply.hlen) { + req->hlen != reply.hlen || !reply.yiaddr.s_addr) { dest.sin_addr.s_addr = INADDR_BROADCAST; dest.sin_port = htons(DHCPV4_CLIENT_PORT); } else { |