libcoap  4.3.0rc1
Go to the documentation of this file.
1 /*
2  * async.h -- state management for asynchronous messages
3  *
4  * Copyright (C) 2010-2011 Olaf Bergmann <>
5  *
6  * This file is part of the CoAP library libcoap. Please see README for terms
7  * of use.
8  */
15 #ifndef COAP_ASYNC_H_
16 #define COAP_ASYNC_H_
18 #include "coap2/net.h"
20 #ifndef WITHOUT_ASYNC
30 typedef struct coap_async_state_t {
31  unsigned char flags;
44  void *appdata;
48  size_t tokenlen;
49  uint8_t token[8];
52 /* Definitions for Async Status Flags These flags can be used to control the
53  * behaviour of asynchronous response generation.
54  */
55 #define COAP_ASYNC_CONFIRM 0x01
56 #define COAP_ASYNC_SEPARATE 0x02
84  coap_pdu_t *request,
85  unsigned char flags,
86  void *data);
104 int coap_remove_async(coap_context_t *context,
106  coap_mid_t id,
107  coap_async_state_t **s);
116 void
151 void
154 #endif /* WITHOUT_ASYNC */
156 #endif /* COAP_ASYNC_H_ */
void coap_delete_all_async(coap_context_t *context)
Removes and frees off all of the async entries for the given context.
Definition: async.c:109
void coap_ticks(coap_tick_t *t)
Sets t to the internal time with COAP_TICKS_PER_SECOND resolution.
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
Definition: coap_time.h:120
coap_async_state_t * coap_find_async(coap_context_t *context, coap_session_t *session, coap_mid_t id)
Retrieves the object identified by id from the list of asynchronous transactions that are registered ...
Definition: async.c:77
struct coap_async_state_t coap_async_state_t
coap_async_state_t * coap_register_async(coap_context_t *context, coap_session_t *session, coap_pdu_t *request, unsigned char flags, void *data)
Allocates a new coap_async_state_t object and fills its fields according to the given request.
Definition: async.c:30
void coap_free_async(coap_async_state_t *state)
Releases the memory that was allocated by coap_async_state_init() for the object s.
Definition: async.c:96
COAP_STATIC_INLINE void coap_touch_async(coap_async_state_t *s)
Updates the time stamp of s.
Definition: async.h:140
int coap_remove_async(coap_context_t *context, coap_session_t *session, coap_mid_t id, coap_async_state_t **s)
Removes the state object identified by id from context.
Definition: async.c:84
Definition: libcoap.h:38
int coap_mid_t
coap_mid_t is used to store the CoAP Message ID of a CoAP PDU.
Definition: pdu.h:244
coap_tick_t created
Holds the internal time when the object was registered with a resource.
Definition: async.h:38
unsigned char flags
holds the flags to control behaviour
Definition: async.h:31
void * appdata
This field can be used to register opaque application data with the asynchronous state object.
Definition: async.h:44
size_t tokenlen
length of the token
Definition: async.h:48
coap_session_t * session
transaction session
Definition: async.h:45
struct coap_async_state_t * next
internally used for linking
Definition: async.h:47
uint8_t token[8]
the token to use in a response
Definition: async.h:49
coap_mid_t id
message id
Definition: async.h:46
The CoAP stack's global state is stored in a coap_context_t object.
Definition: net.h:150
structure for CoAP PDUs token, if any, follows the fixed size header, then options until payload mark...
Definition: pdu.h:287