SatCat5
io_checksum.h File Reference

Detailed Description

Inline checksum insertion (ChecksumTx) and verification (ChecksumRx).

Many frame formats consist of frame data followed by a checksum. io::ChecksumTx and io::ChecksumRx define two templates for working with such streams. The templates are able to work with any byte-aligned checksum with byte-aligned inputs, including most CRC types and many other formats.

Each template accepts data using the io::Writeable interface and writes modified data to a designated io::Writeable pointer:

  • ChecksumTx: For each incoming frame, append the calculated checksum.
  • ChecksumRx: For each incoming frame, strip the last N bytes and compare against the calculated checksum. If it is a match call write_finalize(), and otherwise call write_abort().

Because checksum validation is often tied to a network interface, these classes include the io::Counter API for counting sent and received frames.

In all child classes of either template, the user MUST override the methods write_next() and write_finalize() to calculate and format the checksum. For child classes of io::ChecksumTx, the implementation of write_finalize() MUST call chk_finalize(). For example usage, refer to eth::ChecksumTx and eth::ChecksumRx.

Template type T stores the checksum (u8/u16/u32/u64). Template value N is the checksum length in bytes.

Definition in file io_checksum.h.

Include dependency graph for io_checksum.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  satcat5::io::ChecksumTxCommon
 Parent class for non-template elements of ChecksumTx. More...
 
class  satcat5::io::ChecksumTx< T, N >
 Inline checksum insertion, appends FCS to each outgoing frame. More...
 
class  satcat5::io::ChecksumRxCommon
 Parent class for non-template elements of ChecksumRx. More...
 
class  satcat5::io::ChecksumRx< T, N >
 Check and remove FCS from each incoming frame. More...