gcoap: propagate local tx aux to gcoap_req_send() and in _handler_req() #20711
+60
−26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contribution description
The gcoap forward proxy must respond to the client from the same address and port where it has received the request.
The address towards the server can be different.
For that the usual information in
sock_udp_aux_tx_t
are propated to where they are needed ingcoap_req_send()
and_handle_req()
ingcoap.c
Another fix is included by setting the correct payload size in the forwarded PDU right after it is copied.
Testing procedure
Use this branch to run a client and proxy with
examples/gcoap
./dist/tools/tapsetup
Client:
CFLAGS+=-DCONFIG_GCOAP_PDU_BUF_SIZE=512 make flash term
Proxy:
Add another link local address only to the proxy by adding the following to
examples/gcoap/Makefile
:CFLAGS+=-DCONFIG_GCOAP_PDU_BUF_SIZE=512 USEMODULE+=gcoap_forward_proxy make flash term PORT=tap1
Server:
Run a libcoap server on the
tapbr0
interface:coap-server-openssl -A fe80::f0da:e9ff:fe74:594a%tapbr0
Client:
Set the proxy:
coap proxy set coap:https://[fe80::a0ae:a2ff:fe2f:af16]:5683
Send a request to the server:
coap get coap:https://[fe80::f0da:e9ff:fe74:594a]:5683/.well-known/core
As you can see in the wireshark picture, the proxy uses different address toward the client and towards the server.
The same procedure does not work in
master
right now.Issues/PRs references
This is the next split out of #20696.