ICMP Echo Requests
The target is capable of receiving externally generated ICMP Echo Request messages and replying them accordingly.
Furthermore, the ICMP API function NetICMP_TxEchoReq allows a network application to send Echo Requests to a remote host. The following listing shows an example of an application function to send ping request:
Listing - NetApp_TxPing()
CPU_BOOLEAN NetApp_TxPing (NET_IP_ADDR_FAMILY ip_family, void *p_addr_remote, CPU_INT08U addr_len, void *p_data, CPU_INT16U data_len, CPU_INT32U timeout_ms, CPU_INT32U cnt) { CPU_INT32U ix; NET_ERR net_err; /* ---------------- VALIDATE IP FAMILY ---------------- */ if (ip_family == NET_IP_ADDR_FAMILY_IPv4) { #ifndef NET_IPv4_MODULE_EN return (DEF_FAIL); #endif if (addr_len != NET_IPv4_ADDR_SIZE) { return (DEF_FAIL); } } else if (ip_family == NET_IP_ADDR_FAMILY_IPv6) { #ifndef NET_IPv6_MODULE_EN return (DEF_FAIL); #endif if (addr_len != NET_IPv6_ADDR_SIZE) { return (DEF_FAIL); } } else { return (DEF_FAIL); } /* ----------------- SEND ECHO REQUEST ---------------- */ for (ix = 0 ; ix < cnt ; ix++) { (void)NetICMP_TxEchoReq(p_addr_remote, addr_len, timeout_ms, p_data, data_len, &net_err); } switch(net_err) { case NET_ICMP_ERR_NONE: break; case NET_ICMP_ERR_SIGNAL_TIMEOUT: case NET_ERR_IF_LINK_DOWN: default: return (DEF_FAIL); } return (DEF_OK); }