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