-
Notifications
You must be signed in to change notification settings - Fork 2.1k
netif: initial import of a common network interface API #5511
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
Conversation
I changed it so the ID is now starting with |
Rebased and squashed to current master. |
Whats the use-case for this? |
Another one could be implementing POSIX |
Oh, and making |
Except for some setting/getting options (which only would be required for implementing |
Oh, I just saw, that an |
Add any identifier
Done. |
@miri64 IMHO this is way too fat... |
Interesting what counts as bloat these days (3 functions, 44 loc, mainly consting of very short loops...; without the DEVELHELP stuff) |
With
With
|
Without the option requirement we can even drop the internal pointer. |
240bytes brings it at eye-level with all shell commands, the saul registry or the mutex implementation. Don't all network stacks have their own list of network devices, anyways? Be it an array or a linked list. IMHO wrapping another type over that is more than clumsy. A common interface for enumerating interfaces might be nice, but why another type, a forced new set of 5 functions containing custom linked list operations, ... |
netdev2 is 3 words long, and it also contains a pointer to the stack internal structure. Will they point to the same location? @miri64 It is just that, we fight for every needed byte, try to avoid every struct member. All of netif_t is unnecessary, and in that light, the 96 or 244 bytes of additional code seems wasted. |
Where do you get this number from? For the ones pulled in by gnrc_networking alone I have
Yes, but the way they are addressed in each are vastly different: GNRC uses PIDs, lwIP uses names, emb6 doesn't even have interfaces (a slip interface optionally, but its not really addressable like the radio), and as far as I can see is OpenThread using its own interface identifier. For truely stack independent
3 functions, the other two are just for shell user shine (and can be removed if you really hate them) and they are just checking for duplicates (I could use clist though, granted)
netdev2 has no pointer to the internal interface, but to the internal state of the device. For GNRC this would point to the PID in the gnrc_netif array. For others like e.g. OpenThread a pointer to the Netif class (if that is possible).
I don't see it as unnecessary (see common euumeration argument). |
Sorry, I just looked at
Exactly. So use those identifiers. Let gnrc enumerate PIDs, lwIP names (or pointers to the name strings), stackX pointers to it's interface structs. If a stack cannot enumerate it's interfaces easily, it is just a couple of lines to create a simple clist.
There might be no way around a common enumeration API, but certainly a way around the same enumeration implementation. |
So how would your wrapper look like then? |
|
Why restrict the name length via macro? |
In order to not have to deal with variable length names. |
But what if the stack has those? |
Well, linux limits interface names to 16 characters. If one of our stacks uses more, fix it. |
Will provide an alternative with @kaspar030's proposal. |
This PR introduces a new common network interface API. Interfaces are identified by a unique ID. Currently this ID is their position in a global list, that is why interfaces can't be deleted. Alternatively we could add the ID as a field to
netif_t
, but I don't think that deleting an interface is a use-case we need.Things to do as a follow-up PR:
ifconfig
to this APIDepends on #5510.(merged)