tr181: Add OS specific implementations

When code is build with --enable-generic-openwrt,
the tr181 implementations from dmtree/tr181/.*-openwrt.c are used.
Otherwise for IOPSYS-WRT, dmtree/tr181/*-iopsyswrt.c sources are used.

Note that all functions that have OS specific handlers, are prefixed
with 'os__' and are implemented in their OS specific file.

Functions that are only available in IOPSYS-WRT are prefixed with
'os_iopsys_*'.

More OpenWrt OS impelementations will follow in future commits.

Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
This commit is contained in:
Daniel Danzberger 2020-03-16 13:01:48 +01:00
parent ce8bf4e319
commit ff759d2cca
12 changed files with 1958 additions and 1274 deletions

View file

@ -88,6 +88,18 @@ libbbfdm_la_SOURCES += \
../dmtree/tr181/security.c
endif
if GENERIC_OPENWRT
libbbfdm_la_SOURCES += \
../dmtree/tr181/deviceinfo-openwrt.c \
../dmtree/tr181/wifi-openwrt.c \
../dmtree/tr181/hosts-openwrt.c
else
libbbfdm_la_SOURCES += \
../dmtree/tr181/deviceinfo-iopsyswrt.c \
../dmtree/tr181/wifi-iopsyswrt.c \
../dmtree/tr181/hosts-iopsyswrt.c
endif
if BBF_TR104
libbbfdm_la_SOURCES += \
../dmtree/tr104/voice_services.c

View file

@ -0,0 +1,235 @@
#include "os.h"
#include <libbbf_api/dmcommon.h>
char * os__get_deviceid_manufactureroui()
{
char *v, *mac = NULL, str[16], macreadfile[18] = {0};
json_object *res;
FILE *nvrammac = NULL;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
if (!(res)) {
db_get_value_string("hw", "board", "basemac", &mac);
if (!mac || strlen(mac) == 0) {
if ((nvrammac = fopen("/proc/nvram/BaseMacAddr", "r")) == NULL) {
mac = NULL;
} else {
fscanf(nvrammac,"%17[^\n]", macreadfile);
macreadfile[17] = '\0';
sscanf(macreadfile,"%2c %2c %2c", str, str+2, str+4);
str[6] = '\0';
v = dmstrdup(str); // MEM WILL BE FREED IN DMMEMCLEAN
fclose(nvrammac);
return v;
}
}
} else
mac = dmjson_get_value(res, 2, "system", "basemac");
if(mac) {
size_t ln = strlen(mac);
if (ln < 17) goto not_found;
sscanf (mac,"%2c:%2c:%2c",str,str+2,str+4);
str[6] = '\0';
v = dmstrdup(str); // MEM WILL BE FREED IN DMMEMCLEAN
return v;
}
not_found:
return "";
}
int os__get_base_mac_addr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "basemac");
return 0;
}
int os_iopsys_get_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("router.system", "memory_bank", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "code");
return 0;
}
int os_iopsys_set_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
//TODO
return 0;
case VALUESET:
dmubus_call_set("router.system", "memory_bank", UBUS_ARGS{{"bank", value, Integer}}, 1);
return 0;
}
return 0;
}
int os_iopsys_get_catv_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *catv;
dmuci_get_option_value_string("catv", "catv", "enable", &catv);
if (strcmp(catv, "on") == 0)
*value = "1";
else
*value = "0";
return 0;
}
int os_iopsys_set_device_catvenabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value("catv", "catv", "enable", b ? "on" : "off");
return 0;
}
return 0;
}
int os_iopsys_get_catv_optical_input_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("catv", "vpd", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "VPD");
return 0;
}
int os_iopsys_get_catv_rf_output_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("catv", "rf", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "RF");
return 0;
}
int os_iopsys_get_catv_temperature(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("catv", "temp", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "Temperature");
return 0;
}
int os_iopsys_get_catv_voltage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("catv", "vcc", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "VCC");
return 0;
}
/*#Device.DeviceInfo.MemoryStatus.Total!UBUS:router.system/memory//total*/
int os__get_memory_status_total(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("router.system", "memory", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "0");
*value = dmjson_get_value(res, 1, "total");
return 0;
}
/*#Device.DeviceInfo.MemoryStatus.Free!UBUS:router.system/memory//free*/
int os__get_memory_status_free(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("router.system", "memory", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "0");
*value = dmjson_get_value(res, 1, "free");
return 0;
}
/*#Device.DeviceInfo.ProcessStatus.CPUUsage!UBUS:router.system/process//cpu_usage*/
int os__get_process_cpu_usage(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("router.system", "process", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "0");
*value = dmjson_get_value(res, 1, "cpu_usage");
return 0;
}
int os__get_process_number_of_entries(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res = NULL, *processes = NULL;
int nbre_process = 0;
dmubus_call("router.system", "processes", UBUS_ARGS{}, 0, &res);
if (res) {
json_object_object_get_ex(res, "processes", &processes);
if (processes)
nbre_process = json_object_array_length(processes);
}
dmasprintf(value, "%d", nbre_process);
return 0;
}
int os__get_process_pid(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "pid");
return 0;
}
int os__get_process_command(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "command");
return 0;
}
int os__get_process_size(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "vsz");
return 0;
}
int os__get_process_priority(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "priority");
return 0;
}
int os__get_process_cpu_time(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "cputime");
return 0;
}
int os__get_process_state(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "state");
return 0;
}
int os__browseProcessEntriesInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *res = NULL, *processes = NULL, *arrobj = NULL;
char *idx, *idx_last = NULL;
int id = 0, i = 0;
dmubus_call("router.system", "processes", UBUS_ARGS{}, 0, &res);
if (res) {
dmjson_foreach_obj_in_array(res, arrobj, processes, i, 1, "processes") {
idx = handle_update_instance(2, dmctx, &idx_last, update_instance_without_section, 1, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)processes, idx) == DM_STOP)
break;
}
}
return 0;
}

View file

