Skip to content

Conversation

leandrolanzieri
Copy link
Contributor

Contribution description

This adds a function to netif that allows to search an interface by name, using a buffer and length (like the one provided by the URI parser), instead a null-terminated string. tests/gnrc_netif has been extended accordingly.

Testing procedure

tests/gnrc_netif should pass.

Issues/PRs references

Split from #16233

@leandrolanzieri leandrolanzieri added the Type: new feature The issue requests / The PR implemements a new feature for RIOT label Aug 4, 2021
@github-actions github-actions bot added Area: network Area: Networking Area: sys Area: System Area: tests Area: tests and testing framework labels Aug 4, 2021
@jia200x
Copy link
Member

jia200x commented Aug 4, 2021

I like the idea. In fact, I think we should use this new function instead of netif_get_by_name, since the upper layer can always do:

netif_get_by_name_buffer(str, strlen(str));

I would be in favour of changing the API and deprecate the current netif_get_by_name API (and replace it with the signature of this new function).
What do you think?

EDIT: I just noticed netif_get_by_name is just a wrapper now.

@leandrolanzieri
Copy link
Contributor Author

I would be in favour of changing the API and deprecate the current netif_get_by_name API (and replace it with the signature of this new function).
What do you think?

EDIT: I just noticed netif_get_by_name is just a wrapper now.

I don't really have a strong opinion here, there is no overhead in keeping the current function the way it is implemented.

Copy link
Member

@jia200x jia200x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. tests/gnrc_netif passes:

make all test && echo "OK"
...
~~ SNIP  1 - size:  20 byte, type: NETTYPE_NETIF (-1)
if_pid: 6  rssi: -32768  lqi: 0
flags: 0x0
src_l2addr: 3E:E6:B5:22:FD:0B
dst_l2addr: 3E:E6:B5:22:FD:0A
~~ PKT    -  2 snips, total size:  61 byte

OK

Regarding the API change of netif_get_by_name, this can be discussed later.

@miri64
Copy link
Member

miri64 commented Aug 4, 2021

Lol, I just added the same thing to #16705 ^^

Comment on lines 78 to 81
netif_t *netif_get_by_name(const char *name)
{
return netif_get_by_name_buffer(name, strlen(name));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be static inline in the header now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to the header

Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old style function could be inline (Github does not let me make a change request without a comment and I forgot to make one before...)

Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash immediately with my last suggestion.

@leandrolanzieri
Copy link
Contributor Author

Squashed directly!

@leandrolanzieri leandrolanzieri added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Aug 4, 2021
@miri64 miri64 added CI: run tests If set, CI server will run tests on hardware for the labeled PR CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Aug 4, 2021
@leandrolanzieri
Copy link
Contributor Author

Ci found some issues

@leandrolanzieri leandrolanzieri force-pushed the pr/net/netif_get_by_name_buf branch from 78c415f to d2d1c7e Compare August 4, 2021 16:11
@leandrolanzieri
Copy link
Contributor Author

Ci found some issues

Fixed, #include <string.h> was missing in netif.h

@miri64 miri64 merged commit 1b0152b into RIOT-OS:master Aug 4, 2021
@leandrolanzieri leandrolanzieri deleted the pr/net/netif_get_by_name_buf branch August 5, 2021 11:10
@leandrolanzieri leandrolanzieri added this to the Release 2021.10 milestone Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: run tests If set, CI server will run tests on hardware for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants