libcoap 4.3.5b
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-2025 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
16
17#ifndef COAP_RESOURCE_INTERNAL_H_
18#define COAP_RESOURCE_INTERNAL_H_
19
21#include "coap_uthash_internal.h"
22
23#if COAP_SERVER_SUPPORT
30
35#ifndef COAP_RESOURCE_MAX_SUBSCRIBER
36#define COAP_RESOURCE_MAX_SUBSCRIBER 0
37#endif /* COAP_RESOURCE_MAX_SUBSCRIBER */
38
42struct coap_attr_t {
43 struct coap_attr_t *next;
44 coap_str_const_t *name;
45 coap_str_const_t *value;
46 int flags;
47};
48
53struct coap_resource_t {
54 unsigned int dirty:1;
55 unsigned int partiallydirty:1;
57 unsigned int observable:1;
58 unsigned int cacheable:1;
59 unsigned int is_unknown:1;
60 unsigned int is_proxy_uri:1;
61
69 coap_method_handler_t handler[7];
70
71 UT_hash_handle hh;
72
73 coap_attr_t *link_attr;
74 coap_subscription_t *subscribers;
75
81 coap_str_const_t *uri_path;
83 int flags;
84
89 unsigned int observe;
90
94 coap_context_t *context;
95
99 size_t proxy_name_count;
100
104 coap_str_const_t **proxy_name_list;
105
110 void *user_data;
111#if COAP_THREAD_SAFE
112 coap_lock_t lock;
113#endif /* COAP_THREAD_SAFE */
114
115};
116
127void coap_add_resource_lkd(coap_context_t *context, coap_resource_t *resource);
128
142int coap_delete_resource_lkd(coap_context_t *context, coap_resource_t *resource);
143
149void coap_delete_all_resources(coap_context_t *context);
150
151#define RESOURCES_ADD(r, obj) \
152 HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj))
153
154#define RESOURCES_DELETE(r, obj) \
155 HASH_DELETE(hh, (r), (obj))
156
157#define RESOURCES_ITER(r,tmp) \
158 coap_resource_t *tmp, *rtmp; \
159 HASH_ITER(hh, (r), tmp, rtmp)
160
161#define RESOURCES_FIND(r, k, res) { \
162 HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); \
163 }
164
176coap_resource_t *coap_get_resource_from_uri_path_lkd(coap_context_t *context,
177 coap_str_const_t *uri_path);
178
186void coap_delete_attr(coap_attr_t *attr);
187
212coap_print_status_t coap_print_wellknown_lkd(coap_context_t *context,
213 unsigned char *buf,
214 size_t *buflen,
215 size_t offset,
216 const coap_string_t *query_filter);
217
219
220#endif /* COAP_SERVER_SUPPORT */
221
222#endif /* COAP_RESOURCE_INTERNAL_H_ */
struct coap_attr_t coap_attr_t
struct coap_subscription_t coap_subscription_t
struct coap_context_t coap_context_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
struct coap_str_const_t coap_str_const_t
CoAP string data definition with const data.
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:46
CoAP string data definition.
Definition coap_str.h:38