summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Gatti <a.gatti@frob.it>2023-10-08 15:41:20 +0200
committerDamien George <damien@micropython.org>2023-10-31 11:54:25 +1100
commit1cf3085c575095f7f027171759f112033b4060af (patch)
tree322368923f0d4eeace7aac80c7de3b9a5915cba2
parentc146017f8ac9930bd1ae7ce6d8064f3681ba2feb (diff)
esp32/network_ppp: Allow building with IPv6 disabled.
PPP code assumes that IPv6 support is enabled. Whilst this is the default, certain applications may want to disable IPv6 support if not needed (or to reduce code size). This makes the code build with CONFIG_LWIP_IPV6 disabled, reducing code by about 30k in that case. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
-rw-r--r--ports/esp32/network_ppp.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ports/esp32/network_ppp.c b/ports/esp32/network_ppp.c
index ea0dd1706..d5f6715ea 100644
--- a/ports/esp32/network_ppp.c
+++ b/ports/esp32/network_ppp.c
@@ -65,7 +65,11 @@ static void ppp_status_cb(ppp_pcb *pcb, int err_code, void *ctx) {
switch (err_code) {
case PPPERR_NONE:
+ #if CONFIG_LWIP_IPV6
self->connected = (pppif->ip_addr.u_addr.ip4.addr != 0);
+ #else
+ self->connected = (pppif->ip_addr.addr != 0);
+ #endif // CONFIG_LWIP_IPV6
break;
case PPPERR_USER:
self->clean_close = true;
@@ -250,7 +254,11 @@ STATIC mp_obj_t ppp_ifconfig(size_t n_args, const mp_obj_t *args) {
ip_addr_t dns;
mp_obj_t *items;
mp_obj_get_array_fixed_n(args[1], 4, &items);
+ #if CONFIG_LWIP_IPV6
netutils_parse_ipv4_addr(items[3], (uint8_t *)&dns.u_addr.ip4, NETUTILS_BIG);
+ #else
+ netutils_parse_ipv4_addr(items[3], (uint8_t *)&dns, NETUTILS_BIG);
+ #endif // CONFIG_LWIP_IPV6
dns_setserver(0, &dns);
return mp_const_none;
}