Skip to content

Commit 5636fd9

Browse files
committed
Correct lwIP connection/dhcp flags
Fix "connect twice" GreenTea test
1 parent ca23d83 commit 5636fd9

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

features/FEATURE_LWIP/lwip-interface/LWIPInterface.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ char *LWIP::Interface::get_gateway(char *buf, nsapi_size_t buflen)
230230

231231
LWIP::Interface::Interface() :
232232
hw(NULL), has_addr_state(0),
233-
connected(false), dhcp(false), ppp(false)
233+
connected(false), dhcp_started(false), ppp(false)
234234
{
235235
memset(&netif, 0, sizeof netif);
236236

@@ -271,7 +271,6 @@ nsapi_error_t LWIP::add_ethernet_interface(EMAC &emac, bool default_if, OnboardN
271271
return NSAPI_ERROR_NO_MEMORY;
272272
}
273273
interface->emac = &emac;
274-
interface->dhcp = true;
275274
interface->ppp = false;
276275

277276
#if (MBED_MAC_ADDRESS_SUM != MBED_MAC_ADDR_INTERFACE)
@@ -328,7 +327,6 @@ nsapi_error_t LWIP::_add_ppp_interface(void *hw, bool default_if, LWIP::Interfac
328327
return NSAPI_ERROR_NO_MEMORY;
329328
}
330329
interface->hw = hw;
331-
interface->dhcp = true;
332330
interface->ppp = true;
333331

334332
ret = ppp_lwip_if_init(hw, &interface->netif);
@@ -427,13 +425,12 @@ nsapi_error_t LWIP::Interface::bringup(bool dhcp, const char *ip, const char *ne
427425
#if LWIP_DHCP
428426
if (stack != IPV6_STACK) {
429427
// Connect to the network
430-
dhcp = dhcp;
431-
432428
if (dhcp) {
433429
err_t err = dhcp_start(&netif);
434430
if (err) {
435431
return NSAPI_ERROR_DHCP_FAILURE;
436432
}
433+
dhcp_started = true;
437434
}
438435
}
439436
#endif
@@ -446,8 +443,8 @@ nsapi_error_t LWIP::Interface::bringup(bool dhcp, const char *ip, const char *ne
446443
}
447444
return NSAPI_ERROR_DHCP_FAILURE;
448445
}
449-
connected = true;
450446
}
447+
connected = true;
451448

452449
#if PREF_ADDR_TIMEOUT
453450
if (stack != IPV4_STACK && stack != IPV6_STACK) {
@@ -482,10 +479,10 @@ nsapi_error_t LWIP::Interface::bringdown()
482479

483480
#if LWIP_DHCP
484481
// Disconnect from the network
485-
if (dhcp) {
482+
if (dhcp_started) {
486483
dhcp_release(&netif);
487484
dhcp_stop(&netif);
488-
dhcp = false;
485+
dhcp_started = false;
489486
}
490487
#endif
491488

features/FEATURE_LWIP/lwip-interface/LWIPStack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class LWIP : public OnboardNetworkStack, private mbed::NonCopyable<LWIP> {
139139
#endif
140140
char has_addr_state;
141141
bool connected;
142-
bool dhcp;
142+
bool dhcp_started;
143143
bool ppp;
144144
struct netif netif;
145145
};

0 commit comments

Comments
 (0)