summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extmod/lwip-include/lwipopts_common.h3
-rw-r--r--extmod/modnetwork.h3
-rw-r--r--extmod/network_lwip.c13
3 files changed, 19 insertions, 0 deletions
diff --git a/extmod/lwip-include/lwipopts_common.h b/extmod/lwip-include/lwipopts_common.h
index 3e4230909..8cb1acfe2 100644
--- a/extmod/lwip-include/lwipopts_common.h
+++ b/extmod/lwip-include/lwipopts_common.h
@@ -28,6 +28,9 @@
#include "py/mpconfig.h"
+// This is needed to access `next_timeout` via `sys_timeouts_get_next_timeout()`.
+#define LWIP_TESTMODE 1
+
// This sys-arch protection is not needed.
// Ports either protect lwIP code with flags, or run it at PendSV priority.
#define SYS_ARCH_DECL_PROTECT(lev) do { } while (0)
diff --git a/extmod/modnetwork.h b/extmod/modnetwork.h
index d16329f07..754f6e124 100644
--- a/extmod/modnetwork.h
+++ b/extmod/modnetwork.h
@@ -82,6 +82,9 @@ extern const struct _mp_obj_type_t mp_network_ppp_lwip_type;
#endif
struct netif;
+
+void sys_untimeout_all_with_arg(void *arg);
+
void mod_network_lwip_init(void);
void mod_network_lwip_poll_wrapper(uint32_t ticks_ms);
mp_obj_t mod_network_nic_ifconfig(struct netif *netif, size_t n_args, const mp_obj_t *args);
diff --git a/extmod/network_lwip.c b/extmod/network_lwip.c
index 71dc295e1..9cfab6ef4 100644
--- a/extmod/network_lwip.c
+++ b/extmod/network_lwip.c
@@ -52,6 +52,19 @@ int mp_mod_network_prefer_dns_use_ip_version = 4;
// Implementations of network methods that can be used by any interface.
+// This follows sys_untimeout but removes all timeouts with the given argument.
+void sys_untimeout_all_with_arg(void *arg) {
+ for (struct sys_timeo **t = sys_timeouts_get_next_timeout(); *t != NULL;) {
+ if ((*t)->arg == arg) {
+ struct sys_timeo *next = (*t)->next;
+ memp_free(MEMP_SYS_TIMEOUT, *t);
+ *t = next;
+ } else {
+ t = &(*t)->next;
+ }
+ }
+}
+
// This function provides the implementation of nic.ifconfig, is deprecated and will be removed.
// Use network.ipconfig and nic.ipconfig instead.
mp_obj_t mod_network_nic_ifconfig(struct netif *netif, size_t n_args, const mp_obj_t *args) {