libcoap 4.3.5-develop-aef27f2
Loading...
Searching...
No Matches
coap_proxy.h
Go to the documentation of this file.
1/*
2 * coap_proxy.h -- helper functions for proxy handling
3 *
4 * Copyright (C) 2024-2025 Jon Shallow <supjps-libcoap@jpshallow.com>
5 *
6 * SPDX-License-Identifier: BSD-2-Clause
7 *
8 * This file is part of the CoAP library libcoap. Please see README for terms
9 * of use.
10 */
11
17#ifndef COAP_PROXY_H_
18#define COAP_PROXY_H_
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
48typedef enum {
49 /* Old entries, now updated for flexibility */
65 /* New style Proxy types */
66 COAP_PROXY_REV = (1 << 3),
70 /* Start of additional optional bit mask mapping */
71 COAP_PROXY_BIT_STRIP = (1 << 6),
76 COAP_PROXY_BIT_MCAST = (1 << 7),
83
84#define COAP_PROXY_OLD_MASK 0x07
85#define COAP_PROXY_NEW_MASK 0x38
93
108
126typedef coap_pdu_t *(*coap_proxy_response_handler_t)(coap_session_t *session,
127 const coap_pdu_t *sent,
128 coap_pdu_t *received,
129 coap_cache_key_t *cache_key);
130
143
152
179 const coap_pdu_t *request,
180 coap_pdu_t *response,
181 coap_resource_t *resource,
182 coap_cache_key_t *cache_key,
183 coap_proxy_server_list_t *server_list);
184
198 const coap_pdu_t *received,
199 coap_cache_key_t **cache_key);
200
221 coap_proxy_server_list_t *server_list);
222
225#ifdef __cplusplus
226}
227#endif
228
229#endif /* COAP_PROXY_H_ */
#define COAP_API
coap_uri_scheme_t
The scheme specifiers.
Definition coap_uri.h:32
coap_response_t
Definition coap_net.h:54
void coap_register_proxy_response_handler(coap_context_t *context, coap_proxy_response_handler_t handler)
Registers a new message handler that is called whenever a response is received by the proxy logic.
Definition coap_net.c:5170
COAP_API coap_session_t * coap_new_client_session_proxy(coap_context_t *context, coap_proxy_server_list_t *server_list)
Creates a new client session to use the proxy logic going to the defined upstream server.
coap_proxy_t
coap_proxy_t Proxy definitions.
Definition coap_proxy.h:48
COAP_API int coap_proxy_forward_request(coap_session_t *req_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.
int coap_verify_proxy_scheme_supported(coap_uri_scheme_t scheme)
Verify that the CoAP Scheme is supported for an ongoing proxy connection.
coap_pdu_t *(* coap_proxy_response_handler_t)(coap_session_t *session, const coap_pdu_t *sent, coap_pdu_t *received, coap_cache_key_t *cache_key)
Proxy response handler that is used as callback held in coap_context_t.
Definition coap_proxy.h:126
coap_response_t COAP_API coap_proxy_forward_response(coap_session_t *rsp_session, const coap_pdu_t *received, coap_cache_key_t **cache_key)
Forward the returning response back to the appropriate client.
@ COAP_PROXY_DIRECT_STRIP
Old - do not use - Act as a forward-dynamic proxy, strip out proxy options.
Definition coap_proxy.h:57
@ COAP_PROXY_BIT_STRIP
If COAP_PROXY_BIT_STRIP set, then remove any Proxy-Uri or Proxy-Scheme, else leave them.
Definition coap_proxy.h:71
@ COAP_PROXY_REVERSE_STRIP
Old - do not use - Act as a reverse proxy, strip out proxy options.
Definition coap_proxy.h:51
@ COAP_PROXY_FORWARD_DYNAMIC
Old - do not use - Act as a forward-dynamic proxy.
Definition coap_proxy.h:59
@ COAP_PROXY_FWD_STATIC
forward-static proxy.
Definition coap_proxy.h:67
@ COAP_PROXY_REV
reverse proxy.
Definition coap_proxy.h:66
@ COAP_PROXY_REVERSE
Old - do not use - Act as a reverse proxy.
Definition coap_proxy.h:50
@ COAP_PROXY_DIRECT
Old - do not use - Act as a forward-dynamic proxy.
Definition coap_proxy.h:56
@ COAP_PROXY_FORWARD_DYNAMIC_STRIP
Old - do not use - Act as a forward-dynamic proxy, strip out proxy options.
Definition coap_proxy.h:61
@ COAP_PROXY_FORWARD_STRIP
Old - do not use - Act as a forward-static proxy, strip out proxy options.
Definition coap_proxy.h:54
@ COAP_PROXY_FWD_DYNAMIC
forward-dynamic proxy.
Definition coap_proxy.h:68
@ COAP_PROXY_FORWARD
Old - do not use - Act as a forward-static proxy.
Definition coap_proxy.h:53
@ COAP_PROXY_BIT_MCAST
If COAP_PROXY_BIT_MCAST set, then upstream servers can be multicast, else only unicast.
Definition coap_proxy.h:76
The CoAP stack's global state is stored in a coap_context_t object.
The structure used for defining the Client PSK setup data to be used.
Definition coap_dtls.h:414
The structure used for defining the PKI setup data to be used.
Definition coap_dtls.h:316
The structure used to hold the OSCORE configuration information.
structure for CoAP PDUs
int track_client_session
If 1, track individual connections to upstream server, else 0 for all clients to be multiplexed over ...
Definition coap_proxy.h:100
coap_proxy_server_t * entry
Set of servers to connect to.
Definition coap_proxy.h:95
coap_proxy_t type
The proxy type and option controlling bits (if old type used, will get mapped into new + bits.
Definition coap_proxy.h:98
unsigned int idle_timeout_secs
Proxy upstream session idle timeout (0 is no timeout).
Definition coap_proxy.h:103
size_t next_entry
Next server to use (% entry_count)
Definition coap_proxy.h:97
size_t entry_count
The number of servers in entry list.
Definition coap_proxy.h:96
coap_dtls_pki_t * dtls_pki
PKI configuration to use if not NULL.
Definition coap_proxy.h:89
coap_oscore_conf_t * oscore_conf
OSCORE configuration if not NULL.
Definition coap_proxy.h:91
coap_uri_t uri
host and port define the server, scheme method
Definition coap_proxy.h:88
coap_dtls_cpsk_t * dtls_cpsk
PSK configuration to use if not NULL.
Definition coap_proxy.h:90
Abstraction of resource that can be attached to coap_context_t.
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
Representation of parsed URI.
Definition coap_uri.h:72