#include <rtl.h>
BOOL icmp_ping (
U8* remip, /* IP address of the remote host. */
void (*cbfunc)(U8 event) ); /* Function to call when the ping session ends. */
Description
The icmp_ping function starts the ICMP ping process on the
TCPnet system. This causes the ICMP client to send the ICMP Echo
request to remote ip address and waits for an ICMP Echo reply.
The argument remip points to an array of 4 bytes containing
the dotted-decimal notation of the IP address of the remote host to
ping to.
The argument cbfunc points to a function that the ICMP
client running on TCPnet calls when the ping session ends. The
cbfunc is an event callback function that uses the
event argument of the cbfunc function to signal one of
the following ICMP events:
Event
Description
ICMP_EVT_SUCCESS
Remote host responded to ping.
ICMP_EVT_TIMEOUT
Ping session has timed out, remote host did not respond.
The icmp_ping function is in the RL-TCPnet library. The
prototype is defined in rtl.h.
Return Value
The icmp_ping function returns __TRUE if the ICMP client
has been successfully started. Otherwise it returns __FALSE.
Example
static void ping_cback (U8 event);
void ping_host (void) {
U8 hostip[4] = {192,168,0,100};
if (icmp_ping (&hostip[0], ping_cback) == __TRUE) {
printf("Ping started.\n");
}
else {
printf("Ping not started, ICMP not ready or bad parameters.\n");
}
}
static void ping_cback (U8 event) {
switch (event) {
case ICMP_EVT_SUCCESS:
printf ("Remote host responded to ping.\n");
break;
case ICMP_EVT_TIMEOUT:
/* Timeout, try again. */
printf ("Ping timeout, no response.\n");
break;
}
}
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.