SatCat5
port_adapter.h
Go to the documentation of this file.
1 // Copyright 2024-2025 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
40 
41 #pragma once
42 
43 #include <satcat5/codec_cobs.h>
44 #include <satcat5/codec_slip.h>
45 #include <satcat5/eth_checksum.h>
46 #include <satcat5/eth_switch.h>
47 #include <satcat5/eth_sw_vlan.h>
48 #include <satcat5/io_core.h>
49 
50 namespace satcat5 {
51  namespace port {
58  public:
63 
64  protected:
67  };
68 
73  class MailAdapter final : public satcat5::port::VlanAdapter {
74  public:
80 
81  protected:
82  satcat5::io::BufferedCopy m_rx_copy; // Push/pull adapter
83  };
84 
89  class CobsAdapter final : public satcat5::port::VlanAdapter {
90  public:
96 
99  { return &m_rx_copy; }
100 
103  { return satcat5::io::TrafficStats::query(m_rx_fcs, m_tx_fcs); }
104 
105  protected:
106  satcat5::io::BufferedCopy m_rx_copy; // Push/pull adapter
107  satcat5::io::CobsDecoder m_rx_cobs; // COBS decoder
108  satcat5::eth::ChecksumRx m_rx_fcs; // Checksum verification
109  satcat5::eth::ChecksumTx m_tx_fcs; // Checksum calculation
110  satcat5::io::CobsEncoder m_tx_cobs; // COBS encoder
111  };
112 
118  public:
120  SlipAdapter(
124 
127  { return &m_rx_copy; }
128 
131  { return satcat5::io::TrafficStats::query(m_rx_fcs, m_tx_fcs); }
132 
133  protected:
134  satcat5::io::BufferedCopy m_rx_copy; // Push/pull adapter
135  satcat5::io::SlipDecoder m_rx_slip; // SLIP decoder
136  satcat5::eth::ChecksumRx m_rx_fcs; // Checksum verification
137  satcat5::eth::ChecksumTx m_tx_fcs; // Checksum calculation
138  satcat5::io::SlipEncoder m_tx_slip; // SLIP encoder
139  };
140 
147  : public satcat5::eth::SwitchPort
149  public:
151  };
152 
156  template <unsigned SIZE = 4096>
160  public:
162  : VlanAdapter(sw, &m_buff)
163  , ReadableRedirect(&m_buff)
164  , m_buff() {}
165 
166  protected:
168  };
169 
174  public:
178 
179  protected:
180  satcat5::port::VlanAdapter m_a2b, m_b2a;
181  };
182  }
183 }
Check and remove FCS from each incoming frame.
Definition: eth_checksum.h:52
Append FCS to each outgoing frame.
Definition: eth_checksum.h:38
A shared-memory Ethernet switch based on the MultiBuffer class.
Definition: eth_switch.h:93
Generic packetized I/O interface for use with SwitchCore.
Definition: eth_switch.h:245
Port plugin for egress formatting of Virtual-LAN tags.
Definition: eth_sw_vlan.h:25
BufferedCopy copies from any Readable source to any Writeable sink.
Definition: io_buffer.h:68
Inline COBS decoder.
Definition: codec_cobs.h:74
Inline COBS encoder.
Definition: codec_cobs.h:49
Event-handler interface for newly received data.
Definition: io_readable.h:43
Packet buffer with statically-allocated working memory.
Definition: pkt_buffer.h:198
Abstract API for reading byte-streams and packets.
Definition: io_readable.h:68
Wrapper class for forwarding reads to another object.
Definition: io_readable.h:299
constexpr ReadableRedirect(satcat5::io::Readable *src)
Constructor and destructor should only be called by the child.
Definition: io_readable.h:310
Inline SLIP decoder.
Definition: codec_slip.h:62
Inline SLIP encoder.
Definition: codec_slip.h:42
Abstract API for writing byte-streams and packets.
Definition: io_writeable.h:24
Minimalist port adapter with VLAN conversion.
Definition: port_adapter.h:159
Port adapter for COBS-encoded serial ports.
Definition: port_adapter.h:89
CobsAdapter(satcat5::eth::SwitchCore *sw, satcat5::io::Readable *src, satcat5::io::Writeable *dst)
Attach port to the Ethernet switch and its data source/sink.
Definition: port_adapter.cc:38
satcat5::io::TrafficStats stats()
Report packet statistics since the previous query.
Definition: port_adapter.h:102
satcat5::io::EventListener * listen()
Access the event-listener used for read/pull mode.
Definition: port_adapter.h:98
Port adapter for MailBox, MailMap, etc.
Definition: port_adapter.h:73
MailAdapter(satcat5::eth::SwitchCore *sw, satcat5::io::Readable *src, satcat5::io::Writeable *dst)
Attach port to the Ethernet switch and its data source/sink.
Definition: port_adapter.cc:31
Minimalist port adapter with no VLAN conversion.
Definition: port_adapter.h:148
Port adapter for SLIP-encoded serial ports.
Definition: port_adapter.h:117
satcat5::io::EventListener * listen()
Access the event-listener used for read/pull mode.
Definition: port_adapter.h:126
satcat5::io::TrafficStats stats()
Report packet statistics since the previous query.
Definition: port_adapter.h:130
SlipAdapter(satcat5::eth::SwitchCore *sw, satcat5::io::Readable *src, satcat5::io::Writeable *dst)
Attach port to the Ethernet switch and its data source/sink.
Definition: port_adapter.cc:49
Back-to-back connection of one SwitchCore to another SwitchCore.
Definition: port_adapter.h:173
Parent class for handling switch egress and VLAN functions.
Definition: port_adapter.h:57
satcat5::eth::SwitchVlanEgress m_vport
VLAN plugin for this port.
Definition: port_adapter.h:66
VlanAdapter(satcat5::eth::SwitchCore *sw, satcat5::io::Writeable *vdst)
Constructor sets source and destination.
Definition: port_adapter.cc:24
Inline COBS encoder and decoder objects.
Inline SLIP encoder and decoder objects.
Inline Ethernet Checksum insertion and verification.
IEEE802.1Q Virtual-LAN plugin for the software-defined Ethernet switch.
Software-defined Ethernet switch.
I/O interface core definitions.
Data structure for combined transmit and receive statistics.
Definition: io_counter.h:94
static TrafficStats query(satcat5::io::Counter &rx, satcat5::io::Counter &tx)
Read updated statistics from a transmit/receive pair.
Definition: io_counter.cc:58