libcoap 4.3.5-develop-72190a8
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-2024 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_internal.h"
21#include "coap_uthash_internal.h"
22
23#if COAP_SERVER_SUPPORT
35#ifndef COAP_RESOURCE_MAX_SUBSCRIBER
36#define COAP_RESOURCE_MAX_SUBSCRIBER 0
37#endif /* COAP_RESOURCE_MAX_SUBSCRIBER */
38
48
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;
70
71 UT_hash_handle hh;
72
83 int flags;
89 unsigned int observe;
90
95
100
105
111
112};
113
125
140
147
148#define RESOURCES_ADD(r, obj) \
149 HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj))
150
151#define RESOURCES_DELETE(r, obj) \
152 HASH_DELETE(hh, (r), (obj))
153
154#define RESOURCES_ITER(r,tmp) \
155 coap_resource_t *tmp, *rtmp; \
156 HASH_ITER(hh, (r), tmp, rtmp)
157
158#define RESOURCES_FIND(r, k, res) { \
159 HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); \
160 }
161
174 coap_str_const_t *uri_path);
175
184
210 unsigned char *buf,
211 size_t *buflen,
212 size_t offset,
213 const coap_string_t *query_filter);
214
217#endif /* COAP_SERVER_SUPPORT */
218
219#endif /* COAP_RESOURCE_INTERNAL_H_ */
Pulls together all the internal only header files.
void coap_delete_all_resources(coap_context_t *context)
Deletes all resources from given context and frees their storage.
coap_print_status_t coap_print_wellknown_lkd(coap_context_t *context, unsigned char *buf, size_t *buflen, size_t offset, const coap_string_t *query_filter)
Prints the names of all known resources for context to buf.
void coap_delete_attr(coap_attr_t *attr)
Deletes an attribute.
coap_resource_t * coap_get_resource_from_uri_path_lkd(coap_context_t *context, coap_str_const_t *uri_path)
Returns the resource identified by the unique string uri_path.
void coap_add_resource_lkd(coap_context_t *context, coap_resource_t *resource)
Registers the given resource for context.
int coap_delete_resource_lkd(coap_context_t *context, coap_resource_t *resource)
Deletes a resource identified by resource.
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().
Limits the number of subscribers for each resource that this server support.
coap_str_const_t * value
Value of the attribute (can be NULL)
struct coap_attr_t * next
Pointer to next in chain or NULL.
coap_str_const_t * name
Name of the attribute.
The CoAP stack's global state is stored in a coap_context_t object.
Abstraction of resource that can be attached to coap_context_t.
unsigned int dirty
set to 1 if resource has changed
unsigned int partiallydirty
set to 1 if some subscribers have not yet been notified of the last change
coap_subscription_t * subscribers
list of observers for this resource
void * user_data
This pointer is under user control.
coap_str_const_t ** proxy_name_list
Array valid names this host is known by (proxy support)
coap_str_const_t * uri_path
Request URI Path for this resource.
unsigned int observe
The next value for the Observe option.
unsigned int cacheable
can be cached
coap_context_t * context
Pointer back to the context that 'owns' this resource.
coap_method_handler_t handler[7]
Used to store handlers for the seven coap methods GET, POST, PUT, DELETE, FETCH, PATCH and IPATCH.
unsigned int is_proxy_uri
resource created for proxy URI handler
unsigned int is_unknown
resource created for unknown handler
coap_attr_t * link_attr
attributes to be included with the link format
unsigned int observable
can be observed
size_t proxy_name_count
Count of valid names this host is known by (proxy support)
int flags
zero or more COAP_RESOURCE_FLAGS_* or'd together
CoAP string data definition with const data.
Definition coap_str.h:46
CoAP string data definition.
Definition coap_str.h:38
Number of notifications that may be sent non-confirmable before a confirmable message is sent to dete...