net: coap: add coap_pendings_clear and coap_replies_clear
Clears whole stack of pendins and replies. Signed-off-by: Kiril Petrov <retfie@gmail.com>
This commit is contained in:
parent
d4f1f2a07e
commit
7305e7b4a2
2 changed files with 37 additions and 0 deletions
|
@ -768,6 +768,15 @@ bool coap_pending_cycle(struct coap_pending *pending);
|
|||
*/
|
||||
void coap_pending_clear(struct coap_pending *pending);
|
||||
|
||||
/**
|
||||
* @brief Cancels all pending retransmissions, so they become
|
||||
* available again.
|
||||
*
|
||||
* @param pendings Pointer to the array of #coap_pending structures
|
||||
* @param len Size of the array of #coap_pending structures
|
||||
*/
|
||||
void coap_pendings_clear(struct coap_pending *pendings, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Cancels awaiting for this reply, so it becomes available
|
||||
* again. User responsibility to free the memory associated with data.
|
||||
|
@ -776,6 +785,14 @@ void coap_pending_clear(struct coap_pending *pending);
|
|||
*/
|
||||
void coap_reply_clear(struct coap_reply *reply);
|
||||
|
||||
/**
|
||||
* @brief Cancels all replies, so they become available again.
|
||||
*
|
||||
* @param replies Pointer to the array of #coap_reply structures
|
||||
* @param len Size of the array of #coap_reply structures
|
||||
*/
|
||||
void coap_replies_clear(struct coap_reply *replies, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Indicates that this resource was updated and that the @a
|
||||
* notify callback should be called for every registered observer.
|
||||
|
|
|
@ -1226,6 +1226,16 @@ void coap_pending_clear(struct coap_pending *pending)
|
|||
pending->data = NULL;
|
||||
}
|
||||
|
||||
void coap_pendings_clear(struct coap_pending *pendings, size_t len)
|
||||
{
|
||||
struct coap_pending *p;
|
||||
size_t i;
|
||||
|
||||
for (i = 0, p = pendings; i < len; i++, p++) {
|
||||
coap_pending_clear(p);
|
||||
}
|
||||
}
|
||||
|
||||
static int get_observe_option(const struct coap_packet *cpkt)
|
||||
{
|
||||
struct coap_option option = {};
|
||||
|
@ -1318,6 +1328,16 @@ void coap_reply_clear(struct coap_reply *reply)
|
|||
(void)memset(reply, 0, sizeof(*reply));
|
||||
}
|
||||
|
||||
void coap_replies_clear(struct coap_reply *replies, size_t len)
|
||||
{
|
||||
struct coap_reply *r;
|
||||
size_t i;
|
||||
|
||||
for (i = 0, r = replies; i < len; i++, r++) {
|
||||
coap_reply_clear(r);
|
||||
}
|
||||
}
|
||||
|
||||
int coap_resource_notify(struct coap_resource *resource)
|
||||
{
|
||||
struct coap_observer *o;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue