libcoap  4.3.0rc2
resource.h File Reference

Generic resource handling. More...

#include "uthash.h"
#include "async.h"
#include "block.h"
#include "str.h"
#include "pdu.h"
#include "net.h"
#include "subscribe.h"
+ Include dependency graph for resource.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


 The interval in seconds to check if resources have changed. More...
 The URI passed to coap_resource_init() is free'd by coap_delete_resource(). More...
 Notifications will be sent non-confirmable by default. More...
 Notifications will be sent confirmable. More...
 Notifications will always be sent non-confirmable. More...
#define COAP_PRINT_STATUS_MASK   0xF0000000u
#define COAP_PRINT_STATUS_ERROR   0x80000000u
#define COAP_PRINT_STATUS_TRUNC   0x40000000u
#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)


typedef void(* coap_method_handler_t) (coap_context_t *, coap_resource_t *, coap_session_t *, coap_pdu_t *, coap_binary_t *, coap_string_t *, coap_pdu_t *)
 Definition of message handler function. More...
typedef void(* coap_resource_release_userdata_handler_t) (void *user_data)
 Definition of release resource user_data callback function. More...
typedef unsigned int coap_print_status_t
 Status word to encode the result of conditional print or copy operations such as coap_print_link(). More...


coap_resource_tcoap_resource_init (coap_str_const_t *uri_path, int flags)
 Creates a new resource object and initializes the link field to the string uri_path. More...
coap_resource_tcoap_resource_unknown_init (coap_method_handler_t put_handler)
 Creates a new resource object for the unknown resource handler with support for PUT. More...
coap_resource_tcoap_resource_proxy_uri_init (coap_method_handler_t handler, size_t host_name_count, const char *host_name_list[])
 Creates a new resource object for handling proxy URIs. More...
coap_resource_tcoap_get_resource_from_uri_path (coap_context_t *context, coap_str_const_t *uri_path)
 Returns the resource identified by the unique string uri_path. More...
coap_str_const_tcoap_resource_get_uri_path (coap_resource_t *resource)
 Get the uri_path from a resource. More...
void coap_resource_set_mode (coap_resource_t *resource, int mode)
 Sets the notification message type of resource resource to given mode. More...
void coap_resource_set_userdata (coap_resource_t *resource, void *data)
 Sets the user_data. More...
void * coap_resource_get_userdata (coap_resource_t *resource)
 Gets the user_data. More...
void coap_resource_release_userdata_handler (coap_context_t *context, coap_resource_release_userdata_handler_t callback)
 Defines the context wide callback to use to when the resource is deleted to release the data held in the resource's user_data. More...
void coap_add_resource (coap_context_t *context, coap_resource_t *resource)
 Registers the given resource for context. More...
int coap_delete_resource (coap_context_t *context, coap_resource_t *resource)
 Deletes a resource identified by resource. More...
void coap_register_handler (coap_resource_t *resource, coap_request_t method, coap_method_handler_t handler)
 Registers the specified handler as message handler for the request type method. More...
coap_attr_tcoap_add_attr (coap_resource_t *resource, coap_str_const_t *name, coap_str_const_t *value, int flags)
 Registers a new attribute with the given resource. More...
coap_attr_tcoap_find_attr (coap_resource_t *resource, coap_str_const_t *name)
 Returns resource's coap_attr_t object with given name if found, NULL otherwise. More...
coap_str_const_tcoap_attr_get_value (coap_attr_t *attribute)
 Returns attribute's value. More...
coap_print_status_t coap_print_link (const coap_resource_t *resource, unsigned char *buf, size_t *len, size_t *offset)
 Writes a description of this resource in link-format to given text buffer. More...
COAP_DEPRECATED int coap_resource_set_dirty (coap_resource_t *r, const coap_string_t *query)

Detailed Description

Generic resource handling.

Definition in file resource.h.

Macro Definition Documentation



The interval in seconds to check if resources have changed.

Definition at line 20 of file resource.h.


#define RESOURCES_ADD (   r,
)     HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj))

Definition at line 384 of file resource.h.


#define RESOURCES_DELETE (   r,
)     HASH_DELETE(hh, (r), (obj))

Definition at line 387 of file resource.h.


#define RESOURCES_FIND (   r,
{ \
HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); \

Definition at line 394 of file resource.h.


#define RESOURCES_ITER (   r,
coap_resource_t *tmp, *rtmp; \
HASH_ITER(hh, (r), tmp, rtmp)
Abstraction of resource that can be attached to coap_context_t.

Definition at line 390 of file resource.h.

Function Documentation

◆ coap_resource_set_dirty()

COAP_DEPRECATED int coap_resource_set_dirty ( coap_resource_t r,
const coap_string_t query 
use coap_resource_notify_observers() instead.

Definition at line 955 of file resource.c.

+ Here is the call graph for this function: