diff --git a/src/bbf_plugin/hosts.c b/src/bbf_plugin/hosts.c index a53aa68cfd1f027d7628619ebf6e3a8bf991e64b..70855dc0d49b71f9c463302e04e1a4dda318db18 100644 --- a/src/bbf_plugin/hosts.c +++ b/src/bbf_plugin/hosts.c @@ -372,50 +372,44 @@ static int get_HostsHost_DHCPClient(char *refparam, struct dmctx *ctx, void *dat static int get_HostsHost_AssociatedDevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *type = dmjson_get_value((json_object *)data, 1, "interface_type"); - - if (DM_LSTRCMP(type, "Wi-Fi") == 0) { - char buf[4096] = {0}; - unsigned pos = 0; + char buf[4096] = {0}; + unsigned pos = 0; - buf[0] = 0; + buf[0] = 0; - bool is1905 = dmuci_string_to_boolean(dmjson_get_value((json_object *)data, 1, "is1905")); + bool is1905 = dmuci_string_to_boolean(dmjson_get_value((json_object *)data, 1, "is1905")); - char *linker = dmjson_get_value((json_object *)data, 1, is1905 ? "link_macaddr" : "macaddr"); + char *linker = dmjson_get_value((json_object *)data, 1, is1905 ? "link_macaddr" : "macaddr"); - bbf_get_reference_param("Device.WiFi.AccessPoint.*.AssociatedDevice.", "MACAddress", linker, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + bbf_get_reference_param("Device.WiFi.AccessPoint.*.AssociatedDevice.", "MACAddress", linker, value); + if (DM_STRLEN(*value)) + pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); - bbf_get_reference_param("Device.WiFi.DataElements.Network.Device.*.Radio.*.BSS.", "MACAddress", linker, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + bbf_get_reference_param("Device.WiFi.DataElements.Network.Device.*.Radio.*.BSS.", "MACAddress", linker, value); + if (DM_STRLEN(*value)) + pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); - if (pos) - buf[pos - 1] = 0; - - *value = dmstrdup(buf); - } else { - *value = ""; - } + if (pos) + buf[pos - 1] = 0; + *value = dmstrdup(buf); return 0; } static int get_HostsHost_Layer1Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char buf[4096] = {0}; + char *linker = NULL; unsigned pos = 0; buf[0] = 0; - bool is1905 = dmuci_string_to_boolean(dmjson_get_value((json_object *)data, 1, "is1905")); - - char *linker = dmjson_get_value((json_object *)data, 1, is1905 ? "parent_device" : "device"); char *type = dmjson_get_value((json_object *)data, 1, "interface_type"); if (DM_LSTRCMP(type, "Wi-Fi") == 0) { + bool is1905 = dmuci_string_to_boolean(dmjson_get_value((json_object *)data, 1, "is1905")); + linker = dmjson_get_value((json_object *)data, 1, is1905 ? "parent_device" : "device"); + struct uci_section *iface_s = get_dup_section_in_config_opt("wireless", "wifi-iface", "ifname", linker); dmuci_get_value_by_section_string(iface_s, "device", &linker); @@ -423,6 +417,7 @@ static int get_HostsHost_Layer1Interface(char *refparam, struct dmctx *ctx, void if (DM_STRLEN(*value)) pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); } else { + linker = dmjson_get_value((json_object *)data, 1, "device"); struct uci_section *device_s = get_dup_section_in_config_opt("network", "device", "name", linker); dmuci_get_value_by_section_string(device_s, "ifname", &linker);