1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 04:52:59 +01:00

gcoap: add aux local to gcoap_req_send

This commit is contained in:
Fabian Hüßler 2024-05-25 20:23:13 +02:00
parent 611e364864
commit 3973e4bb9d
2 changed files with 10 additions and 4 deletions

View File

@ -964,6 +964,7 @@ static inline ssize_t gcoap_request(coap_pkt_t *pdu, uint8_t *buf, size_t len,
* @param[in] buf Buffer containing the PDU
* @param[in] len Length of the buffer
* @param[in] remote Destination for the packet
* @param[in] local Local endpoint to send from, may be NULL
* @param[in] resp_handler Callback when response received, may be NULL
* @param[in] context User defined context passed to the response handler
* @param[in] tl_type The transport type to use for send. When
@ -980,7 +981,7 @@ static inline ssize_t gcoap_request(coap_pkt_t *pdu, uint8_t *buf, size_t len,
* @return 0 if cannot send
*/
ssize_t gcoap_req_send(const uint8_t *buf, size_t len,
const sock_udp_ep_t *remote,
const sock_udp_ep_t *remote, const sock_udp_ep_t *local,
gcoap_resp_handler_t resp_handler, void *context,
gcoap_socket_type_t tl_type);
@ -1009,7 +1010,7 @@ static inline ssize_t gcoap_req_send_tl(const uint8_t *buf, size_t len,
gcoap_resp_handler_t resp_handler, void *context,
gcoap_socket_type_t tl_type)
{
return gcoap_req_send(buf, len, remote, resp_handler, context, tl_type);
return gcoap_req_send(buf, len, remote, NULL, resp_handler, context, tl_type);
}
/**

View File

@ -1613,7 +1613,7 @@ int gcoap_obs_req_forget(const sock_udp_ep_t *remote, const uint8_t *token,
}
ssize_t gcoap_req_send(const uint8_t *buf, size_t len,
const sock_udp_ep_t *remote,
const sock_udp_ep_t *remote, const sock_udp_ep_t *local,
gcoap_resp_handler_t resp_handler, void *context,
gcoap_socket_type_t tl_type)
{
@ -1743,7 +1743,12 @@ ssize_t gcoap_req_send(const uint8_t *buf, size_t len,
}
if (res == 0) {
res = _tl_send(&socket, buf, len, remote, NULL);
sock_udp_aux_tx_t aux = { 0 };
if (local) {
memcpy(&aux.local, local, sizeof(sock_udp_ep_t));
aux.flags = SOCK_AUX_SET_LOCAL;
}
res = _tl_send(&socket, buf, len, remote, &aux);
}
if (res <= 0) {
if (memo != NULL) {