summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCYFS <[email protected]>2026-02-05 14:30:11 +0800
committerRbb666 <[email protected]>2026-02-05 17:08:37 +0800
commit25b6953501e7ec8eeb7e8c72d2b11e8e49dbecf7 (patch)
treea23b361801738f374a253e7371dde145ef34fd54
parent68da10625347cfe34fad8b73a78feffbe311d561 (diff)
[components][lwip]: fix ping timeout handling and support LWIP_SO_SNDRCVTIMEO_NONSTANDARD
-rw-r--r--components/net/lwip/lwip-1.4.1/src/apps/ping/ping.c9
-rw-r--r--components/net/lwip/lwip-2.0.3/src/apps/ping/ping.c9
-rw-r--r--components/net/lwip/lwip-2.1.2/src/apps/ping/ping.c9
3 files changed, 15 insertions, 12 deletions
diff --git a/components/net/lwip/lwip-1.4.1/src/apps/ping/ping.c b/components/net/lwip/lwip-1.4.1/src/apps/ping/ping.c
index 6251504f59..d2b1f805f7 100644
--- a/components/net/lwip/lwip-1.4.1/src/apps/ping/ping.c
+++ b/components/net/lwip/lwip-1.4.1/src/apps/ping/ping.c
@@ -135,11 +135,12 @@ int lwip_ping_recv(int s, int *ttl)
/* using the lwIP custom ping */
rt_err_t ping(char* target_name, rt_uint32_t times, rt_size_t size)
{
-#if LWIP_VERSION_MAJOR >= 2U
- struct timeval timeout = { PING_RCV_TIMEO / RT_TICK_PER_SECOND, PING_RCV_TIMEO % RT_TICK_PER_SECOND };
+
+#if LWIP_SO_SNDRCVTIMEO_NONSTANDARD
+ int timeout = (int)PING_RCV_TIMEO;
#else
- int timeout = PING_RCV_TIMEO * 1000UL / RT_TICK_PER_SECOND;
-#endif
+ struct timeval timeout = { PING_RCV_TIMEO / RT_TICK_PER_SECOND, PING_RCV_TIMEO % RT_TICK_PER_SECOND };
+#endif / * LWIP_SO_SNDRCVTIMEO_NONSTANDARD */
int s, ttl, recv_len;
ip_addr_t target_addr;
diff --git a/components/net/lwip/lwip-2.0.3/src/apps/ping/ping.c b/components/net/lwip/lwip-2.0.3/src/apps/ping/ping.c
index 989fb0507a..3039ecf14d 100644
--- a/components/net/lwip/lwip-2.0.3/src/apps/ping/ping.c
+++ b/components/net/lwip/lwip-2.0.3/src/apps/ping/ping.c
@@ -135,11 +135,12 @@ int lwip_ping_recv(int s, int *ttl)
/* using the lwIP custom ping */
rt_err_t ping(char* target_name, rt_uint32_t times, rt_size_t size)
{
-#if LWIP_VERSION_MAJOR >= 2U
- struct timeval timeout = { PING_RCV_TIMEO / RT_TICK_PER_SECOND, PING_RCV_TIMEO % RT_TICK_PER_SECOND };
+
+#if LWIP_SO_SNDRCVTIMEO_NONSTANDARD
+ int timeout = (int)PING_RCV_TIMEO;
#else
- int timeout = PING_RCV_TIMEO * 1000UL / RT_TICK_PER_SECOND;
-#endif
+ struct timeval timeout = { PING_RCV_TIMEO / RT_TICK_PER_SECOND, PING_RCV_TIMEO % RT_TICK_PER_SECOND };
+#endif / * LWIP_SO_SNDRCVTIMEO_NONSTANDARD */
int s, ttl, recv_len;
ip_addr_t target_addr;
diff --git a/components/net/lwip/lwip-2.1.2/src/apps/ping/ping.c b/components/net/lwip/lwip-2.1.2/src/apps/ping/ping.c
index 6251504f59..d2b1f805f7 100644
--- a/components/net/lwip/lwip-2.1.2/src/apps/ping/ping.c
+++ b/components/net/lwip/lwip-2.1.2/src/apps/ping/ping.c
@@ -135,11 +135,12 @@ int lwip_ping_recv(int s, int *ttl)
/* using the lwIP custom ping */
rt_err_t ping(char* target_name, rt_uint32_t times, rt_size_t size)
{
-#if LWIP_VERSION_MAJOR >= 2U
- struct timeval timeout = { PING_RCV_TIMEO / RT_TICK_PER_SECOND, PING_RCV_TIMEO % RT_TICK_PER_SECOND };
+
+#if LWIP_SO_SNDRCVTIMEO_NONSTANDARD
+ int timeout = (int)PING_RCV_TIMEO;
#else
- int timeout = PING_RCV_TIMEO * 1000UL / RT_TICK_PER_SECOND;
-#endif
+ struct timeval timeout = { PING_RCV_TIMEO / RT_TICK_PER_SECOND, PING_RCV_TIMEO % RT_TICK_PER_SECOND };
+#endif / * LWIP_SO_SNDRCVTIMEO_NONSTANDARD */
int s, ttl, recv_len;
ip_addr_t target_addr;