-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
net/gcoap: Require interface for link local address in shell example #8223
Conversation
remote.netif = SOCK_ADDR_ANY_NETIF; | ||
|
||
/* parse for interface */ | ||
int iface = ipv6_addr_split_iface(addr_str); |
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.
The ping6 command allows this to be ignored if only one interface exist (using #if GNRC_NETIF_NUMOF == 1U
). In that case the first (and only) interface is selected.
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.
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.
Or is that the purpose of #6413 (stack-independent netif), and we'll need to update the interface lookup here when that PR is merged?
Yes, but also: this application at the moment is also dependent on GNRC (it pulls in GNRC dependencies), so I think it is okay for now.
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.
Two minor nit-picks. Otherwise ready to merge
examples/gcoap/gcoap_cli.c
Outdated
int iface = ipv6_addr_split_iface(addr_str); | ||
if (iface == -1) { | ||
if (gnrc_netif_numof() == 1) { | ||
remote.netif = (uint16_t)gnrc_netif_iter(NULL)->pid; |
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 leave a comment why this is okay without checking.
examples/gcoap/gcoap_cli.c
Outdated
|
||
/* parse destination address */ | ||
if (ipv6_addr_from_str(&addr, addr_str) == NULL) { | ||
puts("gcoap_cli: unable to parse destination address"); | ||
return 0; | ||
} | ||
if (remote.netif == SOCK_ADDR_ANY_NETIF && ipv6_addr_is_link_local(&addr)) { |
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.
Parenthesis around first check
examples/gcoap/gcoap_cli.c
Outdated
@@ -149,6 +149,7 @@ static size_t _send(uint8_t *buf, size_t len, char *addr_str, char *port_str) | |||
int iface = ipv6_addr_split_iface(addr_str); | |||
if (iface == -1) { | |||
if (gnrc_netif_numof() == 1) { | |||
// assign the single interface found in gnrc_netif_numof() |
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.
Please use C-style comments /* ... */
;-)
That was embarassing. =:-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.
ACK, please squash.
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.
Needs more ☕
a9a42a1
to
d36c07c
Compare
Squashed and ready. Thanks for review. |
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.
One last thing: please make teh commit message shorter than 50 characters (or 72 at the pare minimum)
d36c07c
to
a1efa03
Compare
Networking infrastructure updates require that a message to a link local address specifies the interface to use, as discussed in #8199. This PR accepts an interface ID in the gcoap shell example, and requires it for a link local address. See the example below.