mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-03-10 11:27:11 +01:00
Read mac address from sysfs instead of ubus
This is much faster Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
This commit is contained in:
parent
7ce4410723
commit
8708940709
1 changed files with 12 additions and 8 deletions
|
|
@ -1393,15 +1393,19 @@ char **strsplit_by_str(const char str[], char *delim)
|
|||
|
||||
char *get_macaddr(char *interface_name)
|
||||
{
|
||||
json_object *res;
|
||||
char *device, *mac = "";
|
||||
char *device = get_device(interface_name);
|
||||
char *mac;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", interface_name, String}}, 1, &res);
|
||||
device = dmjson_get_value(res, 1, "device");
|
||||
if(device[0] == '\0')
|
||||
return "";
|
||||
dmubus_call("network.device", "status", UBUS_ARGS{{"name", device, String}}, 1, &res);
|
||||
mac = dmjson_get_value(res, 1, "macaddr");
|
||||
if(device[0]) {
|
||||
char file[128];
|
||||
char val[32];
|
||||
|
||||
snprintf(file, sizeof(file), "/sys/class/net/%s/address", device);
|
||||
dm_read_sysfs_file(file, val, sizeof(val));
|
||||
mac = dmstrdup(val);
|
||||
} else {
|
||||
mac = "";
|
||||
}
|
||||
return mac;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue