|
SatCat5
|
Protocol handler for the Internet Control Message Protocol (ICMP).
ICMP provides various auxiliary services to support IPv4 networks, ranging from "ping" (ICMP Echo/Reply) to error reporting (e.g., "Destination host unreachable").
#include <ip_icmp.h>
Public Member Functions | |
| ProtoIcmp (satcat5::ip::Dispatch *iface) | |
| Link this handler to an IPv4 network interface. | |
| bool | send_error (u16 type, satcat5::io::Readable *src, uint32_t arg=0) |
| Send a specific error message. More... | |
| bool | send_ping (satcat5::ip::Address &dst) |
| Initiate a ping (Echo request = Type 8.0). More... | |
| bool | send_timereq (satcat5::ip::Address &dst) |
| Initiate a timestamp request. More... | |
| void | set_log_cooldown (unsigned wait_msec) |
| Adjust the rate-limit for ICMP error logging. More... | |
| void | add (satcat5::ip::PingListener *cb) |
| Add/remove callback handlers for Ping responses. | |
| void | remove (satcat5::ip::PingListener *cb) |
| Add/remove callback handlers for Ping responses. | |
Protected Member Functions | |
| void | frame_rcvd (satcat5::io::LimitedRead &src) override |
| Dispatch calls frame_rcvd(...) for each incoming frame with with a matching net::Type value. More... | |
| void | timer_event () override |
| Child class MUST override this method. | |
| bool | write_icmp (satcat5::io::Writeable *wr, unsigned wcount, u16 *data) |
| void | timer_once (unsigned msec) |
| Configure a one-time notification after X milliseconds. | |
| void | timer_every (unsigned msec) |
| Configure a repeating notification every X milliseconds. | |
| void | timer_stop () |
| Stop all future notifications. | |
| unsigned | timer_interval () const |
| Accessor for recurring timer interval, if one is set. | |
| unsigned | timer_remaining () const |
| Accessor for time to next event, if one is set. | |
Static Protected Member Functions | |
| static unsigned | count_timer () |
| Count all objects of this type, including idle timers. | |
Protected Attributes | |
| satcat5::ip::Dispatch *const | m_iface |
| satcat5::util::List< satcat5::ip::PingListener > | m_listeners |
| unsigned | m_wait_msec |
| satcat5::net::Type | m_filter |
| Incoming packet filter. | |
Private Member Functions | |
| void | query (unsigned elapsed_msec) |
Private Attributes | |
| satcat5::net::Protocol * | m_next |
| Linked list of Protocols. | |
| unsigned | m_trem |
| unsigned | m_tnext |
|
overrideprotectedvirtual |
Dispatch calls frame_rcvd(...) for each incoming frame with with a matching net::Type value.
The child class SHOULD read the frame contents from the provided "src" object, which is only valid until the function returns.
To send a reply:
The child class MUST override this method.
Implements satcat5::net::Protocol.
Definition at line 191 of file ip_icmp.cc.
| bool ProtoIcmp::send_error | ( | u16 | type, |
| satcat5::io::Readable * | src, | ||
| uint32_t | arg = 0 |
||
| ) |
Send a specific error message.
This method is used to send various error-messages, such as "Destination unreachable" (Type 3.x, arg = unused) or "Redirect" (Type 5.x, arg = new address). Note: Readable "src" should contain the first 8 bytes after the IP header of the frame that triggered this error. Returns true if frame sent successfully, false otherwise.
Definition at line 120 of file ip_icmp.cc.
| bool ProtoIcmp::send_ping | ( | satcat5::ip::Address & | dst | ) |
Initiate a ping (Echo request = Type 8.0).
Returns true if frame sent successfully, false otherwise.
Definition at line 151 of file ip_icmp.cc.
| bool ProtoIcmp::send_timereq | ( | satcat5::ip::Address & | dst | ) |
Initiate a timestamp request.
Returns true if frame sent successfully, false otherwise.
Definition at line 168 of file ip_icmp.cc.
|
inline |
Adjust the rate-limit for ICMP error logging.
Incoming ICMP errors (e.g., "Destination Unreachable...") are written to the SatCat5 log. If log message forwarding fails with another ICMP error, this can produce an infinite loop. Prevent this with a rate limit (SATCAT5_ICMP_LOG_COOLDOWN) or override at runtime. A value of zero disables this rate-limit.