File tree Expand file tree Collapse file tree 3 files changed +27
-12
lines changed
Expand file tree Collapse file tree 3 files changed +27
-12
lines changed Original file line number Diff line number Diff line change @@ -135,11 +135,16 @@ int lwip_ping_recv(int s, int *ttl)
135135/* using the lwIP custom ping */
136136rt_err_t ping (char * target_name , rt_uint32_t times , rt_size_t size )
137137{
138- #if LWIP_VERSION_MAJOR >= 2U
139- struct timeval timeout = { PING_RCV_TIMEO / RT_TICK_PER_SECOND , PING_RCV_TIMEO % RT_TICK_PER_SECOND };
138+
139+ #if LWIP_VERSION_MAJOR == 1U /* v1.x */
140+ int timeout = PING_RCV_TIMEO ;
141+ #else /* >= v2.x */
142+ #if LWIP_SO_SNDRCVTIMEO_NONSTANDARD
143+ int timeout = (int )PING_RCV_TIMEO ;
140144#else
141- int timeout = PING_RCV_TIMEO * 1000UL / RT_TICK_PER_SECOND ;
142- #endif
145+ struct timeval timeout = { PING_RCV_TIMEO / RT_TICK_PER_SECOND , PING_RCV_TIMEO % RT_TICK_PER_SECOND };
146+ #endif / * LWIP_SO_SNDRCVTIMEO_NONSTANDARD * /
147+ #endif /* LWIP_VERSION_MAJOR */
143148
144149 int s , ttl , recv_len ;
145150 ip_addr_t target_addr ;
Original file line number Diff line number Diff line change @@ -135,11 +135,16 @@ int lwip_ping_recv(int s, int *ttl)
135135/* using the lwIP custom ping */
136136rt_err_t ping (char * target_name , rt_uint32_t times , rt_size_t size )
137137{
138- #if LWIP_VERSION_MAJOR >= 2U
139- struct timeval timeout = { PING_RCV_TIMEO / RT_TICK_PER_SECOND , PING_RCV_TIMEO % RT_TICK_PER_SECOND };
138+
139+ #if LWIP_VERSION_MAJOR == 1U /* v1.x */
140+ int timeout = PING_RCV_TIMEO ;
141+ #else /* >= v2.x */
142+ #if LWIP_SO_SNDRCVTIMEO_NONSTANDARD
143+ int timeout = (int )PING_RCV_TIMEO ;
140144#else
141- int timeout = PING_RCV_TIMEO * 1000UL / RT_TICK_PER_SECOND ;
142- #endif
145+ struct timeval timeout = { PING_RCV_TIMEO / RT_TICK_PER_SECOND , PING_RCV_TIMEO % RT_TICK_PER_SECOND };
146+ #endif / * LWIP_SO_SNDRCVTIMEO_NONSTANDARD * /
147+ #endif /* LWIP_VERSION_MAJOR */
143148
144149 int s , ttl , recv_len ;
145150 ip_addr_t target_addr ;
Original file line number Diff line number Diff line change @@ -135,11 +135,16 @@ int lwip_ping_recv(int s, int *ttl)
135135/* using the lwIP custom ping */
136136rt_err_t ping (char * target_name , rt_uint32_t times , rt_size_t size )
137137{
138- #if LWIP_VERSION_MAJOR >= 2U
139- struct timeval timeout = { PING_RCV_TIMEO / RT_TICK_PER_SECOND , PING_RCV_TIMEO % RT_TICK_PER_SECOND };
138+
139+ #if LWIP_VERSION_MAJOR == 1U /* v1.x */
140+ int timeout = PING_RCV_TIMEO ;
141+ #else /* >= v2.x */
142+ #if LWIP_SO_SNDRCVTIMEO_NONSTANDARD
143+ int timeout = (int )PING_RCV_TIMEO ;
140144#else
141- int timeout = PING_RCV_TIMEO * 1000UL / RT_TICK_PER_SECOND ;
142- #endif
145+ struct timeval timeout = { PING_RCV_TIMEO / RT_TICK_PER_SECOND , PING_RCV_TIMEO % RT_TICK_PER_SECOND };
146+ #endif / * LWIP_SO_SNDRCVTIMEO_NONSTANDARD * /
147+ #endif /* LWIP_VERSION_MAJOR */
143148
144149 int s , ttl , recv_len ;
145150 ip_addr_t target_addr ;
You can’t perform that action at this time.
0 commit comments