SatCat5
satcat5::eth::SwitchLogToPort Class Reference

Detailed Description

Forward binary packet logs to a network interface.

When used with a software SwitchPort, this class accesses the egress buffer directly, bypassing the switch logic and the normal IP/UDP stack. This avoids creating log messages about forwarded log messages.

When used with a hardware port, duplicates are unavoidable. However, consolidating consecutive messages into a single packet reduces the impact of such overhead.

The recipient can use eth::Socket to receive log packets, then decode the contents using any SwitchLogReader.

Definition at line 342 of file eth_sw_log.h.

#include <eth_sw_log.h>

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

Public Member Functions

 SwitchLogToPort (satcat5::io::Readable *src, satcat5::eth::SwitchPort *dst, satcat5::udp::Dispatch *iface)
 Bind this object to a software egress port. More...
 
 SwitchLogToPort (satcat5::io::Readable *src, satcat5::io::Writeable *dst, satcat5::udp::Dispatch *iface)
 Bind this object to a hardware egress port. More...
 
void connect (const satcat5::eth::MacAddr &addr, const satcat5::eth::MacType &type=satcat5::eth::ETYPE_SWITCH_LOG, const satcat5::eth::VlanTag &vtag=satcat5::eth::VTAG_NONE)
 Connect to a designated raw-Ethernet address.
 
void connect (const satcat5::udp::Addr &addr, const satcat5::udp::Port &port=satcat5::udp::PORT_SWITCH_LOG, const satcat5::eth::VlanTag &vtag=satcat5::eth::VTAG_NONE)
 Connect to a designated IP/UDP address.
 
void close ()
 Close the connection and stop log forwarding.
 
bool ready () const
 Is this connection currently active?
 
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

satcat5::io::MultiWriterBypass m_dst_port
 
satcat5::io::Writeable *const m_dst_raw
 
satcat5::eth::Address m_eth
 
satcat5::udp::Address m_udp
 
bool m_first
 
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
 

Constructor & Destructor Documentation

◆ SwitchLogToPort() [1/2]

SwitchLogToPort::SwitchLogToPort ( satcat5::io::Readable src,
satcat5::eth::SwitchPort dst,
satcat5::udp::Dispatch iface 
)

Bind this object to a software egress port.

Call connect to start forwarding log packets.

Definition at line 320 of file eth_sw_log.cc.

◆ SwitchLogToPort() [2/2]

SwitchLogToPort::SwitchLogToPort ( satcat5::io::Readable src,
satcat5::io::Writeable dst,
satcat5::udp::Dispatch iface 
)

Bind this object to a hardware egress port.

Call connect to start forwarding log packets.

Definition at line 334 of file eth_sw_log.cc.

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: