1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

gcoap: pass aux local to _handle_req()

This commit is contained in:
Fabian Hüßler 2024-05-25 20:33:13 +02:00
parent 40fb250ae4
commit f4b1306460
3 changed files with 24 additions and 3 deletions

View File

@ -390,6 +390,16 @@ uint32_t coap_request_ctx_get_tl_type(const coap_request_ctx_t *ctx);
*/
const sock_udp_ep_t *coap_request_ctx_get_remote_udp(const coap_request_ctx_t *ctx);
/**
* @brief Get the local endpoint on which the request has been received
*
* @param[in] ctx The request context
*
* @return Local endpoint to which the request has been received
* @return NULL The request was not received via UDP
*/
const sock_udp_ep_t *coap_request_ctx_get_local_udp(const coap_request_ctx_t *ctx);
/**
* @brief Block1 helper struct
*/

View File

@ -66,7 +66,7 @@ static ssize_t _well_known_core_handler(coap_pkt_t* pdu, uint8_t *buf, size_t le
coap_request_ctx_t *ctx);
static void _cease_retransmission(gcoap_request_memo_t *memo);
static size_t _handle_req(gcoap_socket_t *sock, coap_pkt_t *pdu, uint8_t *buf,
size_t len, sock_udp_ep_t *remote);
size_t len, sock_udp_ep_t *remote, sock_udp_aux_tx_t *aux);
static void _expire_request(gcoap_request_memo_t *memo);
static gcoap_request_memo_t* _find_req_memo_by_mid(const sock_udp_ep_t *remote,
uint16_t mid);
@ -453,7 +453,7 @@ static void _process_coap_pdu(gcoap_socket_t *sock, sock_udp_ep_t *remote, sock_
COAP_CODE_REQUEST_ENTITY_TOO_LARGE);
} else {
pdu_len = _handle_req(sock, &pdu, _listen_buf,
sizeof(_listen_buf), remote);
sizeof(_listen_buf), remote, aux);
}
if (pdu_len > 0) {
@ -652,7 +652,7 @@ static void _cease_retransmission(gcoap_request_memo_t *memo) {
* return length of response pdu, or < 0 if can't handle
*/
static size_t _handle_req(gcoap_socket_t *sock, coap_pkt_t *pdu, uint8_t *buf,
size_t len, sock_udp_ep_t *remote)
size_t len, sock_udp_ep_t *remote, sock_udp_aux_tx_t *aux)
{
const coap_resource_t *resource = NULL;
gcoap_listener_t *listener = NULL;
@ -760,6 +760,7 @@ static size_t _handle_req(gcoap_socket_t *sock, coap_pkt_t *pdu, uint8_t *buf,
.resource = resource,
.tl_type = (uint32_t)sock->type,
.remote = remote,
.local = aux ? &aux->local : NULL,
};
pdu_len = resource->handler(pdu, buf, len, &ctx);

View File

@ -1464,3 +1464,13 @@ const sock_udp_ep_t *coap_request_ctx_get_remote_udp(const coap_request_ctx_t *c
{
return ctx->remote;
}
const sock_udp_ep_t *coap_request_ctx_get_local_udp(const coap_request_ctx_t *ctx)
{
#if defined(MODULE_SOCK_AUX_LOCAL)
return ctx->local;
#else
(void)ctx;
return NULL;
#endif
}