SatCat5
types.h
Go to the documentation of this file.
1 // Copyright 2021-2025 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
12 
13 #pragma once
14 
15 #include <cinttypes>
16 #include <climits>
17 
18 // Allow safe destruction of SatCat5 objects?
19 //
20 // Some embedded systems never need to delete anything, and disabling this
21 // feature can save significant code-size. (Sometimes 100+ kB, if secondary
22 // libraries are imported for exception handling.)
23 //
24 // However, disabling this flag means that SatCat5 objects cannot be safely
25 // deleted or allowed to fall out of scope. To prevent undefined behavior
26 // and "fail loud" in the event of such exceptions, placeholder destructors
27 // are replaced with an infinite loop. This eases debugging and prevents
28 // catastrophic hazards, such as dangling pointers in global linked lists.
29 //
30 // Disable this flag at your own risk.
31 // For GCC/G++: compiler flag "-DSATCAT5_ALLOW_DELETION=0".
32 #ifndef SATCAT5_ALLOW_DELETION
33 #define SATCAT5_ALLOW_DELETION 1
34 #endif
35 
36 // If applicable, define the placeholder destructor / error-trap.
37 #if SATCAT5_ALLOW_DELETION
38 #define SATCAT5_OPTIONAL_DTOR // Full function defined elsewhere
39 #else
40 #define SATCAT5_OPTIONAL_DTOR {while(1);} // Infinite loop placeholder
41 #endif
42 
43 // Enable use of the QCBOR library?
44 // For GCC/G++: compiler flag "-DSATCAT5_QCBOR_ENABLE=1" to enable.
45 #ifndef SATCAT5_QCBOR_ENABLE
46 #define SATCAT5_QCBOR_ENABLE 0
47 #endif
48 
49 // Default method for accessing the system clock.
50 // (See also: TimeRef class defined in "satcat5/timeref.h")
51 #ifndef SATCAT5_CLOCK
52 #define SATCAT5_CLOCK satcat5::poll::timekeeper.get_clock()
53 #endif
54 
55 // Shortcuts for fixed-size integer types.
56 typedef uint8_t u8;
57 typedef uint16_t u16;
58 typedef uint32_t u32;
59 typedef uint64_t u64;
60 typedef int8_t s8;
61 typedef int16_t s16;
62 typedef int32_t s32;
63 typedef int64_t s64;
64 
65 // Prototypes for widely-used interfaces and data-structures.
66 // (Comment indicates the file containing the full definition.)
67 namespace satcat5 {
68  namespace aes { // Encryption using AES
69  class Cipher; // satcat5/aes_cipher.h
70  class Gcm; // satcat5/aes_gcm.h
71  }
72 
73  namespace cbor {
74  struct Logger; // satcat5/io_cbor.h
75  class CborReader; // satcat5/io_cbor.h
76  class CborWriter; // satcat5/io_cbor.h
77  class ListReader; // satcat5/io_cbor.h
78  class ListWriter; // satcat5/io_cbor.h
79  template <typename KEYTYPE>
80  class MapReader; // satcat5/io_cbor.h
81  template <typename KEYTYPE>
82  class MapWriter; // satcat5/io_cbor.h
83  }
84 
85  namespace ccsds_aos { // CCSDS AOS Space Data Link Protocol
86  struct Header; // satcat5/ccsds_aos.h
87  class Channel; // satcat5/ccsds_aos.h
88  class Dispatch; // satcat5/ccsds_aos.h
89  }
90 
91  namespace ccsds_spp { // CCSDS Space Packet Protocol
92  struct Header; // satcat5/ccsds_spp.h
93  class Address; // satcat5/ccsds_spp.h
94  class Dispatch; // satcat5/ccsds_spp.h
95  class Packetizer; // satcat5/ccsds_spp.h
96  class Protocol; // satcat5/ccsds_spp.h
97  }
98 
99  namespace cfg { // ConfigBus and peripherals
100  struct TrafficStats; // satcat5/cfgbus_stats.h
101  class ConfigBus; // satcat5/cfgbus_core.h
102  class ConfigBusMmap; // satcat5/cfgbus_core.h
103  class ConfigBusRemote; // satcat5/cfgbus_remote.h
104  class GpiRegister; // satcat5/cfgbus_gpio.h
105  class GpoRegister; // satcat5/cfgbus_gpio.h
106  class Hdlc; // satcat5/cfgbus_hdlc.h
107  class I2c; // satcat5/cfgbus_i2c.h
108  class I2cEventListener; // satcat5/cfgbus_i2c.h
109  class Interrupt; // satcat5/cfgbus_interrupt.h
110  class LedArray; // satcat5/cfgbus_led.h
111  class Mdio; // satcat5/cfgbus_mdio.h
112  class MdioEventListener; // satcat5/cfgbus_mdio.h
113  class MdioLogger; // satcat5/cfgbus_mdio.h
114  class MdioWrapper; // satcat5/cfgbus_mdio.h
115  class MultiSerial; // satcat5/cfgbus_multiserial.h
116  class NetworkStats; // satcat5/cfgbus_stats.h
117  class PpsEventListener; // satcat5/cfgbus_pps.h
118  class PpsInput; // satcat5/cfgbus_pps.h
119  class PpsOutput; // satcat5/cfgbus_pps.h
120  class PtpRealtime; // satcat5/cfgbus_ptpref.h
121  class PtpReference; // satcat5/cfgbus_ptpref.h
122  class Spi; // satcat5/cfgbus_spi.h
123  class SpiEventListener; // satcat5/cfgbus_spi.h
124  class Timer; // satcat5/cfgbus_timer.h
125  class Uart; // satcat5/cfgbus_uart.h
126  class WrappedRegister; // satcat5/cfgbus_core.h
127  class WrappedRegisterPtr; // satcat5/cfgbus_core.h
128  }
129 
130  namespace coap {
131  struct Code; // satcat5/coap_constants.h
132  class Connection; // satcat5/coap_connection.h
133  class ConnectionSpp; // satcat5/coap_connection.h
134  class ConnectionUdp; // satcat5/coap_connection.h
135  class Endpoint; // satcat5/coap_endpoint.h
136  class EndpointSpp; // satcat5/coap_endpoint.h
137  class EndpointSppFwd; // satcat5/coap_endpoint.h
138  class EndpointUdp; // satcat5/coap_endpoint.h
139  class EndpointUdpSimple; // satcat5/coap_endpoint.h
140  class ManageSpp; // satcat5/coap_endpoint.h
141  class ManageUdp; // satcat5/coap_endpoint.h
142  class Option; // satcat5/coap_reader.h
143  class ProxyResource; // satcat5/coap_proxy.h
144  class ProxyServer; // satcat5/coap_proxy.h
145  class Reader; // satcat5/coap_reader.h
146  class ReadHeader; // satcat5/coap_reader.h
147  class ReadSimple; // satcat5/coap_reader.h
148  class Resource; // satcat5/coap_resource.h
149  class ResourceServer; // satcat5/coap_resource.h
150  class SimpleClient; // satcat5/coap_client.h
151  class SimpleClientSpp; // satcat5/coap_client.h
152  class SimpleClientUdp; // satcat5/coap_client.h
153  class Writer; // satcat5/coap_writer.h
154  }
155 
156  namespace crc16 { // 16-bit CRC calculation
157  class KermitRx; // satcat5/crc16_checksum.h
158  class KermitTx; // satcat5/crc16_checksum.h
159  class XmodemRx; // satcat5/crc16_checksum.h
160  class XmodemTx; // satcat5/crc16_checksum.h
161  }
162 
163  namespace datetime { // Human-readable date and time
164  struct GpsTime; // satcat5/datetime.h
165  struct RtcTime; // satcat5/datetime.h
166  class Clock; // satcat5/datetime.h
167  }
168 
169  namespace eth { // Ethernet networking
170  struct Header; // satcat5/eth_header.h
171  struct MacAddr; // satcat5/eth_header.h
172  struct MacType; // satcat5/eth_header.h
173  struct PluginPacket; // satcat5/eth_plugin.h
174  struct SwitchLogMessage; // satcat5/eth_sw_log.h
175  struct VlanRate; // satcat5/switch_cfg.h
176  struct VlanTag; // satcat5/eth_header.h
177  struct VtagPolicy; // satcat5/switch_cfg.h
178  struct VlanTag; // satcat5/eth_header.h
179  class Address; // satcat5/eth_address.h
180  class AeroFtpClient; // satcat5/net_aeroftp.h
181  class ArpListener; // satcat5/eth_arp.h
182  class ChecksumRx; // satcat5/eth_checksum.h
183  class ChecksumTx; // satcat5/eth_checksum.h
184  class ConfigBus; // satcat5/cfgbus_remote.h
185  class Dispatch; // satcat5/eth_dispatch.h
186  class MacSec; // satcat5/eth_macsec.h
187  class PluginCore; // satcat5/eth_plugin.h
188  class PluginPort; // satcat5/eth_plugin.h
189  class Protocol; // satcat5/eth_protocol.h
190  class ProtoArp; // satcat5/eth_arp.h
191  class ProtoConfig; // satcat5/net_cfgbus.h
192  class ProtoEcho; // satcat5/net_echo.h
193  class SlipCodec; // satcat5/eth_checksum.h
194  class SlipCodecInverse; // satcat5/eth_checksum.h
195  class Socket; // satcat5/eth_socket.h
196  class SocketCore; // satcat5/eth_socket.h
197  template <unsigned SIZE>
198  class SwitchCache; // satcat5/eth_sw_cache.h
199  class SwitchConfig; // satcat5/switch_cfg.h
200  class SwitchCore; // satcat5/eth_switch.h
201  class SwitchLogFormatter; // satcat5/eth_sw_log.h
202  class SwitchLogHardware; // satcat5/eth_sw_log.h
203  class SwitchLogReader; // satcat5/eth_sw_log.h
204  class SwitchLogWriter; // satcat5/eth_sw_log.h
205  class SwitchPort; // satcat5/eth_switch.h
206  template <unsigned VMAX>
207  class SwitchVlan; // satcat5/eth_sw_vlan.h
208  class Telemetry; // satcat5/net_telemetry.h
209  class TelemetryRx; // satcat5/net_telemetry.h
210  class Tpipe; // satcat5/net_tpipe.h
211  }
212 
213  namespace gui { // Graphical user interfaces
214  struct Cursor; // satcat5/gui_display.h
215  struct Icon8x8; // satcat5/gui_icons.h
216  struct Icon16x16; // satcat5/gui_icons.h
217  struct LogColors; // satcat5/gui_display.h
218  template <class T>
219  class Font; // satcat5/gui_icons.h
220  class Canvas; // satcat5/gui_display.h
221  class Display; // satcat5/gui_display.h
222  class DrawCmd; // satcat5/gui_display.h
223  class LogToDisplay; // satcat5/gui_display.h
224  }
225 
226  namespace igmp { // Internet Group Message Protocol (IGMP)
227  struct Address; // satcat5/igmp_client.h
228  struct Group; // satcat5/igmp_server.h
229  class Client; // satcat5/igmp_client.h
230  class Server; // satcat5/igmp_server.h
231  }
232 
233  namespace io { // Input and output streams
234  struct TrafficStats; // satcat5/io_checksum.h
235  class ArrayRead; // satcat5/io_readable.h
236  class ArrayWrite; // satcat5/io_writeable.h
237  class BufferedCopy; // satcat5/io_buffer.h
238  class BufferedIO; // satcat5/io_buffer.h
239  class BufferedWriter; // satcat5/io_buffer.h
240  class ChecksumRxCommon; // satcat5/io_checksum.h
241  class ChecksumTxCommon; // satcat5/io_checksum.h
242  class CobsCodec; // satcat5/codec_cobs.h
243  class CobsCodecInverse; // satcat5/codec_cobs.h
244  class CobsDecoder; // satcat5/codec_cobs.h
245  class CobsEncoder; // satcat5/codec_cobs.h
246  class Counter; // satcat5/io_counter.h
247  class CounterInline; // satcat5/io_counter.h
248  class CounterSimple; // satcat5/io_counter.h
249  class EventListener; // satcat5/io_readable.h
250  class HdlcDecoder; // satcat5/codec_hdlc.h
251  class HdlcEncoder; // satcat5/codec_hdlc.h
252  class LimitedRead; // satcat5/io_readable.h
253  class LimitedWrite; // satcat5/io_writeable.h
254  class MultiBuffer; // satcat5/multi_buffer.h
255  class MultiReader; // satcat5/multi_buffer.h
256  class MultiReaderPriority; // satcat5/multi_buffer.h
257  class MultiReaderSimple; // satcat5/multi_buffer.h
258  class MultiWriter; // satcat5/multi_buffer.h
259  class MuxDown; // satcat5/io_multiplexer.h
260  class MuxUp; // satcat5/io_multiplexer.h
261  class NullRead; // satcat5/io_readable.h
262  class NullSink; // satcat5/io_readable.h
263  class NullWrite; // satcat5/io_writeable.h
264  class PacketBuffer; // satcat5/pkt_buffer.h
265  class PacketCombiner; // satcat5/pkt_combine.h
266  class Readable; // satcat5/io_readable.h
267  class ReadableRedirect; // satcat5/io_readable.h
268  class SlipCodec; // satcat5/codec_slip.h
269  class SlipCodecInverse; // satcat5/codec_slip.h
270  class SlipDecoder; // satcat5/codec_slip.h
271  class SlipEncoder; // satcat5/codec_slip.h
272  class TriMode; // satcat5/io_trimode.h
273  class Writeable; // satcat5/io_writeable.h
274  class WriteableBroadcast; // satcat5/io_broadcast.h
275  class WriteableRedirect; // satcat5/io_writeable.h
276  }
277 
278  namespace ip { // Internet Protocol v4 (IPv4)
279  struct Addr; // satcat5/ip_core.h
280  struct Header; // satcat5/ip_core.h
281  struct IgmpAddress; // satcat5/ip_igmp_client.h
282  struct IgmpGroup; // satcat5/ip_igmp_server.h
283  struct Mask; // satcat5/ip_core.h
284  struct Port; // satcat5/ip_core.h
285  struct Route; // satcat5/ip_table.h
286  struct Subnet; // satcat5/ip_core.h
287  class Address; // satcat5/ip_address.h
288  class DhcpClient; // satcat5/ip_dhcp.h
289  class DhcpServer; // satcat5/ip_dhcp.h
290  class IgmpClient; // satcat5/ip_igmp_client.h
291  class IgmpServer; // satcat5/ip_igmp_server.h
292  class Dispatch; // satcat5/ip_dispatch.h
293  class Ping; // satcat5/ip_ping.h
294  class ProtoIcmp; // satcat5/ip_icmp.h
295  class Stack; // satcat5/ip_stack.h
296  class Table; // satcat5/ip_table.h
297  }
298 
299  namespace irq { // Interrupt handling
300  class AtomicLock; // satcat5/interrupts.h
301  class Controller; // satcat5/interrupts.h
302  class Handler; // satcat5/interrupts.h
303  class Shared; // satcat5/interrupts.h
304  class VirtualTimer; // satcat5/polling.h
305  }
306 
307  namespace log { // Logging
308  class EventHandler; // satcat5/log.h
309  class Log; // satcat5/log.h
310  class LogBuffer; // satcat5/log.h
311  class ToWriteable; // satcat5/log.h
312  }
313 
314  namespace net { // Generic networking
315  struct Type; // satcat5/net_type.h
316  class Address; // satcat5/net_address.h
317  class AeroFtpClient; // satcat5/net_aeroftp.h
318  class Dispatch; // satcat5/net_dispatch.h
319  class Protocol; // satcat5/net_protocol.h
320  class ProtoConfig; // satcat5/net_cfgbus.h
321  class SocketCore; // satcat5/net_socket.h
322  class TelemetryAggregator; // satcat5/net_telemetry.h
323  class TelemetryCbor; // satcat5/net_telemetry.h
324  class TelemetryKey; // satcat5/net_telemetry.h
325  class TelemetryLogger; // satcat5/net_telemetry.h
326  class TelemetryRx; // satcat5/net_telemetry.h
327  class TelemetrySink; // satcat5/net_telemetry.h
328  class TelemetrySource; // satcat5/net_telemetry.h
329  class TelemetryTier; // satcat5/net_telemetry.h
330  class TelemetryWatcher; // satcat5/net_telemetry.h
331  class Tpipe; // satcat5/net_tpipe.h
332  }
333 
334  namespace ntp { // Network time protocol (NTP)
335  class Client; // satcat5/ntp_client.h
336  struct Header; // satcat5/ntp_header.h
337  }
338 
339  namespace poll { // Queued-task servicing
340  class Always; // satcat5/polling.h
341  class OnDemand; // satcat5/polling.h
342  class Timer; // satcat5/polling.h
343  class TimerAdapter; // satcat5/polling.h
344  }
345 
346  namespace port { // Network ports
347  class CobsAdapter; // satcat5/port_adapter.h
348  class MailAdapter; // satcat5/port_adapter.h
349  class Mailbox; // satcat5/port_mailbox.h
350  class Mailmap; // satcat5/port_mailmap.h
351  class NullAdapter; // satcat5/port_adapter.h
352  class RecoveryEgress; // satcat5/port_recovery.h
353  class RecoveryIngress; // satcat5/port_recovery.h
354  class SerialGeneric; // satcat5/port_serial.h
355  class SerialAuto; // satcat5/port_serial.h
356  class SerialI2cController; // satcat5/port_serial.h
357  class SerialI2cPeripheral; // satcat5/port_serial.h
358  class SerialSpiController; // satcat5/port_serial.h
359  class SerialSpiPeripheral; // satcat5/port_serial.h
360  class SerialUart; // satcat5/port_serial.h
361  class SlipAdapter; // satcat5/port_adapter.h
362  class SwitchAdapter; // satcat5/port_adapter.h
363  class VlanAdapter; // satcat5/port_adapter.h
364  }
365 
366  namespace ptp { // Precision Time Protocol (PTP)
367  class Callback; // satcat5/ptp_source.h
368  class Client; // satcat5/ptp_client.h
369  struct ClockInfo; // satcat5/ptp_header.h
370  struct CoeffLR; // satcat5/ptp_filters.h
371  struct CoeffPI; // satcat5/ptp_filters.h
372  struct CoeffPII; // satcat5/ptp_filters.h
373  template <unsigned>
374  class ControllerLR; // satcat5/ptp_filters.h
375  class ControllerLR_Inner; // satcat5/ptp_filters.h
376  class ControllerPI; // satcat5/ptp_filters.h
377  class ControllerPII; // satcat5/ptp_filters.h
378  class Dispatch; // satcat5/ptp_dispatch.h
379  class DopplerTlv; // satcat5/ptp_doppler.h
380  class Filter; // satcat5/ptp_filters.h
381  struct Header; // satcat5/ptp_header.h
382  class Interface; // satcat5/ptp_interface.h
383  struct Measurement; // satcat5/ptp_measurement.h
384  class MeasurementCache; // satcat5/ptp_measurement.h
385  class Source; // satcat5/ptp_source.h
386  class SyncUnicastL2; // satcat5/ptp_client.h
387  class SyncUnicastL3; // satcat5/ptp_client.h
388  class Time; // satcat5/ptp_time.h
389  class TlvHandler; // satcat5/ptp_tlv.h
390  struct TlvHeader; // satcat5/ptp_tlv.h
391  struct TlvType; // satcat5/ptp_tlv.h
392  class TrackingClock; // satcat5/ptp_tracking.h
393  class TrackingController; // satcat5/ptp_tracking.h
394  }
395 
396  namespace router2 { // Software-defined IPv4 router
397  class DeferFwd; // satcat5/router2_deferfwd.h
398  struct DeferPkt; // satcat5/router2_deferfwd.h
399  class Dispatch; // satcat5/router2_dispatch.h
400  class Offload; // satcat5/router2_offload.h
401  class StackCommon; // satcat5/router2_stack.h
402  template <unsigned>
403  class StackGateware; // satcat5/router2_stack.h
404  template <unsigned>
405  class StackSoftware; // satcat5/router2_stack.h
406  class Table; // satcat5/router2_table.h
407  }
408 
409  namespace tcp { // TCP networking
410  struct Header; // satcat5/tcp_core.h
411  }
412 
413  namespace test { // Unit test framework
414  class TftpClient; // sim/cpp/test_udp_tftp.cc
415  class TftpServer; // sim/cpp/test_udp_tftp.cc
416  }
417 
418  namespace udp { // UDP networking
419  struct Header; // satcat5/udp_core.h
420  class Address; // satcat5/udp_core.h
421  class AeroFtpClient; // satcat5/net_aeroftp.h
422  class ConfigBus; // satcat5/cfgbus_remote.h
423  class Dispatch; // satcat5/udp_dispatch.h
424  class ProtoConfig; // satcat5/net_cfgbus.h
425  class ProtoEcho; // satcat5/net_echo.h
426  class Socket; // satcat5/udp_socket.h
427  class SocketCore; // satcat5/udp_socket.h
428  class Telemetry; // satcat5/net_telemetry.h
429  class TelemetryRx; // satcat5/net_telemetry.h
430  class TftpClient; // satcat5/udp_tftp.h
431  class TftpServerCore; // satcat5/udp_tftp.h
432  class TftpServerSimple; // satcat5/udp_tftp.h
433  class Tpipe; // satcat5/net_tpipe.h
434  }
435 
436  namespace util { // Other utilities
437  struct I2cAddr; // satcat5/cfg_i2c.h
438  struct TimeVal; // satcat5/timeref.h
439  class ListCore; // satcat5/list.h
440  template <class T>
441  class List; // satcat5/list.h
442  template <class T>
443  class LruCache; // satcat5/lru_cache.h
444  class Prng; // satcat5/utils.h
445  class RunningMax; // satcat5/utils.h
446  class TimeRef; // satcat5/timeref.h
447  class TimeRegister; // satcat5/timeref.h
448  template <unsigned W>
449  struct WideSigned; // satcat5/wide_integer.h
450  template <unsigned W>
451  struct WideUnsigned; // satcat5/wide_integer.h
452  }
453 }