libcoap 4.3.5-develop-ea01661
Loading...
Searching...
No Matches
coap_proxy_internal.h
Go to the documentation of this file.
1/*
2 * coap_proxy_internal.h -- Proxy functions for libcoap
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_INTERNAL_H_
18#define COAP_PROXY_INTERNAL_H_
19
20#include "coap_internal.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#if COAP_PROXY_SUPPORT
34/* Client <--> Proxy-Server | Proxy-Client <--> Server */
35
36typedef struct coap_proxy_cache_t {
37 UT_hash_handle hh;
38 coap_cache_key_t cache_req;
39 coap_pdu_t *req_pdu;
40 coap_pdu_t *rsp_pdu;
41 coap_tick_t expire;
42 uint64_t etag;
43 unsigned ref;
44} coap_proxy_cache_t;
45
46typedef struct coap_proxy_req_t {
47 struct coap_proxy_req_t *next;
48 coap_pdu_t *pdu;
49 coap_resource_t *resource;
50 coap_session_t *incoming;
51 coap_bin_const_t *token_used;
52 coap_cache_key_t *cache_key;
53 coap_proxy_cache_t *proxy_cache;
54 coap_mid_t mid;
55 unsigned doing_observe;
56} coap_proxy_req_t;
57
58struct coap_proxy_list_t {
59 coap_session_t *ongoing;
60 coap_session_t *incoming;
61 coap_proxy_req_t *proxy_req;
62 coap_proxy_cache_t *rsp_cache; /* Response cache list */
63 coap_uri_t uri;
64 uint8_t *uri_host_keep;
65 coap_tick_t idle_timeout_ticks;
68 coap_tick_t last_used;
69};
70
71typedef enum {
72 COAP_PROXY_SUBS_ALL,
73 COAP_PROXY_SUBS_TOKEN,
74 COAP_PROXY_SUBS_MID,
75} coap_proxy_subs_delete_t;
76
82void coap_proxy_cleanup(coap_context_t *context);
83
94int coap_proxy_check_timeouts(coap_context_t *context, coap_tick_t now,
95 coap_tick_t *tim_rem);
96
105int coap_proxy_remove_association(coap_session_t *session, int send_failure);
106
132int coap_proxy_forward_request_lkd(coap_session_t *session,
133 const coap_pdu_t *request,
134 coap_pdu_t *response,
135 coap_resource_t *resource,
136 coap_cache_key_t *cache_key,
137 coap_proxy_server_list_t *server_list);
138
153coap_response_t coap_proxy_forward_response_lkd(coap_session_t *session,
154 const coap_pdu_t *received,
155 coap_cache_key_t **cache_key);
156
178coap_session_t *coap_new_client_session_proxy_lkd(coap_context_t *context,
179 coap_proxy_server_list_t *server_list);
180
190coap_mid_t coap_proxy_local_write(coap_session_t *session, coap_pdu_t *pdu);
191
202struct coap_proxy_req_t *coap_proxy_map_outgoing_request(coap_session_t *ongoing,
203 const coap_pdu_t *received,
204 coap_proxy_list_t **proxy_entry);
205
217void coap_proxy_process_incoming(coap_session_t *session,
218 coap_pdu_t *rcvd, void *body_free,
219 coap_proxy_req_t *proxy_req,
220 coap_proxy_list_t *proxy_entry);
221
229void coap_proxy_del_req(coap_proxy_list_t *proxy_entry, coap_proxy_req_t *proxy_req);
230
240void coap_delete_proxy_subscriber(coap_session_t *session, coap_bin_const_t *token,
241 coap_mid_t mid, coap_proxy_subs_delete_t type);
242
245#define PROXY_CACHE_ADD(e, obj) \
246 HASH_ADD(hh, (e), cache_req, sizeof((obj)->cache_req), (obj))
247
248#define PROXY_CACHE_DELETE(e, obj) \
249 HASH_DELETE(hh, (e), (obj))
250
251#define PROXY_CACHE_ITER(e, el, rtmp) \
252 HASH_ITER(hh, (e), el, rtmp)
253
254#define PROXY_CACHE_ITER_SAFE(e, el, rtmp) \
255 for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
256
257#define PROXY_CACHE_FIND(e, k, res) { \
258 HASH_FIND(hh, (e), (k), sizeof(*k), (res)); \
259 }
260
261#endif /* COAP_PROXY_SUPPORT */
262
263#ifdef __cplusplus
264}
265#endif
266
267#endif /* COAP_PROXY_INTERNAL_H_ */
struct coap_proxy_list_t coap_proxy_list_t
Proxy information.
Pulls together all the internal only header files.
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
Definition coap_time.h:152
coap_response_t
Definition coap_net.h:57
int coap_mid_t
coap_mid_t is used to store the CoAP Message ID of a CoAP PDU.
Definition coap_pdu.h:268
CoAP binary data definition with const data.
Definition coap_str.h:67
The CoAP stack's global state is stored in a coap_context_t object.
structure for CoAP PDUs
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