libcoap 4.3.5-develop-72190a8
|
Internal API for handling resources. More...
Data Structures | |
struct | coap_attr_t |
Limits the number of subscribers for each resource that this server support. More... | |
struct | coap_resource_t |
Abstraction of resource that can be attached to coap_context_t. More... | |
Macros | |
#define | RESOURCES_ADD(r, obj) HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj)) |
#define | RESOURCES_DELETE(r, obj) HASH_DELETE(hh, (r), (obj)) |
#define | RESOURCES_ITER(r, tmp) |
#define | RESOURCES_FIND(r, k, res) |
Functions | |
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_delete_all_resources (coap_context_t *context) |
Deletes all resources from given context and frees their storage. | |
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_delete_attr (coap_attr_t *attr) |
Deletes an attribute. | |
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 . | |
Internal API for handling resources.
#define RESOURCES_ADD | ( | r, | |
obj | |||
) | HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj)) |
Definition at line 148 of file coap_resource_internal.h.
#define RESOURCES_DELETE | ( | r, | |
obj | |||
) | HASH_DELETE(hh, (r), (obj)) |
Definition at line 151 of file coap_resource_internal.h.
#define RESOURCES_FIND | ( | r, | |
k, | |||
res | |||
) |
Definition at line 158 of file coap_resource_internal.h.
#define RESOURCES_ITER | ( | r, | |
tmp | |||
) |
Definition at line 154 of file coap_resource_internal.h.
void coap_add_resource_lkd | ( | coap_context_t * | context, |
coap_resource_t * | resource | ||
) |
Registers the given resource
for context
.
The resource must have been created by coap_resource_init() or coap_resource_unknown_init(), the storage allocated for the resource will be released by coap_delete_resource_lkd().
Note: This function must be called in the locked state.
context | The context to use. |
resource | The resource to store. |
void coap_delete_all_resources | ( | coap_context_t * | context | ) |
Deletes all resources from given context
and frees their storage.
context | The CoAP context with the resources to be deleted. |
void coap_delete_attr | ( | coap_attr_t * | attr | ) |
Deletes an attribute.
Note: This is for internal use only, as it is not deleted from its chain.
attr | Pointer to a previously created attribute. |
int coap_delete_resource_lkd | ( | coap_context_t * | context, |
coap_resource_t * | resource | ||
) |
Deletes a resource identified by resource
.
The storage allocated for that resource is freed, and removed from the context.
Note: This function must be called in the locked state.
context | This parameter is ignored, but kept for backward compatibility. |
resource | The resource to delete. |
1
if the resource was found (and destroyed), 0
otherwise. 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
.
If no resource was found, this function returns NULL
.
Note: This function must be called in the locked state.
context | The context to look for this resource. |
uri_path | The unique string uri of the resource. |
NULL
if not found. 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
.
This function sets buflen
to the number of bytes actually written and returns COAP_PRINT_STATUS_ERROR
on error. On error, the value in buflen
is undefined. Otherwise, the lower 28 bits are set to the number of bytes that have actually been written. COAP_PRINT_STATUS_TRUNC is set when the output has been truncated.
Note: This function must be called in the locked state.
context | The context with the resource map. |
buf | The buffer to write the result. |
buflen | Must be initialized to the maximum length of buf and will be set to the length of the well-known response on return. |
offset | The offset in bytes where the output shall start and is shifted accordingly with the characters that have been processed. This parameter is used to support the block option. |
query_filter | A filter query according to Link Format |
buf
. COAP_PRINT_STATUS_TRUNC is set when the output has been truncated.