@ -0,0 +1,79 @@
#include "os.h"
#include <libbbf_api/dmcommon.h>
#define BASE_IFACE "br-lan"
char * os__get_deviceid_manufactureroui()
{
char *v;
get_net_device_sysfs(BASE_IFACE, "address", &v);
return v;
}
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);
}
static int not_implemented(char **value)
{
*value = "";
return 0;
}
int os__get_memory_status_total(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_memory_status_free(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_process_cpu_usage(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_process_number_of_entries(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_process_pid(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_process_command(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_process_size(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_process_priority(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_process_cpu_time(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_process_state(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__browseProcessEntriesInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
return 0;
}

View file

@ -10,6 +10,7 @@
*/
#include "deviceinfo.h"
#include "os.h"
/*
*DeviceInfo. functions
@ -23,44 +24,12 @@ char *get_deviceid_manufacturer()
char *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] == '\0') {
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
if (!(res)) {
db_get_value_string("hw", "board", "basemac", &mac);
if (!mac || strlen(mac) == 0) {
if ((nvrammac = fopen("/proc/nvram/BaseMacAddr", "r")) == NULL) {
mac = NULL;
} else {
fscanf(nvrammac,"%17[^\n]", macreadfile);
macreadfile[17] = '\0';
sscanf(macreadfile,"%2c %2c %2c", str, str+2, str+4);
str[6] = '\0';
v = dmstrdup(str); // MEM WILL BE FREED IN DMMEMCLEAN
fclose(nvrammac);
return v;
}
}
} else
mac = dmjson_get_value(res, 2, "system", "basemac");
char *v;
dmuci_get_option_value_string("cwmp", "cpe", "override_oui", &v);
if (v[0] == '\0')
v = os__get_deviceid_manufactureroui();
if(mac) {
size_t ln = strlen(mac);
if (ln < 17) goto not_found;
sscanf (mac,"%2c:%2c:%2c",str,str+2,str+4);
str[6] = '\0';
v = dmstrdup(str); // MEM WILL BE FREED IN DMMEMCLEAN
return v;
} else
goto not_found;
}
return v;
not_found:
v = "";
return v;
}
@ -220,100 +189,6 @@ static int set_device_provisioningcode(char *refparam, struct dmctx *ctx, void *
return 0;
}
static int get_base_mac_addr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "basemac");
return 0;
}
static int get_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("router.system", "memory_bank", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "code");
return 0;
}
static int set_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
//TODO
return 0;
case VALUESET:
dmubus_call_set("router.system", "memory_bank", UBUS_ARGS{{"bank", value, Integer}}, 1);
return 0;
}
return 0;
}
static int get_catv_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *catv;
dmuci_get_option_value_string("catv", "catv", "enable", &catv);
if (strcmp(catv, "on") == 0)
*value = "1";
else
*value = "0";
return 0;
}
static int set_device_catvenabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value("catv", "catv", "enable", b ? "on" : "off");
return 0;
}
return 0;
}
static int get_catv_optical_input_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("catv", "vpd", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "VPD");
return 0;
}
static int get_catv_rf_output_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("catv", "rf", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "RF");
return 0;
}
static int get_catv_temperature(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("catv", "temp", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "Temperature");
return 0;
}
static int get_catv_voltage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("catv", "vcc", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "VCC");
return 0;
}
static int get_vcf_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "name", value);
@ -437,104 +312,6 @@ static int get_vlf_persistent(char *refparam, struct dmctx *ctx, void *data, cha
return 0;
}
/*#Device.DeviceInfo.MemoryStatus.Total!UBUS:router.system/memory//total*/
static int get_memory_status_total(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("router.system", "memory", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "0");
*value = dmjson_get_value(res, 1, "total");
return 0;
}
/*#Device.DeviceInfo.MemoryStatus.Free!UBUS:router.system/memory//free*/
static int get_memory_status_free(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("router.system", "memory", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "0");
*value = dmjson_get_value(res, 1, "free");
return 0;
}
/*#Device.DeviceInfo.ProcessStatus.CPUUsage!UBUS:router.system/process//cpu_usage*/
static int get_process_cpu_usage(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("router.system", "process", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "0");
*value = dmjson_get_value(res, 1, "cpu_usage");
return 0;
}
static int get_process_number_of_entries(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res = NULL, *processes = NULL;
int nbre_process = 0;
dmubus_call("router.system", "processes", UBUS_ARGS{}, 0, &res);
if (res) {
json_object_object_get_ex(res, "processes", &processes);
if (processes)
nbre_process = json_object_array_length(processes);
}
dmasprintf(value, "%d", nbre_process);
return 0;
}
static int get_process_pid(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "pid");
return 0;
}
static int get_process_command(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "command");
return 0;
}
static int get_process_size(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "vsz");
return 0;
}
static int get_process_priority(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "priority");
return 0;
}
static int get_process_cpu_time(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "cputime");
return 0;
}
static int get_process_state(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "state");
return 0;
}
static int browsePocessEntriesInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *res = NULL, *processes = NULL, *arrobj = NULL;
char *idx, *idx_last = NULL;
int id = 0, i = 0;
dmubus_call("router.system", "processes", UBUS_ARGS{}, 0, &res);
if (res) {
dmjson_foreach_obj_in_array(res, arrobj, processes, i, 1, "processes") {
idx = handle_update_instance(2, dmctx, &idx_last, update_instance_without_section, 1, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)processes, idx) == DM_STOP)
break;
}
}
return 0;
}
static int browseVcfInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *vcf = NULL, *vcf_last = NULL, *name;
@ -627,9 +404,11 @@ DMLEAF tDeviceInfoParams[] = {
{"DeviceLog", &DMREAD, DMT_STRING, get_device_devicelog, NULL, NULL, NULL, BBFDM_BOTH},
{"SpecVersion", &DMREAD, DMT_STRING, get_device_specversion, NULL, &DMFINFRM, NULL, BBFDM_BOTH},
{"ProvisioningCode", &DMWRITE, DMT_STRING, get_device_provisioningcode, set_device_provisioningcode, &DMFINFRM, &DMACTIVE, BBFDM_BOTH},
{CUSTOM_PREFIX"BaseMacAddr", &DMREAD, DMT_STRING, get_base_mac_addr, NULL, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"CATVEnabled", &DMWRITE, DMT_BOOL, get_catv_enabled, set_device_catvenabled, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"MemoryBank", &DMWRITE, DMT_INT, get_device_memory_bank, set_device_memory_bank, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"BaseMacAddr", &DMREAD, DMT_STRING, os__get_base_mac_addr, NULL, NULL, NULL, BBFDM_BOTH},
#ifndef GENERIC_OPENWRT
{CUSTOM_PREFIX"CATVEnabled", &DMWRITE, DMT_BOOL, os_iopsys_get_catv_enabled, os_iopsys_set_device_catvenabled, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"MemoryBank", &DMWRITE, DMT_INT, os_iopsys_get_device_memory_bank, os_iopsys_set_device_memory_bank, NULL, NULL, BBFDM_BOTH},
#endif
{0}
};
@ -648,45 +427,47 @@ DMLEAF tDeviceInfoVendorConfigFileParams[] = {
/* *** Device.DeviceInfo.MemoryStatus. *** */
DMLEAF tDeviceInfoMemoryStatusParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Total", &DMREAD, DMT_UNINT, get_memory_status_total, NULL, NULL, NULL, BBFDM_BOTH},
{"Free", &DMREAD, DMT_UNINT, get_memory_status_free, NULL, NULL, NULL, BBFDM_BOTH},
{"Total", &DMREAD, DMT_UNINT, os__get_memory_status_total, NULL, NULL, NULL, BBFDM_BOTH},
{"Free", &DMREAD, DMT_UNINT, os__get_memory_status_free, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.DeviceInfo.ProcessStatus. *** */
DMOBJ tDeviceInfoProcessStatusObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextdynamicobj, nextobj, leaf, linker, bbfdm_type*/
{"Process", &DMREAD, NULL, NULL, NULL, browsePocessEntriesInst, NULL, NULL, NULL, NULL, tDeviceInfoProcessStatusProcessParams, NULL, BBFDM_BOTH},
{"Process", &DMREAD, NULL, NULL, NULL, os__browseProcessEntriesInst, NULL, NULL, NULL, NULL, tDeviceInfoProcessStatusProcessParams, NULL, BBFDM_BOTH},
{0}
};
DMLEAF tDeviceInfoProcessStatusParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"CPUUsage", &DMREAD, DMT_UNINT, get_process_cpu_usage, NULL, NULL, NULL, BBFDM_BOTH},
{"ProcessNumberOfEntries", &DMREAD, DMT_UNINT, get_process_number_of_entries, NULL, NULL, NULL, BBFDM_BOTH},
{"CPUUsage", &DMREAD, DMT_UNINT, os__get_process_cpu_usage, NULL, NULL, NULL, BBFDM_BOTH},
{"ProcessNumberOfEntries", &DMREAD, DMT_UNINT, os__get_process_number_of_entries, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.DeviceInfo.ProcessStatus.Process.{i}. *** */
DMLEAF tDeviceInfoProcessStatusProcessParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"PID", &DMREAD, DMT_UNINT, get_process_pid, NULL, NULL, NULL, BBFDM_BOTH},
{"Command", &DMREAD, DMT_STRING, get_process_command, NULL, NULL, NULL, BBFDM_BOTH},
{"Size", &DMREAD, DMT_UNINT, get_process_size, NULL, NULL, NULL, BBFDM_BOTH},
{"Priority", &DMREAD, DMT_UNINT, get_process_priority, NULL, NULL, NULL, BBFDM_BOTH},
{"CPUTime", &DMREAD, DMT_UNINT, get_process_cpu_time, NULL, NULL, NULL, BBFDM_BOTH},
{"State", &DMREAD, DMT_STRING, get_process_state, NULL, NULL, NULL, BBFDM_BOTH},
{"PID", &DMREAD, DMT_UNINT, os__get_process_pid, NULL, NULL, NULL, BBFDM_BOTH},
{"Command", &DMREAD, DMT_STRING, os__get_process_command, NULL, NULL, NULL, BBFDM_BOTH},
{"Size", &DMREAD, DMT_UNINT, os__get_process_size, NULL, NULL, NULL, BBFDM_BOTH},
{"Priority", &DMREAD, DMT_UNINT, os__get_process_priority, NULL, NULL, NULL, BBFDM_BOTH},
{"CPUTime", &DMREAD, DMT_UNINT, os__get_process_cpu_time, NULL, NULL, NULL, BBFDM_BOTH},
{"State", &DMREAD, DMT_STRING, os__get_process_state, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/*** DeviceInfo.X_IOPSYS_EU_CATV. ***/
DMLEAF tCatTvParams[] = {
#ifndef GENERIC_OPENWRT
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Enabled", &DMWRITE, DMT_STRING, get_catv_enabled, set_device_catvenabled, NULL, NULL, BBFDM_BOTH},
{"OpticalInputLevel", &DMREAD, DMT_STRING, get_catv_optical_input_level, NULL, NULL, NULL, BBFDM_BOTH},
{"RFOutputLevel", &DMREAD, DMT_STRING, get_catv_rf_output_level, NULL, NULL, NULL, BBFDM_BOTH},
{"Temperature", &DMREAD, DMT_STRING, get_catv_temperature, NULL, NULL, NULL, BBFDM_BOTH},
{"Voltage", &DMREAD, DMT_STRING, get_catv_voltage, NULL, NULL, NULL, BBFDM_BOTH},
{"Enabled", &DMWRITE, DMT_STRING, os_iopsys_get_catv_enabled, os_iopsys_set_device_catvenabled, NULL, NULL, BBFDM_BOTH},
{"OpticalInputLevel", &DMREAD, DMT_STRING, os_iopsys_get_catv_optical_input_level, NULL, NULL, NULL, BBFDM_BOTH},
{"RFOutputLevel", &DMREAD, DMT_STRING, os_iopsys_get_catv_rf_output_level, NULL, NULL, NULL, BBFDM_BOTH},
{"Temperature", &DMREAD, DMT_STRING, os_iopsys_get_catv_temperature, NULL, NULL, NULL, BBFDM_BOTH},
{"Voltage", &DMREAD, DMT_STRING, os_iopsys_get_catv_voltage, NULL, NULL, NULL, BBFDM_BOTH},
#endif
{0}
};

View file

@ -0,0 +1,258 @@
#include "os.h"
#include "dmentry.h"
struct host_args
{
json_object *client;
char *key;
};
static char * get_interface_type(char *mac, char *ndev)
{
json_object *res;
int wlctl_num;
struct uci_section *s, *d;
char buf[8], *p, *network, *value, *wunit;
uci_foreach_sections("wireless", "wifi-device", d) {
wlctl_num = 0;
wunit = section_name(d);
uci_foreach_option_eq("wireless", "wifi-iface", "device", wunit, s) {
dmuci_get_value_by_section_string(s, "network", &network);
if (strcmp(network, ndev) == 0) {
if (wlctl_num != 0) {
snprintf(buf, sizeof(buf), "%s.%d", wunit, wlctl_num);
p = buf;
} else {
p = wunit;
}
dmubus_call("router.wireless", "stas", UBUS_ARGS{{"vif", p, String}}, 1, &res);
if(res) {
json_object_object_foreach(res, key, val) {
UNUSED(key);
value = dmjson_get_value(val, 1, "macaddr");
if (strcasecmp(value, mac) == 0)
return "802.11";
}
}
wlctl_num++;
}
}
}
return "Ethernet";
}
static inline int init_host_args(struct host_args *args, json_object *clients, char *key)
{
args->client = clients;
args->key = key;
return 0;
}
int os__browsehostInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *res;
char *idx, *idx_last = NULL, *connected;
int id = 0;
struct host_args curr_host_args = {0};
dmubus_call("router.network", "clients", UBUS_ARGS{}, 0, &res);
if (res) {
json_object_object_foreach(res, key, client_obj) {
connected = dmjson_get_value(client_obj, 1, "connected");
if(strcmp(connected, "false") == 0)
continue;
init_host_args(&curr_host_args, client_obj, key);
idx = handle_update_instance(2, dmctx, &idx_last, update_instance_without_section, 1, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_host_args, idx) == DM_STOP)
break;
}
}
return 0;
}
int os__get_host_nbr_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
int entries = 0;
json_object *res;
dmubus_call("router.network", "clients", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "0");
json_object_object_foreach(res, key, client_obj) {
UNUSED(key);
UNUSED(client_obj);
entries++;
}
dmasprintf(value, "%d", entries); // MEM WILL BE FREED IN DMMEMCLEAN
return 0;
}
int os__get_host_interfacetype(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *mac, *network;
mac = dmjson_get_value(((struct host_args *)data)->client, 1, "macaddr");
network = dmjson_get_value(((struct host_args *)data)->client, 1, "network");
*value = get_interface_type(mac, network);
return 0;
}
/*************************************************************
* GET & SET PARAM
**************************************************************/
int os__get_host_associateddevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ss;
char *accesspointInstance = NULL, *wifiAssociativeDeviecPath;
char *macaddr_linker = dmjson_get_value(((struct host_args *)data)->client, 1, "macaddr");
uci_path_foreach_sections(bbfdm, "dmmap_wireless", "wifi-iface", ss) {
dmuci_get_value_by_section_string(ss, "accesspointinstance", &accesspointInstance);
if(accesspointInstance[0] != '\0')
dmasprintf(&wifiAssociativeDeviecPath, "Device.WiFi.AccessPoint.%s.AssociatedDevice.", accesspointInstance);
accesspointInstance = NULL;
adm_entry_get_linker_param(ctx, wifiAssociativeDeviecPath, macaddr_linker, value);
if(*value != NULL)
break;
}
if (*value == NULL)
*value = "";
return 0;
}
int os__get_host_layer3interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *ip_linker=dmjson_get_value(((struct host_args *)data)->client, 1, "network");
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", ip_linker, value);
if (*value == NULL)
*value = "";
return 0;
}
int os__get_host_interface_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *type= NULL;
char *ifname = dmjson_get_value(((struct host_args *)data)->client, 1, "network");
struct uci_section *ss = NULL;
uci_foreach_sections("network", "interface", ss) {
if (!strcmp(ifname, section_name(ss))) {
dmuci_get_value_by_section_string(ss, "type", &type);
if (type!=NULL) {
if (!strcmp(type, "bridge")) *value="Bridge";else *value= "Normal";
break;
}
}
}
return 0;
}
int os__get_host_interfacename(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *frequency, *wireless;
frequency = dmjson_get_value(((struct host_args *)data)->client, 1, "frequency");
wireless = dmjson_get_value(((struct host_args *)data)->client, 1, "wireless");
if ((*frequency != '\0') && (strcmp(wireless, "true")==0)) {
if(strcmp(frequency,"5GHz")==0)
*value = "WiFi@5GHz";
else
*value = "WiFi@2.4GHz";
} else {
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "ethport");
if (*value == NULL)
*value = "";
}
return 0;
}
int os__get_host_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "ipaddr");
return 0;
}
int os__get_host_hostname(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "hostname");
return 0;
}
int os__get_host_active(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "connected");
return 0;
}
int os__get_host_phy_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "macaddr");
return 0;
}
int os__get_host_address_source(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *dhcp;
dhcp = dmjson_get_value(((struct host_args *)data)->client, 1, "dhcp");
if (strcasecmp(dhcp, "true") == 0)
*value = "DHCP";
else
*value = "Static";
return 0;
}
int os__get_host_leasetime_remaining(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *dhcp;
FILE *fp;
char line[MAX_DHCP_LEASES];
char *leasetime, *mac_f, *mac, *line1;
char delimiter[] = " \t";
dhcp = dmjson_get_value(((struct host_args *)data)->client, 1, "dhcp");
if (strcmp(dhcp, "false") == 0) {
*value = "0";
}
else {
mac = dmjson_get_value(((struct host_args *)data)->client, 1, "macaddr");
fp = fopen(DHCP_LEASES_FILE, "r");
if ( fp != NULL)
{
while (fgets(line, MAX_DHCP_LEASES, fp) != NULL )
{
if (line[0] == '\n')
continue;
line1 = dmstrdup(line);
leasetime = cut_fx(line, delimiter, 1);
mac_f = cut_fx(line1, delimiter, 2);
if (strcasecmp(mac, mac_f) == 0) {
int rem_lease = atoi(leasetime) - time(NULL);
if (rem_lease < 0)
*value = "-1";
else
dmasprintf(value, "%d", rem_lease); // MEM WILL BE FREED IN DMMEMCLEAN
fclose(fp) ;
return 0;
}
}
fclose(fp);
*value = "0";
}
}
return 0;
}
int os__get_host_dhcp_client(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker;
dmasprintf(&linker, "%s", ((struct host_args *)data)->key);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cDHCPv4%c", dmroot, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL) {
*value = "";
}
dmfree(linker);
return 0;
}

View file

@ -0,0 +1,78 @@
#include "os.h"
static int not_implemented(char **value)
{
*value = "";
return 0;
}
int os__browsehostInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
return 0;
}
int os__get_host_nbr_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_host_interfacetype(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_host_associateddevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_host_layer3interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_host_interface_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_host_interfacename(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_host_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_host_hostname(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_host_active(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_host_phy_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_host_address_source(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_host_leasetime_remaining(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_host_dhcp_client(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}

View file

@ -9,297 +9,37 @@
*
*/
#include "dmentry.h"
#include "hosts.h"
#include "os.h"
struct host_args
{
json_object *client;
char *key;
};
/*************************************************************
* INIT
**************************************************************/
static inline int init_host_args(struct host_args *args, json_object *clients, char *key)
{
args->client = clients;
args->key = key;
return 0;
}
/*************************************************************
* GET & SET PARAM
**************************************************************/
static int get_host_associateddevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ss;
char *accesspointInstance = NULL, *wifiAssociativeDeviecPath;
char *macaddr_linker = dmjson_get_value(((struct host_args *)data)->client, 1, "macaddr");
uci_path_foreach_sections(bbfdm, "dmmap_wireless", "wifi-iface", ss) {
dmuci_get_value_by_section_string(ss, "accesspointinstance", &accesspointInstance);
if(accesspointInstance[0] != '\0')
dmasprintf(&wifiAssociativeDeviecPath, "Device.WiFi.AccessPoint.%s.AssociatedDevice.", accesspointInstance);
accesspointInstance = NULL;
adm_entry_get_linker_param(ctx, wifiAssociativeDeviecPath, macaddr_linker, value);
if(*value != NULL)
break;
}
if (*value == NULL)
*value = "";
return 0;
}
static int get_host_layer3interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *ip_linker=dmjson_get_value(((struct host_args *)data)->client, 1, "network");
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", ip_linker, value);
if (*value == NULL)
*value = "";
return 0;
}
static int get_host_interface_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *type= NULL;
char *ifname = dmjson_get_value(((struct host_args *)data)->client, 1, "network");
struct uci_section *ss = NULL;
uci_foreach_sections("network", "interface", ss) {
if (!strcmp(ifname, section_name(ss))) {
dmuci_get_value_by_section_string(ss, "type", &type);
if (type!=NULL) {
if (!strcmp(type, "bridge")) *value="Bridge";else *value= "Normal";
break;
}
}
}
return 0;
}
static int get_host_interfacename(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *frequency, *wireless;
frequency = dmjson_get_value(((struct host_args *)data)->client, 1, "frequency");
wireless = dmjson_get_value(((struct host_args *)data)->client, 1, "wireless");
if ((*frequency != '\0') && (strcmp(wireless, "true")==0)) {
if(strcmp(frequency,"5GHz")==0)
*value = "WiFi@5GHz";
else
*value = "WiFi@2.4GHz";
} else {
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "ethport");
if (*value == NULL)
*value = "";
}
return 0;
}
static int get_host_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "ipaddr");
return 0;
}
static int get_host_hostname(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "hostname");
return 0;
}
static int get_host_active(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "connected");
return 0;
}
static int get_host_phy_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "macaddr");
return 0;
}
static int get_host_address_source(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *dhcp;
dhcp = dmjson_get_value(((struct host_args *)data)->client, 1, "dhcp");
if (strcasecmp(dhcp, "true") == 0)
*value = "DHCP";
else
*value = "Static";
return 0;
}
static int get_host_leasetime_remaining(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *dhcp;
FILE *fp;
char line[MAX_DHCP_LEASES];
char *leasetime, *mac_f, *mac, *line1;
char delimiter[] = " \t";
dhcp = dmjson_get_value(((struct host_args *)data)->client, 1, "dhcp");
if (strcmp(dhcp, "false") == 0) {
*value = "0";
}
else {
mac = dmjson_get_value(((struct host_args *)data)->client, 1, "macaddr");
fp = fopen(DHCP_LEASES_FILE, "r");
if ( fp != NULL)
{
while (fgets(line, MAX_DHCP_LEASES, fp) != NULL )
{
if (line[0] == '\n')
continue;
line1 = dmstrdup(line);
leasetime = cut_fx(line, delimiter, 1);
mac_f = cut_fx(line1, delimiter, 2);
if (strcasecmp(mac, mac_f) == 0) {
int rem_lease = atoi(leasetime) - time(NULL);
if (rem_lease < 0)
*value = "-1";
else
dmasprintf(value, "%d", rem_lease); // MEM WILL BE FREED IN DMMEMCLEAN
fclose(fp) ;
return 0;
}
}
fclose(fp);
*value = "0";
}
}
return 0;
}
static int get_host_dhcp_client(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker;
dmasprintf(&linker, "%s", ((struct host_args *)data)->key);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cDHCPv4%c", dmroot, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL) {
*value = "";
}
dmfree(linker);
return 0;
}
static char *get_interface_type(char *mac, char *ndev)
{
json_object *res;
int wlctl_num;
struct uci_section *s, *d;
char buf[8], *p, *network, *value, *wunit;
uci_foreach_sections("wireless", "wifi-device", d) {
wlctl_num = 0;
wunit = section_name(d);
uci_foreach_option_eq("wireless", "wifi-iface", "device", wunit, s) {
dmuci_get_value_by_section_string(s, "network", &network);
if (strcmp(network, ndev) == 0) {
if (wlctl_num != 0) {
snprintf(buf, sizeof(buf), "%s.%d", wunit, wlctl_num);
p = buf;
} else {
p = wunit;
}
dmubus_call("router.wireless", "stas", UBUS_ARGS{{"vif", p, String}}, 1, &res);
if(res) {
json_object_object_foreach(res, key, val) {
UNUSED(key);
value = dmjson_get_value(val, 1, "macaddr");
if (strcasecmp(value, mac) == 0)
return "802.11";
}
}
wlctl_num++;
}
}
}
return "Ethernet";
}
static int get_host_interfacetype(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *mac, *network;
mac = dmjson_get_value(((struct host_args *)data)->client, 1, "macaddr");
network = dmjson_get_value(((struct host_args *)data)->client, 1, "network");
*value = get_interface_type(mac, network);
return 0;
}
static int get_host_nbr_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
int entries = 0;
json_object *res;
dmubus_call("router.network", "clients", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "0");
json_object_object_foreach(res, key, client_obj) {
UNUSED(key);
UNUSED(client_obj);
entries++;
}
dmasprintf(value, "%d", entries); // MEM WILL BE FREED IN DMMEMCLEAN
return 0;
}
/*************************************************************
* ENTRY METHOD
**************************************************************/
static int browsehostInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *res;
char *idx, *idx_last = NULL, *connected;
int id = 0;
struct host_args curr_host_args = {0};
dmubus_call("router.network", "clients", UBUS_ARGS{}, 0, &res);
if (res) {
json_object_object_foreach(res, key, client_obj) {
connected = dmjson_get_value(client_obj, 1, "connected");
if(strcmp(connected, "false") == 0)
continue;
init_host_args(&curr_host_args, client_obj, key);
idx = handle_update_instance(2, dmctx, &idx_last, update_instance_without_section, 1, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_host_args, idx) == DM_STOP)
break;
}
}
return 0;
}
/* *** Device.Hosts. *** */
DMOBJ tHostsObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextdynamicobj, nextobj, leaf, linker, bbfdm_type*/
{"Host", &DMREAD, NULL, NULL, NULL, browsehostInst, NULL, NULL, NULL, NULL, tHostsHostParams, NULL, BBFDM_BOTH},
{"Host", &DMREAD, NULL, NULL, NULL, os__browsehostInst, NULL, NULL, NULL, NULL, tHostsHostParams, NULL, BBFDM_BOTH},
{0}
};
DMLEAF tHostsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"HostNumberOfEntries", &DMREAD, DMT_UNINT, get_host_nbr_entries, NULL, NULL, NULL, BBFDM_BOTH},
{"HostNumberOfEntries", &DMREAD, DMT_UNINT, os__get_host_nbr_entries, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.Hosts.Host.{i}. *** */
DMLEAF tHostsHostParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"AssociatedDevice", &DMREAD, DMT_STRING, get_host_associateddevice, NULL, NULL, NULL, BBFDM_BOTH},
{"Layer3Interface", &DMREAD, DMT_STRING, get_host_layer3interface, NULL, NULL, NULL, BBFDM_BOTH},
{"IPAddress", &DMREAD, DMT_STRING, get_host_ipaddress, NULL, NULL, NULL, BBFDM_BOTH},
{"HostName", &DMREAD, DMT_STRING, get_host_hostname, NULL, NULL, NULL, BBFDM_BOTH},
{"Active", &DMREAD, DMT_BOOL, get_host_active, NULL, NULL, NULL, BBFDM_BOTH},
{"PhysAddress", &DMREAD, DMT_STRING, get_host_phy_address, NULL, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"LinkType", &DMREAD, DMT_STRING, get_host_interfacetype, NULL, NULL, NULL, BBFDM_BOTH},
{"AddressSource", &DMREAD, DMT_STRING, get_host_address_source, NULL, NULL, NULL, BBFDM_BOTH},
{"LeaseTimeRemaining", &DMREAD, DMT_INT, get_host_leasetime_remaining, NULL, NULL, NULL, BBFDM_BOTH},
{"DHCPClient", &DMREAD, DMT_STRING, get_host_dhcp_client, NULL, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"InterfaceType", &DMREAD, DMT_STRING, get_host_interface_type, NULL, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"ifname", &DMREAD, DMT_STRING, get_host_interfacename, NULL, NULL, NULL, BBFDM_BOTH},
{"AssociatedDevice", &DMREAD, DMT_STRING, os__get_host_associateddevice, NULL, NULL, NULL, BBFDM_BOTH},
{"Layer3Interface", &DMREAD, DMT_STRING, os__get_host_layer3interface, NULL, NULL, NULL, BBFDM_BOTH},
{"IPAddress", &DMREAD, DMT_STRING, os__get_host_ipaddress, NULL, NULL, NULL, BBFDM_BOTH},
{"HostName", &DMREAD, DMT_STRING, os__get_host_hostname, NULL, NULL, NULL, BBFDM_BOTH},
{"Active", &DMREAD, DMT_BOOL, os__get_host_active, NULL, NULL, NULL, BBFDM_BOTH},
{"PhysAddress", &DMREAD, DMT_STRING, os__get_host_phy_address, NULL, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"LinkType", &DMREAD, DMT_STRING, os__get_host_interfacetype, NULL, NULL, NULL, BBFDM_BOTH},
{"AddressSource", &DMREAD, DMT_STRING, os__get_host_address_source, NULL, NULL, NULL, BBFDM_BOTH},
{"LeaseTimeRemaining", &DMREAD, DMT_INT, os__get_host_leasetime_remaining, NULL, NULL, NULL, BBFDM_BOTH},
{"DHCPClient", &DMREAD, DMT_STRING, os__get_host_dhcp_client, NULL, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"InterfaceType", &DMREAD, DMT_STRING, os__get_host_interface_type, NULL, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"ifname", &DMREAD, DMT_STRING, os__get_host_interfacename, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};

117
dmtree/tr181/os.h Normal file
View file

@ -0,0 +1,117 @@
#ifndef __BBF_TR181_OPERATING_SYTEM_H
#define __BBF_TR181_OPERATING_SYTEM_H
#include <libbbf_api/dmbbf.h>
/* IOPSYS-WRT and OpenWrt
*/
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);
int os__get_memory_status_free(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_process_cpu_usage(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_process_number_of_entries(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_process_pid(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_process_command(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_process_size(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_process_priority(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_process_cpu_time(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_process_state(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__browseProcessEntriesInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int os__browsehostInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int os__get_host_nbr_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_host_interfacetype(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_host_associateddevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_host_layer3interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_host_interface_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_host_interfacename(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_host_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_host_hostname(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_host_active(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_host_phy_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_host_address_source(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_host_leasetime_remaining(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_host_dhcp_client(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#include "wifi.h"
int os__get_wlan_bssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiRadioStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiRadioStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiRadioStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiRadioStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiRadioStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiRadioStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiRadioStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiRadioStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiRadioStats_FCSErrorCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_UnicastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_UnicastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_MulticastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_BroadcastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_BroadcastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_RetransCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_FailedRetransCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_RetryCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_MultipleRetryCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_ACKFailureCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_AggregatedPacketCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiSSIDStats_UnknownProtoPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_access_point_associative_device_statistics_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_access_point_associative_device_statistics_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_access_point_associative_device_statistics_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_access_point_associative_device_statistics_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_access_point_associative_device_statistics_tx_errors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_access_point_associative_device_statistics_retrans_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_access_point_associative_device_statistics_failed_retrans_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_access_point_associative_device_statistics_retry_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_access_point_associative_device_statistics_multiple_retry_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_radio_max_bit_rate (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_radio_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_radio_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_neighboring_wifi_diagnostics_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_neighboring_wifi_diagnostics_result_ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_neighboring_wifi_diagnostics_result_bssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_neighboring_wifi_diagnostics_result_number_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_neighboring_wifi_diagnostics_result_noise(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_neighboring_wifi_diagnostics_result_operating_frequency_band(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_neighboring_wifi_diagnostics_result_signal_strength(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_neighboring_wifi_diagnostics_result_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_radio_possible_channels(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__browseWifiNeighboringWiFiDiagnosticResultInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int os__get_WiFiRadio_CurrentOperatingChannelBandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_WiFiRadio_SupportedOperatingChannelBandwidths(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_radio_supported_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__get_access_point_total_associations(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os__browse_wifi_associated_device(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
char * os__get_radio_frequency_nocache(const struct wifi_radio_args *args);
char * os__get_radio_channel_nocache(const struct wifi_radio_args *args);
void os__wifi_start_scan(const char *radio);
/* IOPSYS-WRT only
*/
#ifndef GENERIC_OPENWRT
int os_iopsys_get_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os_iopsys_set_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int os_iopsys_get_catv_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os_iopsys_set_device_catvenabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int os_iopsys_get_catv_optical_input_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os_iopsys_get_catv_rf_output_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os_iopsys_get_catv_temperature(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int os_iopsys_get_catv_voltage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#endif
#endif

View file

@ -0,0 +1,653 @@
#include "os.h"
/*#Device.WiFi.SSID.{i}.BSSID!UBUS:wifi.ap.@Name/status//bssid*/
int os__get_wlan_bssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res = NULL;
char object[32];
snprintf(object, sizeof(object), "wifi.ap.%s", ((struct wifi_ssid_args *)data)->ifname);
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "bssid");
return 0;
}
static int ssid_read_ubus(const struct wifi_ssid_args *args, const char *name, char **value)
{
json_object *res = NULL;
char object[32];
snprintf(object, sizeof(object), "wifi.ap.%s", args->ifname);
dmubus_call(object, "stats", UBUS_ARGS{}, 0, &res);
if (!res) {
*value = "0";
return 0;
}
*value = dmjson_get_value(res, 1, name);
return 0;
}
static int radio_read_ubus(const struct wifi_radio_args *args, const char *name, char **value)
{
json_object *res = NULL;
char object[32];
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(args->wifi_radio_sec));
dmubus_call(object, "stats", UBUS_ARGS{}, 0, &res);
if (!res) {
*value = "0";
return 0;
}
*value = dmjson_get_value(res, 1, name);
return 0;
}
/*#Device.WiFi.Radio.{i}.Stats.BytesSent!UBUS:wifi.radio.@Name/stats//tx_bytes*/
int os__get_WiFiRadioStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return radio_read_ubus(data, "tx_bytes", value);
}
/*#Device.WiFi.Radio.{i}.Stats.BytesReceived!UBUS:wifi.radio.@Name/stats//rx_bytes*/
int os__get_WiFiRadioStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return radio_read_ubus(data, "rx_bytes", value);
}
/*#Device.WiFi.Radio.{i}.Stats.PacketsSent!UBUS:wifi.radio.@Name/stats//tx_packets*/
int os__get_WiFiRadioStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return radio_read_ubus(data, "tx_packets", value);
}
/*#Device.WiFi.Radio.{i}.Stats.PacketsReceived!UBUS:wifi.radio.@Name/stats//rx_packets*/
int os__get_WiFiRadioStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return radio_read_ubus(data, "rx_packets", value);
}
/*#Device.WiFi.Radio.{i}.Stats.ErrorsSent!UBUS:wifi.radio.@Name/stats//tx_error_packets*/
int os__get_WiFiRadioStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return radio_read_ubus(data, "tx_error_packets", value);
}
/*#Device.WiFi.Radio.{i}.Stats.ErrorsReceived!UBUS:wifi.radio.@Name/stats//rx_error_packets*/
int os__get_WiFiRadioStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return radio_read_ubus(data, "rx_error_packets", value);
}
/*#Device.WiFi.Radio.{i}.Stats.DiscardPacketsSent!UBUS:wifi.radio.@Name/stats//tx_dropped_packets*/
int os__get_WiFiRadioStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return radio_read_ubus(data, "tx_dropped_packets", value);
}
/*#Device.WiFi.Radio.{i}.Stats.DiscardPacketsReceived!UBUS:wifi.radio.@Name/stats//rx_dropped_packets*/
int os__get_WiFiRadioStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return radio_read_ubus(data, "rx_dropped_packets", value);
}
/*#Device.WiFi.Radio.{i}.Stats.FCSErrorCount!UBUS:wifi.radio.@Name/stats//rx_fcs_error_packets*/
int os__get_WiFiRadioStats_FCSErrorCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return radio_read_ubus(data, "rx_fcs_error_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.BytesSent!UBUS:wifi.ap.@Name/stats//tx_bytes*/
int os__get_WiFiSSIDStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "tx_bytes", value);
}
/*#Device.WiFi.SSID.{i}.Stats.BytesReceived!UBUS:wifi.ap.@Name/stats//rx_bytes*/
int os__get_WiFiSSIDStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "rx_bytes", value);
}
/*#Device.WiFi.SSID.{i}.Stats.PacketsSent!UBUS:wifi.ap.@Name/stats//tx_packets*/
int os__get_WiFiSSIDStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "tx_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.PacketsReceived!UBUS:wifi.ap.@Name/stats//rx_packets*/
int os__get_WiFiSSIDStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "rx_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.ErrorsSent!UBUS:wifi.ap.@Name/stats//tx_error_packets*/
int os__get_WiFiSSIDStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "tx_error_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.ErrorsReceived!UBUS:wifi.ap.@Name/stats//rx_error_packets*/
int os__get_WiFiSSIDStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "rx_error_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.DiscardPacketsSent!UBUS:wifi.ap.@Name/stats//tx_dropped_packets*/
int os__get_WiFiSSIDStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "tx_dropped_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.DiscardPacketsReceived!UBUS:wifi.ap.@Name/stats//rx_dropped_packets*/
int os__get_WiFiSSIDStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "rx_dropped_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.UnicastPacketsSent!UBUS:wifi.ap.@Name/stats//tx_unicast_packets*/
int os__get_WiFiSSIDStats_UnicastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "tx_unicast_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.UnicastPacketsReceived!UBUS:wifi.ap.@Name/stats//rx_unicast_packets*/
int os__get_WiFiSSIDStats_UnicastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "rx_unicast_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.MulticastPacketsSent!UBUS:wifi.ap.@Name/stats//tx_multicast_packets*/
int os__get_WiFiSSIDStats_MulticastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "tx_multicast_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.MulticastPacketsReceived!UBUS:wifi.ap.@Name/stats//rx_multicast_packets*/
int os__get_WiFiSSIDStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "rx_multicast_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.BroadcastPacketsSent!UBUS:wifi.ap.@Name/stats//tx_broadcast_packets*/
int os__get_WiFiSSIDStats_BroadcastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "tx_broadcast_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.BroadcastPacketsReceived!UBUS:wifi.ap.@Name/stats//rx_broadcast_packets*/
int os__get_WiFiSSIDStats_BroadcastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "rx_broadcast_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.RetransCount!UBUS:wifi.ap.@Name/stats//tx_retrans_packets*/
int os__get_WiFiSSIDStats_RetransCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "tx_retrans_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.FailedRetransCount!UBUS:wifi.ap.@Name/stats//tx_retrans_fail_packets*/
int os__get_WiFiSSIDStats_FailedRetransCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "tx_retrans_fail_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.RetryCount!UBUS:wifi.ap.@Name/stats//tx_retry_packets*/
int os__get_WiFiSSIDStats_RetryCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "tx_retry_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.MultipleRetryCount!UBUS:wifi.ap.@Name/stats//tx_multi_retry_packets*/
int os__get_WiFiSSIDStats_MultipleRetryCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "tx_multi_retry_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.ACKFailureCount!UBUS:wifi.ap.@Name/stats//ack_fail_packets*/
int os__get_WiFiSSIDStats_ACKFailureCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "ack_fail_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.AggregatedPacketCount!UBUS:wifi.ap.@Name/stats//aggregate_packets*/
int os__get_WiFiSSIDStats_AggregatedPacketCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "aggregate_packets", value);
}
/*#Device.WiFi.SSID.{i}.Stats.UnknownProtoPacketsReceived!UBUS:wifi.ap.@Name/stats//rx_unknown_packets*/
int os__get_WiFiSSIDStats_UnknownProtoPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return ssid_read_ubus(data, "rx_unknown_packets", value);
}
static char *get_associative_device_statistics(struct wifi_associative_device_args *wifi_associative_device, char *key)
{
json_object *res, *jobj;
char *macaddr, *stats = "0";
int entries = 0;
dmubus_call("wifix", "stations", UBUS_ARGS{{"vif", wifi_associative_device->wdev, String}}, 1, &res);
while (res) {
jobj = dmjson_select_obj_in_array_idx(res, entries, 1, "stations");
if(jobj) {
macaddr = dmjson_get_value(jobj, 1, "macaddr");
if (!strcmp(macaddr, wifi_associative_device->macaddress)) {
stats = dmjson_get_value(jobj, 2, "stats", key);
if(*stats != '\0')
return stats;
}
entries++;
} else
break;
}
return stats;
}
/*#Device.WiFi.AccessPoint.{i}.Stats.BytesSent!UBUS:wifix/stations/vif,@Name/stats.tx_total_bytes*/
int os__get_access_point_associative_device_statistics_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data;
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "tx_total_bytes");
return 0;
}
/*#Device.WiFi.AccessPoint.{i}.Stats.BytesReceived!UBUS:wifix/stations/vif,@Name/stats.rx_data_bytes*/
int os__get_access_point_associative_device_statistics_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data;
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "rx_data_bytes");
return 0;
}
/*#Device.WiFi.AccessPoint.{i}.Stats.PacketsSent!UBUS:wifix/stations/vif,@Name/stats.tx_total_pkts*/
int os__get_access_point_associative_device_statistics_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data;
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "tx_total_pkts");
return 0;
}
/*#Device.WiFi.AccessPoint.{i}.Stats.PacketsReceived!UBUS:wifix/stations/vif,@Name/stats.rx_data_pkts*/
int os__get_access_point_associative_device_statistics_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data;
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "rx_data_pkts");
return 0;
}
/*#Device.WiFi.AccessPoint.{i}.Stats.ErrorsSent!UBUS:wifix/stations/vif,@Name/stats.tx_failures*/
int os__get_access_point_associative_device_statistics_tx_errors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data;
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "tx_failures");
return 0;
}
/*#Device.WiFi.AccessPoint.{i}.Stats.RetransCount!UBUS:wifix/stations/vif,@Name/stats.tx_pkts_retries*/
int os__get_access_point_associative_device_statistics_retrans_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data;
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "tx_pkts_retries");
return 0;
}
/*#Device.WiFi.AccessPoint.{i}.Stats.FailedRetransCount!UBUS:wifix/stations/vif,@Name/stats.tx_pkts_retry_exhausted*/
int os__get_access_point_associative_device_statistics_failed_retrans_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data;
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "tx_pkts_retry_exhausted");
return 0;
}
/*#Device.WiFi.AccessPoint.{i}.Stats.RetryCount!UBUS:wifix/stations/vif,@Name/stats.tx_pkts_retries*/
int os__get_access_point_associative_device_statistics_retry_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data;
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "tx_pkts_retries");
return 0;
}
/*#Device.WiFi.AccessPoint.{i}.Stats.MultipleRetryCount!UBUS:wifix/stations/vif,@Name/stats.tx_data_pkts_retried*/
int os__get_access_point_associative_device_statistics_multiple_retry_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data;
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "tx_data_pkts_retried");
return 0;
}
/*#Device.WiFi.Radio.{i}.MaxBitRate!UBUS:wifi.radio.@Name/status//maxrate*/
int os__get_radio_max_bit_rate (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res = NULL;
char object[32];
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(((struct wifi_radio_args *)data)->wifi_radio_sec));
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "maxrate");
return 0;
}
/*#Device.WiFi.Radio.{i}.OperatingFrequencyBand!UBUS:wifi.radio.@Name/status//band*/
int os__get_radio_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res = NULL;
char object[32];
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(((struct wifi_radio_args *)data)->wifi_radio_sec));
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "band");
return 0;
}
/*#Device.WiFi.Radio.{i}.ChannelsInUse!UCI:wireless/wifi-device,@i-1/channel*/
int os__get_radio_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res = NULL;
dmuci_get_value_by_section_string(((struct wifi_radio_args *)data)->wifi_radio_sec, "channel", value);
if (strcmp(*value, "auto") == 0 || (*value)[0] == '\0') {
char object[32];
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(((struct wifi_radio_args *)data)->wifi_radio_sec));
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "channel");
}
return 0;
}
char * os__get_radio_channel_nocache(const struct wifi_radio_args *args)
{
char object[32];
char *value = "";
json_object *res;
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(args->wifi_radio_sec));
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
if (res)
value = dmjson_get_value(res, 1, "channel");
return value;
}
char * os__get_radio_frequency_nocache(const struct wifi_radio_args *args)
{
char object[32];
json_object *res;
char *freq = "";
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(args->wifi_radio_sec));
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
if (res)
freq = dmjson_get_value(res, 1, "frequency");
return freq;
}
int os__get_neighboring_wifi_diagnostics_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ss;
json_object *res = NULL, *neighboring_wifi_obj = NULL;
char object[32];
uci_foreach_sections("wireless", "wifi-device", ss) {
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(ss));
dmubus_call(object, "scanresults", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "None");
neighboring_wifi_obj = dmjson_select_obj_in_array_idx(res, 0, 1, "accesspoints");
if (neighboring_wifi_obj) {
*value = "Complete";
break;
} else
*value = "None";
}
return 0;
}
int os__get_neighboring_wifi_diagnostics_result_number_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ss;
json_object *res = NULL, *accesspoints = NULL;
size_t entries = 0, result = 0;
char object[32];
*value = "0";
uci_foreach_sections("wireless", "wifi-device", ss) {
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(ss));
dmubus_call(object, "scanresults", UBUS_ARGS{}, 0, &res);
if (res) {
json_object_object_get_ex(res, "accesspoints", &accesspoints);
if (accesspoints)
entries = json_object_array_length(accesspoints);
}
result = result + entries;
entries = 0;
}
dmasprintf(value, "%d", result); // MEM WILL BE FREED IN DMMEMCLEAN
return 0;
}
void os__wifi_start_scan(const char *radio)
{
char object[32];
snprintf(object, sizeof(object), "wifi.radio.%s", radio);
dmubus_call_set(object, "scan", UBUS_ARGS{}, 0);
}
int os__get_neighboring_wifi_diagnostics_result_ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "ssid");
return 0;
}
int os__get_neighboring_wifi_diagnostics_result_bssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "bssid");
return 0;
}
int os__get_neighboring_wifi_diagnostics_result_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "channel");
return 0;
}
int os__get_neighboring_wifi_diagnostics_result_signal_strength(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "rssi");
return 0;
}
int os__get_neighboring_wifi_diagnostics_result_operating_frequency_band(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "band");
return 0;
}
int os__get_neighboring_wifi_diagnostics_result_noise(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "snr");
return 0;
}
/*#Device.WiFi.Radio.{i}.PossibleChannels!UBUS:wifi.radio.@Name/status//supp_channels[0].channels*/
int os__get_radio_possible_channels(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res = NULL, *supp_channels = NULL;
char object[32];
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(((struct wifi_radio_args *)data)->wifi_radio_sec));
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
supp_channels = dmjson_select_obj_in_array_idx(res, 0, 1, "supp_channels");
if (supp_channels)
*value = dmjson_get_value_array_all(supp_channels, DELIMITOR, 1, "channels");
return 0;
}
/*#Device.WiFi.Radio.{i}.SupportedOperatingChannelBandwidths!UBUS:wifi.radio.@Name/status//supp_channels[0].bandwidth*/
int os__get_WiFiRadio_SupportedOperatingChannelBandwidths(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res = NULL, *supp_channels = NULL;
char object[32];
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(((struct wifi_radio_args *)data)->wifi_radio_sec));
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
supp_channels = dmjson_select_obj_in_array_idx(res, 0, 1, "supp_channels");
if (supp_channels)
*value = dmjson_get_value(supp_channels, 1, "bandwidth");
return 0;
}
/*#Device.WiFi.Radio.{i}.CurrentOperatingChannelBandwidth!UBUS:wifi.radio.@Name/status//bandwidth*/
int os__get_WiFiRadio_CurrentOperatingChannelBandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
char object[32];
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(((struct wifi_radio_args *)data)->wifi_radio_sec));
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "bandwidth");
return 0;
}
int os__browseWifiNeighboringWiFiDiagnosticResultInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct uci_section *ss;
json_object *res = NULL, *accesspoints = NULL, *arrobj = NULL;
char object[32], *idx, *idx_last = NULL;
int id = 0, i = 0;
uci_foreach_sections("wireless", "wifi-device", ss) {
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(ss));
dmubus_call(object, "scanresults", UBUS_ARGS{}, 0, &res);
if (res) {
dmjson_foreach_obj_in_array(res, arrobj, accesspoints, i, 1, "accesspoints") {
idx = handle_update_instance(3, dmctx, &idx_last, update_instance_without_section, 1, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)accesspoints, idx) == DM_STOP)
return 0;
}
}
}
return 0;
}
/*#Device.WiFi.Radio.{i}.SupportedStandards!UBUS:wifi/status//radio[i-1].standard*/
int os__get_radio_supported_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res = NULL, *radios = NULL, *arrobj = NULL;
char *name;
int i = 0;
dmubus_call("wifi", "status", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
dmjson_foreach_obj_in_array(res, arrobj, radios, i, 1, "radios") {
name = dmjson_get_value(radios, 1, "name");
if (strcmp(name, section_name(((struct wifi_radio_args *)data)->wifi_radio_sec)) == 0) {
*value = dmjson_get_value(radios, 1, "standard");
return 0;
}
}
return 0;
}
int os__get_access_point_total_associations(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res, *jobj;
int entries = 0;
dmubus_call("wifix", "stations", UBUS_ARGS{{"vif", ((struct wifi_ssid_args *)data)->ifname, String}}, 1, &res);
DM_ASSERT(res, *value = "0");
while (1) {
jobj = dmjson_select_obj_in_array_idx(res, entries, 1, "stations");
if (jobj == NULL)
break;
entries++;
}
dmasprintf(value, "%d", entries); // MEM WILL BE FREED IN DMMEMCLEAN
return 0;
}
int os__browse_wifi_associated_device(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *res, *associated_client_obj;
struct uci_section *ss = NULL;
char *value, *ap_ifname, *idx, *idx_last = NULL;
int id = 0, entries = 0;
char *macaddr = NULL, *lastdatadownloadlinkrate = NULL, *lastdatauplinkrate = NULL, *signalstrength = NULL, *noise = NULL, *retrans = NULL, *assoctimestr = NULL;
struct wifi_associative_device_args cur_wifi_associative_device_args = {0};
struct uci_section *dmmap_section;
uci_foreach_sections("wireless", "wifi-iface", ss) {
get_dmmap_section_of_config_section("dmmap_wireless", "wifi-iface", section_name(ss), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "accesspointinstance", &value);
if(!strcmp(value, prev_instance)){
dmuci_get_value_by_section_string(ss, "ifname", &ap_ifname);
break;
}
}
dmubus_call("wifix", "stations", UBUS_ARGS{{"vif", ap_ifname, String}}, 1, &res);
while (res) {
associated_client_obj = dmjson_select_obj_in_array_idx(res, entries, 1, "stations");
if(associated_client_obj) {
cur_wifi_associative_device_args.wdev = ap_ifname;
macaddr = dmjson_get_value(associated_client_obj, 1, "macaddr");
if(macaddr!=NULL && strlen(macaddr)>0)
dmasprintf(&(cur_wifi_associative_device_args.macaddress),dmjson_get_value(associated_client_obj, 1, "macaddr"));
cur_wifi_associative_device_args.active = 1;
lastdatadownloadlinkrate = dmjson_get_value(associated_client_obj, 2, "stats", "rate_of_last_rx_pkt");
if(lastdatadownloadlinkrate!=NULL && strlen(lastdatadownloadlinkrate)>0)
cur_wifi_associative_device_args.lastdatadownloadlinkrate = atoi(lastdatadownloadlinkrate);
else
cur_wifi_associative_device_args.lastdatadownloadlinkrate = 0;
lastdatauplinkrate = dmjson_get_value(associated_client_obj, 2, "stats", "rate_of_last_tx_pkt");
if(lastdatauplinkrate!=NULL && strlen(lastdatauplinkrate)>0)
cur_wifi_associative_device_args.lastdatauplinkrate = atoi(lastdatauplinkrate);
else
cur_wifi_associative_device_args.lastdatauplinkrate = 0;
signalstrength=dmjson_get_value(associated_client_obj, 1, "rssi");
if(signalstrength!=NULL && strlen(signalstrength)>0)
cur_wifi_associative_device_args.signalstrength = atoi(signalstrength);
else
cur_wifi_associative_device_args.signalstrength = 0;
noise=dmjson_get_value(associated_client_obj, 1, "snr");
if(noise!=NULL && strlen(noise)>0)
cur_wifi_associative_device_args.noise = atoi(noise);
else
cur_wifi_associative_device_args.noise = 0;
retrans= dmjson_get_value(associated_client_obj, 2, "stats", "tx_pkts_retries");
cur_wifi_associative_device_args.retransmissions= atoi(retrans);
assoctimestr=dmjson_get_value(associated_client_obj, 1, "in_network");
if(assoctimestr!=NULL && strlen(assoctimestr)>0)
cur_wifi_associative_device_args.assoctime = atoi(assoctimestr);
else
cur_wifi_associative_device_args.assoctime = 0;
entries++;
idx = handle_update_instance(3, dmctx, &idx_last, update_instance_without_section, 1, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&cur_wifi_associative_device_args, idx) == DM_STOP)
break;
}
else
break;
}
return 0;
}

