Network Component
Version 7.19.0
MDK Middleware for IPv4 and IPv6 Networking
|
A Ping Client checks the reachability of a host on IP network. More...
Content | |
Enumerations | |
Ping Callback Events. | |
Typedefs | |
typedef void(* | netPing_cb_t) (netPing_Event event) |
Ping Event callback function. More... | |
Functions | |
netStatus | netPing_Echo (const NET_ADDR *addr, netPing_cb_t cb_func) |
Start ICMP ping process. [thread-safe]. More... | |
netStatus | netPing_EchoX (const char *target, uint32_t flags) |
Start ICMP ping process in blocking mode. [thread-safe]. More... | |
A Ping Client checks the reachability of a host on IP network.
The Ping Client is used to test the reachability of a network device on an IP network and to measure the round-trip time for messages sent from the host to a destination node. It operates by sending Internet Control Message Protocol (ICMP) Echo request packets to the target and waiting for an ICMP Echo reply.
void(* netPing_cb_t)(netPing_Event event) |
Ping Event callback function.
[in] | event | - Ping event as defined in netPing_Event. |
Is the type definition for the Ping callback function. Users must provide the function. The callback function uses the event argument to signal one of the following Ping events:
Event | Description |
---|---|
netPing_EventSuccess | Remote host responded to ping. |
netPing_EventTimeout | Ping session has timed out, remote host did not respond. |
Parameter for:
netStatus netPing_Echo | ( | const NET_ADDR * | addr, |
netPing_cb_t | cb_func | ||
) |
Start ICMP ping process. [thread-safe].
[in] | addr | structure containing IP address of remote host. |
[in] | cb_func | callback function to call, when ping session ends. |
The non-blocking function netPing_Echo starts the ping process on the Network Core. This causes the Ping client to send an echo request to the remote IP address. The result of the operation is provided with the callback function.
The argument addr is a pointer to the buffer containing the IP address of the remote host to be pinged.
The argument cb_func points to an event callback function called by the Ping client (running on Network Core) when the ping session ends. Refer to netPing_cb_t.
Possible netStatus return values:
Code Example
netStatus netPing_EchoX | ( | const char * | target, |
uint32_t | flags | ||
) |
Start ICMP ping process in blocking mode. [thread-safe].
[in] | target | remote hostname or absolute IP address. |
[in] | flags | ping process control flags. |
The blocking function netPing_EchoX starts the ping process on the Network Core and returns the result of the operation. This causes the Ping client to send an echo request to the remote IP address and wait for an echo response.
The argument target is a fully qualified domain name or an absolute IP address of the remote host that needs to be pinged. If target is a hostname, the ping client uses the DNS resolver to resolve the destination IP address.
The argument flags specify the IP version to be used for ping. The value of 0 for flags is the use default ping settings.
Flags | Description |
---|---|
NET_PING_IP4_ONLY | Force using IP version 4 only. |
NET_PING_IP6_ONLY | Force using IP version 6 only. |
Possible netStatus return values:
Code Example (absolute IP address)
Code Example (fully qualified domain name)