From 52173292db0a3d6c8fa823671cd2ec07647a96db Mon Sep 17 00:00:00 2001 From: Amin Ben Romdhane Date: Fri, 2 Jun 2023 15:57:00 +0200 Subject: [PATCH] Fix LowerLayer value of IP.Interface. and Ethernet.Link. --- libbbfdm/dmtree/tr181/ethernet.c | 5 +---- libbbfdm/dmtree/tr181/ip.c | 10 ++++++++-- libbbfdm/dmtree/tr181/ppp.c | 16 +++++++++++++--- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/libbbfdm/dmtree/tr181/ethernet.c b/libbbfdm/dmtree/tr181/ethernet.c index 79ed25fe..82bafb5d 100644 --- a/libbbfdm/dmtree/tr181/ethernet.c +++ b/libbbfdm/dmtree/tr181/ethernet.c @@ -132,7 +132,7 @@ static void dmmap_synchronizeEthernetLink(struct dmctx *dmctx, DMNODE *parent_no // Skip this interface section if its device starts with prfix 'link_' dmuci_get_value_by_section_string(s, "device", &device); - if (DM_STRNCMP(device, "link_", 5) == 0) + if (DM_STRNCMP(device, "link_", 5) == 0 || DM_STRNCMP(device, "iface", 5) == 0) continue; // Skip this interface section if its device is empty @@ -140,10 +140,7 @@ static void dmmap_synchronizeEthernetLink(struct dmctx *dmctx, DMNODE *parent_no if (DM_STRLEN(device) == 0) continue; - // Skip this interface section if its device name isn't a real device get_net_device_sysfs(device, "address", &macaddr); - if (DM_STRLEN(macaddr) == 0) - continue; DM_STRNCPY(dev_name, device, sizeof(dev_name)); diff --git a/libbbfdm/dmtree/tr181/ip.c b/libbbfdm/dmtree/tr181/ip.c index cfc07f9c..28c1d4c6 100644 --- a/libbbfdm/dmtree/tr181/ip.c +++ b/libbbfdm/dmtree/tr181/ip.c @@ -1298,8 +1298,11 @@ static int get_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void * if ((*value)[0] == '\0') { char *device = get_device(section_name((struct uci_section *)data)); - if (DM_STRLEN(device) == 0) - return 0; + if (DM_STRLEN(device) == 0) { + dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device); + if (DM_STRLEN(device) == 0) + return 0; + } adm_entry_get_linker_param(ctx, "Device.PPP.Interface.", device, value); if (*value != NULL && (*value)[0] != 0) @@ -1428,6 +1431,9 @@ static int set_IPInterface_Router(char *refparam, struct dmctx *ctx, void *data, if (!rt_table || *rt_table == 0) return FAULT_9007; + get_dmmap_section_of_config_section("dmmap_network", "interface", section_name((struct uci_section *)data), &s); + dmuci_set_value_by_section(s, "Router", value); + dmuci_set_value_by_section((struct uci_section *)data, "ip4table", rt_table); dmuci_set_value_by_section((struct uci_section *)data, "ip6table", rt_table); diff --git a/libbbfdm/dmtree/tr181/ppp.c b/libbbfdm/dmtree/tr181/ppp.c index 10729722..f51e9c98 100644 --- a/libbbfdm/dmtree/tr181/ppp.c +++ b/libbbfdm/dmtree/tr181/ppp.c @@ -996,10 +996,13 @@ static int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch if ((*value)[0] == '\0') { char *device = NULL; - if (ppp->iface_s) + if (ppp->iface_s) { device = get_device(section_name(ppp->iface_s)); - else + if (DM_STRLEN(device) == 0) + dmuci_get_value_by_section_string(ppp->iface_s, "device", &device); + } else { dmuci_get_value_by_section_string(ppp->dmmap_s, "device", &device); + } if (DM_STRLEN(device) == 0) return 0; @@ -1165,7 +1168,14 @@ static int set_PPPInterfacePPPoE_ServiceName(char *refparam, struct dmctx *ctx, ***************************************************************************/ static int get_linker_ppp_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) { - dmuci_get_value_by_section_string(((struct ppp_args *)data)->dmmap_s, "device", linker); + if (((struct ppp_args *)data)->iface_s) { + *linker = get_device(section_name(((struct ppp_args *)data)->iface_s)); + if (DM_STRLEN(*linker) == 0) + dmuci_get_value_by_section_string(((struct ppp_args *)data)->iface_s, "device", linker); + } else { + dmuci_get_value_by_section_string(((struct ppp_args *)data)->dmmap_s, "device", linker); + } + return 0; }