mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-02-21 11:52:42 +01:00
Ticket refs#2585: TR-181: Device.InterfaceStack. object
This commit is contained in:
parent
6acb70c71c
commit
85b5f603b5
3 changed files with 400 additions and 260 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2019 iopsys Software Solutions AB
|
||||
* Copyright (C) 2020 iopsys Software Solutions AB
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 2.1
|
||||
|
|
@ -24,21 +24,22 @@ struct interfacestack_data {
|
|||
static char *get_instance_by_section(int mode, char *dmmap_config, char *section, struct uci_section *s, char *instance_option, char *alias_option)
|
||||
{
|
||||
struct uci_section *dmmap_section;
|
||||
char *instance;
|
||||
char *instance = "";
|
||||
|
||||
get_dmmap_section_of_config_section(dmmap_config, section, section_name(s), &dmmap_section);
|
||||
if (mode == INSTANCE_MODE_NUMBER) {
|
||||
|
||||
if (mode == INSTANCE_MODE_NUMBER)
|
||||
dmuci_get_value_by_section_string(dmmap_section, instance_option, &instance);
|
||||
} else {
|
||||
else
|
||||
dmuci_get_value_by_section_string(dmmap_section, alias_option, &instance);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
static char *get_alias_by_section(char *dmmap_config, char *section, struct uci_section *s, char *alias_option)
|
||||
{
|
||||
struct uci_section *dmmap_section;
|
||||
char *alias;
|
||||
char *alias = "";
|
||||
|
||||
get_dmmap_section_of_config_section(dmmap_config, section, section_name(s), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(dmmap_section, alias_option, &alias);
|
||||
|
|
@ -63,35 +64,38 @@ static struct uci_section *create_dmmap_interface_stack_section(char *curr_inst)
|
|||
|
||||
int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct interfacestack_data ifdata = {0};
|
||||
struct uci_section *s = NULL, *port = NULL, *port_s = NULL, *ss = NULL, *dmmap_s = NULL;
|
||||
char *proto, *type, *pch, *layer_inst, *vb, *higheralias, *ifname, *br_inst, *mg, *value, *device, *name, *bridge_port_inst;
|
||||
char *loweralias = "", *v = "";
|
||||
char *interface_stack_int = NULL, *interface_stack_int_last = NULL, *wanifname, *mac;
|
||||
struct interfacestack_data intf_stack_data = {0};
|
||||
struct uci_section *s = NULL, *dmmap_s = NULL;
|
||||
char *layer_inst = "", *loweralias = "", *higheralias = "";
|
||||
char *intf_stack_inst = NULL, *intf_stack_last = NULL;
|
||||
char buf_lowerlayer[128] = {0};
|
||||
char buf_higherlayer[128] = {0};
|
||||
char buf_higheralias[64] = {0};
|
||||
char buf_loweralias[64] = {0};
|
||||
char buf_instance[32] = {0};
|
||||
char linker[512] = {0};
|
||||
char buf_tmp[64] = {0};
|
||||
int instance = 0, found = 0;
|
||||
char buf_instance[16] = {0};
|
||||
int instance = 0;
|
||||
|
||||
/* Higher layers are Device.IP.Interface.{i}. */
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
char *proto;
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if (strcmp(section_name(s), "loopback") == 0 || *proto == '\0')
|
||||
continue;
|
||||
|
||||
// The higher layer is Device.IP.Interface.{i}.
|
||||
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "interface", s, "ip_int_instance", "ip_int_alias");
|
||||
if (*layer_inst == '\0')
|
||||
continue;
|
||||
snprintf(buf_higherlayer, sizeof(buf_higherlayer), "Device.IP.Interface.%s.", layer_inst);
|
||||
|
||||
higheralias = get_alias_by_section("dmmap_network", "interface", s, "ip_int_alias");
|
||||
if (*higheralias == '\0')
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "cpe-%s", layer_inst);
|
||||
else
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s", higheralias);
|
||||
|
||||
if (strstr(proto, "ppp")) {
|
||||
// The lower layer is Device.PPP.Interface.{i}.
|
||||
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "interface", s, "ppp_int_instance", "ppp_int_alias");
|
||||
if (*layer_inst == '\0')
|
||||
continue;
|
||||
|
|
@ -99,252 +103,302 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
loweralias = get_alias_by_section("dmmap_network", "interface", s, "ppp_int_alias");
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s", loweralias);
|
||||
} else {
|
||||
device = get_device(section_name(s));
|
||||
// The lower layer is Device.Ethernet.VLANTermination.{i}.
|
||||
char *value = NULL;
|
||||
int found = 0;
|
||||
char *device = get_device(section_name(s));
|
||||
if (device[0] != '\0') {
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cVLANTermination%c", dmroot, dm_delim, dm_delim, dm_delim), device, &v);
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cVLANTermination%c", dmroot, dm_delim, dm_delim, dm_delim), device, &value);
|
||||
loweralias = get_alias_by_section("dmmap_network", "device", s, "vlan_term_alias");
|
||||
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "device", s, "vlan_term_instance", "vlan_term_alias");
|
||||
if (v != NULL)
|
||||
if (value != NULL)
|
||||
found = 1;
|
||||
}
|
||||
mac = get_macaddr(section_name(s));
|
||||
if (mac[0] != '\0' && found == 0) {
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), mac, &v);
|
||||
|
||||
if (device[0] != '\0' && found == 0) {
|
||||
// The lower layer is Device.Ethernet.Link.{i}.
|
||||
char linker[32] = {0};
|
||||
strncpy(linker, device, sizeof(linker) - 1);
|
||||
char *vid = strchr(linker, '.');
|
||||
if (vid) *vid = '\0';
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &value);
|
||||
loweralias = get_alias_by_section("dmmap", "link", s, "link_alias");
|
||||
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap", "link", s, "link_instance", "link_alias");
|
||||
if (v == NULL)
|
||||
v = "";
|
||||
if (value == NULL)
|
||||
value = "";
|
||||
}
|
||||
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", v);
|
||||
|
||||
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value);
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "cpe-%s", layer_inst);
|
||||
else
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s", loweralias);
|
||||
}
|
||||
ifdata.higherlayer = buf_higherlayer;
|
||||
ifdata.lowerlayer = buf_lowerlayer;
|
||||
ifdata.higheralias = buf_higheralias;
|
||||
ifdata.loweralias = buf_loweralias;
|
||||
|
||||
// fill interface stack data
|
||||
intf_stack_data.higherlayer = buf_higherlayer;
|
||||
intf_stack_data.lowerlayer = buf_lowerlayer;
|
||||
intf_stack_data.higheralias = buf_higheralias;
|
||||
intf_stack_data.loweralias = buf_loweralias;
|
||||
|
||||
// create dmmap section
|
||||
snprintf(buf_instance, sizeof(buf_instance), "%d", ++instance);
|
||||
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
|
||||
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
|
||||
|
||||
// link instance to interface stack data
|
||||
intf_stack_inst = handle_update_instance(1, dmctx, &intf_stack_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&intf_stack_data, intf_stack_inst) == DM_STOP)
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Higher layers are Device.PPP.Interface.{i}. */
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
char *proto;
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if (!strstr(proto, "ppp"))
|
||||
continue;
|
||||
|
||||
// The higher layer is Device.PPP.Interface.{i}.
|
||||
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "interface", s, "ppp_int_instance", "ppp_int_alias");
|
||||
if (*layer_inst == '\0')
|
||||
continue;
|
||||
snprintf(buf_higherlayer, sizeof(buf_higherlayer), "Device.PPP.Interface.%s.", layer_inst);
|
||||
|
||||
higheralias = get_alias_by_section("dmmap_network", "interface", s, "ppp_int_alias");
|
||||
if (*higheralias == '\0')
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "cpe-%s", layer_inst);
|
||||
else
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s", higheralias);
|
||||
found = 0;
|
||||
device = get_device(section_name(s));
|
||||
|
||||
char *value = NULL;
|
||||
int found = 0;
|
||||
// The lower layer is Device.Ethernet.VLANTermination.{i}.
|
||||
char *device = get_device(section_name(s));
|
||||
if (device[0] != '\0') {
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cVLANTermination%c", dmroot, dm_delim, dm_delim, dm_delim), device, &v);
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cVLANTermination%c", dmroot, dm_delim, dm_delim, dm_delim), device, &value);
|
||||
loweralias = get_alias_by_section("dmmap_network", "device", s, "vlan_term_alias");
|
||||
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "device", s, "vlan_term_instance", "vlan_term_alias");
|
||||
if (v != NULL)
|
||||
if (value != NULL)
|
||||
found = 1;
|
||||
}
|
||||
mac = get_macaddr(section_name(s));
|
||||
if (mac[0] != '\0' && found == 0) {
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), mac, &v);
|
||||
|
||||
if (device[0] != '\0' && found == 0) {
|
||||
// The lower layer is Device.Ethernet.Link.{i}.
|
||||
char linker[32] = {0};
|
||||
strncpy(linker, device, sizeof(linker) - 1);
|
||||
char *vid = strchr(linker, '.');
|
||||
if (vid) *vid = '\0';
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &value);
|
||||
loweralias = get_alias_by_section("dmmap", "link", s, "link_alias");
|
||||
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap", "link", s, "link_instance", "link_alias");
|
||||
if (v == NULL)
|
||||
v = "";
|
||||
if (value == NULL)
|
||||
value = "";
|
||||
}
|
||||
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", v);
|
||||
|
||||
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value);
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "cpe-%s", layer_inst);
|
||||
else
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s", loweralias);
|
||||
ifdata.higherlayer = buf_higherlayer;
|
||||
ifdata.lowerlayer = buf_lowerlayer;
|
||||
ifdata.higheralias = buf_higheralias;
|
||||
ifdata.loweralias = buf_loweralias;
|
||||
|
||||
// fill interface stack data
|
||||
intf_stack_data.higherlayer = buf_higherlayer;
|
||||
intf_stack_data.lowerlayer = buf_lowerlayer;
|
||||
intf_stack_data.higheralias = buf_higheralias;
|
||||
intf_stack_data.loweralias = buf_loweralias;
|
||||
|
||||
// create dmmap section
|
||||
snprintf(buf_instance, sizeof(buf_instance), "%d", ++instance);
|
||||
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
|
||||
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
|
||||
|
||||
// link instance to interface stack data
|
||||
intf_stack_inst = handle_update_instance(1, dmctx, &intf_stack_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&intf_stack_data, intf_stack_inst) == DM_STOP)
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Higher layers are Device.Ethernet.VLANTermination.{i}. */
|
||||
uci_foreach_sections("network", "device", s) {
|
||||
char *type, *name, *value = NULL;
|
||||
dmuci_get_value_by_section_string(s, "type", &type);
|
||||
dmuci_get_value_by_section_string(s, "name", &name);
|
||||
if (strcmp(type, "untagged") == 0 || !is_vlan_termination_section(name))
|
||||
if (strcmp(type, "untagged") == 0 || (*name != '\0' && !is_vlan_termination_section(name)))
|
||||
continue;
|
||||
|
||||
// The higher layer is Device.Ethernet.VLANTermination.{i}.
|
||||
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "device", s, "vlan_term_instance", "vlan_term_alias");
|
||||
if (*layer_inst == '\0')
|
||||
continue;
|
||||
|
||||
snprintf(buf_higherlayer, sizeof(buf_higherlayer), "Device.Ethernet.VLANTermination.%s.", layer_inst);
|
||||
|
||||
higheralias = get_alias_by_section("dmmap_network", "device", s, "vlan_term_alias");
|
||||
if (*higheralias == '\0')
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "cpe-%s", layer_inst);
|
||||
else
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s", higheralias);
|
||||
char *macaddr = get_macaddr_from_device(name);
|
||||
if (macaddr[0] != '\0') {
|
||||
if (is_mac_exist(macaddr)) {
|
||||
pch = macaddr;
|
||||
} else {
|
||||
char intf_tag[64] = {0};
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifname);
|
||||
snprintf(intf_tag, sizeof(intf_tag), "%s.1", ifname);
|
||||
pch = get_macaddr_from_device(intf_tag);
|
||||
}
|
||||
}
|
||||
if (pch[0] != '\0') {
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), pch, &v);
|
||||
if (v == NULL)
|
||||
v = "";
|
||||
}
|
||||
uci_foreach_sections("network", "interface", ss) {
|
||||
mac = get_macaddr(section_name(ss));
|
||||
if (strcmp(pch, mac) == 0) {
|
||||
loweralias = get_alias_by_section("dmmap", "link", ss, "link_alias");
|
||||
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap", "link", ss, "link_instance", "link_alias");
|
||||
break;
|
||||
}
|
||||
}
|
||||
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", v);
|
||||
|
||||
// The lower layer is Device.Ethernet.Link.{i}.
|
||||
char *vid = strchr(name, '.');
|
||||
if (vid) *vid = '\0';
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), name, &value);
|
||||
if (value == NULL)
|
||||
value = "";
|
||||
|
||||
struct uci_section *link_s = NULL;
|
||||
get_dmmap_section_of_config_section_eq("dmmap", "link", "device", name, &link_s);
|
||||
dmuci_get_value_by_section_string(link_s, "link_instance", &layer_inst);
|
||||
dmuci_get_value_by_section_string(link_s, "link_alias", &loweralias);
|
||||
|
||||
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value);
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "cpe-%s", layer_inst);
|
||||
else
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s", loweralias);
|
||||
ifdata.higherlayer = buf_higherlayer;
|
||||
ifdata.lowerlayer = buf_lowerlayer;
|
||||
ifdata.higheralias = buf_higheralias;
|
||||
ifdata.loweralias = buf_loweralias;
|
||||
|
||||
// fill interface stack data
|
||||
intf_stack_data.higherlayer = buf_higherlayer;
|
||||
intf_stack_data.lowerlayer = buf_lowerlayer;
|
||||
intf_stack_data.higheralias = buf_higheralias;
|
||||
intf_stack_data.loweralias = buf_loweralias;
|
||||
|
||||
// create dmmap section
|
||||
snprintf(buf_instance, sizeof(buf_instance), "%d", ++instance);
|
||||
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
|
||||
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
|
||||
|
||||
// link instance to interface stack data
|
||||
intf_stack_inst = handle_update_instance(1, dmctx, &intf_stack_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&intf_stack_data, intf_stack_inst) == DM_STOP)
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Higher layers are Device.Ethernet.Link.{i}. */
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
dmuci_get_value_by_section_string(s, "type", &type);
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if (strcmp(section_name(s), "loopback") == 0 || *proto == '\0')
|
||||
continue;
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifname);
|
||||
if (*ifname == '\0' || *ifname == '@')
|
||||
continue;
|
||||
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap", "link", s, "link_instance", "link_alias");
|
||||
uci_path_foreach_sections(bbfdm, DMMAP, "link", s) {
|
||||
|
||||
// The higher layer is Device.Ethernet.Link.{i}.
|
||||
dmuci_get_value_by_section_string(s, "link_instance", &layer_inst);
|
||||
if (*layer_inst == '\0')
|
||||
continue;
|
||||
|
||||
snprintf(buf_higherlayer, sizeof(buf_higherlayer), "Device.Ethernet.Link.%s.", layer_inst);
|
||||
higheralias = get_alias_by_section("dmmap", "link", s, "link_alias");
|
||||
|
||||
dmuci_get_value_by_section_string(s, "link_alias", &higheralias);
|
||||
if (*higheralias == '\0')
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "cpe-%s", layer_inst);
|
||||
else
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s", higheralias);
|
||||
if (strcmp(type, "bridge") == 0) {
|
||||
br_inst = get_alias_by_section("dmmap_network", "interface", s, "bridge_instance");
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", br_inst, port) {
|
||||
dmuci_get_value_by_section_string(port, "management", &mg);
|
||||
if (strcmp(mg, "1") == 0) {
|
||||
dmuci_get_value_by_section_string(port, "device", &device);
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+%s", br_inst, section_name(port), device);
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &v);
|
||||
dmuci_get_value_by_section_string(port, "bridge_port_alias", &loweralias);
|
||||
dmuci_get_value_by_section_string(port, "bridge_port_instance", &layer_inst);
|
||||
break;
|
||||
|
||||
|
||||
char *linker, *value = NULL;
|
||||
dmuci_get_value_by_section_string(s, "device", &linker);
|
||||
char *bridge = strstr(linker, "br-");
|
||||
if (bridge) {
|
||||
// The lower layer is Device.Bridging.Bridge.{i}.Port.{i}.
|
||||
char *int_name;
|
||||
dmuci_get_value_by_section_string(s, "section_name", &int_name);
|
||||
struct uci_section *dmmap_section, *port;
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", int_name, &dmmap_section);
|
||||
if (dmmap_section != NULL) {
|
||||
char *br_inst, *mg;
|
||||
dmuci_get_value_by_section_string(dmmap_section, "bridge_instance", &br_inst);
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", br_inst, port) {
|
||||
dmuci_get_value_by_section_string(port, "management", &mg);
|
||||
if (strcmp(mg, "1") == 0) {
|
||||
char *device, linker[512] = "";
|
||||
dmuci_get_value_by_section_string(port, "device", &device);
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+%s", br_inst, section_name(port), device);
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
uci_foreach_option_eq("ports", "ethport", "name", "WAN", port_s) {
|
||||
dmuci_get_value_by_section_string(port_s, "ifname", &wanifname);
|
||||
if(strstr(ifname, wanifname)) {
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), wanifname, &v);
|
||||
loweralias = get_alias_by_section("dmmap_ports", "ethport", port_s, "eth_port_alias");
|
||||
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_ports", "ethport", port_s, "eth_port_instance", "eth_port_alias");
|
||||
break;
|
||||
}
|
||||
}
|
||||
// The lower layer is Device.Ethernet.Interface.{i}.
|
||||
char *vid = strchr(linker, '.');
|
||||
if (vid) *vid = '\0';
|
||||
char *macvlan = strchr(linker, '_');
|
||||
if (macvlan) *macvlan = '\0';
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &value);
|
||||
}
|
||||
if (v == NULL)
|
||||
v = "";
|
||||
|
||||
if (value == NULL)
|
||||
value = "";
|
||||
|
||||
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value);
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "cpe-%s", layer_inst);
|
||||
else
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s", loweralias);
|
||||
ifdata.higherlayer = buf_higherlayer;
|
||||
ifdata.lowerlayer = v;
|
||||
ifdata.higheralias = buf_higheralias;
|
||||
ifdata.loweralias = buf_loweralias;
|
||||
|
||||
// fill interface stack data
|
||||
intf_stack_data.higherlayer = buf_higherlayer;
|
||||
intf_stack_data.lowerlayer = buf_lowerlayer;
|
||||
intf_stack_data.higheralias = buf_higheralias;
|
||||
intf_stack_data.loweralias = buf_loweralias;
|
||||
|
||||
// create dmmap section
|
||||
snprintf(buf_instance, sizeof(buf_instance), "%d", ++instance);
|
||||
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
|
||||
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
|
||||
|
||||
// link instance to interface stack data
|
||||
intf_stack_inst = handle_update_instance(1, dmctx, &intf_stack_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&intf_stack_data, intf_stack_inst) == DM_STOP)
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Higher layers are Device.Bridging.Bridge.{i}.Port.{i}.*/
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
char *type;
|
||||
dmuci_get_value_by_section_string(s, "type", &type);
|
||||
if (strcmp(type, "bridge") != 0)
|
||||
continue;
|
||||
br_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "interface", s, "bridge_instance", "bridge_alias");
|
||||
|
||||
char *br_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "interface", s, "bridge_instance", "bridge_alias");
|
||||
if (*br_inst == '\0')
|
||||
continue;
|
||||
|
||||
// The higher layer is Device.Bridging.Bridge.{i}.Port.{i}.
|
||||
char *bridge_port_inst, *mg_value = NULL,*value = NULL;
|
||||
char buf_mngr[64] = {0};
|
||||
struct uci_section *port = NULL;
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", br_inst, port) {
|
||||
char *mg;
|
||||
dmuci_get_value_by_section_string(port, "management", &mg);
|
||||
if (strcmp(mg, "1") == 0) {
|
||||
char *device, linker[512] = {0};
|
||||
dmuci_get_value_by_section_string(port, "device", &device);
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+%s", br_inst, section_name(port), device);
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &pch);
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &mg_value);
|
||||
dmuci_get_value_by_section_string(port, "bridge_port_alias", &higheralias);
|
||||
dmuci_get_value_by_section_string(port, "bridge_port_instance", &bridge_port_inst);
|
||||
if (*higheralias == '\0')
|
||||
snprintf(buf_tmp, sizeof(buf_tmp), "cpe-%s", bridge_port_inst);
|
||||
snprintf(buf_mngr, sizeof(buf_mngr), "cpe-%s", bridge_port_inst);
|
||||
else
|
||||
snprintf(buf_tmp, sizeof(buf_tmp), "%s", higheralias);
|
||||
if (pch == NULL)
|
||||
pch = "";
|
||||
snprintf(buf_mngr, sizeof(buf_mngr), "%s", higheralias);
|
||||
|
||||
if (mg_value == NULL)
|
||||
mg_value = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
struct uci_section *sd = NULL;
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", br_inst, sd) {
|
||||
char *mg;
|
||||
dmuci_get_value_by_section_string(sd, "management", &mg);
|
||||
if (strcmp(mg, "1") == 0)
|
||||
continue;
|
||||
|
||||
char *sectionname, *package, *section;
|
||||
dmuci_get_value_by_section_string(sd, "section_name", §ionname);
|
||||
dmuci_get_value_by_section_string(sd, "package", &package);
|
||||
dmuci_get_value_by_section_string(sd, "section", §ion);
|
||||
char *vb = NULL, *device, linker[512] = {0};
|
||||
dmuci_get_value_by_section_string(sd, "device", &device);
|
||||
|
||||
uci_foreach_sections(package, section, port_s) {
|
||||
if(strcmp(section_name(port_s), sectionname) == 0) {
|
||||
dmuci_get_value_by_section_string(port_s, "ifname", &ifname);
|
||||
dmuci_get_value_by_section_string(port_s, "name", &name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(strcmp(package, "network") == 0 && strcmp(section, "device") == 0)
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+%s", br_inst, sectionname, name);
|
||||
else
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+%s", br_inst, sectionname, ifname);
|
||||
// The lower layer is Device.Bridging.Bridge.{i}.Port.{i}.
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+%s", br_inst, section_name(sd), device);
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &vb);
|
||||
|
||||
if (vb == NULL)
|
||||
vb = "";
|
||||
|
||||
dmuci_get_value_by_section_string(sd, "bridge_port_alias", &loweralias);
|
||||
bridge_port_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_bridge_port", "bridge_port", sd, "bridge_port_instance", "bridge_port_alias");
|
||||
if (*loweralias == '\0')
|
||||
|
|
@ -352,80 +406,150 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
else
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s", loweralias);
|
||||
|
||||
ifdata.higherlayer = pch;
|
||||
ifdata.lowerlayer = vb;
|
||||
ifdata.higheralias = buf_tmp;
|
||||
ifdata.loweralias = buf_loweralias;
|
||||
// fill interface stack data
|
||||
intf_stack_data.higherlayer = mg_value;
|
||||
intf_stack_data.lowerlayer = vb;
|
||||
intf_stack_data.higheralias = buf_mngr;
|
||||
intf_stack_data.loweralias = buf_loweralias;
|
||||
|
||||
// create dmmap section
|
||||
snprintf(buf_instance, sizeof(buf_instance), "%d", ++instance);
|
||||
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
|
||||
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
|
||||
|
||||
// link instance to interface stack data
|
||||
intf_stack_inst = handle_update_instance(1, dmctx, &intf_stack_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&intf_stack_data, intf_stack_inst) == DM_STOP)
|
||||
goto end;
|
||||
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "cpe-%s", bridge_port_inst);
|
||||
else
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s", loweralias);
|
||||
if(strcmp(package, "ports") == 0) {
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), ifname, &v);
|
||||
loweralias = get_alias_by_section("dmmap_ports", "ethport", port_s, "eth_port_alias");
|
||||
bridge_port_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_ports", "ethport", port_s, "eth_port_instance", "eth_port_alias");
|
||||
} else if(strcmp(package, "wireless") == 0) {
|
||||
adm_entry_get_linker_param(dmctx,dm_print_path("%s%cWiFi%cSSID%c", dmroot, dm_delim, dm_delim, dm_delim), ifname, &v);
|
||||
loweralias = get_alias_by_section("dmmap_wireless", "wifi-iface", port_s, "ssidalias");
|
||||
bridge_port_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_wireless", "wifi-iface", port_s, "ssidinstance", "ssidalias");
|
||||
} else if(strcmp(package, "network") == 0) {
|
||||
if(strstr(ifname, "atm")) {
|
||||
adm_entry_get_linker_param(dmctx,dm_print_path("%s%cATM%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), ifname, &v);
|
||||
uci_foreach_sections("dsl", "atm-device", ss) {
|
||||
if(strcmp(section_name(ss), ifname) == 0) {
|
||||
loweralias = get_alias_by_section("dmmap_dsl", "atm-device", ss, "atmlinkalias");
|
||||
bridge_port_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_dsl", "atm-device", port_s, "atmlinkinstance", "atmlinkalias");
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if(strstr(ifname, "ptm")) {
|
||||
adm_entry_get_linker_param(dmctx,dm_print_path("%s%cPTM%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), ifname, &v);
|
||||
uci_foreach_sections("dsl", "ptm-device", ss) {
|
||||
if(strcmp(section_name(ss), ifname) == 0) {
|
||||
loweralias = get_alias_by_section("dmmap_dsl", "ptm-device", ss, "ptmlinkalias");
|
||||
bridge_port_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_dsl", "ptm-device", port_s, "ptmlinkinstance", "ptmlinkalias");
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
snprintf(linker, sizeof(linker), "%s", ifname);
|
||||
adm_entry_get_linker_param(dmctx,dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), linker, &v);
|
||||
|
||||
char package[32] = {0};
|
||||
int found = 0;
|
||||
// The lower layer is Device.Ethernet.Interface.{i}.
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), device, &value);
|
||||
|
||||
if (value != NULL) {
|
||||
strncpy(package, "ports", sizeof(package) - 1);
|
||||
struct uci_section *port_s = NULL;
|
||||
uci_foreach_option_eq("ports", "ethport", "ifname", device, port_s) {
|
||||
loweralias = get_alias_by_section("dmmap_ports", "ethport", port_s, "eth_port_alias");
|
||||
bridge_port_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_ports", "ethport", port_s, "eth_port_instance", "eth_port_alias");
|
||||
break;
|
||||
}
|
||||
found = 1;
|
||||
}
|
||||
|
||||
// The lower layer is Device.WiFi.SSID.{i}.
|
||||
if (!found && value == NULL)
|
||||
adm_entry_get_linker_param(dmctx,dm_print_path("%s%cWiFi%cSSID%c", dmroot, dm_delim, dm_delim, dm_delim), device, &value);
|
||||
|
||||
if (!found && value != NULL) {
|
||||
strncpy(package, "wireless", sizeof(package) - 1);
|
||||
struct uci_section *wl_s = NULL;
|
||||
uci_foreach_option_eq("wireless", "wifi-iface", "ifname", device, wl_s) {
|
||||
loweralias = get_alias_by_section("dmmap_wireless", "wifi-iface", wl_s, "ssidalias");
|
||||
bridge_port_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_wireless", "wifi-iface", wl_s, "ssidinstance", "ssidalias");
|
||||
break;
|
||||
}
|
||||
found = 1;
|
||||
}
|
||||
|
||||
// The lower layer is Device.ATM.Link.{i}.
|
||||
if (!found && value == NULL) {
|
||||
char *tag = strchr(device, '.');
|
||||
if (tag) *tag = '\0';
|
||||
adm_entry_get_linker_param(dmctx,dm_print_path("%s%cATM%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), device, &value);
|
||||
}
|
||||
|
||||
if (!found && value != NULL) {
|
||||
strncpy(package, "dsl:atm", sizeof(package) - 1);
|
||||
struct uci_section *dsl_s = NULL;
|
||||
uci_foreach_option_eq("dsl", "atm-device", "device", device, dsl_s) {
|
||||
loweralias = get_alias_by_section("dmmap_dsl", "atm-device", dsl_s, "atmlinkalias");
|
||||
bridge_port_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_dsl", "atm-device", dsl_s, "atmlinkinstance", "atmlinkalias");
|
||||
break;
|
||||
}
|
||||
found = 1;
|
||||
}
|
||||
|
||||
// The lower layer is Device.PTM.Link.{i}.
|
||||
if (!found && value == NULL) {
|
||||
char *tag = strchr(device, '.');
|
||||
if (tag) *tag = '\0';
|
||||
adm_entry_get_linker_param(dmctx,dm_print_path("%s%cPTM%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), device, &value);
|
||||
}
|
||||
|
||||
if (!found && value != NULL) {
|
||||
strncpy(package, "dsl:ptm", sizeof(package) - 1);
|
||||
struct uci_section *dsl_s = NULL;
|
||||
uci_foreach_option_eq("dsl", "ptm-device", "device", device, dsl_s) {
|
||||
loweralias = get_alias_by_section("dmmap_dsl", "ptm-device", dsl_s, "ptmlinkalias");
|
||||
bridge_port_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_dsl", "ptm-device", dsl_s, "ptmlinkinstance", "ptmlinkalias");
|
||||
break;
|
||||
}
|
||||
found = 1;
|
||||
}
|
||||
|
||||
// The lower layer is Device.Ethernet.Interface.{i}.
|
||||
if (!found && value == NULL) {
|
||||
char *tag = strchr(device, '.');
|
||||
if (tag) *tag = '\0';
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), device, &value);
|
||||
}
|
||||
|
||||
if (!found && value != NULL) {
|
||||
strncpy(package, "ports", sizeof(package) - 1);
|
||||
struct uci_section *port_s = NULL;
|
||||
uci_foreach_option_eq("ports", "ethport", "ifname", device, port_s) {
|
||||
loweralias = get_alias_by_section("dmmap_ports", "ethport", port_s, "eth_port_alias");
|
||||
bridge_port_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_ports", "ethport", port_s, "eth_port_instance", "eth_port_alias");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "cpe-%s", bridge_port_inst);
|
||||
else
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s", loweralias);
|
||||
if (v == NULL)
|
||||
v = "";
|
||||
ifdata.higherlayer = vb;
|
||||
ifdata.lowerlayer = v;
|
||||
ifdata.higheralias = buf_higheralias;
|
||||
ifdata.loweralias = buf_loweralias;
|
||||
|
||||
if (value == NULL)
|
||||
value = "";
|
||||
|
||||
// fill interface stack data
|
||||
intf_stack_data.higherlayer = vb;
|
||||
intf_stack_data.lowerlayer = value;
|
||||
intf_stack_data.higheralias = buf_higheralias;
|
||||
intf_stack_data.loweralias = buf_loweralias;
|
||||
|
||||
// create dmmap section
|
||||
snprintf(buf_instance, sizeof(buf_instance), "%d", ++instance);
|
||||
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
|
||||
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
|
||||
|
||||
// link instance to interface stack data
|
||||
intf_stack_inst = handle_update_instance(1, dmctx, &intf_stack_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&intf_stack_data, intf_stack_inst) == DM_STOP)
|
||||
goto end;
|
||||
|
||||
// The lower layer is Device.WiFi.Radio.{i}.
|
||||
if(strcmp(package, "wireless") == 0) {
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "cpe-%s", bridge_port_inst);
|
||||
else
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s", loweralias);
|
||||
uci_foreach_option_eq("wireless", "wifi-iface", "ifname", ifname, ss) {
|
||||
dmuci_get_value_by_section_string(ss, "device", &device);
|
||||
|
||||
struct uci_section *wl_s = NULL;
|
||||
char *wl_device;
|
||||
uci_foreach_option_eq("wireless", "wifi-iface", "ifname", device, wl_s) {
|
||||
dmuci_get_value_by_section_string(wl_s, "device", &wl_device);
|
||||
break;
|
||||
}
|
||||
if (device[0] != '\0') {
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cWiFi%cRadio%c", dmroot, dm_delim, dm_delim, dm_delim), device, &vb);
|
||||
|
||||
if (wl_device[0] != '\0') {
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cWiFi%cRadio%c", dmroot, dm_delim, dm_delim, dm_delim), wl_device, &vb);
|
||||
struct uci_section *ss = NULL;
|
||||
uci_foreach_sections("wireless", "wifi-device", ss) {
|
||||
if(strcmp(section_name(ss), device) == 0) {
|
||||
loweralias = get_alias_by_section("dmmap_wireless", "wifi-device", ss, "radioalias");
|
||||
|
|
@ -434,77 +558,108 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vb == NULL)
|
||||
vb = "";
|
||||
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "cpe-%s", bridge_port_inst);
|
||||
else
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s", loweralias);
|
||||
ifdata.higherlayer = v;
|
||||
ifdata.lowerlayer = vb;
|
||||
ifdata.higheralias = buf_higheralias;
|
||||
ifdata.loweralias = buf_loweralias;
|
||||
|
||||
// fill interface stack data
|
||||
intf_stack_data.higherlayer = value;
|
||||
intf_stack_data.lowerlayer = vb;
|
||||
intf_stack_data.higheralias = buf_higheralias;
|
||||
intf_stack_data.loweralias = buf_loweralias;
|
||||
|
||||
// create dmmap section
|
||||
snprintf(buf_instance, sizeof(buf_instance), "%d", ++instance);
|
||||
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
|
||||
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
|
||||
|
||||
// link instance to interface stack data
|
||||
intf_stack_inst = handle_update_instance(1, dmctx, &intf_stack_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&intf_stack_data, intf_stack_inst) == DM_STOP)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if(strcmp(package, "network") == 0) {
|
||||
if(strstr(ifname, "atm") || strstr(ifname, "ptm")) {
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "cpe-%s", bridge_port_inst);
|
||||
else
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s", loweralias);
|
||||
char *link_channel = "channel_0";
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cDSL%cChannel%c", dmroot, dm_delim, dm_delim, dm_delim), link_channel, &vb);
|
||||
if (vb == NULL)
|
||||
vb = "";
|
||||
uci_path_foreach_sections(bbfdm, "dmmap", "dsl_channel", ss) {
|
||||
dmuci_get_value_by_section_string(ss, "dsl_channel_alias", &loweralias);
|
||||
bridge_port_inst = get_instance_by_section(dmctx->instance_mode, "dmmap", "dsl_channel", ss, "dsl_channel_instance", "dsl_channel_alias");
|
||||
}
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "cpe-%s", bridge_port_inst);
|
||||
else
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s", loweralias);
|
||||
ifdata.higherlayer = v;
|
||||
ifdata.lowerlayer = vb;
|
||||
ifdata.higheralias = buf_higheralias;
|
||||
ifdata.loweralias = buf_loweralias;
|
||||
snprintf(buf_instance, sizeof(buf_instance), "%d", ++instance);
|
||||
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
|
||||
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
|
||||
goto end;
|
||||
// The lower layer is Device.DSL.Channel.{i}.
|
||||
if(strcmp(package, "dsl:atm") == 0) {
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "cpe-%s", bridge_port_inst);
|
||||
else
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s", loweralias);
|
||||
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "cpe-%s", bridge_port_inst);
|
||||
else
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s", loweralias);
|
||||
char *link_line = "line_0";
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cDSL%cLine%c", dmroot, dm_delim, dm_delim, dm_delim), link_line, &value);
|
||||
if (value == NULL)
|
||||
value = "";
|
||||
uci_path_foreach_sections(bbfdm, "dmmap", "dsl_line", ss) {
|
||||
dmuci_get_value_by_section_string(ss, "dsl_line_alias", &loweralias);
|
||||
bridge_port_inst = get_instance_by_section(dmctx->instance_mode, "dmmap", "dsl_line", ss, "dsl_line_instance", "dsl_line_alias");
|
||||
}
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "cpe-%s", bridge_port_inst);
|
||||
else
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s", loweralias);
|
||||
ifdata.higherlayer = vb;
|
||||
ifdata.lowerlayer = value;
|
||||
ifdata.higheralias = buf_higheralias;
|
||||
ifdata.loweralias = buf_loweralias;
|
||||
snprintf(buf_instance, sizeof(buf_instance), "%d", ++instance);
|
||||
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
|
||||
interface_stack_int = handle_update_instance(1, dmctx, &interface_stack_int_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&ifdata, interface_stack_int) == DM_STOP)
|
||||
goto end;
|
||||
char *link_channel = "channel_0";
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cDSL%cChannel%c", dmroot, dm_delim, dm_delim, dm_delim), link_channel, &vb);
|
||||
if (vb == NULL)
|
||||
vb = "";
|
||||
|
||||
struct uci_section *dsl_s = NULL;
|
||||
uci_path_foreach_sections(bbfdm, "dmmap", "dsl_channel", dsl_s) {
|
||||
dmuci_get_value_by_section_string(dsl_s, "dsl_channel_alias", &loweralias);
|
||||
bridge_port_inst = get_instance_by_section(dmctx->instance_mode, "dmmap", "dsl_channel", dsl_s, "dsl_channel_instance", "dsl_channel_alias");
|
||||
}
|
||||
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "cpe-%s", bridge_port_inst);
|
||||
else
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s", loweralias);
|
||||
|
||||
// fill interface stack data
|
||||
intf_stack_data.higherlayer = value;
|
||||
intf_stack_data.lowerlayer = vb;
|
||||
intf_stack_data.higheralias = buf_higheralias;
|
||||
intf_stack_data.loweralias = buf_loweralias;
|
||||
|
||||
// create dmmap section
|
||||
snprintf(buf_instance, sizeof(buf_instance), "%d", ++instance);
|
||||
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
|
||||
|
||||
// link instance to interface stack data
|
||||
intf_stack_inst = handle_update_instance(1, dmctx, &intf_stack_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&intf_stack_data, intf_stack_inst) == DM_STOP)
|
||||
goto end;
|
||||
|
||||
}
|
||||
|
||||
// The lower layer is Device.DSL.Line.{i}.
|
||||
if(strcmp(package, "dsl:ptm") == 0) {
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "cpe-%s", bridge_port_inst);
|
||||
else
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s", loweralias);
|
||||
|
||||
char *link_line = "line_0";
|
||||
adm_entry_get_linker_param(dmctx, dm_print_path("%s%cDSL%cLine%c", dmroot, dm_delim, dm_delim, dm_delim), link_line, &value);
|
||||
if (value == NULL)
|
||||
value = "";
|
||||
|
||||
struct uci_section *dsl_s = NULL;
|
||||
uci_path_foreach_sections(bbfdm, "dmmap", "dsl_line", dsl_s) {
|
||||
dmuci_get_value_by_section_string(dsl_s, "dsl_line_alias", &loweralias);
|
||||
bridge_port_inst = get_instance_by_section(dmctx->instance_mode, "dmmap", "dsl_line", dsl_s, "dsl_line_instance", "dsl_line_alias");
|
||||
}
|
||||
|
||||
if (*loweralias == '\0')
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "cpe-%s", bridge_port_inst);
|
||||
else
|
||||
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s", loweralias);
|
||||
|
||||
// fill interface stack data
|
||||
intf_stack_data.higherlayer = vb;
|
||||
intf_stack_data.lowerlayer = value;
|
||||
intf_stack_data.higheralias = buf_higheralias;
|
||||
intf_stack_data.loweralias = buf_loweralias;
|
||||
|
||||
// create dmmap section
|
||||
snprintf(buf_instance, sizeof(buf_instance), "%d", ++instance);
|
||||
dmmap_s = create_dmmap_interface_stack_section(buf_instance);
|
||||
|
||||
// link instance to interface stack data
|
||||
intf_stack_inst = handle_update_instance(1, dmctx, &intf_stack_last, update_instance_alias, 3, dmmap_s, "interface_stack_instance", "interface_stack_alias");
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&intf_stack_data, intf_stack_inst) == DM_STOP)
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -549,9 +704,8 @@ static int set_InterfaceStack_Alias(char *refparam, struct dmctx *ctx, void *dat
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_interface_stack", "interface_stack", "interface_stack_instance", instance, s) {
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_interface_stack", "interface_stack", "interface_stack_instance", instance, s)
|
||||
dmuci_set_value_by_section(s, "interface_stack_alias", value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1510,19 +1510,6 @@ int dm_time_format(time_t ts, char **dst)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int is_mac_exist(char *macaddr)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
char *mac;
|
||||
|
||||
uci_path_foreach_sections(bbfdm, DMMAP, "link", s) {
|
||||
dmuci_get_value_by_section_string(s, "mac", &mac);
|
||||
if (strcmp(mac, macaddr) == 0)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool match(const char *string, const char *pattern)
|
||||
{
|
||||
regex_t re;
|
||||
|
|
|
|||
|
|
@ -306,7 +306,6 @@ int get_net_iface_sysfs(const char *uci_iface, const char *name, char **value);
|
|||
int get_net_device_sysfs(const char *uci_iface, const char *name, char **value);
|
||||
char *get_device_from_wifi_iface(const char *wifi_iface, const char *wifi_section);
|
||||
int dm_time_format(time_t ts, char **dst);
|
||||
int is_mac_exist(char *macaddr);
|
||||
bool match(const char *string, const char *pattern);
|
||||
int dm_validate_string(char *value, int min_length, int max_length, char *enumeration[], int enumeration_size, char *pattern[], int pattern_size);
|
||||
int dm_validate_boolean(char *value);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue