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

gcoap: propagate local tx aux to gcoap_req_send() and in _handler_req() #20711

Merged
merged 5 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
gcoap: add aux local to gcoap_req_send
  • Loading branch information
fabian18 committed May 29, 2024
commit 3973e4bb9d42201bf8a311fb2d4c4878aa4b37ed
5 changes: 3 additions & 2 deletions sys/include/net/gcoap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);

Expand Down Expand Up @@ -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);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions sys/net/application_layer/gcoap/gcoap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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) {
Expand Down