mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
bbf : Updated some functions and resolved vlan deployment issues.
- Fixed issue in Ethernet Link deletion. - Fixed deletion of untagged interfaces section from UCI. - Fixed in setting lower layers for Ethernet link in case of untagged management interface. - Fixed issue of adding same ports with different vlan id under different bridge.
This commit is contained in:
parent
e3788f3400
commit
dc554fa385
4 changed files with 488 additions and 233 deletions
|
|
@ -115,7 +115,7 @@ static int check_ifname_exist_in_br_ifname_list(char *ifname, char *section)
|
|||
return 0;
|
||||
|
||||
for (pch = strtok_r(br_ifname_list, " ", &spch); pch != NULL; pch = strtok_r(NULL, " ", &spch)) {
|
||||
/* Fix : Check to support tagged and untagged interfaces. */
|
||||
/* Check to support tagged and untagged interfaces. */
|
||||
if (strncmp(ifname, pch, 4) == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -329,7 +329,7 @@ static int get_br_vlan_number_of_entries(char *refparam, struct dmctx *ctx, void
|
|||
struct uci_section *s = NULL;
|
||||
int cnt = 0;
|
||||
|
||||
/* Fix: Interface section needs to be browsed to get the vlan entries. */
|
||||
/* Interface section needs to be browsed to get the vlan entries. */
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_network", "interface", "bridge_key", instance, s) {
|
||||
cnt++;
|
||||
}
|
||||
|
|
@ -805,7 +805,7 @@ static int set_br_vlan_name(char *refparam, struct dmctx *ctx, void *data, char
|
|||
|
||||
static int get_br_vlan_vid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
/* Fix : Fetch the vlan id from the ifname option of "network", "interface" section. */
|
||||
/* Fetch the vlan id from the ifname option of "network", "interface" section. */
|
||||
char *ifname;
|
||||
dmuci_get_value_by_section_string(((struct bridging_vlan_args *)data)->bridge_vlan_sec, "ifname", &ifname);
|
||||
char tag[20] = {0};
|
||||
|
|
@ -830,7 +830,7 @@ static int get_br_vlan_vid(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
static int set_br_vlan_vid(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *name, *ifname;
|
||||
struct uci_section *sec;
|
||||
struct uci_section *sec = NULL, *prev_s = NULL;
|
||||
struct bridging_vlan_args *vlan_args = (struct bridging_vlan_args *)data;
|
||||
|
||||
switch (action) {
|
||||
|
|
@ -839,13 +839,13 @@ static int set_br_vlan_vid(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
/* Fix : Set the value of vid in Bridging.Bridge.x.VLAN object. */
|
||||
/* Set the value of vid in Bridging.Bridge.x.VLAN object. */
|
||||
dmuci_get_value_by_section_string(vlan_args->bridge_sec, "ifname", &ifname);
|
||||
char intf_name[250] = {0};
|
||||
if (*ifname == '\0') {
|
||||
/* Get the name of all ports from port UCI file. */
|
||||
struct uci_section *port_s = NULL;
|
||||
uci_foreach_option_eq("ports", "ethport", "speed", "auto", port_s) {
|
||||
uci_foreach_option_eq("ports", "ethport", "enabled", "1", port_s) {
|
||||
char *intf;
|
||||
dmuci_get_value_by_section_string(port_s, "ifname", &intf);
|
||||
if (*intf != '\0') {
|
||||
|
|
@ -881,10 +881,11 @@ static int set_br_vlan_vid(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
strncpy(vlan_id, tag, sizeof(vlan_id) - 1);
|
||||
if (strncmp(vlan_id, "1", sizeof(vlan_id)) == 0) {
|
||||
uci_foreach_option_eq("network", "device", "name", token, sec) {
|
||||
dmuci_delete_by_section(sec, "name", token);
|
||||
dmuci_delete_by_section(sec, "type", "untagged");
|
||||
dmuci_delete_by_section(sec, "ifname", tok);
|
||||
prev_s = sec;
|
||||
break;
|
||||
}
|
||||
if (prev_s) dmuci_delete_by_section(prev_s, NULL, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
dmasprintf(&name, "%s.%s", intf, vid);
|
||||
|
|
@ -1014,7 +1015,7 @@ static int get_br_vlan_alias(char *refparam, struct dmctx *ctx, void *data, char
|
|||
{
|
||||
struct uci_section *dmmap_section = NULL;
|
||||
|
||||
/* Fix: Interface section needs to be browsed to get the value for vlan alias. */
|
||||
/* Interface section needs to be browsed to get the value for vlan alias. */
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct bridging_vlan_args *)data)->bridge_vlan_sec), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(dmmap_section, "bridge_vlan_alias", value);
|
||||
return 0;
|
||||
|
|
@ -1055,7 +1056,7 @@ static int add_bridge(char *refparam, struct dmctx *ctx, void *data, char **inst
|
|||
dmstrappendend(p);
|
||||
dmuci_set_value("network", bridge_name, "", "interface");
|
||||
dmuci_set_value("network", bridge_name, "type", "bridge");
|
||||
/* Fix : Bridge should be created without specifying the proto.*/
|
||||
/* Bridge should be created without specifying the proto.*/
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_network", "interface", &dmmap_bridge, &v);
|
||||
dmuci_set_value_by_section(dmmap_bridge, "section_name", bridge_name);
|
||||
|
|
@ -1128,7 +1129,7 @@ static int add_br_vlanport(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
{
|
||||
char *v, *name;
|
||||
|
||||
/* Fix: To add Bridge.VLANPort object from the management methods. */
|
||||
/* To add Bridge.VLANPort object from the management methods. */
|
||||
struct bridging_args *br_args = (struct bridging_args *)data;
|
||||
char *br_ifname_list, *br_ifname_dup, *pch, *spch;
|
||||
|
||||
|
|
@ -1221,10 +1222,10 @@ static int remove_ifname_from_uci(char *ifname, void *data, char *nontag_name)
|
|||
|
||||
static int delete_br_vlanport(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
||||
{
|
||||
/* Fix: To delete Bridge.VLANPort object from the management methods. */
|
||||
/* To delete Bridge.VLANPort object from the management methods. */
|
||||
struct bridging_args *br_args = (struct bridging_args *)data;
|
||||
char *br_ifname_list = NULL, *br_ifname_dup = NULL, *pch = NULL, *spch = NULL;
|
||||
struct uci_section *sec, *s, *vport_sec;
|
||||
struct uci_section *sec = NULL, *s = NULL, *vport_sec = NULL, *prev_s = NULL;
|
||||
char new_ifname[250] = {0};
|
||||
int inst_found = 0;
|
||||
char *name;
|
||||
|
|
@ -1262,10 +1263,10 @@ static int delete_br_vlanport(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
if (strncmp(vid, "1", sizeof(vid)) == 0) {
|
||||
/* Remove the config device section. */
|
||||
uci_foreach_option_eq("network", "device", "name", ifname, sec) {
|
||||
dmuci_delete_by_section(sec, "name", ifname);
|
||||
dmuci_delete_by_section(sec, "type", "untagged");
|
||||
dmuci_delete_by_section(sec, "ifname", tok);
|
||||
prev_s = sec;
|
||||
break;
|
||||
}
|
||||
if (prev_s) dmuci_delete_by_section(prev_s, NULL, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1332,10 +1333,10 @@ static int delete_br_vlanport(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
|
||||
if(strncmp(if_tag, "1", sizeof(if_tag)) == 0) {
|
||||
uci_foreach_option_eq("network", "device", "name", pch, sec) {
|
||||
dmuci_delete_by_section(sec, "name", pch);
|
||||
dmuci_delete_by_section(sec, "type", "untagged");
|
||||
dmuci_delete_by_section(sec, "ifname", name);
|
||||
prev_s = sec;
|
||||
break;
|
||||
}
|
||||
if (prev_s) dmuci_delete_by_section(prev_s, NULL, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1359,7 +1360,7 @@ static int delete_br_vlanport(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
|
||||
static int add_br_vlan(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
/* Fix: To add Bridge.VLAN object from the management methods. */
|
||||
/* To add Bridge.VLAN object from the management methods. */
|
||||
char *v, *name;
|
||||
struct uci_section *sec = NULL, *dmmap_bridge_vlan = NULL;
|
||||
|
||||
|
|
@ -1379,7 +1380,7 @@ static int add_br_vlan(char *refparam, struct dmctx *ctx, void *data, char **ins
|
|||
|
||||
static int delete_br_vlan(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
||||
{
|
||||
/* Fix: To delete Bridge.VLAN object from the management methods. */
|
||||
/* To delete Bridge.VLAN object from the management methods. */
|
||||
char *type;
|
||||
struct uci_section *prev_s = NULL, *vlan_s = NULL, *dmmap_section = NULL;
|
||||
int is_enabled;
|
||||
|
|
@ -1428,12 +1429,12 @@ static int delete_br_vlan(char *refparam, struct dmctx *ctx, void *data, char *i
|
|||
strncpy(vid, end2, sizeof(vid) - 1);
|
||||
if (strncmp(vid, "1", sizeof(vid)) == 0) {
|
||||
/* Remove the config device section. */
|
||||
struct uci_section *sec = NULL;
|
||||
struct uci_section *sec = NULL, *prev_s = NULL;
|
||||
uci_foreach_option_eq("network", "device", "name", intf, sec) {
|
||||
dmuci_delete_by_section(sec, "name", intf);
|
||||
dmuci_delete_by_section(sec, "type", "untagged");
|
||||
dmuci_delete_by_section(sec, "ifname", tag);
|
||||
prev_s = sec;
|
||||
break;
|
||||
}
|
||||
if (prev_s) dmuci_delete_by_section(prev_s, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Remove the vlanport instance from the dmmap_network file. */
|
||||
|
|
@ -1559,7 +1560,7 @@ static int check_port_with_ifname (char *ifname, struct uci_section **ss, int *i
|
|||
}
|
||||
}
|
||||
} else if (strncmp(ifname, wan_baseifname, strlen(ifname)) == 0) {
|
||||
/* Fix: For wan, no entry will be found in "network", "device".
|
||||
/* For wan, no entry will be found in "network", "device".
|
||||
* Entry for untagged interfaces would be there. */
|
||||
uci_foreach_option_eq("ports", "ethport", "ifname", ifname, s) {
|
||||
*ss = s;
|
||||
|
|
@ -1571,7 +1572,7 @@ static int check_port_with_ifname (char *ifname, struct uci_section **ss, int *i
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
/* Fix : Add support for untagged interfaces(vlan id =1) in lower layer. */
|
||||
/* Add support for untagged interfaces(vlan id =1) in lower layer. */
|
||||
char intf[50] = {0};
|
||||
strncpy(intf, ifname, sizeof(intf) - 1);
|
||||
char *p = strstr(intf, ".");
|
||||
|
|
@ -1587,7 +1588,7 @@ static int check_port_with_ifname (char *ifname, struct uci_section **ss, int *i
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
/* Fix : Add support for tagged interfaces in lower layer. */
|
||||
/* Add support for tagged interfaces in lower layer. */
|
||||
uci_foreach_option_eq("ports", "ethport", "ifname", token, s) {
|
||||
*is_tag = 1;
|
||||
*ss = s;
|
||||
|
|
@ -1617,7 +1618,7 @@ static int get_port_lower_layer(char *refparam, struct dmctx *ctx, void *data, c
|
|||
ifname_dup = dmstrdup(ifname);
|
||||
p = lbuf;
|
||||
for (pch = strtok_r(ifname_dup, " ", &spch); pch != NULL; pch = strtok_r(NULL, " ", &spch)) {
|
||||
/* Fix: Added support for tagged and untagged interfaces. */
|
||||
/* Added support for tagged and untagged interfaces. */
|
||||
int is_tag = 0;
|
||||
check_port_with_ifname(pch, &s, &is_tag);
|
||||
if(s == NULL)
|
||||
|
|
@ -1660,15 +1661,46 @@ static int get_port_lower_layer(char *refparam, struct dmctx *ctx, void *data, c
|
|||
|
||||
static void set_bridge_port_parameters(struct uci_section *dmmap_section, char* bridge_key)
|
||||
{
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_section, "bridge_key", bridge_key);
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_section, "mg_port", "false");
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_section, "penable", "1");
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_section, "is_dmmap", "false");
|
||||
char *br_key;
|
||||
char *name;
|
||||
dmuci_get_value_by_section_string(dmmap_section, "bridge_key", &br_key);
|
||||
dmuci_get_value_by_section_string(dmmap_section, "section_name", &name);
|
||||
if (*br_key != '\0') {
|
||||
/* Check if the bridge_key of the dmmap_section same as the bridge_key. */
|
||||
if (strcmp(br_key, bridge_key) == 0) {
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_section, "bridge_key", bridge_key);
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_section, "mg_port", "false");
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_section, "penable", "1");
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_section, "is_dmmap", "false");
|
||||
} else {
|
||||
/* Find out the dmmap_section with the specified bridge_key and add
|
||||
* the values to it. */
|
||||
struct uci_section *br_s;
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "bridge_key", bridge_key, br_s) {
|
||||
/* Fetch the section name. */
|
||||
char *sec_name;
|
||||
dmuci_get_value_by_section_string(br_s, "section_name", &sec_name);
|
||||
if (strcmp(sec_name, name) == 0) {
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, br_s, "bridge_key", bridge_key);
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, br_s, "mg_port", "false");
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, br_s, "penable", "1");
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, br_s, "is_dmmap", "false");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* If the bridge key is not found in the dmmap section, then set the
|
||||
* attributes under the section. */
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_section, "bridge_key", bridge_key);
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_section, "mg_port", "false");
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_section, "penable", "1");
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_section, "is_dmmap", "false");
|
||||
}
|
||||
}
|
||||
|
||||
static int set_port_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
/* Fix : Set lower layer value from management methods. */
|
||||
/* Set lower layer value from management methods. */
|
||||
char *linker_intf, *br_key;
|
||||
char *newvalue = NULL;
|
||||
|
||||
|
|
@ -1692,18 +1724,13 @@ static int set_port_lower_layer(char *refparam, struct dmctx *ctx, void *data, c
|
|||
strncpy(intf, linker_intf, sizeof(intf) - 1);
|
||||
|
||||
/* Get the upstream interface. */
|
||||
struct uci_section *port_s = NULL;
|
||||
char intf_tag[50] = {0};
|
||||
uci_foreach_option_eq("ports", "ethport", "uplink", "1", port_s) {
|
||||
char *iface;
|
||||
dmuci_get_value_by_section_string(port_s, "ifname", &iface);
|
||||
if (*iface != '\0') {
|
||||
strncpy(intf_tag, iface, sizeof(intf_tag) - 1);
|
||||
}
|
||||
}
|
||||
/* Get the upstream interface. */
|
||||
get_upstream_interface(intf_tag, sizeof(intf_tag));
|
||||
|
||||
/* Create untagged upstream interface. */
|
||||
strcat(intf_tag, ".1");
|
||||
if (intf_tag[0] != '\0')
|
||||
strcat(intf_tag, ".1");
|
||||
|
||||
if (strncmp(intf, intf_tag, sizeof(intf)) == 0) {
|
||||
char *tok = strtok(intf, ".");
|
||||
|
|
@ -1780,7 +1807,7 @@ static int get_vlan_port_port_ref(char *refparam, struct dmctx *ctx, void *data,
|
|||
if (ifname[0] != '\0') {
|
||||
for (pch = strtok_r(ifname, " ", &spch); pch != NULL; pch = strtok_r(NULL, " ", &spch)) {
|
||||
if (cnt == atoi(instance)) {
|
||||
/* Fix: Added support for tagged and untagged interfaces. */
|
||||
/* Added support for tagged and untagged interfaces. */
|
||||
int is_tag = 0;
|
||||
check_port_with_ifname(pch, &s, &is_tag);
|
||||
if (s == NULL)
|
||||
|
|
@ -1892,12 +1919,12 @@ static int set_vlan_port_port_ref(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
if (strncmp(vid, "1", sizeof(vid)) == 0) {
|
||||
/* remove device section. */
|
||||
struct uci_section *sec = NULL;
|
||||
struct uci_section *sec = NULL, *prev_s = NULL;
|
||||
uci_foreach_option_eq("network", "device", "name", tok, sec) {
|
||||
dmuci_delete_by_section(sec, "name", tok);
|
||||
dmuci_delete_by_section(sec, "type", "untagged");
|
||||
dmuci_delete_by_section(sec, "ifname", if_tag);
|
||||
prev_s = sec;
|
||||
break;
|
||||
}
|
||||
if (prev_s) dmuci_delete_by_section(prev_s, NULL, NULL);
|
||||
}
|
||||
}
|
||||
if (new_ifname[0] != '\0') {
|
||||
|
|
@ -2010,7 +2037,7 @@ static int browseBridgePortInst(struct dmctx *dmctx, DMNODE *parent_node, void *
|
|||
found = false;
|
||||
|
||||
if (!found) {
|
||||
/* Fix : Add support for untagged interfaces.*/
|
||||
/* Add support for untagged interfaces.*/
|
||||
char val[50] = {0};
|
||||
strncpy(val, pch, sizeof(val) - 1);
|
||||
char *p = strstr(val, ".");
|
||||
|
|
@ -2023,13 +2050,13 @@ static int browseBridgePortInst(struct dmctx *dmctx, DMNODE *parent_node, void *
|
|||
if (strncmp(tag, "1", sizeof(tag)) == 0) {
|
||||
found = synchronize_multi_config_sections_with_dmmap_eq("network", "device", "dmmap_bridge_port", "bridge_port", "name", pch, pch, &dup_list);
|
||||
} else {
|
||||
/* Fix : Add support for tagged interfaces(eth0.100, eth1.200 etc).*/
|
||||
/* Add support for tagged interfaces(eth0.100, eth1.200 etc).*/
|
||||
found = synchronize_multi_config_sections_with_dmmap_eq("ports", "ethport", "dmmap_bridge_port", "bridge_port", "ifname", tok, pch, &dup_list);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Add support for interfaces eth0, eth1, eth2.....etc.*/
|
||||
found = synchronize_multi_config_sections_with_dmmap_eq("ports", "ethport", "dmmap_bridge_port", "bridge_port", "ifname", pch, pch, &dup_list);
|
||||
found = synchronize_multi_config_sections_with_dmmap_port("ports", "ethport", "dmmap_bridge_port", "bridge_port", "ifname", pch, pch, &dup_list, ((struct bridging_args *)prev_data)->br_key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2097,7 +2124,7 @@ static int browseBridgeVlanInst(struct dmctx *dmctx, DMNODE *parent_node, void *
|
|||
LIST_HEAD(dup_list);
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap_vlan("network", "interface", "dmmap_network", br_args->ifname, &dup_list, &count, &id);
|
||||
/* Fix : TO add bridge object and lower layer through management method. */
|
||||
/* To add bridge object and lower layer through management method. */
|
||||
if (count != 0) {
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
if (!p->config_section)
|
||||
|
|
|
|||
|
|
@ -312,6 +312,61 @@ static int addObjEthernetLink(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int del_ethernet_link_instance(char *sect_name)
|
||||
{
|
||||
char intf_tag[50] = {0};
|
||||
struct uci_section *s = NULL, *intf_s = NULL, *prev_s = NULL, *dev_s = NULL;
|
||||
int ret = 0;
|
||||
|
||||
/* Get the upstream interface. */
|
||||
get_upstream_interface(intf_tag, sizeof(intf_tag));
|
||||
|
||||
/* Create untagged upstream interface. */
|
||||
if (intf_tag[0] != '\0')
|
||||
strcat(intf_tag, ".1");
|
||||
|
||||
/* Get section from section_name.*/
|
||||
uci_foreach_sections("network", "interface", intf_s) {
|
||||
if (strcmp(section_name(intf_s), sect_name) == 0) {
|
||||
|
||||
char *intf;
|
||||
dmuci_get_value_by_section_string(intf_s, "ifname", &intf);
|
||||
|
||||
/* If ifname is same as of WAN port then delete the interface
|
||||
* section and the device section.*/
|
||||
if (strncmp(intf_tag, intf, sizeof(intf_tag)) == 0) {
|
||||
prev_s = intf_s;
|
||||
ret = 1;
|
||||
break;
|
||||
} else {
|
||||
char *proto;
|
||||
dmuci_get_value_by_section_string(intf_s, "proto", &proto);
|
||||
dmuci_delete_by_section(intf_s, "proto", proto);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == 1) {
|
||||
/* Remove the section from UCI. */
|
||||
if (prev_s) dmuci_delete_by_section(prev_s, NULL, NULL);
|
||||
|
||||
/* Remove the device section from the UCI. */
|
||||
uci_foreach_option_eq("network", "device", "name", intf_tag, s) {
|
||||
dev_s = s;
|
||||
break;
|
||||
}
|
||||
if (dev_s) dmuci_delete_by_section(dev_s, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Remove the Link section from dmmap. */
|
||||
struct uci_section *dmmap_section;
|
||||
get_dmmap_section_of_config_section("dmmap", "link", sect_name, &dmmap_section);
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int delObjEthernetLink(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
||||
{
|
||||
char *sect_name = NULL;
|
||||
|
|
@ -325,20 +380,7 @@ static int delObjEthernetLink(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
if(!s) {
|
||||
dmuci_delete_by_section(((struct dm_args *)data)->section, NULL, NULL);
|
||||
} else {
|
||||
/* Get section from section_name.*/
|
||||
struct uci_section *intf_s = NULL;
|
||||
uci_foreach_sections("network", "interface", intf_s) {
|
||||
if (strcmp(section_name(intf_s), sect_name) == 0) {
|
||||
char *proto;
|
||||
dmuci_get_value_by_section_string(intf_s, "proto", &proto);
|
||||
dmuci_delete_by_section(intf_s, "proto", proto);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Remove the Link section from dmmap. */
|
||||
struct uci_section *dmmap_section;
|
||||
get_dmmap_section_of_config_section("dmmap", "link", sect_name, &dmmap_section);
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
del_ethernet_link_instance(sect_name);
|
||||
}
|
||||
return 0;
|
||||
case DEL_ALL:
|
||||
|
|
@ -350,8 +392,8 @@ static int delObjEthernetLink(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
|
||||
static int addObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *v, *eth_wan, *vid, *name, *vlan_name, *val;
|
||||
struct uci_section *dmmap_network= NULL, *s;
|
||||
char *inst, *eth_wan, *vid, *name, *vlan_name, *val, *v;
|
||||
struct uci_section *s = NULL, *dmmap_network = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_network");
|
||||
inst = get_vlan_last_instance_bbfdm("dmmap_network", "interface", "vlan_term_instance");
|
||||
|
|
@ -367,15 +409,9 @@ static int addObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
/* Get the upstream interface. */
|
||||
char *mac;
|
||||
struct uci_section *port_s = NULL;
|
||||
char intf_tag[50] = {0};
|
||||
uci_foreach_option_eq("ports", "ethport", "uplink", "1", port_s) {
|
||||
char *iface;
|
||||
dmuci_get_value_by_section_string(port_s, "ifname", &iface);
|
||||
if (*iface != '\0') {
|
||||
strncpy(intf_tag, iface, sizeof(intf_tag) - 1);
|
||||
}
|
||||
}
|
||||
/* Get the upstream interface. */
|
||||
get_upstream_interface(intf_tag, sizeof(intf_tag));
|
||||
|
||||
/* Fetch the macaddress of upstream interface. */
|
||||
if (intf_tag[0] != '\0') {
|
||||
|
|
@ -391,19 +427,11 @@ static int addObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
/* Create a mac address for the tagged upstream interfaces
|
||||
* using the base mac address. */
|
||||
char mac_addr[20] = {0};
|
||||
int num = 0;
|
||||
if (*mac != '\0') {
|
||||
strncpy(mac_addr, mac, sizeof(mac_addr) - 1);
|
||||
int len = strlen(mac_addr);
|
||||
char mac_addr[25] = {0};
|
||||
create_mac_addr_upstream_intf(mac_addr, mac, sizeof(mac_addr));
|
||||
|
||||
/* Fetch the last octect of base mac address in integer variable. */
|
||||
if (sscanf(&mac_addr[len - 2], "%02x", &num) > 0) {
|
||||
num += 1;
|
||||
sprintf(&mac_addr[len - 2], "%02x", num);
|
||||
dmuci_set_value_by_section(s, "macaddr", mac_addr);
|
||||
}
|
||||
}
|
||||
if (mac_addr[0] != '\0')
|
||||
dmuci_set_value_by_section(s, "macaddr", mac_addr);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_network", "interface", &dmmap_network, &v);
|
||||
dmuci_set_value_by_section(dmmap_network, "section_name", vlan_name);
|
||||
|
|
@ -876,17 +904,13 @@ static int get_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
|
|||
}
|
||||
} else {
|
||||
/* For upstream interface, set the lowerlayer to wan port of Ethernet.Interface */
|
||||
struct uci_section *port_s = NULL;
|
||||
char intf_tag[50] = {0};
|
||||
uci_foreach_option_eq("ports", "ethport", "uplink", "1", port_s) {
|
||||
char *iface;
|
||||
dmuci_get_value_by_section_string(port_s, "ifname", &iface);
|
||||
if (*iface != '\0') {
|
||||
strncpy(intf_tag, iface, sizeof(intf_tag) - 1);
|
||||
}
|
||||
}
|
||||
strcat(intf_tag, ".1");
|
||||
|
||||
/* Get the upstream interface. */
|
||||
get_upstream_interface(intf_tag, sizeof(intf_tag));
|
||||
|
||||
if (intf_tag[0] != '\0') {
|
||||
strcat(intf_tag, ".1");
|
||||
adm_entry_get_linker_param(ctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), intf_tag, value);
|
||||
if (*value == NULL)
|
||||
*value = "";
|
||||
|
|
@ -897,10 +921,233 @@ static int get_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int set_ethlink_lowerlayer_bridge(char *lower_layer, char *instance)
|
||||
{
|
||||
int len = 0, i = 0;
|
||||
char new_if[250] = {0}, key[10] = {0};
|
||||
struct uci_section *s = NULL, *intf_s = NULL;
|
||||
char *sec_name;
|
||||
char *p = strstr(lower_layer, "Port");
|
||||
if (p) {
|
||||
/* Get the bridge_key. */
|
||||
len = strlen(p);
|
||||
for (i = 0; i < strlen(lower_layer) - len; i++) {
|
||||
new_if[i] = lower_layer[i];
|
||||
}
|
||||
|
||||
char br_key = new_if[strlen(new_if) - 2];
|
||||
snprintf(key, sizeof(key), "%c", br_key);
|
||||
|
||||
/* Find out bridge section name using bridge key. */
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_network", "interface", "bridge_instance", key, s) {
|
||||
dmuci_get_value_by_section_string(s, "section_name", &sec_name);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check if section name is present in network UCI wd type as bridge
|
||||
* and ifname not empty, if yes then update
|
||||
* the section with proto 'dhcp' else do nothing. */
|
||||
uci_foreach_sections("network", "interface", intf_s) {
|
||||
char sec[20] = {0};
|
||||
strncpy(sec, section_name(intf_s), sizeof(sec) - 1);
|
||||
|
||||
if (strncmp(sec, sec_name, sizeof(sec)) == 0) {
|
||||
char *type, *ifname;
|
||||
dmuci_get_value_by_section_string(intf_s, "type", &type);
|
||||
if (*type == '\0' || strcmp(type, "bridge") != 0)
|
||||
return -1;
|
||||
|
||||
dmuci_get_value_by_section_string(intf_s, "ifname", &ifname);
|
||||
if (*ifname == '\0')
|
||||
return -1;
|
||||
|
||||
/* Add ethernet link params to dmmap link section. */
|
||||
uci_path_foreach_sections(bbfdm, DMMAP, "link", s) {
|
||||
char *inst;
|
||||
char link_inst[10] = {0};
|
||||
dmuci_get_value_by_section_string(s, "link_instance", &inst);
|
||||
strncpy(link_inst, instance, sizeof(link_inst) - 1);
|
||||
|
||||
/* Check if the link instance are same or not. */
|
||||
if (strncmp(link_inst, inst, sizeof(link_inst)) == 0) {
|
||||
dmuci_set_value_by_section(s, "section_name", section_name(intf_s));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the value of proto to the section. */
|
||||
dmuci_set_value_by_section(intf_s, "proto", "dhcp");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_set_linker_in_uci(char *intf, char *instance, char *mac_addr)
|
||||
{
|
||||
struct uci_section *s = NULL, *link_s = NULL, *mac_s = NULL, *prev_s = NULL;
|
||||
int mac_present = 0;
|
||||
uci_foreach_option_eq("network", "interface", "ifname", intf, s) {
|
||||
/* Fetch the mac address of the interface. */
|
||||
char *macaddr = get_macaddr(section_name(s));
|
||||
|
||||
/* Check if mac is present in dmmap link section. */
|
||||
uci_path_foreach_option_eq(bbfdm, DMMAP, "link", "mac", macaddr, mac_s) {
|
||||
/* Get the link instance of the section. */
|
||||
char *link;
|
||||
dmuci_get_value_by_section_string(mac_s, "link_instance", &link);
|
||||
|
||||
/* Check if the link instance are same or not. */
|
||||
if (strcmp(link, instance) != 0) {
|
||||
/* Delete the new link inst as mac already exists. */
|
||||
uci_path_foreach_option_eq(bbfdm, DMMAP, "link", "link_instance", instance, link_s) {
|
||||
prev_s = link_s;
|
||||
}
|
||||
if (prev_s) dmuci_delete_by_section(prev_s, NULL, NULL);
|
||||
}
|
||||
mac_present = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (mac_present == 1) {
|
||||
dmuci_set_value_by_section(s, "proto", "dhcp");
|
||||
return 1;
|
||||
} else {
|
||||
/* Add section name and mac in dmmap link section if
|
||||
* link instances are same. */
|
||||
uci_path_foreach_sections(bbfdm, DMMAP, "link", link_s) {
|
||||
char *inst;
|
||||
char link_inst[10] = {0};
|
||||
dmuci_get_value_by_section_string(link_s, "link_instance", &inst);
|
||||
strncpy(link_inst, instance, sizeof(link_inst) - 1);
|
||||
|
||||
/* Check if the link instance are same or not. */
|
||||
if (strncmp(link_inst, inst, sizeof(link_inst)) == 0) {
|
||||
dmuci_set_value_by_section(link_s, "section_name", section_name(s));
|
||||
dmuci_set_value_by_section(link_s, "mac", mac_addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
dmuci_set_value_by_section(s, "proto", "dhcp");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_lowerlayer_in_uci(char *mac_addr, char *instance, char *intf, char *linker)
|
||||
{
|
||||
int val_present = 0;
|
||||
char *val;
|
||||
struct uci_section *s = NULL, *link_s = NULL, *mac_s = NULL, *prev_s = NULL;
|
||||
|
||||
dmuci_add_section_and_rename("network", "interface", &s, &val);
|
||||
|
||||
/* Check if mac is present in dmmap link section. */
|
||||
uci_path_foreach_option_eq(bbfdm, DMMAP, "link", "mac", mac_addr, mac_s) {
|
||||
/* Get the link instance of the section. */
|
||||
char *link;
|
||||
dmuci_get_value_by_section_string(mac_s, "link_instance", &link);
|
||||
|
||||
/* Check if the link instance are same or not. */
|
||||
if (strcmp(link, instance) != 0) {
|
||||
/* Delete the new link inst as mac already exists. */
|
||||
uci_path_foreach_option_eq(bbfdm, DMMAP, "link", "link_instance", instance, link_s) {
|
||||
prev_s = link_s;
|
||||
}
|
||||
if (prev_s) dmuci_delete_by_section(prev_s, NULL, NULL);
|
||||
}
|
||||
val_present = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (val_present == 0) {
|
||||
/* Add ethernet link params to dmmap link section. */
|
||||
uci_path_foreach_sections(bbfdm, DMMAP, "link", link_s) {
|
||||
char *inst;
|
||||
char link_inst[10] = {0};
|
||||
dmuci_get_value_by_section_string(link_s, "link_instance", &inst);
|
||||
strncpy(link_inst, instance, sizeof(link_inst) - 1);
|
||||
|
||||
/* Check if the link instance are same or not. */
|
||||
if (strncmp(link_inst, inst, sizeof(link_inst)) == 0) {
|
||||
dmuci_set_value_by_section(link_s, "section_name", section_name(s));
|
||||
dmuci_set_value_by_section(link_s, "mac", mac_addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dmuci_set_value_by_section(s, "proto", "dhcp");
|
||||
dmuci_set_value_by_section(s, "ifname", intf);
|
||||
|
||||
/* Add config device section. */
|
||||
struct uci_section *dev_s;
|
||||
dmuci_add_section_and_rename("network", "device", &dev_s, &val);
|
||||
dmuci_set_value_by_section(dev_s, "type", "untagged");
|
||||
char *tok = strtok(linker, ".");
|
||||
dmuci_set_value_by_section(dev_s, "ifname", tok);
|
||||
dmuci_set_value_by_section(dev_s, "name", intf);
|
||||
dmuci_set_value_by_section(dev_s, "macaddr", mac_addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_ethlink_lowerlayer_eth_intf(char *lower_layer, char *instance, char *linker)
|
||||
{
|
||||
|
||||
/* Get the upstream interface. */
|
||||
char intf_tag[50] = {0};
|
||||
|
||||
/* Get the upstream interface. */
|
||||
get_upstream_interface(intf_tag, sizeof(intf_tag));
|
||||
|
||||
/* Fetch the macaddress of upstream interface. */
|
||||
char *mac;
|
||||
if (intf_tag[0] != '\0') {
|
||||
char file[128];
|
||||
char val[32];
|
||||
snprintf(file, sizeof(file), "/sys/class/net/%s/address", intf_tag);
|
||||
dm_read_sysfs_file(file, val, sizeof(val));
|
||||
mac = dmstrdup(val);
|
||||
} else {
|
||||
mac = "";
|
||||
}
|
||||
|
||||
/* Create a mac address for the tagged upstream interfaces
|
||||
* using the base mac address. */
|
||||
char mac_addr[25] = {0};
|
||||
create_mac_addr_upstream_intf(mac_addr, mac, sizeof(mac_addr));
|
||||
|
||||
/* Create untagged upstream interface. */
|
||||
if (intf_tag[0] != '\0')
|
||||
strcat(intf_tag, ".1");
|
||||
|
||||
char intf[20] = {0};
|
||||
if (strcmp(linker, intf_tag) == 0)
|
||||
strncpy(intf, linker, sizeof(intf) - 1);
|
||||
else {
|
||||
snprintf(intf, sizeof(intf), "%s.%s", linker, "1");
|
||||
if (strcmp(intf, intf_tag) != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Check if linker is present in network UCI, if yes the update
|
||||
* the proto, else create a interface and device section. */
|
||||
int ret = check_set_linker_in_uci(intf, instance, mac_addr);
|
||||
|
||||
/* Linker is not present in the UCI. */
|
||||
if (ret == 0) {
|
||||
set_lowerlayer_in_uci(mac_addr, instance, intf, linker);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char lower_layer[250] = {0};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_string_list(value, -1, -1, 1024, -1, -1, NULL, 0, NULL, 0))
|
||||
|
|
@ -914,148 +1161,19 @@ static int set_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
/* Check if the value is valid or not. */
|
||||
if (strncmp(lower_layer, "Device.Bridging.Bridge.", 23) == 0) {
|
||||
char *p = strstr(lower_layer, "Port");
|
||||
if (p) {
|
||||
/* Get the bridge_key. */
|
||||
int len = strlen(p);
|
||||
char new_if[250] = {0};
|
||||
int i;
|
||||
for (i = 0; i < strlen(lower_layer) - len; i++) {
|
||||
new_if[i] = lower_layer[i];
|
||||
}
|
||||
|
||||
char br_key = new_if[strlen(new_if) - 2];
|
||||
|
||||
char key[10] = {0};
|
||||
snprintf(key, sizeof(key), "%c", br_key);
|
||||
|
||||
/* Find out bridge section name using bridge key. */
|
||||
struct uci_section *s = NULL;
|
||||
char *sec_name;
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_network", "interface", "bridge_instance", key, s) {
|
||||
dmuci_get_value_by_section_string(s, "section_name", &sec_name);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check if section name is present in network UCI wd type as bridge
|
||||
* and ifname not empty, if yes then update
|
||||
* the section with proto 'dhcp' else do nothing. */
|
||||
struct uci_section *intf_s = NULL;
|
||||
uci_foreach_sections("network", "interface", intf_s) {
|
||||
struct uci_section *s = NULL;
|
||||
char sec[20] = {0};
|
||||
strncpy(sec, section_name(intf_s), sizeof(sec) - 1);
|
||||
if (strncmp(sec, sec_name, sizeof(sec)) == 0) {
|
||||
char *type, *ifname;
|
||||
dmuci_get_value_by_section_string(intf_s, "type", &type);
|
||||
if (*type == '\0' || strcmp(type, "bridge") != 0)
|
||||
return -1;
|
||||
|
||||
dmuci_get_value_by_section_string(intf_s, "ifname", &ifname);
|
||||
if (*ifname == '\0')
|
||||
return -1;
|
||||
|
||||
/* Add ethernet link params to dmmap link section. */
|
||||
uci_path_foreach_sections(bbfdm, DMMAP, "link", s) {
|
||||
char *inst;
|
||||
char link_inst[10] = {0};
|
||||
dmuci_get_value_by_section_string(s, "link_instance", &inst);
|
||||
strncpy(link_inst, instance, sizeof(link_inst) - 1);
|
||||
|
||||
/* Check if the link instance are same or not. */
|
||||
if (strncmp(link_inst, inst, sizeof(link_inst)) == 0) {
|
||||
dmuci_set_value_by_section(s, "section_name", section_name(intf_s));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the value of proto to the section. */
|
||||
dmuci_set_value_by_section(intf_s, "proto", "dhcp");
|
||||
}
|
||||
}
|
||||
}
|
||||
set_ethlink_lowerlayer_bridge(lower_layer, instance);
|
||||
} else if (strncmp(lower_layer, "Device.Ethernet.Interface.", 26) == 0) {
|
||||
/* Find the linker of the lowerlayer value to be set. */
|
||||
char *linker;
|
||||
adm_entry_get_linker_value(ctx, lower_layer, &linker);
|
||||
set_ethlink_lowerlayer_eth_intf(lower_layer, instance, linker);
|
||||
|
||||
/* Get the upstream interface. */
|
||||
struct uci_section *port_s = NULL;
|
||||
char intf_tag[50] = {0};
|
||||
uci_foreach_option_eq("ports", "ethport", "uplink", "1", port_s) {
|
||||
char *iface;
|
||||
dmuci_get_value_by_section_string(port_s, "ifname", &iface);
|
||||
if (*iface != '\0') {
|
||||
strncpy(intf_tag, iface, sizeof(intf_tag) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Create untagged upstream interface. */
|
||||
strcat(intf_tag, ".1");
|
||||
|
||||
/* Check if linker is present in network UCI, if yes the update
|
||||
* the proto, else create a interface and device section. */
|
||||
char intf[20] = {0};
|
||||
if (strcmp(linker, intf_tag) == 0)
|
||||
strncpy(intf, linker, sizeof(intf) - 1);
|
||||
else
|
||||
snprintf(intf, sizeof(intf), "%s.%s", linker, "1");
|
||||
|
||||
struct uci_section *s = NULL, *link_s = NULL;
|
||||
char *val;
|
||||
int ret = 0;
|
||||
uci_foreach_option_eq("network", "interface", "ifname", intf, s) {
|
||||
/* Add ethernet link params to dmmap link section. */
|
||||
uci_path_foreach_sections(bbfdm, DMMAP, "link", link_s) {
|
||||
char *inst;
|
||||
char link_inst[10] = {0};
|
||||
dmuci_get_value_by_section_string(link_s, "link_instance", &inst);
|
||||
strncpy(link_inst, instance, sizeof(link_inst) - 1);
|
||||
|
||||
/* Check if the link instance are same or not. */
|
||||
if (strncmp(link_inst, inst, sizeof(link_inst)) == 0) {
|
||||
dmuci_set_value_by_section(link_s, "section_name", section_name(s));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dmuci_set_value_by_section(s, "proto", "dhcp");
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
dmuci_add_section_and_rename("network", "interface", &s, &val);
|
||||
|
||||
/* Add ethernet link params to dmmap link section. */
|
||||
uci_path_foreach_sections(bbfdm, DMMAP, "link", link_s) {
|
||||
char *inst;
|
||||
char link_inst[10] = {0};
|
||||
dmuci_get_value_by_section_string(link_s, "link_instance", &inst);
|
||||
strncpy(link_inst, instance, sizeof(link_inst) - 1);
|
||||
|
||||
/* Check if the link instance are same or not. */
|
||||
if (strncmp(link_inst, inst, sizeof(link_inst)) == 0) {
|
||||
dmuci_set_value_by_section(link_s, "section_name", section_name(s));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dmuci_set_value_by_section(s, "proto", "dhcp");
|
||||
dmuci_set_value_by_section(s, "ifname", intf);
|
||||
|
||||
/* Add config device section. */
|
||||
struct uci_section *dev_s;
|
||||
dmuci_add_section_and_rename("network", "device", &dev_s, &val);
|
||||
dmuci_set_value_by_section(dev_s, "type", "untagged");
|
||||
char *tok = strtok(linker, ".");
|
||||
dmuci_set_value_by_section(dev_s, "ifname", tok);
|
||||
dmuci_set_value_by_section(dev_s, "name", intf);
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ pid_t get_pid(char *pname)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int check_file(char *path)
|
||||
int check_file(char *path)
|
||||
{
|
||||
glob_t globbuf;
|
||||
if(glob(path, 0, NULL, &globbuf) == 0) {
|
||||
|
|
@ -859,7 +859,7 @@ void synchronize_specific_config_sections_with_dmmap(char *package, char *sectio
|
|||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_sect, "section_name", section_name(s));
|
||||
}
|
||||
|
||||
/* Fix : Change to fix multiple IP interface creation. */
|
||||
/* Change to fix multiple IP interface creation. */
|
||||
if (strcmp(package, "network") == 0 && strcmp(section_type, "interface") == 0 && strcmp(dmmap_package, "dmmap_network") == 0) {
|
||||
char *value;
|
||||
dmuci_get_value_by_section_string(s, "proto", &value);
|
||||
|
|
@ -997,6 +997,73 @@ void synchronize_multi_config_sections_with_dmmap_set(char *package, char *secti
|
|||
}
|
||||
}
|
||||
|
||||
bool synchronize_multi_config_sections_with_dmmap_port(char *package, char *section_type, char *dmmap_package, char* dmmap_section, char* option_name, char* option_value, void* additional_attribute, struct list_head *dup_list, char *br_key)
|
||||
{
|
||||
struct uci_section *s, *stmp, *dmmap_sect;
|
||||
char *v, *pack, *sect;
|
||||
bool found = false;
|
||||
|
||||
dmmap_file_path_get(dmmap_package);
|
||||
|
||||
uci_foreach_option_eq(package, section_type, option_name, option_value, s) {
|
||||
found = true;
|
||||
/*
|
||||
* create/update corresponding dmmap section that have same config_section link and using param_value_array
|
||||
*/
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap(dmmap_package, dmmap_section, section_name(s))) == NULL) {
|
||||
dmuci_add_section_bbfdm(dmmap_package, dmmap_section, &dmmap_sect, &v);
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_sect, "section_name", section_name(s));
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_sect, "package", package);
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_sect, "section", section_type);
|
||||
} else {
|
||||
/* Get the bridge_key associated with the dmmap section. */
|
||||
char *key;
|
||||
dmuci_get_value_by_section_string(dmmap_sect, "bridge_key", &key);
|
||||
if (strcmp(br_key, key) == 0) {
|
||||
/* Dmmap set for configuring the lower layer of Bridge.Port object. */
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_sect, "section_name", section_name(s));
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_sect, "package", package);
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_sect, "section", section_type);
|
||||
} else {
|
||||
struct uci_section *br_s = NULL;
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "bridge_key", br_key, br_s) {
|
||||
/* Get the section name. */
|
||||
char *sec_name;
|
||||
dmuci_get_value_by_section_string(br_s, "section_name", &sec_name);
|
||||
|
||||
if (strcmp(sec_name, section_name(s)) == 0) {
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, br_s, "section_name", section_name(s));
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, br_s, "package", package);
|
||||
DMUCI_SET_VALUE_BY_SECTION(bbfdm, br_s, "section", section_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add system and dmmap sections to the list
|
||||
*/
|
||||
add_sectons_list_paramameter(dup_list, s, dmmap_sect, additional_attribute);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete unused dmmap sections
|
||||
*/
|
||||
uci_path_foreach_sections_safe(bbfdm, dmmap_package, dmmap_section, stmp, s) {
|
||||
dmuci_get_value_by_section_string(s, "section_name", &v);
|
||||
dmuci_get_value_by_section_string(s, "package", &pack);
|
||||
dmuci_get_value_by_section_string(s, "section", §);
|
||||
if (v != NULL && strlen(v) > 0 && strcmp(package, pack) == 0 && strcmp(section_type, sect) == 0) {
|
||||
if(get_origin_section_from_config(package, section_type, v) == NULL){
|
||||
dmuci_delete_by_section(s, NULL, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
bool synchronize_multi_config_sections_with_dmmap_eq(char *package, char *section_type, char *dmmap_package, char* dmmap_section, char* option_name, char* option_value, void* additional_attribute, struct list_head *dup_list)
|
||||
{
|
||||
struct uci_section *s, *stmp, *dmmap_sect;
|
||||
|
|
@ -2132,3 +2199,43 @@ int is_vlan_termination_section(struct uci_section *s)
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int get_upstream_interface(char *intf_tag, int len)
|
||||
{
|
||||
/* Get the upstream interface. */
|
||||
struct uci_section *port_s = NULL;
|
||||
uci_foreach_option_eq("ports", "ethport", "uplink", "1", port_s) {
|
||||
char *iface;
|
||||
dmuci_get_value_by_section_string(port_s, "ifname", &iface);
|
||||
if (*iface != '\0') {
|
||||
strncpy(intf_tag, iface, len - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int create_mac_addr_upstream_intf(char *mac_addr, char *mac, int len)
|
||||
{
|
||||
int num = 0;
|
||||
char macaddr[25] = {0};
|
||||
|
||||
if (*mac != '\0') {
|
||||
strncpy(macaddr, mac, sizeof(macaddr) - 1);
|
||||
int len = strlen(macaddr);
|
||||
|
||||
/* Fetch the last octect of base mac address in integer variable. */
|
||||
if (sscanf(&macaddr[len - 2], "%02x", &num) > 0) {
|
||||
num += 1;
|
||||
snprintf(&macaddr[len - 2], sizeof(macaddr), "%02x", num);
|
||||
}
|
||||
|
||||
if (macaddr[0] != '\0') {
|
||||
strncpy(mac_addr, macaddr, len);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -273,6 +273,7 @@ void synchronize_specific_config_sections_with_dmmap_eq(char *package, char *sec
|
|||
void synchronize_specific_config_sections_with_dmmap_eq_no_delete(char *package, char *section_type, char *dmmap_package,char* option_name, char* option_value, struct list_head *dup_list);
|
||||
void synchronize_specific_config_sections_with_dmmap_cont(char *package, char *section_type, char *dmmap_package,char* option_name, char* option_value, struct list_head *dup_list);
|
||||
bool synchronize_multi_config_sections_with_dmmap_eq(char *package, char *section_type, char *dmmap_package, char* dmmap_section, char* option_name, char* option_value, void* additional_attribute, struct list_head *dup_list);
|
||||
bool synchronize_multi_config_sections_with_dmmap_port(char *package, char *section_type, char *dmmap_package, char* dmmap_section, char* option_name, char* option_value, void* additional_attribute, struct list_head *dup_list, char *br_key);
|
||||
bool synchronize_multi_config_sections_with_dmmap_eq_diff(char *package, char *section_type, char *dmmap_package, char* dmmap_section, char* option_name, char* option_value, char* opt_diff_name, char* opt_diff_value, void* additional_attribute, struct list_head *dup_list);
|
||||
void add_sysfs_sectons_list_paramameter(struct list_head *dup_list, struct uci_section *dmmap_section, char *file_name, char* filepath);
|
||||
int synchronize_system_folders_with_dmmap_opt(char *sysfsrep, char *dmmap_package, char *dmmap_section, char *opt_name, char* inst_opt, struct list_head *dup_list);
|
||||
|
|
@ -325,4 +326,6 @@ char *decode64 (char *enc);
|
|||
char *stringToHex(char *text, int length);
|
||||
char *replace_char(char *str, char find, char replace);
|
||||
int is_vlan_termination_section(struct uci_section *s);
|
||||
int get_upstream_interface(char *intf_tag, int len);
|
||||
int create_mac_addr_upstream_intf(char *mac_addr, char *mac, int len);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue