|
SatCat5
|
Minimalist port adapter with no VLAN conversion.
Implementation of eth::SwitchPort without VLAN tag formatting or other interface conversions. Suitable for use with "ip::Stack". Note: Network ports using this adapter bypass all plugin egress processing. The SwitchPort::data_rcvd() method will not be called.
Definition at line 146 of file port_adapter.h.
#include <port_adapter.h>
Public Member Functions | |
| NullAdapter (satcat5::eth::SwitchCore *sw) | |
| bool | accept (SATCAT5_PMASK_TYPE dst_mask, satcat5::io::MultiPacket *packet) |
| Accept delivery of a given packet? | |
| bool | consistency () const |
| Internal consistency check, mainly used for unit testing. | |
| satcat5::io::MultiReaderPriority * | get_egress () |
| Source for data leaving the switch through this port. | |
| satcat5::eth::SwitchCore * | get_switch () |
| Pointer to the parent SwitchCore object. | |
| void | port_enable (bool enable) |
| Enable or disable this port, pausing data-flow. | |
| bool | port_enabled () const |
| Is this port currently enabled? | |
| void | port_flush () |
| Discard all pending ingress and egress data. | |
| unsigned | port_index () const |
| Port number for attachment to the parent SwitchCore. More... | |
| SATCAT5_PMASK_TYPE | port_mask () const |
| Bit-mask for all port(s) associated with this interface. | |
| void | set_callback (satcat5::io::EventListener *cb) |
| Set egress data callback, mainly used for unit testing. | |
| satcat5::eth::VtagPolicy | vlan_config () const |
| Return this port's VLAN configuration. | |
| void | vlan_config (const VtagPolicy &cfg) |
| Set this port's VLAN configuration. | |
| void | write_abort () override |
| Override write_abort() to allow additional error handling. More... | |
| bool | write_finalize () override |
| Override write_finalize() to store metadata. More... | |
| virtual void | data_unlink (satcat5::io::Readable *src) |
| Unlink this EventListener from the designated source, because the designated Readable object is being destroyed. More... | |
| void | set_max_packet (unsigned max_bytes) |
| Update the maximum allowed packet length. More... | |
| void | set_priority (u16 priority) |
| Set priority of the current packet. More... | |
| void | set_timeout (unsigned timeout_msec) |
| Update the watchdog timeout. More... | |
| unsigned | get_write_partial () const |
| Get current write length. | |
| unsigned | get_write_space () const override |
| How many bytes can be written without blocking? More... | |
| void | write_bytes (unsigned nbytes, const void *src) override |
| Write 0 or more bytes from a buffer. More... | |
| bool | write_bypass (satcat5::io::MultiReader *dst) |
| Deliver data directly to the designated MultiReader. More... | |
| void | write_u8 (u8 data) |
| One of many functions for writing integer/floating point values, see details. More... | |
| void | write_str (const char *str) |
| Write the contents of a null-terminated string. More... | |
| template<class T > | |
| void | write_obj (const T &obj) |
Templated wrapper for any object with the following method: void write_to(satcat5::io::Writeable* wr) const; | |
| 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. | |
| void | set_callback (satcat5::io::EventListener *callback) override |
| Update registered callback for data_rcvd() events. More... | |
| unsigned | get_read_ready () const override |
| How many bytes can be read without blocking? More... | |
| bool | read_bytes (unsigned nbytes, void *dst) override |
| Read 0 or more bytes into a buffer. More... | |
| bool | read_consume (unsigned nbytes) override |
| Read and discard 0 or more bytes. More... | |
| void | read_finalize () override |
| Consume any remaining bytes in this frame, if applicable. More... | |
| u8 | read_u8 () |
| One of many functions for reading integer/floating point values, see details. More... | |
| unsigned | read_str (unsigned dst_size, char *dst) |
| Safely read a null-terminated input string. More... | |
| template<class T > | |
| bool | read_obj (T &t) |
Templated wrapper for any object with the following method: bool read_from(satcat5::io::Readable* rd); | |
| unsigned | copy_to (satcat5::io::Writeable *dst) |
| Copy data to a Writeable object, without finalizing. More... | |
| bool | copy_and_finalize (satcat5::io::Writeable *dst, satcat5::io::CopyMode mode=CopyMode::PACKET) |
| Copy data to a Writeable object, then finalize. More... | |
| void | request_poll () |
| Call this method to request polling at a later time. More... | |
| void | request_cancel () |
| Call this method to cancel a previous request_poll(). | |
| void | plugin_add (satcat5::eth::PluginPort *plugin) |
| Plugin management. More... | |
| void | plugin_remove (satcat5::eth::PluginPort *plugin) |
| Plugin management. More... | |
| void | plugin_ingress (satcat5::eth::PluginPacket &pkt) |
| Issue notifications to all attached plugins. | |
| void | plugin_egress (satcat5::eth::PluginPacket &pkt) |
| Issue notifications to all attached plugins. | |
Static Public Member Functions | |
| static unsigned | count_timer () |
| Count all objects of this type, including idle timers. | |
| static unsigned | count_ondemand () |
| Count queued objects of this type (i.e., non-idle). | |
Protected Member Functions | |
| void | data_rcvd (satcat5::io::Readable *src) override |
| The data_rcvd() callback is polled whenever data is available. More... | |
| void | timer_event () override |
| Timeouts help prevent resource-hogging. | |
| void | write_next (u8 data) override |
| Write the next byte to the underlying buffer or device. More... | |
| void | write_overflow () override |
| Optional error handling for write overflow. More... | |
| unsigned | write_prep () |
| Open a new packet or allocate additional buffers. More... | |
| satcat5::io::MultiPacket * | prepare_pkt () |
| Prepare packet for delivery and reset internal state. | |
| u8 | read_next () override |
| Read the next byte from the underlying buffer or device. More... | |
| void | read_underflow () override |
| Optional error handling for read underflow. More... | |
| void | read_src (satcat5::io::Readable *src) |
| Children may reset the source object as needed. | |
| void | read_notify () |
Attempt notification by calling m_callback->data_rcvd(). More... | |
Protected Attributes | |
| satcat5::eth::SwitchCore *const | m_switch |
| Pointer to the associated switch. | |
| satcat5::eth::VtagPolicy | m_vlan_cfg |
| Metadata required for VLAN functionality. | |
| satcat5::io::MultiReaderPriority | m_egress |
| Egress data source. | |
| satcat5::io::Writeable *const | m_eg_dst |
| Egress destination. | |
| bool | m_eg_hdr |
| Frame header copied? | |
| satcat5::util::List< satcat5::eth::PluginPort > | m_plugins |
| Linked list of attached plugins. | |
| satcat5::io::MultiBuffer *const | m_dst |
| Pointer to the destination buffer. | |
| friend | LimitedWrite |
| friend | WriteableBroadcast |
| friend | WriteableRedirect |
| SATCAT5_PMASK_TYPE | m_port_mask |
| Define this port's connection to the switch. More... | |
| const unsigned | m_port_index |
| Define this port's connection to the switch. More... | |
| satcat5::io::MultiPacket * | m_write_pkt |
| Current write state. | |
| satcat5::io::MultiChunk * | m_write_tail |
| Current write state. | |
| unsigned | m_write_pos |
| Current write state. | |
| unsigned | m_write_len |
| Current write state. | |
| unsigned | m_write_maxlen |
| Current write state. | |
| unsigned | m_write_timeout |
| Current write state. | |
Private Member Functions | |
| void | query (unsigned elapsed_msec) |
| void | poll_demand () |
| Event handler for on-demand polling. | |
Private Attributes | |
| satcat5::eth::SwitchPort * | m_next |
| unsigned | m_trem |
| unsigned | m_tnext |
| satcat5::io::Readable * | m_src |
| satcat5::io::EventListener * | m_callback |
| Pointer to the callback object, or NULL. More... | |
| bool | m_idle |
|
inherited |
Copy data to a Writeable object, then finalize.
As copy_to(), but also calls read_finalize() and/or write_finalize() depending on the input/output mode.
In packet mode (the default), call both read_finalize() and write_finalize() if the operation copies all available data. Use this mode whenever the input is packetized.
In byte-stream mode, call write_finalize() if the operation copies any data, but never call read_finalize(). Use this mode for inputs that do not delimit packet boundaries.
| dst | The destination object. |
| mode | Select packet mode or stream mode. |
Definition at line 234 of file io_readable.cc.
|
inherited |
Copy data to a Writeable object, without finalizing.
Copy the contents of this Readable to a Writeable object, stopping at end-of-input, end-of-frame, or the capacity of the destination buffer (whichever comes first). This method does not call read_finalize or write_finalize(). To automatically make finalize calls,
Definition at line 214 of file io_readable.cc.
|
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 368 of file eth_switch.cc.
|
inlinevirtualinherited |
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 in satcat5::io::Override, satcat5::io::MuxUp, satcat5::io::MuxDown, satcat5::io::BufferedPackets, satcat5::io::BufferedStream, satcat5::io::BufferedCopy, satcat5::eth::SwitchLogReader, satcat5::eth::Dispatch, satcat5::ccsds_spp::Dispatch, satcat5::ccsds_aos::Dispatch, satcat5::ccsds_aos::Channel, satcat5::test::MockOffload::Port, and satcat5::freertos::MessageCopy.
Definition at line 54 of file io_readable.h.
|
overridevirtualinherited |
How many bytes can be read without blocking?
Child objects of io::Readable MUST override this method.
Implements satcat5::io::Readable.
Definition at line 336 of file io_readable.cc.
|
overridevirtualinherited |
How many bytes can be written without blocking?
Child objects of io::Writeable MUST override this method.
Implements satcat5::io::Writeable.
Definition at line 465 of file multi_buffer.cc.
|
inherited |
Plugin management.
The switch maintains a linked list of regstered PluginCore objects. For each incoming packet, the switch calls query(...) on each registered plugin. These methods are automatically called by the PluginCore constructor and destructor.
Definition at line 295 of file eth_switch.cc.
|
inherited |
Plugin management.
The switch maintains a linked list of regstered PluginCore objects. For each incoming packet, the switch calls query(...) on each registered plugin. These methods are automatically called by the PluginCore constructor and destructor.
Definition at line 297 of file eth_switch.cc.
|
inlineinherited |
Port number for attachment to the parent SwitchCore.
Note: Does not apply to multi-port API,
Definition at line 292 of file eth_switch.h.
|
overridevirtualinherited |
Read 0 or more bytes into a buffer.
Child objects of io::Readable MAY override this method for improved performance.
Reimplemented from satcat5::io::Readable.
Definition at line 339 of file io_readable.cc.
|
overridevirtualinherited |
Read and discard 0 or more bytes.
Child objects of io::Readable MAY override this method for improved performance.
Reimplemented from satcat5::io::Readable.
Definition at line 342 of file io_readable.cc.
|
overridevirtualinherited |
Consume any remaining bytes in this frame, if applicable.
Child objects of io::Readable SHOULD override this method if they support framing.
Reimplemented from satcat5::io::Readable.
Definition at line 345 of file io_readable.cc.
|
overrideprotectedvirtualinherited |
Read the next byte from the underlying buffer or device.
Child objects of io::Readable MUST override this method.
Implements satcat5::io::Readable.
Definition at line 348 of file io_readable.cc.
|
protectedinherited |
Attempt notification by calling m_callback->data_rcvd().
Child objects of io::Readable MAY call this to override default notifications.
Definition at line 254 of file io_readable.cc.
|
inherited |
Safely read a null-terminated input string.
The input is always consumed up to the end-of-input or the first zero byte, whichever comes first.
Definition at line 179 of file io_readable.cc.
|
inherited |
One of many functions for reading integer/floating point values, see details.
Several functions are provided for reading and writing scalar types to/from io::Readable and io::Writeable instances. Since there are many of these that are frequently inherited, they are hidden from documentation. These functions follow a shared template:
read_ or write_ prefix.u for unsigned, s for signed, f for floating-point.l suffix if little-endian, no suffix if big-endian.Example: write_s48l is "Write 48 bits (6 bytes) to this
io::Writeable as a signed value in little-endian order".
Definition at line 44 of file io_readable.cc.
|
overrideprotectedvirtualinherited |
Optional error handling for read underflow.
Child objects of io::Readable MAY override this method.
Reimplemented from satcat5::io::Readable.
Definition at line 351 of file io_readable.cc.
|
inherited |
Call this method to request polling at a later time.
Safe to stack requests, but only one call to poll().
Definition at line 208 of file polling.cc.
|
overridevirtualinherited |
Update registered callback for data_rcvd() events.
Child objects of io::Readable SHOULD usually leave this method as-is.
Reimplemented from satcat5::io::Readable.
Definition at line 331 of file io_readable.cc.
|
inlineinherited |
Update the maximum allowed packet length.
(Longer packets are terminated to avoid resource hogging.)
Definition at line 413 of file multi_buffer.h.
|
inherited |
Set priority of the current packet.
Call this method after writing data, but before calling write_finalize or write_bypass. Priority affects readout order for recipient(s) using the MultiReaderPriority class.
Definition at line 461 of file multi_buffer.cc.
|
inlineinherited |
Update the watchdog timeout.
The watchdog is reset each time a byte is written; if a partial packet is not finalized or aborted within the time limit, then it is dicarded.
Definition at line 425 of file multi_buffer.h.
|
overridevirtualinherited |
Override write_abort() to allow additional error handling.
For example, logging of dropped packets.
eth_sw_log.h. Reimplemented from satcat5::io::Writeable.
Definition at line 329 of file eth_switch.cc.
|
inherited |
Deliver data directly to the designated MultiReader.
The write_finalize method delivers the current packet to the MultiBuffer, which then decides which port(s) should receive that packet.
This alternative method delivers the packet directly to the designated MultiReader, bypassing MultiBuffer delivery logic.
Definition at line 521 of file multi_buffer.cc.
|
overridevirtualinherited |
Write 0 or more bytes from a buffer.
Child objects of io::Writeable MAY override write_bytes as needed for performance.
Reimplemented from satcat5::io::Writeable.
Definition at line 474 of file multi_buffer.cc.
|
overridevirtualinherited |
Override write_finalize() to store metadata.
Children with multiple logical ports MUST override this method to indicate the correct specific source port index.
Reimplemented from satcat5::io::Writeable.
Definition at line 335 of file eth_switch.cc.
|
overrideprotectedvirtualinherited |
Write the next byte to the underlying buffer or device.
Child objects of io::Writeable MUST override this method.
Implements satcat5::io::Writeable.
Definition at line 531 of file multi_buffer.cc.
|
overrideprotectedvirtualinherited |
Optional error handling for write overflow.
Child objects of io::Writeable MAY override this method for error handling.
Reimplemented from satcat5::io::Writeable.
Definition at line 547 of file multi_buffer.cc.
|
protectedinherited |
Open a new packet or allocate additional buffers.
Definition at line 558 of file multi_buffer.cc.
|
inherited |
Write the contents of a null-terminated string.
Note: Null-termination is not copied to the output.
Definition at line 180 of file io_writeable.cc.
|
inherited |
One of many functions for writing integer/floating point values, see details.
Several functions are provided for reading and writing scalar types to/from io::Readable and io::Writeable instances. Since there are many of these that are frequently inherited, they are hidden from documentation. These functions follow a shared template:
read_ or write_ prefix.u for unsigned, s for signed, f for floating-point.l suffix if little-endian, no suffix if big-endian.Example: write_s48l is "Write 48 bits (6 bytes) to this
io::Writeable as a signed value in little-endian order".
Definition at line 20 of file io_writeable.cc.
|
privateinherited |
Pointer to the callback object, or NULL.
This can only be modified through the set_callback(...) method.
Definition at line 199 of file io_readable.h.
|
protectedinherited |
Define this port's connection to the switch.
Note: Usually m_port_mask contains a single '1' bit, but some port objects represent several logical ports. The "m_port_index" SHOULD NOT be used in such cases.
Definition at line 340 of file eth_switch.h.
|
protectedinherited |
Define this port's connection to the switch.
Note: Usually m_port_mask contains a single '1' bit, but some port objects represent several logical ports. The "m_port_index" SHOULD NOT be used in such cases.
Definition at line 339 of file eth_switch.h.