SatCat5
satcat5::eth::SwitchLogFormatter Class Reference

Detailed Description

Read binary packet logs to produce human-readable log messages.

Do not use this class in systems where log messages are relayed over the network, because this may create an infinite loop.

Definition at line 303 of file eth_sw_log.h.

#include <eth_sw_log.h>

Inheritance diagram for satcat5::eth::SwitchLogFormatter:
[legend]
Collaboration diagram for satcat5::eth::SwitchLogFormatter:
[legend]

Public Member Functions

 SwitchLogFormatter (satcat5::io::Readable *src, const char *lbl="PktLog")
 Bind this object to a stream of packet-logging data.
 
 SwitchLogFormatter (satcat5::eth::Dispatch *iface, satcat5::eth::MacType etype=satcat5::eth::ETYPE_SWITCH_LOG, const char *lbl="PktLog")
 Bind this object to an Ethernet interface.
 
 SwitchLogFormatter (satcat5::udp::Dispatch *iface, satcat5::udp::Port port=satcat5::udp::PORT_SWITCH_LOG, const char *lbl="PktLog")
 Bind this object to a UDP interface.
 
void log_event (const satcat5::eth::SwitchLogMessage &msg) override
 Implement the SwitchLogReader callback.
 
void set_polling_interval (unsigned msec)
 Set polling interval, in milliseconds. More...
 

Protected Member Functions

void data_rcvd (satcat5::io::Readable *src) override
 The data_rcvd() callback is polled whenever data is available. More...
 
void data_unlink (satcat5::io::Readable *src) override
 Unlink this EventListener from the designated source, because the designated Readable object is being destroyed. More...
 
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.
 
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

const char *const m_label
 
satcat5::io::Readablem_src
 
satcat5::net::Dispatch *const m_iface
 
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

◆ data_rcvd()

void SwitchLogReader::data_rcvd ( satcat5::io::Readable src)
overrideprotectedvirtualinherited

The data_rcvd() callback is polled whenever data is available.

A pointer is provided to assist handlers with multiple sources. Child objects of io::EventListener MUST override this method.

Implements satcat5::io::EventListener.

Definition at line 278 of file eth_sw_log.cc.

◆ data_unlink()

void SwitchLogReader::data_unlink ( satcat5::io::Readable src)
overrideprotectedvirtualinherited

Unlink this EventListener from the designated source, because the designated Readable object is being destroyed.

Child objects of io::EventListener MAY override this method if action is required.

Reimplemented from satcat5::io::EventListener.

Definition at line 286 of file eth_sw_log.cc.

◆ frame_rcvd()

void SwitchLogReader::frame_rcvd ( satcat5::io::LimitedRead src)
overrideprotectedvirtualinherited

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 288 of file eth_sw_log.cc.

◆ set_polling_interval()

void SwitchLogReader::set_polling_interval ( unsigned  msec)
inherited

Set polling interval, in milliseconds.

This method applies to buffered sources only. By default (interval = zero), log descriptors are read and processed immediately. To rate-limit outgoing messages, set the desired polling interval in milliseconds.

Definition at line 267 of file eth_sw_log.cc.


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