1
1
#include " CNetIf.h"
2
2
#include < functional>
3
+ #include < stdlib.h>
3
4
#include " lwip/include/lwip/raw.h"
4
5
#include " lwip/include/lwip/icmp.h"
5
6
#include " lwip/include/lwip/ip_addr.h"
@@ -23,7 +24,9 @@ static u8_t icmp_receive_callback(void *arg, struct raw_pcb *pcb, struct pbuf *p
23
24
struct icmp_echo_hdr *iecho;
24
25
(void )(pcb);
25
26
(void )(addr);
26
- LWIP_ASSERT (" p != NULL" , p != NULL );
27
+ if (p == NULL ) {
28
+ return 0 ; /* don't consume the packet */
29
+ }
27
30
28
31
recv_callback_data* request = (recv_callback_data*)arg;
29
32
if ((p->tot_len < (PBUF_IP_HLEN + sizeof (struct icmp_echo_hdr ))) ||
@@ -164,7 +167,8 @@ int CLwipIf::ping(IPAddress ip, uint8_t ttl)
164
167
165
168
/* initialize callback data for a new request */
166
169
memset (&requestCbkData, 0 , sizeof (recv_callback_data));
167
- requestCbkData.seqNum = (uint16_t )random (0xffff );
170
+ srand (millis ());
171
+ requestCbkData.seqNum = (uint16_t )rand ()%65535 ;
168
172
169
173
/* Create a raw socket */
170
174
struct raw_pcb * s = raw_new (IP_PROTO_ICMP);
0 commit comments