async.h
Go to the documentation of this file.
/*
* async.h -- state management for asynchronous messages
*
* Copyright (C) 2010-2011 Olaf Bergmann <bergmann@tzi.org>
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
*/
#ifndef COAP_ASYNC_H_
#define COAP_ASYNC_H_
#include "net.h"
#ifndef WITHOUT_ASYNC
typedef struct coap_async_state_t {
unsigned char flags;
coap_tick_t created;
void *appdata;
coap_session_t *session;
coap_tid_t id;
struct coap_async_state_t *next;
size_t tokenlen;
uint8_t token[8];
} coap_async_state_t;
/* Definitions for Async Status Flags These flags can be used to control the
* behaviour of asynchronous response generation.
*/
#define COAP_ASYNC_CONFIRM 0x01
#define COAP_ASYNC_SEPARATE 0x02
#define COAP_ASYNC_OBSERVED 0x04
#define COAP_ASYNC_RELEASE_DATA 0x08
coap_async_state_t *
coap_register_async(coap_context_t *context,
coap_session_t *session,
coap_pdu_t *request,
unsigned char flags,
void *data);
int coap_remove_async(coap_context_t *context,
coap_session_t *session,
coap_tid_t id,
coap_async_state_t **s);
void
coap_free_async(coap_async_state_t *state);
coap_async_state_t *coap_find_async(coap_context_t *context, coap_session_t *session, coap_tid_t id);
COAP_STATIC_INLINE void
coap_touch_async(coap_async_state_t *s) { coap_ticks(&s->created); }
#endif /* WITHOUT_ASYNC */
#endif /* COAP_ASYNC_H_ */
coap_async_state_t::created
coap_tick_t created
Holds the internal time when the object was registered with a resource.
Definition: async.h:39
coap_session_t
Definition: coap_session.h:59
coap_async_state_t::appdata
void * appdata
This field can be used to register opaque application data with the asynchronous state object...
Definition: async.h:45
net.h
coap_tid_t
int coap_tid_t
coap_tid_t is used to store CoAP transaction id, i.e.
Definition: pdu.h:238
coap_async_state_t::flags
unsigned char flags
holds the flags to control behaviour
Definition: async.h:32
coap_async_state_t
Definition: async.h:31
coap_touch_async
COAP_STATIC_INLINE void coap_touch_async(coap_async_state_t *s)
Updates the time stamp of s.
Definition: async.h:142
coap_async_state_t::id
coap_tid_t id
transaction id
Definition: async.h:47
coap_async_state_t::session
coap_session_t * session
transaction session
Definition: async.h:46
coap_pdu_t
structure for CoAP PDUs token, if any, follows the fixed size header, then options until payload mark...
Definition: pdu.h:287
coap_async_state_t
struct coap_async_state_t coap_async_state_t
coap_tick_t
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
Definition: coap_time.h:93
coap_register_async
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
coap_remove_async
int coap_remove_async(coap_context_t *context, coap_session_t *session, coap_tid_t id, coap_async_state_t **s)
Removes the state object identified by id from context.
Definition: async.c:84
coap_ticks
void coap_ticks(coap_tick_t *t)
Sets t to the internal time with COAP_TICKS_PER_SECOND resolution.
COAP_STATIC_INLINE
#define COAP_STATIC_INLINE
Definition: libcoap.h:38
coap_find_async
coap_async_state_t * coap_find_async(coap_context_t *context, coap_session_t *session, coap_tid_t id)
Retrieves the object identified by id from the list of asynchronous transactions that are registered ...
Definition: async.c:77
coap_free_async
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_async_state_t::token
uint8_t token[8]
the token to use in a response
Definition: async.h:50
coap_async_state_t::tokenlen
size_t tokenlen
length of the token
Definition: async.h:49
coap_async_state_t::next
struct coap_async_state_t * next
internally used for linking
Definition: async.h:48
uint8_t
unsigned char uint8_t
Definition: uthash.h:79
coap_context_t
The CoAP stack&#39;s global state is stored in a coap_context_t object.
Definition: net.h:147