64 #include <satcat5/eth_address.h>
67 #include <satcat5/pkt_buffer.h>
69 #include <satcat5/udp_core.h>
99 static constexpr
unsigned
202 template <
unsigned SIZE = satcat5::eth::PMASK_SIZE>
220 : m_dst(dst), m_skip_drop(0), m_skip_keep(0) {}
238 template <
unsigned NPKT>
247 { m_buffer.
clear(); }
251 {
return &m_writer; }
308 const char* lbl =
"PktLog");
314 const char* lbl =
"PktLog");
320 const char* lbl =
"PktLog");
326 const char*
const m_label;
ConfigBus core definitions.
Pointer-like wrapper for one or more ConfigBus registers.
Send packets to a specific Ethernet address.
bool ready() const override
Is this address object ready for use? Child MUST override this method.
void close() override
Close any open connections and revert to idle.
Implemention of "net::Dispatch" for Ethernet frames.
Combine a SwitchLogWriter with a built-in output buffer.
void clear()
Flush contents of the internal buffer.
SwitchLogBuffer()
Create and link the writer and buffer objects.
SwitchLogHandler * writer()
Return the inner object for passing to SwitchCore::add_log().
Define the API for packet-logging callbacks from eth::SwitchCore.
Poll a hardware switch or router for log data.
void timer_event() override
Child class MUST override this method.
SwitchLogHardware(satcat5::eth::SwitchLogHandler *dst, satcat5::cfg::Register src)
Link this object to a log-writer and a data source.
Read packet-logs from an input stream or network interface.
virtual void log_event(const satcat5::eth::SwitchLogMessage &msg)=0
The child class MUST override this method.
void set_polling_interval(unsigned msec)
Set polling interval, in milliseconds.
void frame_rcvd(satcat5::io::LimitedRead &src) override
Dispatch calls frame_rcvd(...) for each incoming frame with with a matching net::Type value.
void data_unlink(satcat5::io::Readable *src) override
Unlink this EventListener from the designated source, because the designated Readable object is being...
void data_rcvd(satcat5::io::Readable *src) override
The data_rcvd() callback is polled whenever data is available.
void timer_event() override
Child class MUST override this method.
SwitchLogReader(satcat5::io::Readable *src)
Constructor for buffered mode.
Record packet statistics based on switch log events.
TrafficStats get_port(unsigned idx)
Read most recent statistics for the Nth port.
const unsigned m_size
Buffer size.
TrafficStats *const m_stats
Working counters.
SwitchLogStats(TrafficStats *buff, unsigned size)
Constructor accepts a pointer to the working buffer.
void log_packet(const satcat5::eth::SwitchLogMessage &msg) override
Process each packet event.
Static allocation wrapper for eth::SwitchLogStats.
Forward binary packet logs to a network interface.
void close()
Close the connection and stop log forwarding.
SwitchLogToPort(satcat5::io::Readable *src, satcat5::eth::SwitchPort *dst, satcat5::udp::Dispatch *iface)
Bind this object to a software egress port.
bool ready() const
Is this connection currently active?
void log_event(const satcat5::eth::SwitchLogMessage &msg) override
Implement the SwitchLogReader callback.
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.
Record rate-limited packet-logs for a switch or router.
void timer_event() override
Child class MUST override this method.
SwitchLogWriter(satcat5::io::Writeable *dst)
Link this object to a Writeable destination.
void log_packet(const satcat5::eth::SwitchLogMessage &msg) override
Process each packet event.
Generic packetized I/O interface for use with SwitchCore.
Event-handler interface for newly received data.
Limited read of next N bytes.
MultiWriter adapter for bypass mode.
void clear()
Reset buffer contents.
Abstract API for reading byte-streams and packets.
Wrapper class for forwarding reads to another object.
constexpr ReadableRedirect(satcat5::io::Readable *src)
Constructor and destructor should only be called by the child.
Abstract API for writing byte-streams and packets.
Internal buffer used by the Log class.
The "Dispatch" is a generic interface that knows how to read a designated protocol layer and sort inc...
A net::Protocol is the counterpart to net::Dispatch that handles a particular data stream,...
Timer objects are polled after a fixed delay or at a regular interval.
Implementation of "net::Address" for UDP Dispatch.
bool ready() const override
Is this address object ready for use? Child MUST override this method.
void close() override
Close any open connections and revert to idle.
Dispatcher sorts incoming UDP messages by port index.
Software-defined Ethernet switch.
#define SATCAT5_PMASK_TYPE
Set the integer type used to identify source and destination ports.
"Writeable" I/O interface core definitions
Core event-processing loop for SatCat5 software.
An Ethernet MAC address (with serializable interface).
EtherType field (uint16) is used a protocol-ID [1536..65535].
A single 24-byte packet-log message.
void init_keep(const satcat5::eth::Header &hdr, u8 src, u32 dst)
Initialize a KEEP message.
static constexpr u8 DROP_UNKNOWN
Other unspecified error.
satcat5::eth::Header hdr
Ethernet packet header.
static constexpr u8 DROP_VLAN
Virtual-LAN policy.
static constexpr u8 DROP_MCTRL
Link-local control packet.
bool read_from(satcat5::io::Readable *rd)
Read descriptor from the designated stream.
static constexpr unsigned LEN_BYTES
Message length, in bytes.
static constexpr u8 DROP_BADFRM
Frame length, source MAC, etc.
void init_drop(const satcat5::eth::Header &hdr, u8 src, u8 why)
Initialize a DROP message.
u16 count_keep() const
Count delivered packets.
static constexpr u8 DROP_PTPERR
PTP error (no timestamp)
static constexpr u8 DROP_BADFCS
Invalid frame check sequence.
static constexpr u8 TYPE_SKIP
Message type: SKIP (summary)
u16 count_drop() const
Count dropped packets.
static constexpr u8 DROP_DISABLED
Ingress or egress port disabled.
u8 type_src
Type and source port.
void init_skip(u16 drop, u16 keep)
Initialize a SKIP message.
const char * reason_str() const
Human-readable reason for a dropped packet, if applicable.
static constexpr u8 DROP_NO_ROUTE
No destination or null route.
static constexpr u8 REASON_KEEP
Packet accepted / not dropped.
static constexpr u8 DROP_VRATE
Virtual-LAN rate limits.
static constexpr u8 TYPE_MASK
Mask for message type.
u8 reason() const
Coded reason for a dropped packet, if applicable.
u32 meta
Additional metadata.
void log_to(satcat5::log::LogBuffer &wr) const
Format this field as a human-readable string.
u8 type() const
< Message type.
static constexpr u8 TYPE_DROP
Message type: DROP (dropped)
static constexpr u32 TIME_MASK
Timestamp wraparound at 2^24.
static constexpr u8 DROP_OVERFLOW
FIFO overflow (Rx or Tx)
u32 tstamp
Timestamp in microseconds.
static constexpr u8 TYPE_KEEP
Message type: KEEP (delivered)
static constexpr u8 SRC_MASK
Mask for source index.
void write_to(satcat5::io::Writeable *wr) const
Write descriptor to the designated stream.
SATCAT5_PMASK_TYPE dstmask() const
Destination mask (KEEP messages only).
u8 srcport() const
< Source port index.
Data structure for reporting per-port traffic statistics.
u32 bcast_frames
Broadcast frames received from device.
u32 errct_total
Total packet errors, all types.
u32 errct_ovr
Frames dropped due to FIFO overflow.
u32 sent_frames
Total frames sent from switch to device.
u32 rcvd_frames
Total frames received from device.
u32 errct_pkt
Invalid packets (bad checksum, etc.)
Header contents for an 802.1Q Virtual-LAN tag.
IPv4 address is a 32-bit unsigned integer.
UDP and TCP ports are both 16-bit unsigned integers.
Multipurpose filter for matching fields in network packets.