-
Notifications
You must be signed in to change notification settings - Fork 2k
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
gcoap: propagate local tx aux to gcoap_req_send() and in _handler_req() #20711
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx. The change looks good to me.
I guess it would be possible to rename the function and provide a backward compatible version. But I do believe that having a gcoap_req_send()
and a gcoap_req_send2()
or whatever would cause more confusion than it would save time for app developers that would profit from a deprecation period. And updating the calls is relatively easy by adding the additional parameter.
6d2d511
to
f50dd7d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me and the explanation makes sense.
🎉 |
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://[fe80::a0ae:a2ff:fe2f:af16]:5683
Send a request to the server:
coap get coap://[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.