• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * coap_async_internal.h -- state management for asynchronous messages
3  *
4  * Copyright (C) 2010-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 
12 /**
13  * @file coap_async_internal.h
14  * @brief CoAP async internal information
15  */
16 
17 #ifndef COAP_ASYNC_INTERNAL_H_
18 #define COAP_ASYNC_INTERNAL_H_
19 
20 #include "coap3/net.h"
21 
22 #ifndef WITHOUT_ASYNC
23 
24 /**
25  * @defgroup coap_async_internal Asynchronous Messaging (Internal)
26  * @{
27  * CoAP Async Structures, Enums and Functions that are not exposed to
28  * applications.
29  * A coap_context_t object holds a list of coap_async_t objects that can be
30  * used to generate a separate response in the case a result of a request cannot
31  * be delivered immediately.
32  */
33 struct coap_async_t {
34   struct coap_async_t *next; /**< internally used for linking */
35   coap_tick_t delay;    /**< When to delay to before triggering the response
36                              0 indicates never trigger */
37   coap_session_t *session;         /**< transaction session */
38   coap_pdu_t *pdu;                 /**< copy of request pdu */
39   void* appdata;                   /** User definable data pointer */
40 };
41 
42 /**
43  * Checks if there are any pending Async requests - if so, send them off.
44  * Otherewise return the time remaining for the next Async to be triggered
45  * or 0 if nothing to do.
46  *
47  * @param context The current context.
48  * @param now     The current time in ticks.
49  *
50  * @return The tick time before the next Async needs to go, else 0 if
51  *         nothing to do.
52  */
53 coap_tick_t coap_check_async(coap_context_t *context, coap_tick_t now);
54 
55 /**
56  * Removes and frees off all of the async entries for the given context.
57  *
58  * @param context The context to remove all async entries from.
59  */
60 void
61 coap_delete_all_async(coap_context_t *context);
62 
63 /** @} */
64 
65 #endif /*  WITHOUT_ASYNC */
66 
67 #endif /* COAP_ASYNC_INTERNAL_H_ */
68