From: Jin-Seong Kim Date: Thu, 25 May 2017 08:30:55 +0000 (+0900) Subject: netutils/dhcpc : do not send decline message to same dhcp server X-Git-Tag: 1.1_Public_Release~457^2~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=97ac4d053296eddef1d358baceea4cc2a809ad0b;p=rtos%2Ftinyara.git netutils/dhcpc : do not send decline message to same dhcp server This commit is bug fix to prevent send decline message - dhcp declient message is used to announce duplicated assigned IP address in a network - dhcp client doesn't have routine to check duplicate IP via ARP, so no need to send decline message to same server Change-Id: Iae6036e064d767159fa6d1b6a10f95fcaa3c317f Signed-off-by: Jin-Seong Kim --- diff --git a/apps/netutils/dhcpc/dhcpc.c b/apps/netutils/dhcpc/dhcpc.c index 354a0f1..6b8cac0 100644 --- a/apps/netutils/dhcpc/dhcpc.c +++ b/apps/netutils/dhcpc/dhcpc.c @@ -592,10 +592,15 @@ int dhcpc_request(void *handle, struct dhcpc_state *presult) */ else if (msgtype == DHCPOFFER) { - ndbg("Received another OFFER, send DECLINE\n"); - result = dhcpc_sendmsg(pdhcpc, presult, DHCPDECLINE); - if (result <= 0) { - ndbg("recv request error(%d)(%d)\n", result, errno); + /* If we get OFFERs from same dhcp server, do not send DECLINE */ + if (pdhcpc->serverid.s_addr == presult->serverid.s_addr) { + ndbg("Received duplicated OFFER from %08x\n", ntohl(presult->serverid.s_addr)); + } else { + ndbg("Received another OFFER from %08x, send DECLINE\n", ntohl(presult->serverid.s_addr)); + result = dhcpc_sendmsg(pdhcpc, presult, DHCPDECLINE); + if (result <= 0) { + ndbg("recv request error(%d)(%d)\n", result, errno); + } } }