libcoap  4.3.0
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-2021 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 "uthash.h"
21 
31 struct coap_attr_t {
32  struct coap_attr_t *next;
35  int flags;
36 };
37 
43  unsigned int dirty:1;
44  unsigned int partiallydirty:1;
46  unsigned int observable:1;
47  unsigned int cacheable:1;
48  unsigned int is_unknown:1;
49  unsigned int is_proxy_uri:1;
59 
60  UT_hash_handle hh;
61 
72  int flags;
78  unsigned int observe;
79 
84 
89 
94 
99  void *user_data;
100 
101 };
102 
109 
110 #define RESOURCES_ADD(r, obj) \
111  HASH_ADD(hh, (r), uri_path->s[0], (obj)->uri_path->length, (obj))
112 
113 #define RESOURCES_DELETE(r, obj) \
114  HASH_DELETE(hh, (r), (obj))
115 
116 #define RESOURCES_ITER(r,tmp) \
117  coap_resource_t *tmp, *rtmp; \
118  HASH_ITER(hh, (r), tmp, rtmp)
119 
120 #define RESOURCES_FIND(r, k, res) { \
121  HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); \
122  }
123 
131 void coap_delete_attr(coap_attr_t *attr);
132 
134  unsigned char *,
135  size_t *, size_t,
136  coap_opt_t *);
137 
138 
141 #endif /* COAP_RESOURCE_INTERNAL_H_ */
coap_print_status_t coap_print_wellknown(coap_context_t *, unsigned char *, size_t *, size_t, coap_opt_t *)
Prints the names of all known resources to buf.
Definition: resource.c:171
void coap_delete_all_resources(coap_context_t *context)
Deletes all resources from given context and frees their storage.
Definition: resource.c:590
void coap_delete_attr(coap_attr_t *attr)
Deletes an attribute.
Definition: resource.c:468
unsigned int coap_print_status_t
Status word to encode the result of conditional print or copy operations such as coap_print_link().
Definition: resource.h:324
void(* coap_method_handler_t)(coap_resource_t *, coap_session_t *, const coap_pdu_t *, const coap_string_t *, coap_pdu_t *)
Definition of message handler function.
Definition: resource.h:42
uint8_t coap_opt_t
Use byte-oriented access methods here because sliding a complex struct coap_opt_t over the data buffe...
Definition: option.h:26
Abstraction of attribute associated with a resource.
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: str.h:40
Subscriber information.