mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-03-09 10:57:12 +01:00
bbf : Fix Inconsistent MACAddress case
This commit is contained in:
parent
20548f2301
commit
800d216222
2 changed files with 23 additions and 2 deletions
|
|
@ -1075,7 +1075,19 @@ static int set_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
static int get_EthernetLink_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "mac", value);
|
||||
char *mac_addr;
|
||||
char address[64] = {0};
|
||||
int i;
|
||||
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "mac", &mac_addr);
|
||||
strncpy(address, mac_addr, sizeof(address));
|
||||
for (i = 0; address[i] != '\0'; i++) {
|
||||
if(address[i] >= 'a' && address[i] <= 'z') {
|
||||
address[i] = address[i] - 32;
|
||||
}
|
||||
}
|
||||
|
||||
*value = dmstrdup(address);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1016,10 +1016,19 @@ int get_net_device_sysfs(const char *device, const char *name, char **value)
|
|||
{
|
||||
if (device && device[0]) {
|
||||
char file[256];
|
||||
char val[64];
|
||||
char val[64] = {0};
|
||||
|
||||
snprintf(file, sizeof(file), "/sys/class/net/%s/%s", device, name);
|
||||
dm_read_sysfs_file(file, val, sizeof(val));
|
||||
if (0 == strcmp(name, "address")) {
|
||||
// Convert the mac address to upper case.
|
||||
int i;
|
||||
for (i = 0; val[i] != '\0'; i++) {
|
||||
if (val[i] >= 'a' && val[i] <= 'z') {
|
||||
val[i] = val[i] - 32;
|
||||
}
|
||||
}
|
||||
}
|
||||
*value = dmstrdup(val);
|
||||
} else {
|
||||
*value = "0";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue