ATM,PTM: get Status value from sysfs instead of hard coding it

This commit is contained in:
Amin Ben Ramdhane 2021-02-11 11:55:07 +01:00
parent 92d1f62cab
commit 9d3f12e527
3 changed files with 28 additions and 2 deletions

View file

@ -223,9 +223,16 @@ static int set_atm_enable(char *refparam, struct dmctx *ctx, void *data, char *i
return 0;
}
/*#Device.ATM.Link.{i}.Status!SYSFS:/sys/class/net/@Name/operstate*/
static int get_atm_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "Up";
get_net_device_sysfs(((struct atm_args *)data)->ifname, "operstate", value);
if (strcmp(*value, "up") == 0)
*value = "Up";
else if (strcmp(*value, "down") == 0)
*value = "Down";
else
*value = "Unknown";
return 0;
}

View file

@ -120,9 +120,16 @@ static int set_ptm_enable(char *refparam, struct dmctx *ctx, void *data, char *i
return 0;
}
/*#Device.PTM.Link.{i}.Status!SYSFS:/sys/class/net/@Name/operstate*/
static int get_ptm_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "Up";
get_net_device_sysfs(((struct ptm_args *)data)->ifname, "operstate", value);
if (strcmp(*value, "up") == 0)
*value = "Up";
else if (strcmp(*value, "down") == 0)
*value = "Down";
else
*value = "Unknown";
return 0;
}

View file

@ -17380,6 +17380,12 @@
"NotPresent",
"LowerLayerDown",
"Error"
],
"mapping": [
{
"type": "sysfs",
"file": "/sys/class/net/@Name/operstate"
}
]
},
"Alias": {
@ -18248,6 +18254,12 @@
"NotPresent",
"LowerLayerDown",
"Error"
],
"mapping": [
{
"type": "sysfs",
"file": "/sys/class/net/@Name/operstate"
}
]
},
"Alias": {