SatCat5
coap_posix.cc
1 // Copyright 2024-2025 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
5 
6 #include <hal_posix/coap_posix.h>
7 #include <satcat5/udp_dispatch.h>
8 
11 
12 ManageUdpHeap::ManageUdpHeap(satcat5::coap::Endpoint* coap, unsigned size)
13  : ManageUdp(coap)
14 {
16  for (unsigned a = 0 ; a < size ; ++a)
17  m_connections.push_back(new ConnectionUdp(coap, udp));
18 }
19 
20 ManageUdpHeap::~ManageUdpHeap() {
21  for (auto a = m_connections.begin() ; a != m_connections.end() ; ++a)
22  delete *a;
23 }
24 
26  : Endpoint(udp)
27  , ManageUdpHeap(this, size)
28 {
29  // Nothing else to initialize.
30 }
Variant of coap::Connection for UDP connections.
CoAP endpoint (i.e., client, server, or combined client+server).
Definition: coap_endpoint.h:41
satcat5::net::Dispatch * iface() const
Fetch the associated network interface.
Definition: coap_endpoint.h:44
CoAP client/server implementation that requires POSIX features.
Definition: coap_posix.h:35
EndpointUdpHeap(satcat5::udp::Dispatch *udp, unsigned size)
Constructor binds to the specified UDP interface and immediately allocates each requested Connection ...
Definition: coap_posix.cc:25
Variant of ManageUdp using heap-allocated Connection objects.
Definition: coap_posix.h:15
std::vector< ConnectionUdp * > m_connections
Pointers to heap-allocated Connection objects.
Definition: coap_posix.h:28
Connection manager for CoAP endpoints using UDP.
satcat5::udp::Dispatch * udp() const
Pointer to the parent's network interface.
Dispatcher sorts incoming UDP messages by port index.
Definition: udp_dispatch.h:20