71 static u16_t ping_seq_num = 0;
72 static u32_t ping_time;
83 pingresp.ping_err = -1;
100 if (ping_seq_num == 0x7fff)
103 iecho->seqno =
htons(ping_seq_num);
106 for(i = 0; i < data_len; i++) {
126 ping_recv(
void *arg,
struct raw_pcb *pcb,
struct pbuf *p,
ip_addr_t *addr)
129 static u16_t seqno = 0;
140 if ((iecho->id ==
PING_ID) && (iecho->seqno ==
htons(ping_seq_num)) && iecho->type ==
ICMP_ER) {
144 if (iecho->seqno != seqno){
152 os_bzero(ipaddrstr,
sizeof(ipaddrstr));
156 source_ip.addr = iphdr->src.addr;
164 pingresp.resp_time = delay;
165 pingresp.seqno =
ntohs(iecho->seqno);
166 pingresp.ping_err = 0;
170 seqno = iecho->seqno;
197 ping_send(
struct raw_pcb *raw,
ip_addr_t *addr)
206 LWIP_ASSERT(
"ping_size <= 0xffff", ping_size <= 0xffff);
215 ping_prepare_echo(iecho, (
u16_t)ping_size);
217 raw_sendto(raw, p, addr);
224 ping_coarse_tmr(
void *arg)
236 ping_send(pingmsg->
ping_pcb, &ping_target);
245 os_printf(
"ping %d, timeout %d, total payload %d bytes, %d ms\n",
249 pingresp.total_count = pingmsg->
max_count;
252 pingresp.total_time = delay;
253 pingresp.ping_err = 0;
264 ping_raw_init(
struct ping_msg *pingmsg)
273 raw_recv(pingmsg->
ping_pcb, ping_recv, pingmsg);
278 ping_send(pingmsg->
ping_pcb, &ping_target);
290 if (pingmsg ==
NULL || ping_opt ==
NULL)
294 if (ping_opt->
count != 0)
306 return ping_raw_init(pingmsg);
312 if (ping_opt ==
NULL)
322 if (ping_opt ==
NULL)
#define PING_RESULT(ping_ok)
bool ping_regist_recv(struct ping_option *ping_opt, ping_recv_function ping_recv)
u16_t inet_chksum(void *dataptr, u16_t len) ICACHE_FLASH_ATTR
void(* ping_sent_function)(void *arg, void *pdata)
ping_recv_function recv_function
#define ip_addr_debug_print(debug, ipaddr)
struct ping_option * ping_opt
const ip_addr_t ip_addr_any ICACHE_RODATA_ATTR
#define ICACHE_FLASH_ATTR
ping_sent_function sent_function
static u32_t sys_now(void) ICACHE_FLASH_ATTR
uint32 system_get_time(void)
void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg) ICACHE_FLASH_ATTR
#define LWIP_DEBUGF(debug, message)
struct raw_pcb * ping_pcb
#define ICMPH_CODE_SET(hdr, c)
typedefPACK_STRUCT_END struct ip_addr ip_addr_t
char * ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen) ICACHE_FLASH_ATTR
void sys_untimeout(sys_timeout_handler handler, void *arg) ICACHE_FLASH_ATTR
u8_t pbuf_free(struct pbuf *p) ICACHE_FLASH_ATTR
u8_t pbuf_header(struct pbuf *p, s16_t header_size) ICACHE_FLASH_ATTR
void(* ping_recv_function)(void *arg, void *pdata)
#define LWIP_ASSERT(message, assertion)
#define DEFAULT_PING_MAX_COUNT
bool ping_start(struct ping_option *ping_opt)
bool ping_regist_sent(struct ping_option *ping_opt, ping_sent_function ping_sent)
#define LWIP_UNUSED_ARG(x)
struct pbuf * pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type) ICACHE_FLASH_ATTR
#define ICMPH_TYPE_SET(hdr, t)