SatCat5
udp_keep_alive.h
1 // Copyright 2025 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
5 // Send and receive keep-alive messages.
6 
7 #pragma once
8 #include <satcat5/udp_core.h>
9 
10 namespace satcat5 {
11  namespace udp {
25  class KeepAlive
26  : public satcat5::net::Protocol
27  , public satcat5::poll::Timer {
28  public:
33  explicit KeepAlive(
35  satcat5::udp::Port port,
36  const char* label = nullptr);
37  ~KeepAlive();
38 
42  void connect(
43  const satcat5::ip::Addr& dstaddr,
44  const satcat5::eth::VlanTag& vtag = satcat5::eth::VTAG_NONE);
45 
47  void send_now(const char* msg);
48 
49  protected:
50  void frame_rcvd(satcat5::io::LimitedRead& src) override;
51  void timer_event() override;
52 
53  satcat5::udp::Address m_addr;
54  const char* const m_label;
55  };
56  }
57 }
Limited read of next N bytes.
Definition: io_readable.h:255
A net::Protocol is the counterpart to net::Dispatch that handles a particular data stream,...
Definition: net_protocol.h:28
Timer objects are polled after a fixed delay or at a regular interval.
Definition: polling.h:213
Implementation of "net::Address" for UDP Dispatch.
Definition: udp_core.h:72
Dispatcher sorts incoming UDP messages by port index.
Definition: udp_dispatch.h:20
Send and receive keep-alive messages.
void timer_event() override
Child class MUST override this method.
void send_now(const char *msg)
Immediately send a keep-alive, with an optional message.
void connect(const satcat5::ip::Addr &dstaddr, const satcat5::eth::VlanTag &vtag=satcat5::eth::VTAG_NONE)
Connect to a specific destination address.
void frame_rcvd(satcat5::io::LimitedRead &src) override
Dispatch calls frame_rcvd(...) for each incoming frame with with a matching net::Type value.
KeepAlive(satcat5::udp::Dispatch *iface, satcat5::udp::Port port, const char *label=nullptr)
Bind this object to a network interface and UDP port.
Header contents for an 802.1Q Virtual-LAN tag.
Definition: eth_header.h:124
IPv4 address is a 32-bit unsigned integer.
Definition: ip_core.h:15
UDP and TCP ports are both 16-bit unsigned integers.
Definition: ip_core.h:119