From 3b5993e6ee7a91e46f29a4f82f6aeb12f619f8e1 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Tue, 28 Apr 2009 19:29:46 +0000 Subject: [PATCH] Integrated patch #6721: new option to adjust the time when DHCP gives over to AUTOIP and some improvements in DHCP/AUTOIP cooperation --- CHANGELOG | 3 +++ src/core/dhcp.c | 15 ++++++++++++--- src/include/lwip/opt.h | 11 +++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6b2b3e3b..76063219 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -95,6 +95,9 @@ HISTORY ++ Bugfixes: + 2009-04-28 Simon Goldschmidt, Jakob Stoklund Olesen + * dhcp.c: patch #6721: Some small fixes to DHCP and DHCP/AUTOIP cooperation + 2009-04-25 Simon Goldschmidt, Oleg Tyshev * tcp_out.c: bug #24212: Deadlocked tcp_retransmit due to exceeded pcb->cwnd Fixed by sorting the unsent and unacked queues (segments are inserted at the diff --git a/src/core/dhcp.c b/src/core/dhcp.c index 6cec5376..9bfcc6e9 100644 --- a/src/core/dhcp.c +++ b/src/core/dhcp.c @@ -817,8 +817,7 @@ dhcp_discover(struct netif *netif) } dhcp->tries++; #if LWIP_DHCP_AUTOIP_COOP - /* that means we waited 57 seconds */ - if(dhcp->tries >= 9 && dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_OFF) { + if(dhcp->tries >= LWIP_DHCP_AUTOIP_COOP_TRIES && dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_OFF) { dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_ON; autoip_start(netif); } @@ -899,6 +898,13 @@ dhcp_bind(struct netif *netif) gw_addr.addr |= htonl(0x00000001); } +#if LWIP_DHCP_AUTOIP_COOP + if(dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) { + autoip_stop(netif); + dhcp->autoip_coop_state = DHCP_AUTOIP_COOP_STATE_OFF; + } +#endif /* LWIP_DHCP_AUTOIP_COOP */ + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_bind(): IP: 0x%08"X32_F"\n", dhcp->offered_ip_addr.addr)); netif_set_ipaddr(netif, &dhcp->offered_ip_addr); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_STATE, ("dhcp_bind(): SN: 0x%08"X32_F"\n", sn_mask.addr)); @@ -1405,7 +1411,10 @@ dhcp_create_request(struct netif *netif) dhcp->msg_out->xid = htonl(dhcp->xid); dhcp->msg_out->secs = 0; dhcp->msg_out->flags = 0; - dhcp->msg_out->ciaddr.addr = netif->ip_addr.addr; + dhcp->msg_out->ciaddr.addr = 0; + if (dhcp->state==DHCP_BOUND || dhcp->state==DHCP_RENEWING || dhcp->state==DHCP_REBINDING) { + dhcp->msg_out->ciaddr.addr = netif->ip_addr.addr; + } dhcp->msg_out->yiaddr.addr = 0; dhcp->msg_out->siaddr.addr = 0; dhcp->msg_out->giaddr.addr = 0; diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h index ebb3c9ab..dfa09157 100644 --- a/src/include/lwip/opt.h +++ b/src/include/lwip/opt.h @@ -542,6 +542,17 @@ #define LWIP_DHCP_AUTOIP_COOP 0 #endif +/** + * LWIP_DHCP_AUTOIP_COOP_TRIES: Set to the number of DHCP DISCOVER probes + * that should be sent before falling back on AUTOIP. This can be set + * as low as 1 to get an AutoIP address very quickly, but you should + * be prepared to handle a changing IP address when DHCP overrides + * AutoIP. + */ +#ifndef LWIP_DHCP_AUTOIP_COOP_TRIES +#define LWIP_DHCP_AUTOIP_COOP_TRIES 9 +#endif + /* ---------------------------------- ---------- SNMP options ----------