libcoap 4.3.5-develop-5010974
Loading...
Searching...
No Matches
coap_resource_internal.h
Go to the documentation of this file.
1/*
2 * coap_resource_internal.h -- generic resource handling
3 *
4 * Copyright (C) 2010,2011,2014-2026 Olaf Bergmann <bergmann@tzi.org>
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_RESOURCE_INTERNAL_H_
18#define COAP_RESOURCE_INTERNAL_H_
19
21#include "coap_uthash_internal.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#if COAP_SERVER_SUPPORT
39#ifndef COAP_RESOURCE_MAX_SUBSCRIBER
40#define COAP_RESOURCE_MAX_SUBSCRIBER 0
41#endif /* COAP_RESOURCE_MAX_SUBSCRIBER */
42
46struct coap_attr_t {
47 struct coap_attr_t *next;
48 coap_str_const_t *name;
49 coap_str_const_t *value;
50 int flags;
51};
52
57struct coap_resource_t {
58 unsigned int dirty:1;
59 unsigned int partiallydirty:1;
61 unsigned int observable:1;
62 unsigned int cacheable:1;
63 unsigned int is_unknown:1;
64 unsigned int is_proxy_uri:1;
65 unsigned int is_reverse_proxy:1;
66 unsigned int list_being_traversed:1;
67 unsigned int is_dynamic:1;
69 uint32_t ref;
77 coap_method_handler_t handler[7];
78
79 UT_hash_handle hh;
80
81 coap_attr_t *link_attr;
82 coap_subscription_t *subscribers;
89 coap_str_const_t *uri_path;
91 int flags;
97 unsigned int observe;
98
102 coap_context_t *context;
103
107 size_t proxy_name_count;
108
112 coap_str_const_t **proxy_name_list;
113
118 void *user_data;
119#if COAP_THREAD_SAFE
120 coap_lock_t lock;
121#endif /* COAP_THREAD_SAFE */
122
123};
124
125typedef enum coap_deleting_resource_t {
126 COAP_DELETING_RESOURCE,
127 COAP_NOT_DELETING_RESOURCE,
128 COAP_DELETING_RESOURCE_ON_EXIT
129} coap_deleting_resource_t;
130
141void coap_add_resource_lkd(coap_context_t *context, coap_resource_t *resource);
142
154int coap_delete_resource_lkd(coap_resource_t *resource);
155
166coap_resource_release_lkd(coap_resource_t *resource) {
167 return coap_delete_resource_lkd(resource);
168}
169
170
176void coap_delete_all_resources(coap_context_t *context);
177
185void coap_resource_reference_lkd(coap_resource_t *resource);
186
187#define RESOURCES_ADD(r, obj) \
188 HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj))
189
190#define RESOURCES_DELETE(r, obj) \
191 HASH_DELETE(hh, (r), (obj))
192
193#define RESOURCES_ITER(r,tmp) \
194 coap_resource_t *tmp, *rtmp; \
195 HASH_ITER(hh, (r), tmp, rtmp)
196
197#define RESOURCE_ITER_SAFE(e, el, rtmp) \
198 for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
199
200#define RESOURCES_FIND(r, k, res) { \
201 HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); \
202 }
203
215coap_resource_t *coap_get_resource_from_uri_path_lkd(coap_context_t *context,
216 coap_str_const_t *uri_path);
217
225void coap_delete_attr(coap_attr_t *attr);
226
251coap_print_status_t coap_print_wellknown_lkd(coap_context_t *context,
252 unsigned char *buf,
253 size_t *buflen,
254 size_t offset,
255 const coap_string_t *query_filter);
256
259#endif /* COAP_SERVER_SUPPORT */
260
261#ifdef __cplusplus
262}
263#endif
264
265#endif /* COAP_RESOURCE_INTERNAL_H_ */
struct coap_attr_t coap_attr_t
struct coap_subscription_t coap_subscription_t
struct coap_resource_t coap_resource_t
CoAP mapping of locking functions.
void(* coap_method_handler_t)(coap_resource_t *resource, coap_session_t *session, const coap_pdu_t *request, const coap_string_t *query, coap_pdu_t *response)
Definition of message handler function.
uint32_t coap_print_status_t
Status word to encode the result of conditional print or copy operations such as coap_print_link().
coap_mutex_t coap_lock_t
#define COAP_STATIC_INLINE
Definition libcoap.h:57
The CoAP stack's global state is stored in a coap_context_t object.
CoAP string data definition with const data.
Definition coap_str.h:47
CoAP string data definition.
Definition coap_str.h:39