lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [PATCH] ping: add destroy function


From: Maxim Uvarov
Subject: [lwip-devel] [PATCH] ping: add destroy function
Date: Fri, 15 Sep 2023 20:46:43 +0600

ping in raw mode does some set up and sets timeout, but clean
up procedure is missing. That is needed for case if PING_RESULT() macro
is used for application exit.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 contrib/apps/ping/ping.c | 16 ++++++++++++++++
 contrib/apps/ping/ping.h |  1 +
 2 files changed, 17 insertions(+)

diff --git a/contrib/apps/ping/ping.c b/contrib/apps/ping/ping.c
index 143fb83e..6d2bb8f9 100644
--- a/contrib/apps/ping/ping.c
+++ b/contrib/apps/ping/ping.c
@@ -393,4 +393,20 @@ ping_init(const ip_addr_t* ping_addr)
 #endif /* PING_USE_SOCKETS */
 }
 
+static void
+ping_raw_destroy(void)
+{
+ sys_untimeout(ping_timeout, ping_pcb);
+ raw_remove(ping_pcb);
+ ping_pcb = NULL;
+}
+
+void ping_destroy(void)
+{
+#if !PING_USE_SOCKETS
+ ping_raw_destroy();
+#endif /* !PING_USE_SOCKETS */
+ ping_target = NULL;
+}
+
 #endif /* LWIP_RAW */
diff --git a/contrib/apps/ping/ping.h b/contrib/apps/ping/ping.h
index 1f21c7b0..ed7f1746 100644
--- a/contrib/apps/ping/ping.h
+++ b/contrib/apps/ping/ping.h
@@ -11,6 +11,7 @@
 #endif
 
 void ping_init(const ip_addr_t* ping_addr);
+void ping_destroy(void);
 
 #if !PING_USE_SOCKETS
 void ping_send_now(void);
-- 
2.41.0.478.gee48e70a82




reply via email to

[Prev in Thread] Current Thread [Next in Thread]