Skip to content

mbed-os/LwIP changes and fixes in auto-IP for Bonjour Conformance Test #11339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion features/lwipstack/lwip/src/core/ipv4/lwip_autoip.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
static err_t autoip_arp_announce(struct netif *netif);
static void autoip_start_probing(struct netif *netif);

/* static variables */
static u8_t is_autoip_allocated = 0; /* Set when 'struct autoip' is allocated dynamically and assigned to 'netif' */

/**
* @ingroup autoip
* Set a statically allocated struct autoip to work with.
Expand Down Expand Up @@ -278,6 +281,7 @@ autoip_start(struct netif *netif)
("autoip_start(): could not allocate autoip\n"));
return ERR_MEM;
}
is_autoip_allocated = 1;
/* store this AutoIP client in the netif */
netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP, autoip);
LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE, ("autoip_start(): allocated autoip"));
Expand Down Expand Up @@ -318,7 +322,7 @@ autoip_start_probing(struct netif *netif)
* acquiring and probing address
* compliant to RFC 3927 Section 2.2.1
*/
if (autoip->tried_llipaddr > MAX_CONFLICTS) {
if (autoip->tried_llipaddr >= MAX_CONFLICTS) {
autoip->ttw = RATE_LIMIT_INTERVAL * AUTOIP_TICKS_PER_SECOND;
}
}
Expand Down Expand Up @@ -353,6 +357,16 @@ autoip_stop(struct netif *netif)
LWIP_ASSERT_CORE_LOCKED();
if (autoip != NULL) {
autoip->state = AUTOIP_STATE_OFF;
/* If autoip is dynamically allocated in start, free autoip structure and reset autoip index in netif */
if (is_autoip_allocated) {
/* Reset the auto IP index and then free autoip structure */
netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP, NULL);
mem_free(autoip);
autoip = NULL;
is_autoip_allocated = 0;
} else {
autoip->tried_llipaddr = 0;
}
if (ip4_addr_islinklocal(netif_ip4_addr(netif))) {
netif_set_addr(netif, IP4_ADDR_ANY4, IP4_ADDR_ANY4, IP4_ADDR_ANY4);
}
Expand Down
6 changes: 6 additions & 0 deletions features/lwipstack/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@
#define BOTH_ADDR_TIMEOUT 0
#endif

// Configurable DHCP timeout. DHCP timeout can be configured for specific usecase requirement.
#ifdef MBED_CONF_LWIP_DHCP_TIMEOUT
#define DHCP_TIMEOUT (MBED_CONF_LWIP_DHCP_TIMEOUT)
#else
#define DHCP_TIMEOUT 60
#endif

#define LINK_TIMEOUT 60

#define PREF_IPV4 1
Expand Down