libcoap 4.3.5-develop-146e0bb
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
20#include "coap_uthash_internal.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#if COAP_SERVER_SUPPORT
38#ifndef COAP_RESOURCE_MAX_SUBSCRIBER
39#define COAP_RESOURCE_MAX_SUBSCRIBER 0
40#endif /* COAP_RESOURCE_MAX_SUBSCRIBER */
41
45struct coap_attr_t {
46 struct coap_attr_t *next;
47 coap_str_const_t *name;
48 coap_str_const_t *value;
49 int flags;
50};
51
56struct coap_resource_t {
57 unsigned int dirty:1;
58 unsigned int partiallydirty:1;
60 unsigned int observable:1;
61 unsigned int cacheable:1;
62 unsigned int is_unknown:1;
63 unsigned int is_proxy_uri:1;
64 unsigned int is_reverse_proxy:1;
65 unsigned int list_being_traversed:1;
66 unsigned int is_dynamic:1;
68 uint32_t ref;
76 coap_method_handler_t handler[7];
77
78 UT_hash_handle hh;
79
80 coap_attr_t *link_attr;
81 coap_subscription_t *subscribers;
88 coap_str_const_t *uri_path;
90 int flags;
96 unsigned int observe;
97
101 coap_context_t *context;
102
106 size_t proxy_name_count;
107
111 coap_str_const_t **proxy_name_list;
112
117 void *user_data;
118
119};
120
131void coap_add_resource_lkd(coap_context_t *context, coap_resource_t *resource);
132
146int coap_delete_resource_lkd(coap_context_t *context, coap_resource_t *resource);
147
153void coap_delete_all_resources(coap_context_t *context);
154
162void coap_resource_reference_lkd(coap_resource_t *resource);
163
173void coap_resource_release_lkd(coap_resource_t *resource);
174
175#define RESOURCES_ADD(r, obj) \
176 HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj))
177
178#define RESOURCES_DELETE(r, obj) \
179 HASH_DELETE(hh, (r), (obj))
180
181#define RESOURCES_ITER(r,tmp) \
182 coap_resource_t *tmp, *rtmp; \
183 HASH_ITER(hh, (r), tmp, rtmp)
184
185#define RESOURCES_FIND(r, k, res) { \
186 HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); \
187 }
188
200coap_resource_t *coap_get_resource_from_uri_path_lkd(coap_context_t *context,
201 coap_str_const_t *uri_path);
202
210void coap_delete_attr(coap_attr_t *attr);
211
236coap_print_status_t coap_print_wellknown_lkd(coap_context_t *context,
237 unsigned char *buf,
238 size_t *buflen,
239 size_t offset,
240 const coap_string_t *query_filter);
241
244#endif /* COAP_SERVER_SUPPORT */
245
246#ifdef __cplusplus
247}
248#endif
249
250#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
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().
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