Provides lower-level access to the ICMP Echo Request infrastructure used by the hs.network.ping module. In general, you should not need to use this module directly unless you have specific requirements not met by the hs.network.ping module and the hs.network.ping
object methods.
This module is based heavily on Apple's SimplePing sample project which can be found at https://developer.apple.com/library/content/samplecode/SimplePing/Introduction/Intro.html.
When a callback function argument is specified as an ICMP table, the Lua table returned will contain the following key-value pairs:
checksum
- The ICMP packet checksum used to ensure data integrity.code
- ICMP Control Message Code. This should always be 0 unless the callback has received a "receivedUnexpectedPacket" message.identifier
- The ICMP packet identifier. This should match the results of hs.network.ping.echoRequest:identifier unless the callback has received a "receivedUnexpectedPacket" message.payload
- A string containing the ICMP payload for this packet. The default payload has been constructed to cause the ICMP packet to be exactly 64 bytes to match the convention for ICMP Echo Requests.sequenceNumber
- The ICMP Sequence Number for this packet.type
- ICMP Control Message Type. Unless the callback has received a "receivedUnexpectedPacket" message, this will be 0 (ICMPv4) or 129 (ICMPv6) for packets we receive and 8 (ICMPv4) or 128 (ICMPv6) for packets we send._raw
- A string containing the ICMP packet as raw data.In cases where the callback receives a "receivedUnexpectedPacket" message because the packet is corrupted or truncated, this table may only contain the _raw
field.
Signature | hs.network.ping.echoRequest.echoRequest(server) -> echoRequestObject |
---|---|
Type | Constructor |
Description | Creates a new ICMP Echo Request object for the server specified. |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/network/ping/libnetwork_ping.m line 229 |
Signature | hs.network.ping.echoRequest:acceptAddressFamily([family]) -> echoRequestObject | current value |
---|---|
Type | Method |
Description | Get or set the address family the echoRequestObject should communicate with. |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/network/ping/libnetwork_ping.m line 384 |
Signature | hs.network.ping.echoRequest:hostAddress() -> string | false | nil |
---|---|
Type | Method |
Description | Returns a string representation for the server's IP address, or a boolean if address resolution has not completed yet. |
Parameters |
|
Returns |
|
Source | extensions/network/ping/libnetwork_ping.m line 495 |
Signature | hs.network.ping.echoRequest:hostAddressFamily() -> string |
---|---|
Type | Method |
Description | Returns the host address family currently in use by this echoRequestObject. |
Parameters |
|
Returns |
|
Source | extensions/network/ping/libnetwork_ping.m line 560 |
Signature | hs.network.ping.echoRequest:hostName() -> string |
---|---|
Type | Method |
Description | Returns the name of the target host as provided to the echoRequestObject's constructor |
Parameters |
|
Returns |
|
Source | extensions/network/ping/libnetwork_ping.m line 325 |
Signature | hs.network.ping.echoRequest:identifier() -> integer |
---|---|
Type | Method |
Description | Returns the identifier number for the echoRequestObject. |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/network/ping/libnetwork_ping.m line 342 |
Signature | hs.network.ping.echoRequest:isRunning() -> boolean |
---|---|
Type | Method |
Description | Returns a boolean indicating whether or not this echoRequestObject is currently listening for ICMP Echo Replies. |
Parameters |
|
Returns |
|
Source | extensions/network/ping/libnetwork_ping.m line 476 |
Signature | hs.network.ping.echoRequest:nextSequenceNumber() -> integer |
---|---|
Type | Method |
Description | The sequence number that will be used for the next ICMP packet sent by this object. |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/network/ping/libnetwork_ping.m line 362 |
Signature | hs.network.ping.echoRequest:seeAllUnexpectedPackets([state]) -> boolean | echoRequestObject |
---|---|
Type | Method |
Description | Get or set whether or not the callback should receive all unexpected packets or only those which carry our identifier. |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/network/ping/libnetwork_ping.m line 595 |
Signature | hs.network.ping.echoRequest:sendPayload([payload]) -> echoRequestObject | false | nil |
---|---|
Type | Method |
Description | Sends a single ICMP Echo Request packet. |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/network/ping/libnetwork_ping.m line 522 |
Signature | hs.network.ping.echoRequest:setCallback(fn) -> echoRequestObject |
---|---|
Type | Method |
Description | Set or remove the object callback function |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/network/ping/libnetwork_ping.m line 253 |
Signature | hs.network.ping.echoRequest:start() -> echoRequestObject |
---|---|
Type | Method |
Description | Start the echoRequestObject by resolving the server's address and start listening for ICMP Echo Reply packets. |
Parameters |
|
Returns |
|
Source | extensions/network/ping/libnetwork_ping.m line 427 |
Signature | hs.network.ping.echoRequest:stop() -> echoRequestObject |
---|---|
Type | Method |
Description | Stop listening for ICMP Echo Reply packets with this object. |
Parameters |
|
Returns |
|
Source | extensions/network/ping/libnetwork_ping.m line 452 |