Skip to content

Commit ae8c74e

Browse files
committed
All LWIP_DNS and LWIP_DHCP to allow lightweight lwip stack
Also add MBED_CONF_LWIP_DNS and MBED_CONF_LWIP_DHCP
1 parent 6f8a424 commit ae8c74e

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

features/FEATURE_LWIP/lwip-interface/lwip_stack.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ static void mbed_lwip_socket_callback(struct netconn *nc, enum netconn_evt eh, u
103103

104104
/* TCP/IP and Network Interface Initialisation */
105105
static struct netif lwip_netif;
106+
#if LWIP_DHCP
106107
static bool lwip_dhcp = false;
108+
#endif
107109
static char lwip_mac_address[NSAPI_MAC_SIZE];
108110

109111
#if !LWIP_IPV4 || !LWIP_IPV6
@@ -420,6 +422,12 @@ nsapi_error_t mbed_lwip_bringup(bool dhcp, const char *ip, const char *netmask,
420422
return NSAPI_ERROR_PARAMETER;
421423
}
422424

425+
#if !LWIP_DHCP
426+
if (dhcp) {
427+
return NSAPI_ERROR_PARAMETER;
428+
}
429+
#endif
430+
423431
if(mbed_lwip_init(NULL) != NSAPI_ERROR_OK) {
424432
return NSAPI_ERROR_DEVICE_ERROR;
425433
}
@@ -477,7 +485,7 @@ nsapi_error_t mbed_lwip_bringup(bool dhcp, const char *ip, const char *netmask,
477485

478486
netif_set_up(&lwip_netif);
479487

480-
#if LWIP_IPV4
488+
#if LWIP_IPV4 && LWIP_DHCP
481489
// Connect to the network
482490
lwip_dhcp = dhcp;
483491

@@ -529,7 +537,7 @@ nsapi_error_t mbed_lwip_bringdown(void)
529537
return NSAPI_ERROR_PARAMETER;
530538
}
531539

532-
#if LWIP_IPV4
540+
#if LWIP_IPV4 && LWIP_DNS
533541
// Disconnect from the network
534542
if (lwip_dhcp) {
535543
dhcp_release(&lwip_netif);
@@ -576,6 +584,7 @@ static nsapi_error_t mbed_lwip_err_remap(err_t err) {
576584
}
577585
}
578586

587+
#if LWIP_DNS
579588
/* LWIP network stack implementation */
580589
static nsapi_error_t mbed_lwip_gethostbyname(nsapi_stack_t *stack, const char *host, nsapi_addr_t *addr, nsapi_version_t version)
581590
{
@@ -617,6 +626,7 @@ static nsapi_error_t mbed_lwip_gethostbyname(nsapi_stack_t *stack, const char *h
617626

618627
return 0;
619628
}
629+
#endif
620630

621631
static nsapi_error_t mbed_lwip_socket_open(nsapi_stack_t *stack, nsapi_socket_t *handle, nsapi_protocol_t proto)
622632
{
@@ -885,7 +895,9 @@ static void mbed_lwip_socket_attach(nsapi_stack_t *stack, nsapi_socket_t handle,
885895

886896
/* LWIP network stack */
887897
const nsapi_stack_api_t lwip_stack_api = {
898+
#if LWIP_DNS
888899
.gethostbyname = mbed_lwip_gethostbyname,
900+
#endif
889901
.socket_open = mbed_lwip_socket_open,
890902
.socket_close = mbed_lwip_socket_close,
891903
.socket_bind = mbed_lwip_socket_bind,

features/FEATURE_LWIP/lwip-interface/lwipopts.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,18 @@
157157
#define TCP_QUEUE_OOSEQ 0
158158
#define TCP_OVERSIZE 0
159159

160+
#ifndef MBED_CONF_LWIP_DHCP
160161
#define LWIP_DHCP LWIP_IPV4
162+
#else
163+
#define LWIP_DHCP MBED_CONF_LWIP_DHCP
164+
#endif
165+
166+
#ifndef MBED_CONF_LWIP_DNS
161167
#define LWIP_DNS 1
168+
#else
169+
#define LWIP_DNS MBED_CONF_LWIP_DNS
170+
#endif
171+
162172
#define LWIP_SOCKET 0
163173

164174
#define SO_REUSE 1

0 commit comments

Comments
 (0)