diff --git a/libbbfdm-api/dmbbf.c b/libbbfdm-api/dmbbf.c index c924dd92738fd3b62f750d996c60d25939e9a486..8afc4e2ae210058571985df909699b63b5cb44b4 100644 --- a/libbbfdm-api/dmbbf.c +++ b/libbbfdm-api/dmbbf.c @@ -850,13 +850,30 @@ static char *get_value_by_reference(struct dmctx *ctx, char *value) bool path_resolved = false; unsigned pos = 0; - if (DM_STRLEN(value) == 0 || !DM_STRSTR(value, "==")) + if (DM_STRLEN(value) == 0) return value; DM_STRNCPY(buf, value, sizeof(buf)); buf_val[0] = 0; + if (!DM_STRSTR(value, "==")) { + + for (pch = strtok_r(buf, ",", &spch); pch; pch = strtok_r(NULL, ",", &spch)) { + + adm_entry_get_linker_value(ctx, pch, &val); + if (DM_STRLEN(val) == 0) + continue; + + pos += snprintf(&buf_val[pos], sizeof(buf_val) - pos, "%s,", pch); + } + + if (pos) + buf_val[pos - 1] = 0; + + return dmstrdup(buf_val); + } + for (pch = strtok_r(buf, ",", &spch); pch; pch = strtok_r(NULL, ",", &spch)) { char path[MAX_DM_PATH] = {0}; char key_name[256], key_value[256]; @@ -2152,11 +2169,13 @@ static int mparam_set_value(DMPARAM_ARGS) snprintf(param_value, sizeof(param_value), "%s", dmctx->in_value); } + char *param_val = dmstrdup(param_value); + int fault = (leaf->setvalue)(refparam, dmctx, data, instance, param_value, VALUECHECK); if (fault) return fault; - return (leaf->setvalue)(refparam, dmctx, data, instance, param_value, VALUESET); + return (leaf->setvalue)(refparam, dmctx, data, instance, param_val, VALUESET); } } diff --git a/libbbfdm-api/dmentry.c b/libbbfdm-api/dmentry.c index f11ba8dd758065f79d32ef241c21f904a4e056f2..389d857074f51b3655523e4473da2883130719ed 100644 --- a/libbbfdm-api/dmentry.c +++ b/libbbfdm-api/dmentry.c @@ -341,7 +341,8 @@ int adm_entry_get_reference_param(struct dmctx *ctx, char *param, char *linker, dmctx.linker = linker; dm_entry_get_reference_param(&dmctx); - *value = dmctx.linker_param; + + *value = dmctx.linker_param ? dmctx.linker_param : ""; bbf_ctx_clean_sub(&dmctx); return 0; diff --git a/libbbfdm/dmtree/tr143/diagnostics.c b/libbbfdm/dmtree/tr143/diagnostics.c index 2b2afda927f41a37d342433cc96dbb37574333e3..b6fe625a800f9791d153fbddcf7b4e4fbd32764a 100644 --- a/libbbfdm/dmtree/tr143/diagnostics.c +++ b/libbbfdm/dmtree/tr143/diagnostics.c @@ -62,8 +62,8 @@ static int set_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, void static int get_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = get_diagnostics_option("ipping", "interface"); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + return 0; } static int set_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) @@ -298,8 +298,8 @@ static int set_IPDiagnosticsTraceRoute_DiagnosticsState(char *refparam, struct d static int get_IPDiagnosticsTraceRoute_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = get_diagnostics_option("traceroute", "interface"); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + return 0; } static int set_IPDiagnosticsTraceRoute_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) @@ -543,8 +543,8 @@ static int set_IPDiagnosticsDownloadDiagnostics_DiagnosticsState(char *refparam, static int get_IPDiagnosticsDownloadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = get_diagnostics_option("download", "interface"); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + return 0; } static int set_IPDiagnosticsDownloadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) @@ -872,8 +872,8 @@ static int set_IPDiagnosticsUploadDiagnostics_DiagnosticsState(char *refparam, s static int get_IPDiagnosticsUploadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = get_diagnostics_option("upload", "interface"); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + return 0; } static int set_IPDiagnosticsUploadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) @@ -1217,8 +1217,8 @@ static int set_IPDiagnosticsUDPEchoDiagnostics_DiagnosticsState(char *refparam, static int get_IPDiagnosticsUDPEchoDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = get_diagnostics_option("udpechodiag", "interface"); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + return 0; } static int set_IPDiagnosticsUDPEchoDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) @@ -1477,8 +1477,8 @@ static int set_IPDiagnosticsServerSelectionDiagnostics_DiagnosticsState(char *re static int get_IPDiagnosticsServerSelectionDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = get_diagnostics_option("serverselection", "interface"); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + return 0; } static int set_IPDiagnosticsServerSelectionDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) diff --git a/libbbfdm/dmtree/tr181/atm.c b/libbbfdm/dmtree/tr181/atm.c index ac49126453cced8c5f74f06a5cd5072961bfd088..1893193472fb8fd0bf5b02ec86e3e1ce69989229 100644 --- a/libbbfdm/dmtree/tr181/atm.c +++ b/libbbfdm/dmtree/tr181/atm.c @@ -270,7 +270,7 @@ static int get_atm_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch snprintf(atm_file, sizeof(atm_file), "/sys/class/net/atm%ld", DM_STRTOL(instance) - 1); if (folder_exists(atm_file)) - bbf_get_reference_param("Device.DSL.Channel.", "Name", instance, value); + adm_entry_get_reference_param(ctx, "Device.DSL.Channel.*.Name", instance, value); return 0; } diff --git a/libbbfdm/dmtree/tr181/bridging.c b/libbbfdm/dmtree/tr181/bridging.c index afacc2609f5db10c7d9706a02cb2c5c0a03a3702..1044cfa9a53d9b6058b35811152b2b02736256c7 100644 --- a/libbbfdm/dmtree/tr181/bridging.c +++ b/libbbfdm/dmtree/tr181/bridging.c @@ -1999,7 +1999,7 @@ static int get_BridgingBridgePort_LowerLayers(char *refparam, struct dmctx *ctx, char *port = NULL; char br_buf[64] = {0}; - snprintf(br_buf, sizeof(br_buf), "Device.Bridging.Bridge.%s.Port.", args->br_inst); + snprintf(br_buf, sizeof(br_buf), "Device.Bridging.Bridge.%s.Port.*.Name", args->br_inst); dmuci_get_value_by_section_string(port_s, "management", &mg_port); if (DM_LSTRCMP(mg_port, "1") == 0) @@ -2007,8 +2007,8 @@ static int get_BridgingBridgePort_LowerLayers(char *refparam, struct dmctx *ctx, dmuci_get_value_by_section_string(port_s, "port", &port); - bbf_get_reference_param(br_buf, "Name", port, value); - if (*value && (*value)[0] != 0) + adm_entry_get_reference_param(ctx, br_buf, port, value); + if (DM_STRLEN(*value)) pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); } @@ -2040,10 +2040,10 @@ static int get_BridgingBridgePort_LowerLayers(char *refparam, struct dmctx *ctx, if (tag) tag[0] = '\0'; } - bbf_get_reference_param("Device.Ethernet.Interface.", "Name", port, value); + adm_entry_get_reference_param(ctx, "Device.Ethernet.Interface.*.Name", port, value); } else { struct uci_section *iface_s = get_dup_section_in_config_opt("wireless", "wifi-iface", "ifname", port); - bbf_get_reference_param("Device.WiFi.SSID.", "Name", section_name(iface_s), value); + adm_entry_get_reference_param(ctx, "Device.WiFi.SSID.*.Name", section_name(iface_s), value); } } @@ -2615,11 +2615,10 @@ static int get_BridgingBridgeVLANPort_VLAN(char *refparam, struct dmctx *ctx, vo if (DM_STRLEN(vid) == 0) { *value = ""; } else { - char br_vlan_path[32] = {0}; + char br_vlan_path[64] = {0}; - snprintf(br_vlan_path, sizeof(br_vlan_path),"Device.Bridging.Bridge.%s.VLAN.", args->br_inst); - - bbf_get_reference_param(br_vlan_path, "VLANID", vid, value); + snprintf(br_vlan_path, sizeof(br_vlan_path), "Device.Bridging.Bridge.%s.VLAN.*.VLANID", args->br_inst); + adm_entry_get_reference_param(ctx, br_vlan_path, vid, value); } return 0; } @@ -2700,9 +2699,8 @@ static int get_BridgingBridgeVLANPort_Port(char *refparam, struct dmctx *ctx, vo } else { char br_port_path[128] = {0}; - snprintf(br_port_path, sizeof(br_port_path), "Device.Bridging.Bridge.%s.Port.", args->br_inst); - - bbf_get_reference_param(br_port_path, "Name", name, value); + snprintf(br_port_path, sizeof(br_port_path), "Device.Bridging.Bridge.%s.Port.*.Name", args->br_inst); + adm_entry_get_reference_param(ctx, br_port_path, name, value); } return 0; } diff --git a/libbbfdm/dmtree/tr181/deviceinfo.c b/libbbfdm/dmtree/tr181/deviceinfo.c index fb73d50606a55f32a00ccb75d32ef05aefb48e68..65153578e048437d4fb51c3d3e7600afc5ad458e 100644 --- a/libbbfdm/dmtree/tr181/deviceinfo.c +++ b/libbbfdm/dmtree/tr181/deviceinfo.c @@ -583,7 +583,8 @@ static int get_device_active_fwimage(char *refparam, struct dmctx *ctx, void *da } } - return bbf_get_reference_param("Device.DeviceInfo.FirmwareImage.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.DeviceInfo.FirmwareImage.*.Name", linker, value); + return 0; } static int get_device_boot_fwimage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) @@ -601,7 +602,8 @@ static int get_device_boot_fwimage(char *refparam, struct dmctx *ctx, void *data } } - return bbf_get_reference_param("Device.DeviceInfo.FirmwareImage.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.DeviceInfo.FirmwareImage.*.Name", linker, value); + return 0; } static int set_device_boot_fwimage(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) diff --git a/libbbfdm/dmtree/tr181/dhcpv4.c b/libbbfdm/dmtree/tr181/dhcpv4.c index b8ddd5e656a192a9fafa6124a2a195b82a5d01f3..2ba8c8decb7191e2e4246151c9b3b6aa803e718e 100644 --- a/libbbfdm/dmtree/tr181/dhcpv4.c +++ b/libbbfdm/dmtree/tr181/dhcpv4.c @@ -1423,7 +1423,8 @@ static int set_DHCPv4ServerPool_Order(char *refparam, struct dmctx *ctx, void *d static int get_DHCPv4ServerPool_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - return bbf_get_reference_param("Device.IP.Interface.", "Name", ((struct dhcp_args *)data)->interface, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", ((struct dhcp_args *)data)->interface, value); + return 0; } static int set_DHCPv4ServerPool_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) @@ -2172,12 +2173,12 @@ static int set_DHCPv4Client_Alias(char *refparam, struct dmctx *ctx, void *data, static int get_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - struct dhcp_client_args *dhcpv4_client = (struct dhcp_client_args *)data; char *iface_name = NULL; - dmuci_get_value_by_section_string(dhcpv4_client->dmmap_s, "iface_name", &iface_name); + dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dmmap_s, "iface_name", &iface_name); - return bbf_get_reference_param("Device.IP.Interface.", "Name", iface_name, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", iface_name, value); + return 0; } static int set_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) @@ -3097,7 +3098,8 @@ static int get_DHCPv4RelayForwarding_Interface(char *refparam, struct dmctx *ctx dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dmmap_s, "iface_name", &iface_name); - return bbf_get_reference_param("Device.IP.Interface.", "Name", iface_name, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", iface_name, value); + return 0; } static int set_DHCPv4RelayForwarding_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) diff --git a/libbbfdm/dmtree/tr181/dhcpv6.c b/libbbfdm/dmtree/tr181/dhcpv6.c index aa96647ce598a7d754952bdf9de090c4a3472323..701c5389c81759cf7c53becb047d37c81eb887a7 100644 --- a/libbbfdm/dmtree/tr181/dhcpv6.c +++ b/libbbfdm/dmtree/tr181/dhcpv6.c @@ -514,37 +514,24 @@ static int set_DHCPv6Client_Alias(char *refparam, struct dmctx *ctx, void *data, static int get_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *iface_name = NULL; - char buf[4096] = {0}; - unsigned pos = 0; - - buf[0] = 0; dmuci_get_value_by_section_string(((struct dhcpv6_client_args *)data)->dmmap_s, "iface_name", &iface_name); - bbf_get_reference_param("Device.IP.Interface.", "Name", iface_name, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", iface_name, value); - if (((struct dhcpv6_client_args *)data)->iface_s) { + if (DM_STRLEN(*value) == 0 && ((struct dhcpv6_client_args *)data)->iface_s) { struct uci_section *s = NULL; char *device = NULL; dmuci_get_value_by_section_string(((struct dhcpv6_client_args *)data)->iface_s, "device", &device); if (DM_STRLEN(device) == 0) - goto end; + return 0; s = get_dup_section_in_config_opt("network", "interface", "device", device); - bbf_get_reference_param("Device.IP.Interface.", "Name", section_name(s), value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", section_name(s), value); } -end: - if (pos) - buf[pos - 1] = 0; - - *value = dmstrdup(buf); return 0; } @@ -845,7 +832,8 @@ static int set_DHCPv6ServerPool_Order(char *refparam, struct dmctx *ctx, void *d static int get_DHCPv6ServerPool_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - return bbf_get_reference_param("Device.IP.Interface.", "Name", ((struct dhcpv6_args *)data)->interface, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", ((struct dhcpv6_args *)data)->interface, value); + return 0; } static int set_DHCPv6ServerPool_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) diff --git a/libbbfdm/dmtree/tr181/dns.c b/libbbfdm/dmtree/tr181/dns.c index c77a68e0ea88bf6d59dd7bec8cfad887fd469aef..8e929182799b742d1fe068417f369f590f1bae3c 100644 --- a/libbbfdm/dmtree/tr181/dns.c +++ b/libbbfdm/dmtree/tr181/dns.c @@ -341,8 +341,8 @@ static int get_dns_interface(char *refparam, struct dmctx *ctx, void *data, char char *linker = NULL; dmuci_get_value_by_section_string((struct uci_section *)data, "interface", &linker); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + return 0; } static int get_dns_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) @@ -428,8 +428,8 @@ static int get_nslookupdiagnostics_diagnostics_state(char *refparam, struct dmct static int get_nslookupdiagnostics_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = get_diagnostics_option("nslookup", "interface"); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + return 0; } static int get_nslookupdiagnostics_host_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) diff --git a/libbbfdm/dmtree/tr181/dsl.c b/libbbfdm/dmtree/tr181/dsl.c index 0b78480747d316d699fb84c6496b2201e7aa0431..3b7da0c4688a4fa2ea7626878c7dc6387885f7eb 100644 --- a/libbbfdm/dmtree/tr181/dsl.c +++ b/libbbfdm/dmtree/tr181/dsl.c @@ -978,7 +978,8 @@ static int get_DSLChannel_Name(char *refparam, struct dmctx *ctx, void *data, ch static int get_DSLChannel_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - return bbf_get_reference_param("Device.DSL.Line.", "Name", ((struct dsl_line_args *)data)->id, value); + adm_entry_get_reference_param(ctx, "Device.DSL.Line.*.Name", ((struct dsl_line_args *)data)->id, value); + return 0; } static char *get_dsl_link_encapsulation_standard(char *str) diff --git a/libbbfdm/dmtree/tr181/dynamicdns.c b/libbbfdm/dmtree/tr181/dynamicdns.c index 04a7b07f98d2cdecbc3ffc71be711de1d4963c80..5cdc4a9298c8538aa952e346c89ace494ca3b219 100644 --- a/libbbfdm/dmtree/tr181/dynamicdns.c +++ b/libbbfdm/dmtree/tr181/dynamicdns.c @@ -555,8 +555,8 @@ static int get_DynamicDNSClient_Server(char *refparam, struct dmctx *ctx, void * char *service_name = NULL; dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "service_name", &service_name); - - return bbf_get_reference_param("Device.DynamicDNS.Server.", "ServiceName", service_name, value); + adm_entry_get_reference_param(ctx, "Device.DynamicDNS.Server.*.ServiceName", service_name, value); + return 0; } static int set_DynamicDNSClient_Server(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) @@ -588,8 +588,8 @@ static int get_DynamicDNSClient_Interface(char *refparam, struct dmctx *ctx, voi char *interface = NULL; dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "interface", &interface); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", interface, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", interface, value); + return 0; } static int set_DynamicDNSClient_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) diff --git a/libbbfdm/dmtree/tr181/ethernet.c b/libbbfdm/dmtree/tr181/ethernet.c index e2bcf53a4435fc8e5003434903afa58e5b055462..8808f5c577e4fb4eae32477488376f7e471797d8 100644 --- a/libbbfdm/dmtree/tr181/ethernet.c +++ b/libbbfdm/dmtree/tr181/ethernet.c @@ -951,45 +951,34 @@ static int get_EthernetLink_LastChange(char *refparam, struct dmctx *ctx, void * static int get_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *linker = NULL; - dmuci_get_value_by_section_string((struct uci_section *)data, "LowerLayers", value); if ((*value)[0] == '\0') { - char buf[4096] = {0}; - unsigned pos = 0; + char *linker = NULL; dmuci_get_value_by_section_string((struct uci_section *)data, "device", &linker); - if (!linker || *linker == '\0') + if (DM_STRLEN(linker) == 0) return 0; - buf[0] = 0; - - bbf_get_reference_param("Device.ATM.Link.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.ATM.Link.*.Name", linker, value); if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); - - bbf_get_reference_param("Device.PTM.Link.", "Name", linker, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + goto end; - bbf_get_reference_param("Device.Bridging.Bridge.*.Port.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.PTM.Link.*.Name", linker, value); if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + goto end; - bbf_get_reference_param("Device.Ethernet.Interface.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.Bridging.Bridge.*.Port.*.Name", linker, value); if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + goto end; - if (pos) - buf[pos - 1] = 0; + adm_entry_get_reference_param(ctx, "Device.Ethernet.Interface.*.Name", linker, value); - *value = dmstrdup(buf); - } else { - adm_entry_get_linker_value(ctx, *value, &linker); - if (!linker || *linker == 0) - *value = ""; +end: + // Store LowerLayers value + dmuci_set_value_by_section((struct uci_section *)data, "LowerLayers", *value); } + return 0; } @@ -1315,16 +1304,13 @@ static int get_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ifname", &ifname); if (DM_LSTRCMP(type, "8021ad") == 0) { - bbf_get_reference_param("Device.Ethernet.VLANTermination.", "Name", ifname, value); + adm_entry_get_reference_param(ctx, "Device.Ethernet.VLANTermination.*.Name", ifname, value); } else { - bbf_get_reference_param("Device.Ethernet.Link.", "Name", ifname, value); + adm_entry_get_reference_param(ctx, "Device.Ethernet.Link.*.Name", ifname, value); } - } else { - char *linker = NULL; - adm_entry_get_linker_value(ctx, *value, &linker); - if (!linker || *linker == 0) - *value = ""; + // Store LowerLayers value + dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "LowerLayers", *value); } return 0; @@ -1656,8 +1642,8 @@ static int get_EthernetRMONStats_Interface(char *refparam, struct dmctx *ctx, vo char *linker = NULL; dmuci_get_value_by_section_string((((struct eth_rmon_args *)data)->sections)->config_section, "name", &linker); - - return bbf_get_reference_param("Device.Ethernet.Interface.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.Ethernet.Interface.*.Name", linker, value); + return 0; } static int set_EthernetRMONStats_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) diff --git a/libbbfdm/dmtree/tr181/firewall.c b/libbbfdm/dmtree/tr181/firewall.c index 7db601bb50ac11ed15e00f5b6fcda43a558d7273..4ab5ed6e20c41007c762254ab2124dbc8b472a18 100644 --- a/libbbfdm/dmtree/tr181/firewall.c +++ b/libbbfdm/dmtree/tr181/firewall.c @@ -797,7 +797,7 @@ static int get_rule_source_interface(char *refparam, struct dmctx *ctx, void *da src_iface[0] = 0; uci_foreach_element(net_list, e) { - bbf_get_reference_param("Device.IP.Interface.", "Name", e->name, &ifaceobj); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", e->name, &ifaceobj); if (ifaceobj && *ifaceobj) pos += snprintf(&src_iface[pos], sizeof(src_iface) - pos, "%s,", ifaceobj); } @@ -810,7 +810,8 @@ static int get_rule_source_interface(char *refparam, struct dmctx *ctx, void *da } } - return bbf_get_reference_param("Device.IP.Interface.", "Name", src, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", src, value); + return 0; } static int get_rule_source_all_interfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) @@ -865,7 +866,7 @@ static int get_rule_dest_interface(char *refparam, struct dmctx *ctx, void *data dst_iface[0] = 0; uci_foreach_element(net_list, e) { - bbf_get_reference_param("Device.IP.Interface.", "Name", e->name, &ifaceobj); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", e->name, &ifaceobj); if (ifaceobj && *ifaceobj) pos += snprintf(&dst_iface[pos], sizeof(dst_iface) - pos, "%s,", ifaceobj); } @@ -878,7 +879,8 @@ static int get_rule_dest_interface(char *refparam, struct dmctx *ctx, void *data } } - return bbf_get_reference_param("Device.IP.Interface.", "Name", dest, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", dest, value); + return 0; } static int get_rule_dest_all_interfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) diff --git a/libbbfdm/dmtree/tr181/ieee1905.c b/libbbfdm/dmtree/tr181/ieee1905.c index b640cad03f16a84146502cd92312fb69328a7a12..e6a642a1e14cce901dcbbb71ce3f0c1a891cfd3c 100644 --- a/libbbfdm/dmtree/tr181/ieee1905.c +++ b/libbbfdm/dmtree/tr181/ieee1905.c @@ -436,25 +436,13 @@ static int get_IEEE1905ALInterface_Status(char *refparam, struct dmctx *ctx, voi /*#Device.IEEE1905.AL.Interface.{i}.LowerLayers!UBUS:ieee1905/info//interface[@i-1].ifname*/ static int get_IEEE1905ALInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char buf[4096] = {0}; - unsigned pos = 0; - - buf[0] = 0; - char *linker = dmjson_get_value((json_object *)data, 1, "ifname"); - bbf_get_reference_param("Device.Ethernet.Interface.", "Name", linker, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + adm_entry_get_reference_param(ctx, "Device.Ethernet.Interface.*.Name", linker, value); - bbf_get_reference_param("Device.WiFi.Radio.", "Name", linker, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + if (!DM_STRLEN(*value)) + adm_entry_get_reference_param(ctx, "Device.WiFi.Radio.*.Name", linker, value); - if (pos) - buf[pos - 1] = 0; - - *value = dmstrdup(buf); return 0; } @@ -1405,7 +1393,9 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_FrequencyIndex2( /*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.NonIEEE1905Neighbor.{i}.LocalInterface!UBUS:ieee1905/info//topology.device[@i-1].non1905_neighbors[@i-1].interface_macaddress*/ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905Neighbor_LocalInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - return bbf_get_reference_param("Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.*.Interface.", "InterfaceId", ((struct ieee1905_device_nonieee1905neighbor_args *)data)->mac_addr, value); + adm_entry_get_reference_param(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.*.Interface.*.InterfaceId", ((struct ieee1905_device_nonieee1905neighbor_args *)data)->mac_addr, value); + return 0; + } /*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.NonIEEE1905Neighbor.{i}.NeighborInterfaceId!UBUS:ieee1905/info//topology.device[@i-1].non1905_neighbors[@i-1].neighbors*/ @@ -1439,8 +1429,8 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceL2Neighbor_BehindInterface static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905Neighbor_LocalInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = dmjson_get_value((json_object *)data, 1, "macaddress"); - - return bbf_get_reference_param("Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.*.Interface.", "InterfaceId", linker, value); + adm_entry_get_reference_param(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.*.Interface.*.InterfaceId", linker, value); + return 0; } /*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.NeighborDeviceId!UBUS:ieee1905/info//topology.device[@i-1].ieee1905_neighbors[@i-1].neighbor_device_id*/ @@ -1540,8 +1530,7 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceBridgingTuple_InterfaceLis dmjson_foreach_value_in_array((json_object *)data, json_obj, mac_addr, idx, 1, "tuple") { char *linker = NULL; - bbf_get_reference_param("Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.*.Interface.", "InterfaceId", mac_addr, &linker); - + adm_entry_get_reference_param(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.*.Interface.*.InterfaceId", mac_addr, &linker); if (DM_STRLEN(linker) && (sizeof(buf) - pos) > 0) pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", linker); } diff --git a/libbbfdm/dmtree/tr181/ip.c b/libbbfdm/dmtree/tr181/ip.c index b21782ff0c372b89888fb8160298c45b69860a0c..b893c3e6e8ac2588510c592297bf91c586a7cf99 100644 --- a/libbbfdm/dmtree/tr181/ip.c +++ b/libbbfdm/dmtree/tr181/ip.c @@ -1302,9 +1302,6 @@ static int get_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void * dmuci_get_value_by_section_string(dmmap_section, "LowerLayers", value); if ((*value)[0] == '\0') { - char buf[4096] = {0}; - unsigned pos = 0; - char *device = get_device(section_name((struct uci_section *)data)); if (DM_STRLEN(device) == 0) { dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device); @@ -1312,35 +1309,25 @@ static int get_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void * return 0; } - buf[0] = 0; - - bbf_get_reference_param("Device.PPP.Interface.", "Name", device, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); - - bbf_get_reference_param("Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN", "Name", device, value); + adm_entry_get_reference_param(ctx, "Device.PPP.Interface.*.Name", device, value); if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + goto end; - bbf_get_reference_param("Device.Ethernet.VLANTermination.", "Name", device, value); + adm_entry_get_reference_param(ctx, "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.*.Name", device, value); if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + goto end; - bbf_get_reference_param("Device.Ethernet.Link.", "Name", device, value); + adm_entry_get_reference_param(ctx, "Device.Ethernet.VLANTermination.*.Name", device, value); if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); - - if (pos) - buf[pos - 1] = 0; + goto end; - *value = dmstrdup(buf); - } else { - char *linker = NULL; + adm_entry_get_reference_param(ctx, "Device.Ethernet.Link.*.Name", device, value); - adm_entry_get_linker_value(ctx, *value, &linker); - if (!linker || *linker == 0) - *value = ""; +end: + // Store LowerLayers value + dmuci_set_value_by_section(dmmap_section, "LowerLayers", *value); } + return 0; } @@ -1417,14 +1404,12 @@ static int get_IPInterface_Router(char *refparam, struct dmctx *ctx, void *data, dmuci_get_value_by_section_string((struct uci_section *)data, "ip4table", &ip4table); - bbf_get_reference_param("Device.Routing.Router.", "Alias", DM_STRLEN(ip4table) ? ip4table : "254", value); - } else { - char *linker = NULL; + adm_entry_get_reference_param(ctx, "Device.Routing.Router.*.Alias", DM_STRLEN(ip4table) ? ip4table : "254", value); - adm_entry_get_linker_value(ctx, *value, &linker); - if (!linker || *linker == 0) - *value = "Device.Routing.Router.1"; + // Store LowerLayers value + dmuci_set_value_by_section(dmmap_section, "Router", *value); } + return 0; } @@ -1450,6 +1435,7 @@ static int set_IPInterface_Router(char *refparam, struct dmctx *ctx, void *data, if (DM_STRLEN(reference.value) == 0) return FAULT_9007; + // Store LowerLayers value get_dmmap_section_of_config_section("dmmap_network", "interface", section_name((struct uci_section *)data), &s); dmuci_set_value_by_section(s, "Router", reference.path); @@ -2062,8 +2048,8 @@ static int get_IPInterfaceIPv6Prefix_ParentPrefix(char *refparam, struct dmctx * char *linker = NULL; dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->dmmap_sec, "address", &linker); - - return bbf_get_reference_param("Device.IP.Interface.*.IPv6Prefix.", "Prefix", linker, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.IPv6Prefix.*.Prefix", linker, value); + return 0; } static int set_IPInterfaceIPv6Prefix_ParentPrefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) diff --git a/libbbfdm/dmtree/tr181/mqtt.c b/libbbfdm/dmtree/tr181/mqtt.c index 480345acf08102c3ee8d7c01393212c7ed1077ca..0726707bbbecd4fbe9354ff932b78b6fa0cffa27 100644 --- a/libbbfdm/dmtree/tr181/mqtt.c +++ b/libbbfdm/dmtree/tr181/mqtt.c @@ -210,8 +210,8 @@ static int get_MQTTBroker_Interface(char *refparam, struct dmctx *ctx, void *dat char *intf = NULL; dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "interface", &intf); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", intf, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", intf, value); + return 0; } static int set_MQTTBroker_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) diff --git a/libbbfdm/dmtree/tr181/nat.c b/libbbfdm/dmtree/tr181/nat.c index 0f98a9f5e56d4b47022b948a8ca13bb3d3ad24cc..117ef0f8d6899b2d95f580fa17e6f84d166965cd 100644 --- a/libbbfdm/dmtree/tr181/nat.c +++ b/libbbfdm/dmtree/tr181/nat.c @@ -238,7 +238,7 @@ static int get_nat_interface_setting_interface(char *refparam, struct dmctx *ctx char *ifaceobj = NULL; uci_foreach_element(v, e) { - bbf_get_reference_param("Device.IP.Interface.", "Name", e->name, &ifaceobj); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", e->name, &ifaceobj); if (ifaceobj && *ifaceobj) pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", ifaceobj); } @@ -345,7 +345,7 @@ static int get_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, voi char *ifaceobj = NULL; uci_foreach_element(v, e) { - bbf_get_reference_param("Device.IP.Interface.", "Name", e->name, &ifaceobj); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", e->name, &ifaceobj); if (ifaceobj && *ifaceobj) pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", ifaceobj); } diff --git a/libbbfdm/dmtree/tr181/ppp.c b/libbbfdm/dmtree/tr181/ppp.c index 6fe90010cff642bc5f9c20b7dc591730a097ce55..7528d8cdba78daa3966b246d2911bddede1a89fa 100644 --- a/libbbfdm/dmtree/tr181/ppp.c +++ b/libbbfdm/dmtree/tr181/ppp.c @@ -984,9 +984,7 @@ static int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch dmuci_get_value_by_section_string(ppp->dmmap_s, "LowerLayers", value); if ((*value)[0] == '\0') { - char buf[4096] = {0}; char *device = NULL; - unsigned pos = 0; if (ppp->iface_s) { device = get_device(section_name(ppp->iface_s)); @@ -999,31 +997,21 @@ static int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch if (DM_STRLEN(device) == 0) return 0; - buf[0] = 0; - - bbf_get_reference_param("Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN", "Name", device, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); - - bbf_get_reference_param("Device.Ethernet.VLANTermination.", "Name", device, value); + adm_entry_get_reference_param(ctx, "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.*.Name", device, value); if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + goto end; - bbf_get_reference_param("Device.Ethernet.Link.", "Name", device, value); + adm_entry_get_reference_param(ctx, "Device.Ethernet.VLANTermination.*.Name", device, value); if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + goto end; - if (pos) - buf[pos - 1] = 0; + adm_entry_get_reference_param(ctx, "Device.Ethernet.Link.*.Name", device, value); - *value = dmstrdup(buf); - } else { - char *linker = NULL; - - adm_entry_get_linker_value(ctx, *value, &linker); - if (!linker || *linker == 0) - *value = ""; +end: + // Store LowerLayers value + dmuci_set_value_by_section(ppp->dmmap_s, "LowerLayers", *value); } + return 0; } diff --git a/libbbfdm/dmtree/tr181/ptm.c b/libbbfdm/dmtree/tr181/ptm.c index 8f6ba9a7f968b1e7c505774bb99ceac0ac57b87e..d339eff6ae8fecd1de3e52fc31f57e4a771c249f 100644 --- a/libbbfdm/dmtree/tr181/ptm.c +++ b/libbbfdm/dmtree/tr181/ptm.c @@ -172,31 +172,20 @@ static int get_ptm_link_name(char *refparam, struct dmctx *ctx, void *data, char static int get_ptm_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char buf[1024] = {0}; char ptm_file[128] = {0}; - unsigned pos = 0; - buf[0] = 0; - - bbf_get_reference_param("Device.FAST.Line.", "Status", "Up", value); + adm_entry_get_reference_param(ctx, "Device.FAST.Line.*.Status", "Up", value); if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + return 0; snprintf(ptm_file, sizeof(ptm_file), "/sys/class/net/ptm%ld", DM_STRTOL(instance) - 1); if (folder_exists(ptm_file)) { - bbf_get_reference_param("Device.DSL.Channel.", "Name", "1", value); + adm_entry_get_reference_param(ctx, "Device.DSL.Channel.*.Name", "1", value); if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + return 0; } - bbf_get_reference_param("Device.FAST.Line.", "Name", "1", value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); - - if (pos) - buf[pos - 1] = 0; - - *value = dmstrdup(buf); + adm_entry_get_reference_param(ctx, "Device.FAST.Line.*.Name", "1", value); return 0; } diff --git a/libbbfdm/dmtree/tr181/qos.c b/libbbfdm/dmtree/tr181/qos.c index 5af3d39ace96fa1edbee0eb8db15f12368b4d2ee..cf8ee05cac9f24641aa1a9207d6ce76775c28848 100644 --- a/libbbfdm/dmtree/tr181/qos.c +++ b/libbbfdm/dmtree/tr181/qos.c @@ -388,35 +388,21 @@ static int delObjQoSShaper(char *refparam, struct dmctx *ctx, void *data, char * **************************************************************/ static int get_QInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char buf[1024] = {0}; char *linker = NULL; - unsigned pos = 0; - - buf[0] = 0; dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ifname", &linker); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); - bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); - - bbf_get_reference_param("Device.PPP.Interface.", "Name", linker, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + if (!DM_STRLEN(*value)) + adm_entry_get_reference_param(ctx, "Device.PPP.Interface.*.Name", linker, value); - bbf_get_reference_param("Device.Ethernet.Interface.", "Name", linker, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + if (!DM_STRLEN(*value)) + adm_entry_get_reference_param(ctx, "Device.Ethernet.Interface.*.Name", linker, value); - bbf_get_reference_param("Device.WiFi.Radio.", "Name", linker, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + if (!DM_STRLEN(*value)) + adm_entry_get_reference_param(ctx, "Device.WiFi.Radio.*.Name", linker, value); - if (pos) - buf[pos - 1] = 0; - - *value = dmstrdup(buf); return 0; } @@ -1721,8 +1707,8 @@ static int get_QoSQueueStats_Queue(char *refparam, struct dmctx *ctx, void *data char *queue_link = NULL; dmuci_get_value_by_section_string((struct uci_section *)data, "queue", &queue_link); - - return bbf_get_reference_param("Device.QoS.Queue.", "Alias", queue_link, value); + adm_entry_get_reference_param(ctx, "Device.QoS.Queue.*.Alias", queue_link, value); + return 0; } static int set_QoSQueueStats_Queue(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) @@ -1750,31 +1736,18 @@ static int set_QoSQueueStats_Queue(char *refparam, struct dmctx *ctx, void *data static int get_QoSQueueStats_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char buf[1024] = {0}; char *linker = NULL; - unsigned pos = 0; - - buf[0] = 0; dmuci_get_value_by_section_string((struct uci_section *)data, "interface", &linker); + adm_entry_get_reference_param(ctx, "Device.Ethernet.Interface.*.Name", linker, value); - bbf_get_reference_param("Device.Ethernet.Interface.", "Name", linker, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); - - bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); - - bbf_get_reference_param("Device.PPP.Interface.", "Name", linker, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + if (!DM_STRLEN(*value)) + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); - if (pos) - buf[pos - 1] = 0; + if (!DM_STRLEN(*value)) + adm_entry_get_reference_param(ctx, "Device.PPP.Interface.*.Name", linker, value); - *value = dmstrdup(buf); return 0; } diff --git a/libbbfdm/dmtree/tr181/routeradvertisement.c b/libbbfdm/dmtree/tr181/routeradvertisement.c index da5b7add5c1f8182d5c8cb17180609e9e861dda6..a28484cc49dd244a502e7c32d7d5e42ac811433c 100644 --- a/libbbfdm/dmtree/tr181/routeradvertisement.c +++ b/libbbfdm/dmtree/tr181/routeradvertisement.c @@ -281,8 +281,8 @@ static int get_RouterAdvertisementInterfaceSetting_Interface(char *refparam, str char *linker = NULL; dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "interface", &linker); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + return 0; } static int set_RouterAdvertisementInterfaceSetting_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) diff --git a/libbbfdm/dmtree/tr181/routing.c b/libbbfdm/dmtree/tr181/routing.c index 2b62b48f5086618f0d19a37716fa773db87aab1a..4fae1a2bf1f784cd87422a18a90df6d63d5467fc 100644 --- a/libbbfdm/dmtree/tr181/routing.c +++ b/libbbfdm/dmtree/tr181/routing.c @@ -739,8 +739,8 @@ static int get_RoutingRouterForwarding_Interface(char *refparam, struct dmctx *c char *linker = NULL; dmuci_get_value_by_section_string(((struct routingfwdargs *)data)->routefwdsection, "interface", &linker); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + return 0; } static int set_RoutingRouterForwarding_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) @@ -1036,7 +1036,8 @@ static int get_RoutingRouteInformationInterfaceSetting_Interface(char *refparam, } } - return bbf_get_reference_param("Device.IP.Interface.", "Name", iface, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", iface, value); + return 0; } static int get_RoutingRouteInformationInterfaceSetting_SourceRouter(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) diff --git a/libbbfdm/dmtree/tr181/ssh.c b/libbbfdm/dmtree/tr181/ssh.c index 1bc12cb5b2f413bd753904d3e62d8c722c5af702..ba3a9b3b44649669c0f86936f25be2fc7ebe25a1 100644 --- a/libbbfdm/dmtree/tr181/ssh.c +++ b/libbbfdm/dmtree/tr181/ssh.c @@ -615,8 +615,8 @@ static int get_ssh_server_interface(char *refparam, struct dmctx *ctx, void *dat char *linker = NULL; dmuci_get_value_by_section_string(((struct dmmap_ssh *)data)->config_section, "Interface", &linker); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + return 0; } static int set_ssh_server_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) diff --git a/libbbfdm/dmtree/tr181/upnp.c b/libbbfdm/dmtree/tr181/upnp.c index 7f14e9ed3847fc6f973407dc9f3f1c32daa6efb0..d18ceab141407681ff9feef70af088b170ebe068 100644 --- a/libbbfdm/dmtree/tr181/upnp.c +++ b/libbbfdm/dmtree/tr181/upnp.c @@ -475,23 +475,11 @@ static int get_UPnPDiscoveryService_Location(char *refparam, struct dmctx *ctx, static int get_UPnPDiscoveryService_ParentDevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char buf[1024] = {0}; - unsigned pos = 0; + adm_entry_get_reference_param(ctx, "Device.UPnP.Discovery.Device.*.UUID", ((struct upnpdiscovery *)data)->uuid, value); - buf[0] = 0; + if (!DM_STRLEN(*value)) + adm_entry_get_reference_param(ctx, "Device.UPnP.Discovery.RootDevice.*.UUID", ((struct upnpdiscovery *)data)->uuid, value); - bbf_get_reference_param("Device.UPnP.Discovery.Device.", "UUID", ((struct upnpdiscovery *)data)->uuid, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); - - bbf_get_reference_param("Device.UPnP.Discovery.RootDevice.", "UUID", ((struct upnpdiscovery *)data)->uuid, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); - - if (pos) - buf[pos - 1] = 0; - - *value = dmstrdup(buf); return 0; } @@ -532,7 +520,8 @@ static int get_UPnPDescriptionDeviceInstance_UDN(char *refparam, struct dmctx *c static int get_UPnPDescriptionDeviceInstance_ParentDevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - return bbf_get_reference_param("Device.UPnP.Description.DeviceInstance.", "UDN", ((struct upnp_device_inst *)data)->parentudn, value); + adm_entry_get_reference_param(ctx, "Device.UPnP.Description.DeviceInstance.*.UDN", ((struct upnp_device_inst *)data)->parentudn, value); + return 0; } static int get_UPnPDescriptionDeviceInstance_DiscoveryDevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) @@ -540,32 +529,19 @@ static int get_UPnPDescriptionDeviceInstance_DiscoveryDevice(char *refparam, str struct upnp_device_inst *upnpdevinst = (struct upnp_device_inst *)data; if (upnpdevinst->udn && upnpdevinst->udn[0]) { - char buf[1024] = {0}; size_t length = 0; - unsigned pos = 0; char **udnarray = strsplit(upnpdevinst->udn, ":", &length); if (length != 2) - goto end; - - buf[0] = 0; - - bbf_get_reference_param("Device.UPnP.Discovery.Device.", "UUID", udnarray[1], value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); - - bbf_get_reference_param("Device.UPnP.Discovery.RootDevice.", "UUID", udnarray[1], value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + return 0; - if (pos) - buf[pos - 1] = 0; + adm_entry_get_reference_param(ctx, "Device.UPnP.Discovery.Device.*.UUID", udnarray[1], value); - *value = dmstrdup(buf); + if (!DM_STRLEN(*value)) + adm_entry_get_reference_param(ctx, "Device.UPnP.Discovery.RootDevice.*.UUID", udnarray[1], value); } -end: return 0; } @@ -648,7 +624,8 @@ static int get_UPnPDescriptionDeviceInstance_PresentationURL(char *refparam, str static int get_UPnPDescriptionServiceInstance_ParentDevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - return bbf_get_reference_param("Device.UPnP.Description.DeviceInstance.", "UDN", ((struct upnp_service_inst *)data)->parentudn, value); + adm_entry_get_reference_param(ctx, "Device.UPnP.Description.DeviceInstance.*.UDN", ((struct upnp_service_inst *)data)->parentudn, value); + return 0; } /*#Device.UPnP.Description.ServiceInstance.{i}.ServiceId!UBUS:upnpc/description//servicesinstances[i-1].serviceId*/ @@ -664,7 +641,8 @@ static int get_UPnPDescriptionServiceInstance_ServiceDiscovery(char *refparam, s snprintf(usn, sizeof(usn), "%s::%s", ((struct upnp_service_inst *)data)->parentudn, ((struct upnp_service_inst *)data)->servicetype); - return bbf_get_reference_param("Device.UPnP.Discovery.Service.", "USN", usn, value); + adm_entry_get_reference_param(ctx, "Device.UPnP.Discovery.Service.*.USN", usn, value); + return 0; } /*#Device.UPnP.Description.ServiceInstance.{i}.ServiceType!UBUS:upnpc/description//servicesinstances[i-1].serviceType*/ diff --git a/libbbfdm/dmtree/tr181/usb.c b/libbbfdm/dmtree/tr181/usb.c index 0644bed265e59ad2f7731e0670d779d3a9367f0c..2ab1b934823f9fd16464d576ad2d830687bdd1a4 100644 --- a/libbbfdm/dmtree/tr181/usb.c +++ b/libbbfdm/dmtree/tr181/usb.c @@ -474,7 +474,8 @@ static int get_USBInterface_Name(char *refparam, struct dmctx *ctx, void *data, static int get_USBInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - return bbf_get_reference_param("Device.Ethernet.Interface.", "Name", ((struct usb_interface *)data)->iface_name, value); + adm_entry_get_reference_param(ctx, "Device.Ethernet.Interface.*.Name", ((struct usb_interface *)data)->iface_name, value); + return 0; } static int set_USBInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) @@ -849,7 +850,8 @@ out: static int get_USBUSBHostsHostDevice_USBPort(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - return bbf_get_reference_param("Device.USB.Port.", "Name", ((struct usb_port *)data)->folder_name, value); + adm_entry_get_reference_param(ctx, "Device.USB.Port.*.Name", ((struct usb_port *)data)->folder_name, value); + return 0; } static int get_USBUSBHostsHostDevice_Rate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) @@ -878,9 +880,9 @@ static int get_USBUSBHostsHostDevice_Parent(char *refparam, struct dmctx *ctx, v } dmuci_get_value_by_section_string(usbdev->dmsect, "usb_host_instance", &host_inst); - snprintf(usb_host_path, sizeof(usb_host_path), "Device.USB.USBHosts.Host.%s.Device.", host_inst); + snprintf(usb_host_path, sizeof(usb_host_path), "Device.USB.USBHosts.Host.%s.Device.*.DeviceNumber", host_inst); - bbf_get_reference_param(usb_host_path, "DeviceNumber", port[0], value); + adm_entry_get_reference_param(ctx, usb_host_path, port[0], value); out: regfree(®ex1); diff --git a/libbbfdm/dmtree/tr181/userinterface.c b/libbbfdm/dmtree/tr181/userinterface.c index 757707d9f4e862993df26adacace6c6c80f6ca1c..15c785938178e47c8d63eedc469145986b230b43 100644 --- a/libbbfdm/dmtree/tr181/userinterface.c +++ b/libbbfdm/dmtree/tr181/userinterface.c @@ -471,8 +471,8 @@ static int get_http_access_interface(char *refparam, struct dmctx *ctx, void *da char *linker = NULL; dmuci_get_value_by_section_string(((struct dmmap_http *)data)->config_section, "uci_interface", &linker); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + return 0; } static int set_http_access_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) diff --git a/libbbfdm/dmtree/tr181/wifi.c b/libbbfdm/dmtree/tr181/wifi.c index 8efee4e3832554dd7eac04ffca346f9d4e9d5f5e..0373a34ecf34cade9f643f17e7db3bc2dd0e921b 100644 --- a/libbbfdm/dmtree/tr181/wifi.c +++ b/libbbfdm/dmtree/tr181/wifi.c @@ -2270,7 +2270,8 @@ static int get_WiFiEndPoint_SSIDReference(char *refparam, struct dmctx *ctx, voi { struct uci_section *iface_s = get_dup_section_in_config_opt("wireless", "wifi-iface", "ifname", ((struct wifi_enp_args *)data)->ifname); - return bbf_get_reference_param("Device.WiFi.SSID.", "Name", section_name(iface_s), value); + adm_entry_get_reference_param(ctx, "Device.WiFi.SSID.*.Name", section_name(iface_s), value); + return 0; } static int get_WiFiEndPointStats_LastDataDownlinkRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) @@ -2680,8 +2681,8 @@ static int get_ssid_lower_layer(char *refparam, struct dmctx *ctx, void *data, c char *device = NULL; dmuci_get_value_by_section_string(((struct wifi_ssid_args *)data)->dmmap_s, "device", &device); - - return bbf_get_reference_param("Device.WiFi.Radio.", "Name", device, value); + adm_entry_get_reference_param(ctx, "Device.WiFi.Radio.*.Name", device, value); + return 0; } static int set_ssid_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) @@ -2715,14 +2716,12 @@ static int get_ap_ssid_ref(char *refparam, struct dmctx *ctx, void *data, char * dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->dmmap_section, "LowerLayers", value); if ((*value)[0] == '\0') { - bbf_get_reference_param("Device.WiFi.SSID.", "Name", section_name((((struct wifi_acp_args *)data)->sections)->config_section), value); - } else { - char *linker = NULL; + adm_entry_get_reference_param(ctx, "Device.WiFi.SSID.*.Name", section_name((((struct wifi_acp_args *)data)->sections)->config_section), value); - adm_entry_get_linker_value(ctx, *value, &linker); - if (!linker || *linker == 0) - *value = ""; + // Store LowerLayers value + dmuci_set_value_by_section((((struct wifi_acp_args *)data)->sections)->dmmap_section, "LowerLayers", *value); } + return 0; } diff --git a/libbbfdm/dmtree/tr181/wifi.dataelements.c b/libbbfdm/dmtree/tr181/wifi.dataelements.c index 341f53bccdfe00c902078466c53dd686ff43ff12..4031fd5681f02de18927f38200d48d73850ed7f1 100644 --- a/libbbfdm/dmtree/tr181/wifi.dataelements.c +++ b/libbbfdm/dmtree/tr181/wifi.dataelements.c @@ -2581,8 +2581,8 @@ static int get_WiFiDataElementsNetworkDeviceMultiAPDevice_LastContactTime(char * static int get_WiFiDataElementsNetworkDeviceMultiAPDevice_AssocIEEE1905DeviceRef(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *device_id = dmjson_get_value(((struct wifi_data_element_args *)data)->dump_obj, 1, "ID"); - - return bbf_get_reference_param("Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.", "IEEE1905Id", device_id, value); + adm_entry_get_reference_param(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.*.IEEE1905Id", device_id, value); + return 0; } /* diff --git a/libbbfdm/dmtree/tr471/iplayercap.c b/libbbfdm/dmtree/tr471/iplayercap.c index 47656716bc780bde4197c156d31e1b824af09818..8bb36d8ee4c43ced1de09e43d2731adbed926a73 100644 --- a/libbbfdm/dmtree/tr471/iplayercap.c +++ b/libbbfdm/dmtree/tr471/iplayercap.c @@ -98,8 +98,8 @@ int get_IPDiagnosticsIPLayerCapacity_SupportedMetrics(char *refparam, struct dmc static int get_IPDiagnosticsIPLayerCapacity_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *linker = get_diagnostics_option("iplayercapacity", "interface"); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value); + return 0; } static int set_IPDiagnosticsIPLayerCapacity_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) diff --git a/libbbfdm/dmtree/vendor/iopsys/tr181/ethernet.c b/libbbfdm/dmtree/vendor/iopsys/tr181/ethernet.c index 13265e75b9f44ff7f738f9cb7ff34a8ca4b8b533..4f97134fe1589866c8f1e1f4e87ef586d229f1ea 100644 --- a/libbbfdm/dmtree/vendor/iopsys/tr181/ethernet.c +++ b/libbbfdm/dmtree/vendor/iopsys/tr181/ethernet.c @@ -148,32 +148,21 @@ static int get_EthernetMACVLAN_LowerLayers(char *refparam, struct dmctx *ctx, vo dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "LowerLayers", value); if ((*value)[0] == '\0') { - char buf[4096] = {0}; - unsigned pos = 0; - dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ifname", &linker); if (!linker || *linker == '\0') return 0; - buf[0] = 0; - - bbf_get_reference_param("Device.Ethernet.VLANTermination.", "Name", linker, value); + adm_entry_get_reference_param(ctx, "Device.Ethernet.VLANTermination.*.Name", linker, value); if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + goto end; - bbf_get_reference_param("Device.Ethernet.Link.", "Name", linker, value); - if (DM_STRLEN(*value)) - pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", *value); + adm_entry_get_reference_param(ctx, "Device.Ethernet.Link.*.Name", linker, value); - if (pos) - buf[pos - 1] = 0; - - *value = dmstrdup(buf); - } else { - adm_entry_get_linker_value(ctx, *value, &linker); - if (!linker || *linker == 0) - *value = ""; +end: + // Store LowerLayers value + dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "LowerLayers", *value); } + return 0; } diff --git a/libbbfdm/dmtree/vendor/iopsys/tr181/times.c b/libbbfdm/dmtree/vendor/iopsys/tr181/times.c index f5d2aac320ac0e81e90b2c9605011f860f6aa12c..6583356b55e660b5458c74f5c2edf8f929e701da 100644 --- a/libbbfdm/dmtree/vendor/iopsys/tr181/times.c +++ b/libbbfdm/dmtree/vendor/iopsys/tr181/times.c @@ -24,8 +24,8 @@ static int get_time_source_interface(char *refparam, struct dmctx *ctx, void *da char *iface = NULL; dmuci_get_option_value_string("system", "ntp", "interface", &iface); - - return bbf_get_reference_param("Device.IP.Interface.", "Name", iface, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", iface, value); + return 0; } static int set_time_source_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) diff --git a/libbbfdm/dmtree/vendor/iopsys/tr181/x_iopsys_eu_igmp.c b/libbbfdm/dmtree/vendor/iopsys/tr181/x_iopsys_eu_igmp.c index 1880399672cd1329633b1c55a938d0b5130e31aa..576099c786eb29df2e5edee65178f1050e9b399d 100644 --- a/libbbfdm/dmtree/vendor/iopsys/tr181/x_iopsys_eu_igmp.c +++ b/libbbfdm/dmtree/vendor/iopsys/tr181/x_iopsys_eu_igmp.c @@ -938,7 +938,8 @@ int get_mcast_snooping_interface(char *refparam, struct dmctx *ctx, void *data, // In the dmmap_bridge file, the details related to the instance id etc. associated with this bridge // is stored, we now switch our focus to it to extract the necessary information. - return bbf_get_reference_param("Device.Bridging.Bridge.*.Port.", "Name", val1, value); + adm_entry_get_reference_param(ctx, "Device.Bridging.Bridge.*.Port.*.Name", val1, value); + return 0; } int set_mcast_snooping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) @@ -1314,8 +1315,8 @@ static int get_igmp_cgrp_assoc_dev_no_of_entries(char *refparam, struct dmctx *c static int get_igmp_cgrp_adev_iface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *ifname = dmjson_get_value((json_object *)data, 1, "device"); - - return bbf_get_reference_param("Device.Ethernet.Interface.", "Name", ifname, value); + adm_entry_get_reference_param(ctx, "Device.Ethernet.Interface.*.Name", ifname, value); + return 0; } static int get_igmp_cgrp_adev_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) @@ -1323,7 +1324,8 @@ static int get_igmp_cgrp_adev_host(char *refparam, struct dmctx *ctx, void *data char *ipaddr = dmjson_get_value((json_object *)data, 1, "ipaddr"); char *linker = get_host_linker(ipaddr); - return bbf_get_reference_param("Device.Hosts.Host.", "PhysAddress", linker, value); + adm_entry_get_reference_param(ctx, "Device.Hosts.Host.*.PhysAddress", linker, value); + return 0; } static int get_igmp_cgrp_adev_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) @@ -1789,10 +1791,10 @@ static int get_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *da dmuci_get_value_by_section_string(interface_s, "proto", &proto); if (proto && proto[0] != '\0') { // It is a L3 bridge, get the linker accordingly - bbf_get_reference_param("Device.IP.Interface.", "Name", sec_name, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", sec_name, value); } else { // It is a L2 bridge, get the linker accordingly - bbf_get_reference_param("Device.Bridging.Bridge.*.Port.", "Name", igmpp_ifname, value); + adm_entry_get_reference_param(ctx, "Device.Bridging.Bridge.*.Port.*.Name", igmpp_ifname, value); } break; } @@ -1800,7 +1802,7 @@ static int get_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *da // in case its a L3 interface, the ifname would be section name of network file in the dmmap file, // which infact is the linker, just use that directly. - bbf_get_reference_param("Device.IP.Interface.", "Name", igmpp_ifname, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", igmpp_ifname, value); } end: diff --git a/libbbfdm/dmtree/vendor/iopsys/tr181/x_iopsys_eu_mld.c b/libbbfdm/dmtree/vendor/iopsys/tr181/x_iopsys_eu_mld.c index a37a96539f661f766f06a48c49b7f101cbb3acd5..b6dba18f0dcf4aa2fe98289d6e39c127d065c2ab 100644 --- a/libbbfdm/dmtree/vendor/iopsys/tr181/x_iopsys_eu_mld.c +++ b/libbbfdm/dmtree/vendor/iopsys/tr181/x_iopsys_eu_mld.c @@ -541,10 +541,10 @@ static int get_mldp_interface_iface(char *refparam, struct dmctx *ctx, void *dat dmuci_get_value_by_section_string(intf_s, "proto", &proto); if (proto && proto[0] != '\0') { // It is a L3 bridge, get the linker accordingly - bbf_get_reference_param("Device.IP.Interface.", "Name", sec_name, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", sec_name, value); } else { // It is a L2 bridge, get the linker accordingly - bbf_get_reference_param("Device.Bridging.Bridge.*.Port.", "Name", mldp_ifname, value); + adm_entry_get_reference_param(ctx, "Device.Bridging.Bridge.*.Port.*.Name", mldp_ifname, value); } break; } @@ -560,7 +560,7 @@ static int get_mldp_interface_iface(char *refparam, struct dmctx *ctx, void *dat } } - bbf_get_reference_param("Device.IP.Interface.", "Name", tmp_linker, value); + adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", tmp_linker, value); } end: