mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-28 01:27:09 +03:00
net.c: Delay sending ACK until after response_handler() is called
In handle_response() the ACK is sent before calling ctx->response_handler() so if the response_handler() wants to send RST the server ignores it as the ACK has already been received. By updating coap_response_handler_t to return a value, this can be used to send the ACK (return of COAP_RESPONSE_OK) or a RST (return of COAP_RESPONSE_FAIL) after ctx->response_handler() is called. include/coap2/net.h: man/coap_handler.txt.in: Create a new enum coap_response_t for use as the return value for coap_response_handler_t. Update coap_response_handler_t and associated documentation. src/net.c: Send CoAP ACK or RST depending on return value of ctx->response_handler(). examples/client.c: Update message_handler() to use the new coap_response_handler_t return values (coap_response_t).
This commit is contained in:
1 parent
b0e47d71d0
commit
14e75a54b8
5 files changed
+61
-34
No files matched your search
+13
-5
@@ -79,6 +79,11 @@ void coap_delete_all(coap_queue_t *queue);
|
||||
*/
|
||||
coap_queue_t *coap_new_node(void);
|
||||
|
||||
typedef enum coap_response_t {
|
||||
COAP_RESPONSE_FAIL, /**< Response not liked - send CoAP RST packet */
|
||||
COAP_RESPONSE_OK /**< Response is fine */
|
||||
} coap_response_t;
|
||||
|
||||
/**
|
||||
* Response handler that is used as callback in coap_context_t.
|
||||
*
|
||||
@@ -87,12 +92,15 @@ coap_queue_t *coap_new_node(void);
|
||||
* @param sent The PDU that was transmitted.
|
||||
* @param received The PDU that was received.
|
||||
* @param id CoAP transaction ID.
|
||||
|
||||
* @return @c COAP_RESPONSE_OK if successful, else @c COAP_RESPONSE_FAIL which
|
||||
* triggers sending a RST packet.
|
||||
*/
|
||||
typedef void (*coap_response_handler_t)(struct coap_context_t *context,
|
||||
coap_session_t *session,
|
||||
coap_pdu_t *sent,
|
||||
coap_pdu_t *received,
|
||||
const coap_tid_t id);
|
||||
typedef coap_response_t (*coap_response_handler_t)(struct coap_context_t *context,
|
||||
coap_session_t *session,
|
||||
coap_pdu_t *sent,
|
||||
coap_pdu_t *received,
|
||||
const coap_tid_t id);
|
||||
|
||||
/**
|
||||
* Negative Acknowedge handler that is used as callback in coap_context_t.
|
||||
|
||||
Reference in new issue
Block a user