Loading...
Searching...
No Matches
coap_proxy.h
Go to the documentation of this file.
/*
* coap_proxy.h -- helper functions for proxy handling
*
* Copyright (C) 2024 Jon Shallow <supjps-libcoap@jpshallow.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
*/
#ifndef COAP_PROXY_H_
#define COAP_PROXY_H_
typedef enum {
COAP_PROXY_REVERSE,
COAP_PROXY_REVERSE_STRIP,
COAP_PROXY_FORWARD,
COAP_PROXY_FORWARD_STRIP,
COAP_PROXY_DIRECT,
COAP_PROXY_DIRECT_STRIP,
} coap_proxy_t;
typedef struct coap_proxy_server_t {
coap_uri_t uri;
coap_dtls_pki_t *dtls_pki;
coap_dtls_cpsk_t *dtls_cpsk;
coap_oscore_conf_t *oscore_conf;
} coap_proxy_server_t;
typedef struct coap_proxy_server_list_t {
coap_proxy_server_t *entry;
size_t entry_count;
size_t next_entry;
coap_proxy_t type;
int track_client_session;
unsigned int idle_timeout_secs;
} coap_proxy_server_list_t;
int coap_verify_proxy_scheme_supported(coap_uri_scheme_t scheme);
int COAP_API coap_proxy_forward_request(coap_session_t *session,
const coap_pdu_t *request,
coap_pdu_t *response,
coap_resource_t *resource,
coap_cache_key_t *cache_key,
coap_proxy_server_list_t *server_list);
coap_response_t COAP_API coap_proxy_forward_response(coap_session_t *session,
const coap_pdu_t *received,
coap_cache_key_t **cache_key);
#endif /* COAP_PROXY_H_ */
COAP_API
#define COAP_API
Definition coap_libcoap_build.h:41
coap_uri_scheme_t
coap_uri_scheme_t
The scheme specifiers.
Definition coap_uri.h:28
coap_response_t
coap_response_t
Definition coap_net.h:48
coap_proxy_t
coap_proxy_t
Definition coap_proxy.h:27
coap_proxy_forward_response
coap_response_t COAP_API coap_proxy_forward_response(coap_session_t *session, const coap_pdu_t *received, coap_cache_key_t **cache_key)
Forward the returning response back to the appropriate client.
Definition coap_proxy.c:895
coap_verify_proxy_scheme_supported
int coap_verify_proxy_scheme_supported(coap_uri_scheme_t scheme)
Verify that the CoAP Scheme is supported for an ongoing proxy connection.
Definition coap_proxy.c:905
coap_proxy_forward_request
int COAP_API coap_proxy_forward_request(coap_session_t *session, const coap_pdu_t *request, coap_pdu_t *response, coap_resource_t *resource, coap_cache_key_t *cache_key, coap_proxy_server_list_t *server_list)
Forward incoming request upstream to the next proxy/server.
Definition coap_proxy.c:879
COAP_PROXY_DIRECT_STRIP
@ COAP_PROXY_DIRECT_STRIP
Act as a direct proxy, strip out proxy options.
Definition coap_proxy.h:33
COAP_PROXY_REVERSE_STRIP
@ COAP_PROXY_REVERSE_STRIP
Act as a reverse proxy, strip out proxy options.
Definition coap_proxy.h:29
COAP_PROXY_REVERSE
@ COAP_PROXY_REVERSE
Act as a reverse proxy.
Definition coap_proxy.h:28
COAP_PROXY_DIRECT
@ COAP_PROXY_DIRECT
Act as a direct proxy.
Definition coap_proxy.h:32
COAP_PROXY_FORWARD_STRIP
@ COAP_PROXY_FORWARD_STRIP
Act as a forward proxy, strip out proxy options.
Definition coap_proxy.h:31
COAP_PROXY_FORWARD
@ COAP_PROXY_FORWARD
Act as a forward proxy.
Definition coap_proxy.h:30
coap_cache_key_t
Definition coap_cache_internal.h:37
coap_dtls_cpsk_t
The structure used for defining the Client PSK setup data to be used.
Definition coap_dtls.h:410
coap_dtls_pki_t
The structure used for defining the PKI setup data to be used.
Definition coap_dtls.h:312
coap_oscore_conf_t
The structure used to hold the OSCORE configuration information.
Definition coap_oscore_internal.h:36
coap_pdu_t
structure for CoAP PDUs
Definition coap_pdu_internal.h:135
coap_proxy_server_list_t
Definition coap_proxy.h:43
coap_proxy_server_list_t::track_client_session
int track_client_session
If 1, track individual connections to upstream server, else 0.
Definition coap_proxy.h:48
coap_proxy_server_list_t::entry
coap_proxy_server_t * entry
Set of servers to connect to.
Definition coap_proxy.h:44
coap_proxy_server_list_t::type
coap_proxy_t type
The proxy type.
Definition coap_proxy.h:47
coap_proxy_server_list_t::idle_timeout_secs
unsigned int idle_timeout_secs
Proxy session idle timeout (0 is no timeout).
Definition coap_proxy.h:50
coap_proxy_server_list_t::next_entry
size_t next_entry
Next server to us (% entry_count).
Definition coap_proxy.h:46
coap_proxy_server_list_t::entry_count
size_t entry_count
The number of servers.
Definition coap_proxy.h:45
coap_proxy_server_t
Definition coap_proxy.h:36
coap_proxy_server_t::dtls_pki
coap_dtls_pki_t * dtls_pki
PKI configuration to use if not NULL.
Definition coap_proxy.h:38
coap_proxy_server_t::oscore_conf
coap_oscore_conf_t * oscore_conf
OSCORE configuration if not NULL.
Definition coap_proxy.h:40
coap_proxy_server_t::uri
coap_uri_t uri
host and port define the server, scheme method
Definition coap_proxy.h:37
coap_proxy_server_t::dtls_cpsk
coap_dtls_cpsk_t * dtls_cpsk
PSK configuration to use if not NULL.
Definition coap_proxy.h:39
coap_resource_t
Abstraction of resource that can be attached to coap_context_t.
Definition coap_resource_internal.h:53
coap_session_t
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
Definition coap_session_internal.h:68
coap_uri_t
Representation of parsed URI.
Definition coap_uri.h:65