|
SatCat5
|
CoAP server with a mix of local and reverse-proxy resources.
Handles incoming requests according to the URI-Path. Different URIs may point to local resources (i.e., the Resource base class) or proxy resources (i.e., the ProxyResource class). In the latter case, this server forwards requests to the next-hop server and matches incoming response metadata to the original requestor.
Definition at line 97 of file coap_proxy.h.
#include <coap_proxy.h>
Public Member Functions | |
| ProxyServer (satcat5::udp::Dispatch *udp, satcat5::udp::Port port=satcat5::udp::PORT_COAP) | |
| Constructor. By default, bind this server to port 5683. | |
| Connection * | find_client (u32 token) const |
| Given a token, find associated client connection. More... | |
| ConnectionUdp * | find_server (u32 token) const |
| Given a token, find associated server connection. More... | |
| u16 | next_msgid () |
| Outgoing messages are numbered sequentially. | |
| u32 | next_token () |
| Unique transaction tokens match client and server. | |
| void | add_resource (Resource *resource) |
| Add a Resource to the linked list. | |
| void | remove_resource (Resource *resource) |
| Remove a Resource from the linked list. | |
| satcat5::net::Dispatch * | iface () const |
| Fetch the associated network interface. | |
| satcat5::udp::Port | srcport () const |
| For UDP only, query the local port number. | |
| Connection * | find_token (u32 token) const |
| Scan connections for a matching proxy-ID. More... | |
| satcat5::coap::Connection * | get_idle_connection () const |
| Get the first idle connection, or null if all are busy. | |
| void | set_connection (satcat5::coap::Connection *obj) |
| Set the preferred connection for outgoing requests. More... | |
| void | set_filter (const satcat5::net::Type &filter) |
| Set network interface filter. More... | |
| void | bind (satcat5::udp::Port req_port=satcat5::udp::PORT_COAP) |
| Begin accepting incoming requests on the designated UDP port. | |
| satcat5::coap::ConnectionUdp * | connect (const satcat5::udp::Addr &dstaddr, const satcat5::udp::Port &dstport=satcat5::udp::PORT_COAP, const satcat5::udp::Port &srcport=satcat5::udp::PORT_NONE) |
| Open a connection to the designated remote UDP endpoint. More... | |
| satcat5::eth::Dispatch * | eth () const |
| Pointer to the parent's network interface. | |
| satcat5::ip::Dispatch * | ip () const |
| Pointer to the parent's network interface. | |
| satcat5::udp::Dispatch * | udp () const |
| Pointer to the parent's network interface. | |
Protected Member Functions | |
| virtual void | local_response (Connection *obj, Reader *msg) |
| Event handler for non-proxy responses. More... | |
| void | proxy_response (Connection *client, Reader *msg) |
| Internal handler for proxy responses. | |
| void | coap_response (Connection *obj, Reader *msg) override |
| The Child class overrides these event-handlers: More... | |
| void | coap_reqwait (Connection *obj, Reader *msg) override |
| The Child class overrides these event-handlers: More... | |
| void | coap_separate (Connection *obj, Reader *msg) override |
| The Child class overrides these event-handlers: More... | |
| void | coap_error (Connection *obj) override |
| The Child class overrides these event-handlers: More... | |
| void | coap_request (Connection *obj, Reader *msg) override |
| Handler for an incoming request. | |
| 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 | add_connection (Connection *item) |
| void | remove_connection (Connection *item) |
| bool | reply (u8 type, const satcat5::coap::ReadHeader *msg) |
| virtual void | coap_ping (const Reader *msg) |
| The Child class overrides these event-handlers: More... | |
| virtual void | coap_timeout (Connection *obj) |
| The Child class overrides these event-handlers: More... | |
Protected Attributes | |
| u16 | m_msgid |
| Counter for outgoing message-IDs. | |
| u32 | m_token |
| Counter for client/server tokens. | |
| satcat5::coap::ConnectionUdp | m_extra_connection |
| Proxy operation requires at least two ConnectionUdp objects. More... | |
| satcat5::util::List< Resource > | m_resources |
| List of resources. | |
| satcat5::coap::ConnectionUdp | m_connection |
| Single UDP connection. | |
| satcat5::net::Dispatch *const | m_iface |
| satcat5::util::List< satcat5::coap::Connection > | m_list |
| satcat5::coap::Connection * | m_prefer |
| satcat5::coap::Endpoint * | m_aux_ep |
| satcat5::net::Type | m_filter |
| Incoming packet filter. | |
| satcat5::coap::Endpoint *const | m_endpoint |
| Pointer to the associated Endpoint. | |
Private Attributes | |
| satcat5::net::Protocol * | m_next |
| Linked list of Protocols. | |
|
overrideprotectedvirtual |
The Child class overrides these event-handlers:
Reimplemented from satcat5::coap::Endpoint.
Definition at line 168 of file coap_proxy.cc.
|
inlineprotectedvirtualinherited |
The Child class overrides these event-handlers:
Reimplemented in satcat5::coap::EndpointSppFwd.
Definition at line 107 of file coap_endpoint.h.
|
overrideprotectedvirtual |
The Child class overrides these event-handlers:
Reimplemented from satcat5::coap::Endpoint.
Definition at line 156 of file coap_proxy.cc.
|
overrideprotectedvirtual |
The Child class overrides these event-handlers:
Reimplemented from satcat5::coap::Endpoint.
Definition at line 123 of file coap_proxy.cc.
|
overrideprotectedvirtual |
The Child class overrides these event-handlers:
Reimplemented from satcat5::coap::Endpoint.
Definition at line 162 of file coap_proxy.cc.
|
inlineprotectedvirtualinherited |
The Child class overrides these event-handlers:
Definition at line 108 of file coap_endpoint.h.
|
inherited |
Open a connection to the designated remote UDP endpoint.
In most cases, the source port should be left as PORT_NONE, which automatically chooses an unoccupied local port. (Use the returned coap::Connection object to issue requests.)
Definition at line 154 of file coap_endpoint.cc.
| Connection * ProxyServer::find_client | ( | u32 | token | ) | const |
Given a token, find associated client connection.
Clients may be Connection objects of any type.
Definition at line 100 of file coap_proxy.cc.
| ConnectionUdp * ProxyServer::find_server | ( | u32 | token | ) | const |
Given a token, find associated server connection.
Servers must always be ConnectionUDP objects.
Definition at line 108 of file coap_proxy.cc.
|
inherited |
Scan connections for a matching proxy-ID.
Definition at line 40 of file coap_endpoint.cc.
|
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 56 of file coap_endpoint.cc.
|
inlineprotectedvirtual |
Event handler for non-proxy responses.
By default, this placeholder method does nothing. If a child class issues non-proxy requests, then it should override this callback method to receive incoming responses.
Definition at line 122 of file coap_proxy.h.
|
inlineinherited |
Set the preferred connection for outgoing requests.
Usually called indirectly through ManageSpp or ManageUdp.
Definition at line 58 of file coap_endpoint.h.
|
inlineinherited |
Set network interface filter.
Usually called indirectly through ManageSpp or ManageUdp.
Definition at line 63 of file coap_endpoint.h.
|
protected |
Proxy operation requires at least two ConnectionUdp objects.
The child class may add more as needed for concurrency. Note: Do not add other types of coap::Connection objects.
Definition at line 141 of file coap_proxy.h.