SatCat5
coap_proxy.h File Reference

Detailed Description

CoAP reverse-proxy for specific resources.

The CoAP specification (RFC 7252) section 5.7 defines:

  • Forward-proxies: In which the client that issues a request specifies where it should be forwarded, using the Proxy-Uri option.
  • Reverse-proxies: In which the server decides that a request for a given resource should be forwarded to another server, and acts as a middleman.

This file defines classes used for reverse-proxies, which build on the coap::Resource concept (

See also
coap_resource.h):
  • coap::ProxyResource defines a CoAP resource whose requests should be forwarded to a CoAP server at a designated IP address and UDP port. The next-hop address can be configured separately for each resource.
  • coap::ProxyServer defines a CoAP endpoint that can service a mixture of local and/or proxy Resource objects.

To forward a request, coap::ProxyServer uses two coap::Connection objects:

  • The first Connection is to the client, opened by an incoming request.
  • That event calls ResourceServer::coap_request(), which reads the URI-Path option to identify the matching coap::Resource or coap::ProxyResource.
  • If the URI matches a coap::ProxyResource, then that object processes the get/post/put/delete request.
    See also
    ProxyResource::request_any.
  • The request_any callback opens (or reuses) a coap::Connection to the downstream server, then forwards the request contents. The outgoing message-ID is stored in both client and server objects.
  • When a response is received, that triggers ProxyServer::coap_response(), which tries to match the response's message-ID against the ID stored in the previous step, to find the original client Connection object.
  • If a match is found, ProxyServer::proxy_response forwards the response. Otherwise, it notifies a callback.
    See also
    ProxyServer::local_response.
    TODO: Support caching, etags, and the PROXY_URI tag.

Definition in file coap_proxy.h.

#include <satcat5/coap_connection.h>
#include <satcat5/coap_resource.h>
#include <satcat5/utils.h>
Include dependency graph for coap_proxy.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  satcat5::coap::ProxyResource
 Define a reverse-proxy CoAP resource. More...
 
class  satcat5::coap::ProxyServer
 CoAP server with a mix of local and reverse-proxy resources. More...