Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/gcoap: added remote sock ep to resp handler cb #7407

Merged
merged 1 commit into from
Jul 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions examples/gcoap/gcoap_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
#define ENABLE_DEBUG (0)
#include "debug.h"

static void _resp_handler(unsigned req_state, coap_pkt_t* pdu);
static void _resp_handler(unsigned req_state, coap_pkt_t* pdu,
sock_udp_ep_t *remote);
static ssize_t _stats_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len);

/* CoAP resources */
Expand All @@ -48,8 +49,11 @@ static uint16_t req_count = 0;
/*
* Response callback.
*/
static void _resp_handler(unsigned req_state, coap_pkt_t* pdu)
static void _resp_handler(unsigned req_state, coap_pkt_t* pdu,
sock_udp_ep_t *remote)
{
(void)remote; /* not interested in the source currently */

if (req_state == GCOAP_MEMO_TIMEOUT) {
printf("gcoap: timeout for msg ID %02u\n", coap_get_id(pdu));
return;
Expand Down
3 changes: 2 additions & 1 deletion sys/include/net/gcoap.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ typedef struct gcoap_listener {
*
* If request timed out, the packet header is for the request.
*/
typedef void (*gcoap_resp_handler_t)(unsigned req_state, coap_pkt_t* pdu);
typedef void (*gcoap_resp_handler_t)(unsigned req_state, coap_pkt_t* pdu,
sock_udp_ep_t *remote);

/**
* @brief Memo to handle a response for a request
Expand Down
4 changes: 2 additions & 2 deletions sys/net/application_layer/coap/gcoap.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static void _listen(sock_udp_t *sock)
if (memo) {
xtimer_remove(&memo->response_timer);
memo->state = GCOAP_MEMO_RESP;
memo->resp_handler(memo->state, &pdu);
memo->resp_handler(memo->state, &pdu, &remote);
memo->state = GCOAP_MEMO_UNUSED;
}
}
Expand Down Expand Up @@ -380,7 +380,7 @@ static void _expire_request(gcoap_request_memo_t *memo)
/* Pass response to handler */
if (memo->resp_handler) {
req.hdr = (coap_hdr_t *)&memo->hdr_buf[0]; /* for reference */
memo->resp_handler(memo->state, &req);
memo->resp_handler(memo->state, &req, NULL);
}
memo->state = GCOAP_MEMO_UNUSED;
}
Expand Down