static void ping_send(struct raw_pcb *raw, ip_addr_t *addr) { struct pbuf *p; struct icmp_echo_hdr *iecho; p = pbuf_alloc(PBUF_IP,sizeof(struct icmp_echo_hdr),PBUF_RAM); if (!p) return; iecho = p->payload; ICMPH_TYPE_SET(iecho,ICMP_ECHO); iecho->chksum = 0; iecho->seqno = htons(seq_num); iecho->chksum = inet_chksum(iecho, p->len); raw_send_to(raw,p,addr); pbuf_free(p); seq_num++; }
/** * Send the raw IP packet to the address given by raw_connect() * * @param pcb the raw pcb which to send * @param p the ip payload to send * @param ipaddr the destination address of the whole IP packet * */ err_t raw_send(struct raw_pcb *pcb, struct pbuf *p) { return raw_send_to(pcb,p,&pcb->remote_ip); }