-
Notifications
You must be signed in to change notification settings - Fork 1
Draft: Extend coap_pkt_t with source address #8
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
base: wot_gcoap
Are you sure you want to change the base?
Conversation
|
I thought about that one too. Need to do some research on the API. Maybe it is already possible to get the IP address and just store it in a global variable in order to use it within gcoap. |
|
After delving into the UDP sock API I tried to implement a solution using |
JKRhb
left a comment
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.
I highlighted some points that may require discussion below.
| ifneq (,$(filter nanocoap_pkt_ipv6_address,$(USEMODULE))) | ||
| USEMODULE += sock_aux_local | ||
| endif |
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.
This adds sock_aux_local as a dependency for the newly defined pseudo-module.
| #ifdef MODULE_NANOCOAP_PKT_IPV6_ADDRESS | ||
| ipv6_addr_t source_address; /**< request source address */ | ||
| #endif |
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.
Maybe a different datastructure could be used for storing the ip address. (I just noticed that this field should be renamed to "target address".)
| if (type & SOCK_ASYNC_MSG_RECV) { | ||
| ssize_t res = sock_udp_recv(sock, _listen_buf, sizeof(_listen_buf), | ||
| 0, &remote); | ||
| ssize_t res = sock_udp_recv_aux(sock, _listen_buf, sizeof(_listen_buf), | ||
| 0, &remote, &aux); | ||
| if (res <= 0) { |
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.
Is changing the signature fine or should a separate function be defined for the use of the pseudo-module?
| #if IS_USED(MODULE_NANOCOAP_PKT_IPV6_ADDRESS) | ||
| memcpy(&pdu.source_address, &aux->local.addr.ipv6, sizeof(ipv6_addr_t)); | ||
| #endif |
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.
I wasn't entirely sure if this is actually working but I found something similar in the existing codebase. In any case, compiling the gcoap example with the added submodule works but actual testing (perhaps in the context of our wot implementation) is still needed.
|
Hmm, I think this PR is not relevant anymore, right? |
I actually don't know. I didn't had the time to do a lot with RIOT... I forgot a lot at this point... |
Inspired by the discussion in this issue in the original RIOT repository, this PR is a draft for adding a pseudomodule with the intention of including the source address in CoAP packets.
So far only the submodule definition and the packet field itself have been added. As there are still things that may have to be discussed I opened this PR as a draft. If an actual solution for the problem emerges from this PR, its origin branch could probably also be merged into the RIOT main branch.