|
SatCat5
|
Simple network pipe service over raw Ethernet.
Definition at line 126 of file net_tpipe.h.
#include <net_tpipe.h>
Public Member Functions | |
| Tpipe (satcat5::eth::Dispatch *iface) | |
| Create an idle network pipe. | |
| void | bind (const satcat5::eth::MacType &etype, const satcat5::eth::VlanTag &vtag=satcat5::eth::VTAG_NONE) |
| Wait for incoming connections to the specified EtherType. | |
| void | connect (const satcat5::eth::MacAddr &addr, const satcat5::eth::MacType &etype, const satcat5::eth::VlanTag &vtag=satcat5::eth::VTAG_NONE) |
| Create an outgoing connection with the specified server. | |
| bool | ready () const |
| Is this connection ready to send and receive? | |
| void | close () |
| Close the active connection. More... | |
| bool | completed () const |
| Has all queued data been acknowledged? | |
| void | set_retransmit (u16 msec) |
| Adjust retransmit interval. | |
| void | set_timeout (u16 msec) |
| Adjust lost-connection timeout. | |
| void | set_txonly () |
| Enable unidirectional transmission? Transmit-only endpoints do not wait for acknowledgements. More... | |
| 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(). | |
| unsigned | get_write_space () const override |
| How many bytes can be written without blocking? More... | |
| void | write_abort () override |
| If possible, abort the current partially-written packet. More... | |
| void | write_bytes (unsigned nbytes, const void *src) override |
| Write 0 or more bytes from a buffer. More... | |
| bool | write_finalize () override |
| Mark end of frame and release temporary working data. 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; | |
Static Public Member Functions | |
| 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 | 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 | send_block () |
| Send a synchronization packet, with data if applicable. More... | |
| void | send_start () |
Special case of send_block used to open a new connection. More... | |
| 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... | |
| 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... | |
| void | write_dst (satcat5::io::Writeable *dst) |
| 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 | 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::eth::Address | m_addr |
| satcat5::net::Address *const | m_iface |
| Network interface. | |
| u16 | m_retry |
| Retry elapsed time (msec) | |
| u16 | m_state |
| Status flags. | |
| u16 | m_retransmit |
| Retransmit timeout (msec) | |
| u16 | m_timeout |
| Connection timeout (msec) | |
| u16 | m_txpos |
| Transmit position. | |
| u16 | m_txref |
| Transmit reference. | |
| u16 | m_rxpos |
| Receive position. | |
| u16 | m_rxref |
| Receive reference. | |
| u8 | m_txbuff [MAX_WINDOW] |
| Working buffer (transmit) | |
| u8 | m_rxbuff [MAX_WINDOW] |
| Working buffer (receive) | |
| satcat5::io::PacketBuffer | m_tx |
| Transmit data (user writes, child reads) | |
| satcat5::io::PacketBuffer | m_rx |
| Receive data (user reads, child writes) | |
| friend | WriteableRedirect |
| friend | LimitedWrite |
| friend | WriteableBroadcast |
| satcat5::net::Type | m_filter |
| Incoming packet filter. | |
Static Protected Attributes | |
| static constexpr unsigned | MAX_WINDOW = 512 |
| Buffer size is set by the maximum transmit window. | |
| static constexpr u16 | FLAG_START = 0x8000 |
| Open new connection. | |
| static constexpr u16 | FLAG_STOP = 0x4000 |
| Connection is closing. | |
| static constexpr u16 | FLAG_LEN = 0x03FF |
| Data length. | |
| static constexpr u16 | STATE_OPENREQ = 0x0001 |
| Opening new connection. | |
| static constexpr u16 | STATE_READY = 0x0002 |
| Connection acknowledged. | |
| static constexpr u16 | STATE_TXBUSY = 0x0004 |
| Tx sent, wait for ack. | |
| static constexpr u16 | STATE_CLOSING = 0x0008 |
| Closing connection. | |
| static constexpr u16 | STATE_TXONLY = 0x0010 |
| Unidirectional streaming. | |
Private Member Functions | |
| void | poll_demand () |
| Event handler for on-demand polling. | |
| void | query (unsigned elapsed_msec) |
Private Attributes | |
| satcat5::io::Readable * | m_src |
| satcat5::io::EventListener * | m_callback |
| Pointer to the callback object, or NULL. More... | |
| satcat5::poll::OnDemand * | m_next |
| bool | m_idle |
| satcat5::io::Writeable * | m_dst |
| unsigned | m_trem |
| unsigned | m_tnext |
|
inherited |
Close the active connection.
Note: Does not wait for acknowledgment. If assured delivery is required, wait for completed before calling close.
Definition at line 42 of file net_tpipe.cc.
|
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 62 of file net_tpipe.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.
|
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:
The child class MUST override this method.
Implements satcat5::net::Protocol.
Definition at line 68 of file net_tpipe.cc.
|
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 236 of file io_writeable.cc.
|
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.
|
protectedinherited |
Send a synchronization packet, with data if applicable.
The send_block method is called whenever it's time to send a packet. This serves two purposes simultaneously. First, it sends the latest acknowledgement state (txpos, rxpos) so the other side knows what data we've received. Second, if there's any data in the transmit queue, it sends (or re-sends) that data using the PacketBuffer::peek method. That data will be re-sent as needed (i.e., by future calls to send_block) until it is acknowledged and consumed from the FIFO.
Definition at line 164 of file net_tpipe.cc.
|
protectedinherited |
Special case of send_block used to open a new connection.
To open a new connection, the child class should configure its net::Address object and then call this method.
Definition at line 205 of file net_tpipe.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.
|
inherited |
Enable unidirectional transmission? Transmit-only endpoints do not wait for acknowledgements.
Use this mode for unidirectional connections. Not recommended for connections that may drop or reorder packets frequently. This flag remains set until the connection is closed.
Definition at line 56 of file net_tpipe.cc.
|
overridevirtualinherited |
If possible, abort the current partially-written packet.
Child objects of io::Writeable SHOULD override this method if it is practical to prevent in-progress data from being relayed downstream.
Reimplemented from satcat5::io::Writeable.
Definition at line 239 of file io_writeable.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 242 of file io_writeable.cc.
|
overridevirtualinherited |
Mark end of frame and release temporary working data.
Child objects of io::Writeable SHOULD override this method to mark frame bounds.
Reimplemented from satcat5::io::Writeable.
Definition at line 245 of file io_writeable.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 248 of file io_writeable.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 251 of file io_writeable.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.