libcoap  4.1.1
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
async.h
Go to the documentation of this file.
1 /* async.h -- state management for asynchronous messages
2  *
3  * Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
4  *
5  * This file is part of the CoAP library libcoap. Please see
6  * README for terms of use.
7  */
8 
15 #ifndef _COAP_ASYNC_H_
16 #define _COAP_ASYNC_H_
17 
18 #include "config.h"
19 #include "net.h"
20 
21 #ifndef WITHOUT_ASYNC
22 
32 typedef struct coap_async_state_t {
33  unsigned char flags;
40  coap_tick_t created;
41 
45  void *appdata;
46 
47  unsigned short message_id;
52  coap_address_t peer;
53  size_t tokenlen;
54  unsigned char token[];
56 
57 /* Definitions for Async Status Flags These flags can be used to
58  * control the behaviour of asynchronous response generation. */
59 #define COAP_ASYNC_CONFIRM 0x01
60 #define COAP_ASYNC_SEPARATE 0x02
61 #define COAP_ASYNC_OBSERVED 0x04
64 #define COAP_ASYNC_RELEASE_DATA 0x08
65 
88 coap_register_async(coap_context_t *context, coap_address_t *peer,
89  coap_pdu_t *request, unsigned char flags, void *data);
90 
109  coap_async_state_t **s);
110 
118 void
120 
134 
140 static inline void
142 
145 #endif /* WITHOUT_ASYNC */
146 
147 #endif /* _COAP_ASYNC_H_ */
coap_tick_t created
Holds the internal time when the object was registered with a resource.
Definition: async.h:40
void * appdata
This field can be used to register opaque application data with the asynchronous state object...
Definition: async.h:45
int coap_tid_t
Definition: pdu.h:155
unsigned char flags
holds the flags to control behaviour
Definition: async.h:33
coap_address_t peer
the peer to notify
Definition: async.h:52
coap_tid_t id
transaction id
Definition: async.h:48
void coap_ticks(coap_tick_t *)
Returns the current value of an internal tick counter.
Header structure for CoAP PDUs.
Definition: pdu.h:206
struct coap_async_state_t coap_async_state_t
coap_async_state_t * coap_register_async(coap_context_t *context, coap_address_t *peer, 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:25
static void coap_touch_async(coap_async_state_t *s)
Updates the time stamp of s.
Definition: async.h:141
int flags
Definition: client.c:26
int coap_remove_async(coap_context_t *context, coap_tid_t id, coap_async_state_t **s)
Removes the state object identified by id from context.
Definition: async.c:81
coap_async_state_t * coap_find_async(coap_context_t *context, coap_tid_t id)
Retrieves the object identified by id from the list of asynchronous transactions that are registered ...
Definition: async.c:74
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:93
unsigned short message_id
id of last message seen
Definition: async.h:47
size_t tokenlen
length of the token
Definition: async.h:53
unsigned char token[]
the token to use in a response
Definition: async.h:54
struct coap_async_state_t * next
internally used for linking
Definition: async.h:50
The CoAP stack's global state is stored in a coap_context_t object.
Definition: net.h:97