tr181: deviceinfo: use os spcific implementations for some options

The following attributes are moved to OS specific implementations:
- Manufacturer
- ManufacturerOUI
- SoftwareVersion
- SerialNumber
- ProductClass

Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
This commit is contained in:
Daniel Danzberger 2020-03-23 20:15:04 +01:00
parent 682e6f3977
commit d8438806f1
4 changed files with 73 additions and 25 deletions

View file

@ -2,12 +2,48 @@
#include <libbbf_api/dmcommon.h>
char * os__get_deviceid_manufacturer()
{
char *v;
dmuci_get_option_value_string("cwmp","cpe","manufacturer", &v);
return v;
}
char * os__get_deviceid_productclass()
{
char *v;
dmuci_get_option_value_string("cwmp", "cpe", "override_productclass", &v);
if (v[0] == '\0') {
db_get_value_string("hw", "board", "iopVerBoard", &v);
return v;
}
return v;
}
char * os__get_deviceid_serialnumber()
{
char *v;
db_get_value_string("hw", "board", "serial_number", &v);
return v;
}
char * os__get_softwareversion()
{
char *v;
db_get_value_string("hw", "board", "iopVersion", &v);
return v;
}
char * os__get_deviceid_manufactureroui()
{
char *v, *mac = NULL, str[16], macreadfile[18] = {0};
json_object *res;
FILE *nvrammac = NULL;
dmuci_get_option_value_string("cwmp", "cpe", "override_oui", &v);
if (v[0])
return v;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
if (!(res)) {
db_get_value_string("hw", "board", "basemac", &mac);

View file

@ -4,14 +4,39 @@
#define BASE_IFACE "br-lan"
char * os__get_deviceid_manufactureroui()
static char * get_uci_deviceinfo(char *opt)
{
char *v;
get_net_device_sysfs(BASE_IFACE, "address", &v);
dmuci_get_option_value_string("cwmp", "@deviceinfo[0]", opt, &v);
return v;
}
char * os__get_deviceid_manufacturer()
{
return get_uci_deviceinfo("Manufacturer");
}
char * os__get_deviceid_productclass()
{
return get_uci_deviceinfo("ProductClass");
}
char * os__get_deviceid_serialnumber()
{
return get_uci_deviceinfo("SerialNumber");
}
char * os__get_softwareversion()
{
return get_uci_deviceinfo("SoftwareVersion");
}
char * os__get_deviceid_manufactureroui()
{
return get_uci_deviceinfo("ManufacturerOUI");
}
int os__get_base_mac_addr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_net_device_sysfs(BASE_IFACE, "address", value);

View file

@ -17,45 +17,27 @@
*/
char *get_deviceid_manufacturer()
{
char *v;
dmuci_get_option_value_string("cwmp","cpe","manufacturer", &v);
return v;
return os__get_deviceid_manufacturer();
}
char *get_deviceid_manufactureroui()
{
char *v;
dmuci_get_option_value_string("cwmp", "cpe", "override_oui", &v);
if (v[0] == '\0')
v = os__get_deviceid_manufactureroui();
return v;
return os__get_deviceid_manufactureroui();
}
char *get_deviceid_productclass()
{
char *v;
dmuci_get_option_value_string("cwmp", "cpe", "override_productclass", &v);
if (v[0] == '\0') {
db_get_value_string("hw", "board", "iopVerBoard", &v);
return v;
}
return v;
return os__get_deviceid_productclass();
}
char *get_deviceid_serialnumber()
{
char *v;
db_get_value_string("hw", "board", "serial_number", &v);
return v;
return os__get_deviceid_serialnumber();
}
char *get_softwareversion()
{
char *v;
db_get_value_string("hw", "board", "iopVersion", &v);
return v;
return os__get_softwareversion();
}
int lookup_vcf_name(char *instance, char **value)

View file

@ -5,7 +5,12 @@
/* IOPSYS-WRT and OpenWrt
*/
char * os__get_deviceid_manufacturer();
char * os__get_deviceid_productclass();
char * os__get_deviceid_serialnumber();
char * os__get_softwareversion();
char * os__get_deviceid_manufactureroui();
int os__get_base_mac_addr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_memory_status_total(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);