SatCat5
satcat5::ip::ProtoIcmp Class Referencefinal

Detailed Description

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").

Definition at line 79 of file ip_icmp.h.

#include <ip_icmp.h>

Inheritance diagram for satcat5::ip::ProtoIcmp:
[legend]
Collaboration diagram for satcat5::ip::ProtoIcmp:
[legend]

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::PingListenerm_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::Protocolm_next
 Linked list of Protocols.
 
unsigned m_trem
 
unsigned m_tnext
 

Member Function Documentation

◆ frame_rcvd()

void ProtoIcmp::frame_rcvd ( satcat5::io::LimitedRead src)
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:

  • Call m_iface->open_reply() to obtain a Writable object. (This also writes out any applicable frame headers.)
  • Write frame contents, then call write_finalize().

The child class MUST override this method.

Implements satcat5::net::Protocol.

Definition at line 191 of file ip_icmp.cc.

◆ send_error()

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.

◆ send_ping()

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.

◆ send_timereq()

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.

◆ set_log_cooldown()

void satcat5::ip::ProtoIcmp::set_log_cooldown ( unsigned  wait_msec)
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.

Definition at line 111 of file ip_icmp.h.


The documentation for this class was generated from the following files: