diff --git a/bin/Makefile.am b/bin/Makefile.am index 0c9da6a7..b66d5e0e 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -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 diff --git a/dmtree/tr181/deviceinfo-iopsyswrt.c b/dmtree/tr181/deviceinfo-iopsyswrt.c new file mode 100644 index 00000000..b95b25f4 --- /dev/null +++ b/dmtree/tr181/deviceinfo-iopsyswrt.c @@ -0,0 +1,235 @@ +#include "os.h" + +#include + +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; +} diff --git a/dmtree/tr181/deviceinfo-openwrt.c b/dmtree/tr181/deviceinfo-openwrt.c new file mode 100644 index 00000000..22b0eedf --- /dev/null +++ b/dmtree/tr181/deviceinfo-openwrt.c @@ -0,0 +1,79 @@ +#include "os.h" + +#include + +#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; +} diff --git a/dmtree/tr181/deviceinfo.c b/dmtree/tr181/deviceinfo.c index 7278b751..01b3a002 100644 --- a/dmtree/tr181/deviceinfo.c +++ b/dmtree/tr181/deviceinfo.c @@ -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} }; diff --git a/dmtree/tr181/hosts-iopsyswrt.c b/dmtree/tr181/hosts-iopsyswrt.c new file mode 100644 index 00000000..31dda21d --- /dev/null +++ b/dmtree/tr181/hosts-iopsyswrt.c @@ -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; +} diff --git a/dmtree/tr181/hosts-openwrt.c b/dmtree/tr181/hosts-openwrt.c new file mode 100644 index 00000000..9c887c6a --- /dev/null +++ b/dmtree/tr181/hosts-openwrt.c @@ -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); +} diff --git a/dmtree/tr181/hosts.c b/dmtree/tr181/hosts.c index d7e55915..5d27fba0 100644 --- a/dmtree/tr181/hosts.c +++ b/dmtree/tr181/hosts.c @@ -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} }; diff --git a/dmtree/tr181/os.h b/dmtree/tr181/os.h new file mode 100644 index 00000000..99448d4b --- /dev/null +++ b/dmtree/tr181/os.h @@ -0,0 +1,117 @@ +#ifndef __BBF_TR181_OPERATING_SYTEM_H +#define __BBF_TR181_OPERATING_SYTEM_H + +#include + +/* 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 diff --git a/dmtree/tr181/wifi-iopsyswrt.c b/dmtree/tr181/wifi-iopsyswrt.c new file mode 100644 index 00000000..9683207f --- /dev/null +++ b/dmtree/tr181/wifi-iopsyswrt.c @@ -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; +} diff --git a/dmtree/tr181/wifi-openwrt.c b/dmtree/tr181/wifi-openwrt.c new file mode 100644 index 00000000..0bcb35f7 --- /dev/null +++ b/dmtree/tr181/wifi-openwrt.c @@ -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; +} + diff --git a/dmtree/tr181/wifi.c b/dmtree/tr181/wifi.c index 63ec34ec..912b964c 100644 --- a/dmtree/tr181/wifi.c +++ b/dmtree/tr181/wifi.c @@ -13,43 +13,8 @@ #include "dmentry.h" #include "wepkey.h" #include "wifi.h" +#include "os.h" -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; -}; /************************************************************************** * LINKER @@ -260,19 +225,6 @@ static int set_wlan_ssid(char *refparam, struct dmctx *ctx, void *data, char *in return 0; } -/*#Device.WiFi.SSID.{i}.BSSID!UBUS:wifi.ap.@Name/status//bssid*/ -static int 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; -} - /*#Device.WiFi.SSID.{i}.MACAddress!UBUS:router.device/status/name,@Name/macaddr*/ static int get_WiFiSSID_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { @@ -349,32 +301,6 @@ static int get_WiFiRadio_Name(char *refparam, struct dmctx *ctx, void *data, cha return 0; } -/*#Device.WiFi.Radio.{i}.MaxBitRate!UBUS:wifi.radio.@Name/status//maxrate*/ -static int 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*/ -static int 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; -} - static int get_radio_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { dmuci_get_value_by_section_string(((struct wifi_radio_args *)data)->wifi_radio_sec, "maxassoc", value); @@ -428,25 +354,6 @@ static int set_radio_dfsenable(char *refparam, struct dmctx *ctx, void *data, ch return 0; } -/*#Device.WiFi.Radio.{i}.SupportedStandards!UBUS:wifi/status//radio[i-1].standard*/ -static int 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; -} - /*#Device.WiFi.Radio.{i}.OperatingStandards!UCI:wireless/wifi-device,@i-1/hwmode*/ static int get_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { @@ -456,8 +363,7 @@ static int get_radio_operating_standard(char *refparam, struct dmctx *ctx, void static int set_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { - json_object *res = NULL; - char object[32], *freq; + char *freq; switch (action) { case VALUECHECK: @@ -465,10 +371,7 @@ static int set_radio_operating_standard(char *refparam, struct dmctx *ctx, void return FAULT_9007; return 0; case VALUESET: - 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); - if (!res) return 0; - freq = dmjson_get_value(res, 1, "frequency"); + freq = os__get_radio_frequency_nocache(data); if (strcmp(freq, "5Ghz") == 0) { if (strcmp(value, "n") == 0) value = "11n"; @@ -490,21 +393,6 @@ static int set_radio_operating_standard(char *refparam, struct dmctx *ctx, void return 0; } -/*#Device.WiFi.Radio.{i}.PossibleChannels!UBUS:wifi.radio.@Name/status//supp_channels[0].channels*/ -static int 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; -} - static int get_WiFiRadio_AutoChannelSupported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { *value = "true"; @@ -623,21 +511,6 @@ static int set_WiFiRadio_DTIMPeriod(char *refparam, struct dmctx *ctx, void *dat return 0; } -/*#Device.WiFi.Radio.{i}.SupportedOperatingChannelBandwidths!UBUS:wifi.radio.@Name/status//supp_channels[0].bandwidth*/ -static int 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}.OperatingChannelBandwidth!UCI:wireless/wifi-device,@i-1/bandwidth*/ static int get_WiFiRadio_OperatingChannelBandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { @@ -664,19 +537,6 @@ static int set_WiFiRadio_OperatingChannelBandwidth(char *refparam, struct dmctx return 0; } -/*#Device.WiFi.Radio.{i}.CurrentOperatingChannelBandwidth!UBUS:wifi.radio.@Name/status//bandwidth*/ -static int 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; -} - /*#Device.WiFi.Radio.{i}.PreambleType!UCI:wireless/wifi-device,@i-1/short_preamble*/ static int get_WiFiRadio_PreambleType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { @@ -796,22 +656,6 @@ static int set_WiFiRadio_RegulatoryDomain(char *refparam, struct dmctx *ctx, voi return 0; } -/*#Device.WiFi.Radio.{i}.ChannelsInUse!UCI:wireless/wifi-device,@i-1/channel*/ -static int 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; -} - static int set_radio_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { switch (action) { @@ -840,7 +684,6 @@ static int get_radio_auto_channel_enable(char *refparam, struct dmctx *ctx, void static int set_radio_auto_channel_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { bool b; - json_object *res = NULL; switch (action) { case VALUECHECK: @@ -851,336 +694,15 @@ static int set_radio_auto_channel_enable(char *refparam, struct dmctx *ctx, void string_to_bool(value, &b); if (b) value = "auto"; - else { - 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); - if (res) return 0; - value = dmjson_get_value(res, 1, "channel"); - } + else + value = os__get_radio_channel_nocache(data); + dmuci_set_value_by_section(((struct wifi_radio_args *)data)->wifi_radio_sec, "channel", value); return 0; } return 0; } -/************************************************************* -* GET STAT -**************************************************************/ -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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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*/ -static int 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; -} - /************************************************************************** * SET & GET VALUE ***************************************************************************/ @@ -1252,23 +774,6 @@ static int set_wmm_enabled(char *refparam, struct dmctx *ctx, void *data, char * return 0; } -static int 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; -} - /*#Device.WiFi.AccessPoint.{i}.MaxAssociatedDevices!UCI:wireless/wifi-iface,@i-1/maxassoc*/ static int get_access_point_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { @@ -2504,108 +2009,6 @@ static int set_WiFiEndPointWPS_PIN(char *refparam, struct dmctx *ctx, void *data return 0; } -static int 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; -} - -static int set_neighboring_wifi_diagnostics_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - struct uci_section *ss; - - switch (action) { - case VALUECHECK: - if (dm_validate_string(value, -1, -1, DiagnosticsState, 5, NULL, 0)) - return FAULT_9007; - return 0; - case VALUESET: - if (strcmp(value, "Requested") == 0) { - uci_foreach_sections("wireless", "wifi-device", ss) { - char object[32]; - snprintf(object, sizeof(object), "wifi.radio.%s", section_name(ss)); - dmubus_call_set(object, "scan", UBUS_ARGS{}, 0); - } - dmubus_call_set("tr069", "inform", UBUS_ARGS{{"event", "8 DIAGNOSTICS COMPLETE", String}}, 1); - } - return 0; - } - return 0; -} - -static int 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; -} - -static int 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; -} - -static int 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; -} - -static int 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; -} - -static int 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; -} - -static int 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; -} - -static int 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; -} - /************************************************************************** * SET AND GET ALIAS ***************************************************************************/ @@ -2930,95 +2333,6 @@ static int browseWiFiEndPointInst(struct dmctx *dmctx, DMNODE *parent_node, void return 0; } -static int 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; -} - -static int 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; -} - static int browseWiFiEndPointProfileInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) { struct uci_section *s= NULL; @@ -3040,6 +2354,27 @@ static int browseWiFiEndPointProfileInst(struct dmctx *dmctx, DMNODE *parent_nod return 0; } +int set_neighboring_wifi_diagnostics_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) +{ + struct uci_section *ss; + + switch (action) { + case VALUECHECK: + if (dm_validate_string(value, -1, -1, DiagnosticsState, 5, NULL, 0)) + return FAULT_9007; + return 0; + case VALUESET: + if (strcmp(value, "Requested") == 0) { + uci_foreach_sections("wireless", "wifi-device", ss) + os__wifi_start_scan(section_name(ss)); + + dmubus_call_set("tr069", "inform", UBUS_ARGS{{"event", "8 DIAGNOSTICS COMPLETE", String}}, 1); + } + return 0; + } + return 0; +} + /* *** Device.WiFi. *** */ DMOBJ tWiFiObj[] = { /* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextdynamicobj, nextobj, leaf, linker, bbfdm_type*/ @@ -3075,17 +2410,17 @@ DMLEAF tWiFiRadioParams[] = { {"Status", &DMREAD, DMT_STRING, get_radio_status, NULL, NULL, NULL, BBFDM_BOTH}, {"LowerLayers", &DMWRITE, DMT_STRING, get_WiFiRadio_LowerLayers, set_WiFiRadio_LowerLayers, NULL, NULL, BBFDM_BOTH}, {"Name", &DMREAD, DMT_STRING, get_WiFiRadio_Name, NULL, NULL, NULL, BBFDM_BOTH}, -{"MaxBitRate", &DMREAD, DMT_UNINT,get_radio_max_bit_rate, NULL, NULL, NULL, BBFDM_BOTH}, -{"OperatingFrequencyBand", &DMREAD, DMT_STRING, get_radio_frequency, NULL, NULL, NULL, BBFDM_BOTH}, +{"MaxBitRate", &DMREAD, DMT_UNINT, os__get_radio_max_bit_rate, NULL, NULL, NULL, BBFDM_BOTH}, +{"OperatingFrequencyBand", &DMREAD, DMT_STRING, os__get_radio_frequency, NULL, NULL, NULL, BBFDM_BOTH}, {"SupportedFrequencyBands", &DMREAD, DMT_STRING, get_radio_supported_frequency_bands, NULL, NULL, NULL, BBFDM_BOTH}, {CUSTOM_PREFIX"MaxAssociations", &DMWRITE, DMT_STRING, get_radio_maxassoc, set_radio_maxassoc, NULL, NULL, BBFDM_BOTH}, {CUSTOM_PREFIX"DFSEnable", &DMWRITE, DMT_BOOL, get_radio_dfsenable, set_radio_dfsenable, NULL, NULL, BBFDM_BOTH}, -{"SupportedStandards", &DMREAD, DMT_STRING, get_radio_supported_standard, NULL, NULL, NULL, BBFDM_BOTH}, +{"SupportedStandards", &DMREAD, DMT_STRING, os__get_radio_supported_standard, NULL, NULL, NULL, BBFDM_BOTH}, {"OperatingStandards", &DMWRITE, DMT_STRING, get_radio_operating_standard, set_radio_operating_standard, NULL, NULL, BBFDM_BOTH}, -{"ChannelsInUse", &DMREAD, DMT_STRING, get_radio_channel, NULL, NULL, NULL, BBFDM_BOTH}, -{"Channel", &DMWRITE, DMT_UNINT, get_radio_channel, set_radio_channel, NULL, NULL, BBFDM_BOTH}, +{"ChannelsInUse", &DMREAD, DMT_STRING, os__get_radio_channel, NULL, NULL, NULL, BBFDM_BOTH}, +{"Channel", &DMWRITE, DMT_UNINT, os__get_radio_channel, set_radio_channel, NULL, NULL, BBFDM_BOTH}, {"AutoChannelEnable", &DMWRITE, DMT_BOOL, get_radio_auto_channel_enable, set_radio_auto_channel_enable, NULL, NULL, BBFDM_BOTH}, -{"PossibleChannels", &DMREAD, DMT_STRING, get_radio_possible_channels, NULL, NULL, NULL, BBFDM_BOTH}, +{"PossibleChannels", &DMREAD, DMT_STRING, os__get_radio_possible_channels, NULL, NULL, NULL, BBFDM_BOTH}, {"AutoChannelSupported", &DMREAD, DMT_BOOL, get_WiFiRadio_AutoChannelSupported, NULL, NULL, NULL, BBFDM_BOTH}, {"AutoChannelRefreshPeriod", &DMWRITE, DMT_UNINT, get_WiFiRadio_AutoChannelRefreshPeriod, set_WiFiRadio_AutoChannelRefreshPeriod, NULL, NULL, BBFDM_BOTH}, {"MaxSupportedAssociations", &DMREAD, DMT_UNINT, get_WiFiRadio_MaxSupportedAssociations, NULL, NULL, NULL, BBFDM_BOTH}, @@ -3093,9 +2428,9 @@ DMLEAF tWiFiRadioParams[] = { {"RTSThreshold", &DMWRITE, DMT_UNINT, get_WiFiRadio_RTSThreshold, set_WiFiRadio_RTSThreshold, NULL, NULL, BBFDM_BOTH}, {"BeaconPeriod", &DMWRITE, DMT_UNINT, get_WiFiRadio_BeaconPeriod, set_WiFiRadio_BeaconPeriod, NULL, NULL, BBFDM_BOTH}, {"DTIMPeriod", &DMWRITE, DMT_UNINT, get_WiFiRadio_DTIMPeriod, set_WiFiRadio_DTIMPeriod, NULL, NULL, BBFDM_BOTH}, -{"SupportedOperatingChannelBandwidths", &DMREAD, DMT_STRING, get_WiFiRadio_SupportedOperatingChannelBandwidths, NULL, NULL, NULL, BBFDM_BOTH}, +{"SupportedOperatingChannelBandwidths", &DMREAD, DMT_STRING, os__get_WiFiRadio_SupportedOperatingChannelBandwidths, NULL, NULL, NULL, BBFDM_BOTH}, {"OperatingChannelBandwidth", &DMWRITE, DMT_STRING, get_WiFiRadio_OperatingChannelBandwidth, set_WiFiRadio_OperatingChannelBandwidth, NULL, NULL, BBFDM_BOTH}, -{"CurrentOperatingChannelBandwidth", &DMREAD, DMT_STRING, get_WiFiRadio_CurrentOperatingChannelBandwidth, NULL, NULL, NULL, BBFDM_BOTH}, +{"CurrentOperatingChannelBandwidth", &DMREAD, DMT_STRING, os__get_WiFiRadio_CurrentOperatingChannelBandwidth, NULL, NULL, NULL, BBFDM_BOTH}, {"PreambleType", &DMWRITE, DMT_STRING, get_WiFiRadio_PreambleType, set_WiFiRadio_PreambleType, NULL, NULL, BBFDM_BOTH}, {"IEEE80211hSupported", &DMREAD, DMT_BOOL, get_WiFiRadio_IEEE80211hSupported, NULL, NULL, NULL, BBFDM_BOTH}, {"IEEE80211hEnabled", &DMWRITE, DMT_BOOL, get_WiFiRadio_IEEE80211hEnabled, set_WiFiRadio_IEEE80211hEnabled, NULL, NULL, BBFDM_BOTH}, @@ -3107,41 +2442,41 @@ DMLEAF tWiFiRadioParams[] = { /* *** Device.WiFi.Radio.{i}.Stats. *** */ DMLEAF tWiFiRadioStatsParams[] = { /* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/ -{"BytesSent", &DMREAD, DMT_UNLONG, get_WiFiRadioStats_BytesSent, NULL, NULL, NULL, BBFDM_BOTH}, -{"BytesReceived", &DMREAD, DMT_UNLONG, get_WiFiRadioStats_BytesReceived, NULL, NULL, NULL, BBFDM_BOTH}, -{"PacketsSent", &DMREAD, DMT_UNLONG, get_WiFiRadioStats_PacketsSent, NULL, NULL, NULL, BBFDM_BOTH}, -{"PacketsReceived", &DMREAD, DMT_UNLONG, get_WiFiRadioStats_PacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, -{"ErrorsSent", &DMREAD, DMT_UNINT, get_WiFiRadioStats_ErrorsSent, NULL, NULL, NULL, BBFDM_BOTH}, -{"ErrorsReceived", &DMREAD, DMT_UNINT, get_WiFiRadioStats_ErrorsReceived, NULL, NULL, NULL, BBFDM_BOTH}, -{"DiscardPacketsSent", &DMREAD, DMT_UNINT, get_WiFiRadioStats_DiscardPacketsSent, NULL, NULL, NULL, BBFDM_BOTH}, -{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, get_WiFiRadioStats_DiscardPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, -{"FCSErrorCount", &DMREAD, DMT_UNINT, get_WiFiRadioStats_FCSErrorCount, NULL, NULL, NULL, BBFDM_BOTH}, +{"BytesSent", &DMREAD, DMT_UNLONG, os__get_WiFiRadioStats_BytesSent, NULL, NULL, NULL, BBFDM_BOTH}, +{"BytesReceived", &DMREAD, DMT_UNLONG, os__get_WiFiRadioStats_BytesReceived, NULL, NULL, NULL, BBFDM_BOTH}, +{"PacketsSent", &DMREAD, DMT_UNLONG, os__get_WiFiRadioStats_PacketsSent, NULL, NULL, NULL, BBFDM_BOTH}, +{"PacketsReceived", &DMREAD, DMT_UNLONG, os__get_WiFiRadioStats_PacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, +{"ErrorsSent", &DMREAD, DMT_UNINT, os__get_WiFiRadioStats_ErrorsSent, NULL, NULL, NULL, BBFDM_BOTH}, +{"ErrorsReceived", &DMREAD, DMT_UNINT, os__get_WiFiRadioStats_ErrorsReceived, NULL, NULL, NULL, BBFDM_BOTH}, +{"DiscardPacketsSent", &DMREAD, DMT_UNINT, os__get_WiFiRadioStats_DiscardPacketsSent, NULL, NULL, NULL, BBFDM_BOTH}, +{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, os__get_WiFiRadioStats_DiscardPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, +{"FCSErrorCount", &DMREAD, DMT_UNINT, os__get_WiFiRadioStats_FCSErrorCount, NULL, NULL, NULL, BBFDM_BOTH}, {0} }; /* *** Device.WiFi.NeighboringWiFiDiagnostic. *** */ DMOBJ tWiFiNeighboringWiFiDiagnosticObj[] = { /* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextdynamicobj, nextobj, leaf, linker, bbfdm_type*/ -{"Result", &DMREAD, NULL, NULL, NULL, browseWifiNeighboringWiFiDiagnosticResultInst, NULL, NULL, NULL, NULL, tWiFiNeighboringWiFiDiagnosticResultParams, NULL, BBFDM_CWMP}, +{"Result", &DMREAD, NULL, NULL, NULL, os__browseWifiNeighboringWiFiDiagnosticResultInst, NULL, NULL, NULL, NULL, tWiFiNeighboringWiFiDiagnosticResultParams, NULL, BBFDM_CWMP}, {0} }; DMLEAF tWiFiNeighboringWiFiDiagnosticParams[] = { /* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/ -{"DiagnosticsState", &DMWRITE, DMT_STRING, get_neighboring_wifi_diagnostics_diagnostics_state, set_neighboring_wifi_diagnostics_diagnostics_state, NULL, NULL, BBFDM_CWMP}, -{"ResultNumberOfEntries", &DMREAD, DMT_UNINT, get_neighboring_wifi_diagnostics_result_number_entries, NULL, NULL, NULL, BBFDM_CWMP}, +{"DiagnosticsState", &DMWRITE, DMT_STRING, os__get_neighboring_wifi_diagnostics_diagnostics_state, set_neighboring_wifi_diagnostics_diagnostics_state, NULL, NULL, BBFDM_CWMP}, +{"ResultNumberOfEntries", &DMREAD, DMT_UNINT, os__get_neighboring_wifi_diagnostics_result_number_entries, NULL, NULL, NULL, BBFDM_CWMP}, {0} }; /* *** Device.WiFi.NeighboringWiFiDiagnostic.Result.{i}. *** */ DMLEAF tWiFiNeighboringWiFiDiagnosticResultParams[] = { /* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/ -{"SSID", &DMREAD, DMT_STRING, get_neighboring_wifi_diagnostics_result_ssid, NULL, NULL, NULL, BBFDM_CWMP}, -{"BSSID", &DMREAD, DMT_STRING, get_neighboring_wifi_diagnostics_result_bssid, NULL, NULL, NULL, BBFDM_CWMP}, -{"Channel", &DMREAD, DMT_UNINT, get_neighboring_wifi_diagnostics_result_channel, NULL, NULL, NULL, BBFDM_CWMP}, -{"SignalStrength", &DMREAD, DMT_INT, get_neighboring_wifi_diagnostics_result_signal_strength, NULL, NULL, NULL, BBFDM_CWMP}, -{"OperatingFrequencyBand", &DMREAD, DMT_STRING, get_neighboring_wifi_diagnostics_result_operating_frequency_band, NULL, NULL, NULL, BBFDM_CWMP}, -{"Noise", &DMREAD, DMT_INT, get_neighboring_wifi_diagnostics_result_noise, NULL, NULL, NULL, BBFDM_CWMP}, +{"SSID", &DMREAD, DMT_STRING, os__get_neighboring_wifi_diagnostics_result_ssid, NULL, NULL, NULL, BBFDM_CWMP}, +{"BSSID", &DMREAD, DMT_STRING, os__get_neighboring_wifi_diagnostics_result_bssid, NULL, NULL, NULL, BBFDM_CWMP}, +{"Channel", &DMREAD, DMT_UNINT, os__get_neighboring_wifi_diagnostics_result_channel, NULL, NULL, NULL, BBFDM_CWMP}, +{"SignalStrength", &DMREAD, DMT_INT, os__get_neighboring_wifi_diagnostics_result_signal_strength, NULL, NULL, NULL, BBFDM_CWMP}, +{"OperatingFrequencyBand", &DMREAD, DMT_STRING, os__get_neighboring_wifi_diagnostics_result_operating_frequency_band, NULL, NULL, NULL, BBFDM_CWMP}, +{"Noise", &DMREAD, DMT_INT, os__get_neighboring_wifi_diagnostics_result_noise, NULL, NULL, NULL, BBFDM_CWMP}, {0} }; @@ -3160,7 +2495,7 @@ DMLEAF tWiFiSSIDParams[] = { {"SSID", &DMWRITE, DMT_STRING, get_wlan_ssid, set_wlan_ssid, NULL, NULL, BBFDM_BOTH}, {"Name", &DMWRITE, DMT_STRING, get_wlan_ssid, set_wlan_ssid, NULL, NULL, BBFDM_BOTH}, {"LowerLayers", &DMWRITE, DMT_STRING, get_ssid_lower_layer, set_ssid_lower_layer, NULL, NULL, BBFDM_BOTH}, -{"BSSID", &DMREAD, DMT_STRING, get_wlan_bssid, NULL, NULL, NULL, BBFDM_BOTH}, +{"BSSID", &DMREAD, DMT_STRING, os__get_wlan_bssid, NULL, NULL, NULL, BBFDM_BOTH}, {"MACAddress", &DMREAD, DMT_STRING, get_WiFiSSID_MACAddress, NULL, NULL, NULL, BBFDM_BOTH}, {0} }; @@ -3168,27 +2503,27 @@ DMLEAF tWiFiSSIDParams[] = { /* *** Device.WiFi.SSID.{i}.Stats. *** */ DMLEAF tWiFiSSIDStatsParams[] = { /* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/ -{"BytesSent", &DMREAD, DMT_UNLONG, get_WiFiSSIDStats_BytesSent, NULL, NULL, NULL, BBFDM_BOTH}, -{"BytesReceived", &DMREAD, DMT_UNLONG, get_WiFiSSIDStats_BytesReceived, NULL, NULL, NULL, BBFDM_BOTH}, -{"PacketsSent", &DMREAD, DMT_UNLONG, get_WiFiSSIDStats_PacketsSent, NULL, NULL, NULL, BBFDM_BOTH}, -{"PacketsReceived", &DMREAD, DMT_UNLONG, get_WiFiSSIDStats_PacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, -{"ErrorsSent", &DMREAD, DMT_UNINT, get_WiFiSSIDStats_ErrorsSent, NULL, NULL, NULL, BBFDM_BOTH}, -{"RetransCount", &DMREAD, DMT_UNINT, get_WiFiSSIDStats_RetransCount, NULL, NULL, NULL, BBFDM_BOTH}, -{"FailedRetransCount", &DMREAD, DMT_UNINT, get_WiFiSSIDStats_FailedRetransCount, NULL, NULL, NULL, BBFDM_BOTH}, -{"RetryCount", &DMREAD, DMT_UNINT, get_WiFiSSIDStats_RetryCount, NULL, NULL, NULL, BBFDM_BOTH}, -{"MultipleRetryCount", &DMREAD, DMT_UNINT, get_WiFiSSIDStats_MultipleRetryCount, NULL, NULL, NULL, BBFDM_BOTH}, -{"ACKFailureCount", &DMREAD, DMT_UNINT, get_WiFiSSIDStats_ACKFailureCount, NULL, NULL, NULL, BBFDM_BOTH}, -{"AggregatedPacketCount", &DMREAD, DMT_UNINT, get_WiFiSSIDStats_AggregatedPacketCount, NULL, NULL, NULL, BBFDM_BOTH}, -{"ErrorsReceived", &DMREAD, DMT_UNINT, get_WiFiSSIDStats_ErrorsReceived, NULL, NULL, NULL, BBFDM_BOTH}, -{"UnicastPacketsSent", &DMREAD, DMT_UNLONG, get_WiFiSSIDStats_UnicastPacketsSent, NULL, NULL, NULL, BBFDM_BOTH}, -{"UnicastPacketsReceived", &DMREAD, DMT_UNLONG, get_WiFiSSIDStats_UnicastPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, -{"DiscardPacketsSent", &DMREAD, DMT_UNINT, get_WiFiSSIDStats_DiscardPacketsSent, NULL, NULL, NULL, BBFDM_BOTH}, -{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, get_WiFiSSIDStats_DiscardPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, -{"MulticastPacketsSent", &DMREAD, DMT_UNLONG, get_WiFiSSIDStats_MulticastPacketsSent, NULL, NULL, NULL, BBFDM_BOTH}, -{"MulticastPacketsReceived", &DMREAD, DMT_UNLONG, get_WiFiSSIDStats_MulticastPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, -{"BroadcastPacketsSent", &DMREAD, DMT_UNLONG, get_WiFiSSIDStats_BroadcastPacketsSent, NULL, NULL, NULL, BBFDM_BOTH}, -{"BroadcastPacketsReceived", &DMREAD, DMT_UNLONG, get_WiFiSSIDStats_BroadcastPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, -{"UnknownProtoPacketsReceived", &DMREAD, DMT_UNINT, get_WiFiSSIDStats_UnknownProtoPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, +{"BytesSent", &DMREAD, DMT_UNLONG, os__get_WiFiSSIDStats_BytesSent, NULL, NULL, NULL, BBFDM_BOTH}, +{"BytesReceived", &DMREAD, DMT_UNLONG, os__get_WiFiSSIDStats_BytesReceived, NULL, NULL, NULL, BBFDM_BOTH}, +{"PacketsSent", &DMREAD, DMT_UNLONG, os__get_WiFiSSIDStats_PacketsSent, NULL, NULL, NULL, BBFDM_BOTH}, +{"PacketsReceived", &DMREAD, DMT_UNLONG, os__get_WiFiSSIDStats_PacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, +{"ErrorsSent", &DMREAD, DMT_UNINT, os__get_WiFiSSIDStats_ErrorsSent, NULL, NULL, NULL, BBFDM_BOTH}, +{"RetransCount", &DMREAD, DMT_UNINT, os__get_WiFiSSIDStats_RetransCount, NULL, NULL, NULL, BBFDM_BOTH}, +{"FailedRetransCount", &DMREAD, DMT_UNINT, os__get_WiFiSSIDStats_FailedRetransCount, NULL, NULL, NULL, BBFDM_BOTH}, +{"RetryCount", &DMREAD, DMT_UNINT, os__get_WiFiSSIDStats_RetryCount, NULL, NULL, NULL, BBFDM_BOTH}, +{"MultipleRetryCount", &DMREAD, DMT_UNINT, os__get_WiFiSSIDStats_MultipleRetryCount, NULL, NULL, NULL, BBFDM_BOTH}, +{"ACKFailureCount", &DMREAD, DMT_UNINT, os__get_WiFiSSIDStats_ACKFailureCount, NULL, NULL, NULL, BBFDM_BOTH}, +{"AggregatedPacketCount", &DMREAD, DMT_UNINT, os__get_WiFiSSIDStats_AggregatedPacketCount, NULL, NULL, NULL, BBFDM_BOTH}, +{"ErrorsReceived", &DMREAD, DMT_UNINT, os__get_WiFiSSIDStats_ErrorsReceived, NULL, NULL, NULL, BBFDM_BOTH}, +{"UnicastPacketsSent", &DMREAD, DMT_UNLONG, os__get_WiFiSSIDStats_UnicastPacketsSent, NULL, NULL, NULL, BBFDM_BOTH}, +{"UnicastPacketsReceived", &DMREAD, DMT_UNLONG, os__get_WiFiSSIDStats_UnicastPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, +{"DiscardPacketsSent", &DMREAD, DMT_UNINT, os__get_WiFiSSIDStats_DiscardPacketsSent, NULL, NULL, NULL, BBFDM_BOTH}, +{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, os__get_WiFiSSIDStats_DiscardPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, +{"MulticastPacketsSent", &DMREAD, DMT_UNLONG, os__get_WiFiSSIDStats_MulticastPacketsSent, NULL, NULL, NULL, BBFDM_BOTH}, +{"MulticastPacketsReceived", &DMREAD, DMT_UNLONG, os__get_WiFiSSIDStats_MulticastPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, +{"BroadcastPacketsSent", &DMREAD, DMT_UNLONG, os__get_WiFiSSIDStats_BroadcastPacketsSent, NULL, NULL, NULL, BBFDM_BOTH}, +{"BroadcastPacketsReceived", &DMREAD, DMT_UNLONG, os__get_WiFiSSIDStats_BroadcastPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, +{"UnknownProtoPacketsReceived", &DMREAD, DMT_UNINT, os__get_WiFiSSIDStats_UnknownProtoPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH}, {0} }; @@ -3196,7 +2531,7 @@ DMLEAF tWiFiSSIDStatsParams[] = { DMOBJ tWiFiAccessPointObj[] = { /* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextdynamicobj, nextobj, leaf, linker, bbfdm_type*/ {"Security", &DMWRITE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tWiFiAccessPointSecurityParams, NULL, BBFDM_BOTH}, -{"AssociatedDevice", &DMREAD, NULL, NULL, NULL, browse_wifi_associated_device, NULL, NULL, NULL, tWiFiAccessPointAssociatedDeviceObj, tWiFiAccessPointAssociatedDeviceParams, get_linker_associated_device, BBFDM_BOTH}, +{"AssociatedDevice", &DMREAD, NULL, NULL, NULL, os__browse_wifi_associated_device, NULL, NULL, NULL, tWiFiAccessPointAssociatedDeviceObj, tWiFiAccessPointAssociatedDeviceParams, get_linker_associated_device, BBFDM_BOTH}, {"WPS", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tWiFiAccessPointWPSParams, NULL, BBFDM_BOTH}, {"Accounting", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tWiFiAccessPointAccountingParams, NULL, BBFDM_BOTH}, {CUSTOM_PREFIX"IEEE80211r", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tWiFiAcessPointIEEE80211rParams, NULL, BBFDM_BOTH}, @@ -3212,7 +2547,7 @@ DMLEAF tWiFiAccessPointParams[] = { {"SSIDAdvertisementEnabled", &DMWRITE, DMT_BOOL, get_wlan_ssid_advertisement_enable, set_wlan_ssid_advertisement_enable, NULL, NULL, BBFDM_BOTH}, {"WMMEnable", &DMWRITE, DMT_BOOL, get_wmm_enabled, set_wmm_enabled, NULL, NULL, BBFDM_BOTH}, {"UAPSDEnable", &DMWRITE, DMT_BOOL, get_WiFiAccessPoint_UAPSDEnable, set_WiFiAccessPoint_UAPSDEnable, NULL, NULL, BBFDM_BOTH}, -{"AssociatedDeviceNumberOfEntries", &DMREAD, DMT_UNINT, get_access_point_total_associations, NULL, NULL, NULL, BBFDM_BOTH}, +{"AssociatedDeviceNumberOfEntries", &DMREAD, DMT_UNINT, os__get_access_point_total_associations, NULL, NULL, NULL, BBFDM_BOTH}, {"MaxAssociatedDevices", &DMWRITE, DMT_UNINT, get_access_point_maxassoc, set_access_point_maxassoc, NULL, NULL, BBFDM_BOTH}, {"MACAddressControlEnabled", &DMWRITE, DMT_BOOL, get_access_point_control_enable, set_access_point_control_enable, NULL, NULL, BBFDM_BOTH}, {"UAPSDCapability", &DMREAD, DMT_BOOL, get_WiFiAccessPoint_UAPSDCapability, NULL, NULL, NULL, BBFDM_BOTH}, @@ -3275,15 +2610,15 @@ DMLEAF tWiFiAccessPointAssociatedDeviceParams[] = { /* *** Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.Stats. *** */ DMLEAF tWiFiAccessPointAssociatedDeviceStatsParams[] = { /* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/ -{"BytesSent", &DMREAD, DMT_UNINT, get_access_point_associative_device_statistics_tx_bytes, NULL, NULL, NULL, BBFDM_BOTH}, -{"BytesReceived", &DMREAD, DMT_UNINT, get_access_point_associative_device_statistics_rx_bytes, NULL, NULL, NULL, BBFDM_BOTH}, -{"PacketsSent", &DMREAD, DMT_UNINT, get_access_point_associative_device_statistics_tx_packets, NULL, NULL, NULL, BBFDM_BOTH}, -{"PacketsReceived", &DMREAD, DMT_UNINT, get_access_point_associative_device_statistics_rx_packets, NULL, NULL, NULL, BBFDM_BOTH}, -{"ErrorsSent", &DMREAD, DMT_UNINT, get_access_point_associative_device_statistics_tx_errors, NULL, NULL, NULL, BBFDM_BOTH}, -{"RetransCount", &DMREAD, DMT_UNINT, get_access_point_associative_device_statistics_retrans_count, NULL, NULL, NULL, BBFDM_BOTH}, -{"FailedRetransCount", &DMREAD, DMT_UNINT, get_access_point_associative_device_statistics_failed_retrans_count, NULL, NULL, NULL, BBFDM_BOTH}, -{"RetryCount", &DMREAD, DMT_UNINT, get_access_point_associative_device_statistics_retry_count, NULL, NULL, NULL, BBFDM_BOTH}, -{"MultipleRetryCount", &DMREAD, DMT_UNINT, get_access_point_associative_device_statistics_multiple_retry_count, NULL, NULL, NULL, BBFDM_BOTH}, +{"BytesSent", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_tx_bytes, NULL, NULL, NULL, BBFDM_BOTH}, +{"BytesReceived", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_rx_bytes, NULL, NULL, NULL, BBFDM_BOTH}, +{"PacketsSent", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_tx_packets, NULL, NULL, NULL, BBFDM_BOTH}, +{"PacketsReceived", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_rx_packets, NULL, NULL, NULL, BBFDM_BOTH}, +{"ErrorsSent", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_tx_errors, NULL, NULL, NULL, BBFDM_BOTH}, +{"RetransCount", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_retrans_count, NULL, NULL, NULL, BBFDM_BOTH}, +{"FailedRetransCount", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_failed_retrans_count, NULL, NULL, NULL, BBFDM_BOTH}, +{"RetryCount", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_retry_count, NULL, NULL, NULL, BBFDM_BOTH}, +{"MultipleRetryCount", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_multiple_retry_count, NULL, NULL, NULL, BBFDM_BOTH}, {0} }; diff --git a/dmtree/tr181/wifi.h b/dmtree/tr181/wifi.h index 0189af3f..613b3d08 100644 --- a/dmtree/tr181/wifi.h +++ b/dmtree/tr181/wifi.h @@ -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