359
dmtree/tr181/wifi-openwrt.c Normal file
View file

@ -0,0 +1,359 @@
#include "os.h"
static int not_implemented(char **value)
{
*value = "";
return 0;
}
/*#Device.WiFi.SSID.{i}.BSSID!UBUS:wifi.ap.@Name/status//bssid*/
int os__get_wlan_bssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.Radio.{i}.Stats.BytesSent!UBUS:wifi.radio.@Name/stats//tx_bytes*/
int os__get_WiFiRadioStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.Radio.{i}.Stats.BytesReceived!UBUS:wifi.radio.@Name/stats//rx_bytes*/
int os__get_WiFiRadioStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.Radio.{i}.Stats.PacketsSent!UBUS:wifi.radio.@Name/stats//tx_packets*/
int os__get_WiFiRadioStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.Radio.{i}.Stats.PacketsReceived!UBUS:wifi.radio.@Name/stats//rx_packets*/
int os__get_WiFiRadioStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.Radio.{i}.Stats.ErrorsSent!UBUS:wifi.radio.@Name/stats//tx_error_packets*/
int os__get_WiFiRadioStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.Radio.{i}.Stats.ErrorsReceived!UBUS:wifi.radio.@Name/stats//rx_error_packets*/
int os__get_WiFiRadioStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.Radio.{i}.Stats.DiscardPacketsSent!UBUS:wifi.radio.@Name/stats//tx_dropped_packets*/
int os__get_WiFiRadioStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.Radio.{i}.Stats.DiscardPacketsReceived!UBUS:wifi.radio.@Name/stats//rx_dropped_packets*/
int os__get_WiFiRadioStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.Radio.{i}.Stats.FCSErrorCount!UBUS:wifi.radio.@Name/stats//rx_fcs_error_packets*/
int os__get_WiFiRadioStats_FCSErrorCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.BytesSent!UBUS:wifi.ap.@Name/stats//tx_bytes*/
int os__get_WiFiSSIDStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.BytesReceived!UBUS:wifi.ap.@Name/stats//rx_bytes*/
int os__get_WiFiSSIDStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.PacketsSent!UBUS:wifi.ap.@Name/stats//tx_packets*/
int os__get_WiFiSSIDStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.PacketsReceived!UBUS:wifi.ap.@Name/stats//rx_packets*/
int os__get_WiFiSSIDStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.ErrorsSent!UBUS:wifi.ap.@Name/stats//tx_error_packets*/
int os__get_WiFiSSIDStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.ErrorsReceived!UBUS:wifi.ap.@Name/stats//rx_error_packets*/
int os__get_WiFiSSIDStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.DiscardPacketsSent!UBUS:wifi.ap.@Name/stats//tx_dropped_packets*/
int os__get_WiFiSSIDStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.DiscardPacketsReceived!UBUS:wifi.ap.@Name/stats//rx_dropped_packets*/
int os__get_WiFiSSIDStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.UnicastPacketsSent!UBUS:wifi.ap.@Name/stats//tx_unicast_packets*/
int os__get_WiFiSSIDStats_UnicastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.UnicastPacketsReceived!UBUS:wifi.ap.@Name/stats//rx_unicast_packets*/
int os__get_WiFiSSIDStats_UnicastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.MulticastPacketsSent!UBUS:wifi.ap.@Name/stats//tx_multicast_packets*/
int os__get_WiFiSSIDStats_MulticastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.MulticastPacketsReceived!UBUS:wifi.ap.@Name/stats//rx_multicast_packets*/
int os__get_WiFiSSIDStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.BroadcastPacketsSent!UBUS:wifi.ap.@Name/stats//tx_broadcast_packets*/
int os__get_WiFiSSIDStats_BroadcastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.BroadcastPacketsReceived!UBUS:wifi.ap.@Name/stats//rx_broadcast_packets*/
int os__get_WiFiSSIDStats_BroadcastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.RetransCount!UBUS:wifi.ap.@Name/stats//tx_retrans_packets*/
int os__get_WiFiSSIDStats_RetransCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.FailedRetransCount!UBUS:wifi.ap.@Name/stats//tx_retrans_fail_packets*/
int os__get_WiFiSSIDStats_FailedRetransCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.RetryCount!UBUS:wifi.ap.@Name/stats//tx_retry_packets*/
int os__get_WiFiSSIDStats_RetryCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.MultipleRetryCount!UBUS:wifi.ap.@Name/stats//tx_multi_retry_packets*/
int os__get_WiFiSSIDStats_MultipleRetryCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.ACKFailureCount!UBUS:wifi.ap.@Name/stats//ack_fail_packets*/
int os__get_WiFiSSIDStats_ACKFailureCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.AggregatedPacketCount!UBUS:wifi.ap.@Name/stats//aggregate_packets*/
int os__get_WiFiSSIDStats_AggregatedPacketCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.SSID.{i}.Stats.UnknownProtoPacketsReceived!UBUS:wifi.ap.@Name/stats//rx_unknown_packets*/
int os__get_WiFiSSIDStats_UnknownProtoPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.AccessPoint.{i}.Stats.BytesSent!UBUS:wifix/stations/vif,@Name/stats.tx_total_bytes*/
int os__get_access_point_associative_device_statistics_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.AccessPoint.{i}.Stats.BytesReceived!UBUS:wifix/stations/vif,@Name/stats.rx_data_bytes*/
int os__get_access_point_associative_device_statistics_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.AccessPoint.{i}.Stats.PacketsSent!UBUS:wifix/stations/vif,@Name/stats.tx_total_pkts*/
int os__get_access_point_associative_device_statistics_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.AccessPoint.{i}.Stats.PacketsReceived!UBUS:wifix/stations/vif,@Name/stats.rx_data_pkts*/
int os__get_access_point_associative_device_statistics_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.AccessPoint.{i}.Stats.ErrorsSent!UBUS:wifix/stations/vif,@Name/stats.tx_failures*/
int os__get_access_point_associative_device_statistics_tx_errors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.AccessPoint.{i}.Stats.RetransCount!UBUS:wifix/stations/vif,@Name/stats.tx_pkts_retries*/
int os__get_access_point_associative_device_statistics_retrans_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.AccessPoint.{i}.Stats.FailedRetransCount!UBUS:wifix/stations/vif,@Name/stats.tx_pkts_retry_exhausted*/
int os__get_access_point_associative_device_statistics_failed_retrans_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.AccessPoint.{i}.Stats.RetryCount!UBUS:wifix/stations/vif,@Name/stats.tx_pkts_retries*/
int os__get_access_point_associative_device_statistics_retry_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.AccessPoint.{i}.Stats.MultipleRetryCount!UBUS:wifix/stations/vif,@Name/stats.tx_data_pkts_retried*/
int os__get_access_point_associative_device_statistics_multiple_retry_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.Radio.{i}.MaxBitRate!UBUS:wifi.radio.@Name/status//maxrate*/
int os__get_radio_max_bit_rate (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.Radio.{i}.OperatingFrequencyBand!UBUS:wifi.radio.@Name/status//band*/
int os__get_radio_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.Radio.{i}.ChannelsInUse!UCI:wireless/wifi-device,@i-1/channel*/
int os__get_radio_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
char * os__get_radio_channel_nocache(const struct wifi_radio_args *args)
{
return "";
}
char * os__get_radio_frequency_nocache(const struct wifi_radio_args *args)
{
return "";
}
int os__get_neighboring_wifi_diagnostics_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_neighboring_wifi_diagnostics_result_number_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_neighboring_wifi_diagnostics_result_ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_neighboring_wifi_diagnostics_result_bssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_neighboring_wifi_diagnostics_result_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_neighboring_wifi_diagnostics_result_signal_strength(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_neighboring_wifi_diagnostics_result_operating_frequency_band(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_neighboring_wifi_diagnostics_result_noise(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.Radio.{i}.PossibleChannels!UBUS:wifi.radio.@Name/status//supp_channels[0].channels*/
int os__get_radio_possible_channels(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.Radio.{i}.SupportedOperatingChannelBandwidths!UBUS:wifi.radio.@Name/status//supp_channels[0].bandwidth*/
int os__get_WiFiRadio_SupportedOperatingChannelBandwidths(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
/*#Device.WiFi.Radio.{i}.CurrentOperatingChannelBandwidth!UBUS:wifi.radio.@Name/status//bandwidth*/
int os__get_WiFiRadio_CurrentOperatingChannelBandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
void os__wifi_start_scan(const char *radio)
{
}
int os__browseWifiNeighboringWiFiDiagnosticResultInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
return 0;
}
/*#Device.WiFi.Radio.{i}.SupportedStandards!UBUS:wifi/status//radio[i-1].standard*/
int os__get_radio_supported_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__get_access_point_total_associations(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return not_implemented(value);
}
int os__browse_wifi_associated_device(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -44,4 +44,41 @@ extern DMOBJ tWiFiEndPointProfileObj[];
extern DMLEAF tWiFiEndPointProfileParams[];
extern DMLEAF tWiFiEndPointProfileSecurityParams[];
struct wifi_radio_args
{
struct uci_section *wifi_radio_sec;
};
struct wifi_ssid_args
{
struct uci_section *wifi_ssid_sec;
char *ifname;
char *linker;
};
struct wifi_enp_args
{
struct uci_section *wifi_enp_sec;
char *ifname;
};
struct wifi_acp_args
{
struct uci_section *wifi_acp_sec;
char *ifname;
};
struct wifi_associative_device_args
{
int active;
int lastdatadownloadlinkrate;
int lastdatauplinkrate;
int signalstrength;
char *macaddress;
char *wdev;
int noise;
int retransmissions;
int assoctime;
};
#endif