netifd: add devtype to ubus call
authorFlorian Eckert <fe@dev.tdt.de>
Tue, 11 Jan 2022 14:42:59 +0000 (15:42 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Wed, 12 Jan 2022 19:28:33 +0000 (20:28 +0100)
commit29e6acf3bd34633fa1a3d51559cc1294b772f88e
treedbff176edc241c750dc845d8ecae21c4d86c7adf
parent7ccbf08570619a4d3eccf6401791075908bb1d78
netifd: add devtype to ubus call

Every network device has a type but there is no standard interface here.
The type can be determined either from the file
'/sys/class/net/<device>/uevent' or, if no information is found
there, from the file '/sys/class/net/<device>/type'.

This new function first checks whether there is a DEVTYPE=<type> string
in the 'uevent' file and uses it. If it does not find this information,
the 'type' is used as a fallback and mapped the number to a character
sequence.

This new 'devtype' information can be found in the network.device ubus
call.

Command:
ubus call network.device status

Output:
{
    "eth0": {
        "devtype": "ethernet",

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> [commit rewording]
system-linux.c
system.h