Fix indentation

This commit is contained in:
Amin Ben Ramdhane 2020-03-25 12:38:52 +01:00
parent fa07b8c3b6
commit 50f8d36627
2 changed files with 474 additions and 493 deletions

View file

@ -49,20 +49,19 @@ static int eth_port_sysfs(const struct eth_port_args *args, const char *name, ch
static int is_device_exist(char *device) static int is_device_exist(char *device)
{ {
struct uci_section *s = NULL; struct uci_section *s = NULL;
char *dev; char *dev;
uci_path_foreach_sections(bbfdm, DMMAP, "link", s) { uci_path_foreach_sections(bbfdm, DMMAP, "link", s) {
dmuci_get_value_by_section_string(s, "device", &dev); dmuci_get_value_by_section_string(s, "device", &dev);
char *p = strtok(dev, ".");
char *p = strtok(dev, "."); if (p != NULL) {
if (p != NULL) { if (strcmp(p, device) == 0) {
if (strcmp(p, device) == 0) { return 1;
return 1; }
} }
} }
} return 0;
return 0;
} }
static int is_mac_exist(char *macaddr) static int is_mac_exist(char *macaddr)
@ -96,37 +95,35 @@ static void create_link(char *ifname)
return; return;
} }
/* Fix: For all the Ethernet link objects pointing to same Ethernet Interface, /* Fix: For all the Ethernet link objects pointing to same Ethernet Interface,
* we can omit creating multiple Ethernet link entries.*/ * we can omit creating multiple Ethernet link entries.*/
char intf[250] = {0}; char intf[250] = {0};
strncpy(intf, device, sizeof(intf)); strncpy(intf, device, sizeof(intf));
char *p = strtok(intf, "."); char *p = strtok(intf, ".");
if (p != NULL) { if (p != NULL) {
if (is_device_exist(p)) { if (is_device_exist(p)) {
return; return;
} }
} }
/* Check if section_name exists or not, if yes then do not add section just update /* Check if section_name exists or not, if yes then do not add section just update
* the params else add section and update the params. */ * the params else add section and update the params. */
struct uci_section *s = NULL;
struct uci_section *s = NULL; char *sec_name;
char *sec_name;
int ret = 1; int ret = 1;
uci_path_foreach_sections(bbfdm, DMMAP, "link", s) { uci_path_foreach_sections(bbfdm, DMMAP, "link", s) {
dmuci_get_value_by_section_string(s, "section_name", &sec_name); dmuci_get_value_by_section_string(s, "section_name", &sec_name);
if (strcmp(ifname, sec_name) == 0) { if (strcmp(ifname, sec_name) == 0) {
dmuci_set_value_by_section(s, "mac", macaddr); dmuci_set_value_by_section(s, "mac", macaddr);
dmuci_set_value_by_section(s, "device", device); dmuci_set_value_by_section(s, "device", device);
dmuci_set_value_by_section(s, "section_name", ifname); dmuci_set_value_by_section(s, "section_name", ifname);
ret = 0; ret = 0;
break; break;
} else { } else {
ret = 1; ret = 1;
} }
} }
if (ret == 1 ) { if (ret == 1 ) {
dmuci_add_section_bbfdm(DMMAP, "link", &dmmap, &v); dmuci_add_section_bbfdm(DMMAP, "link", &dmmap, &v);
@ -237,28 +234,26 @@ static int browseEthernetVLANTerminationInst(struct dmctx *dmctx, DMNODE *parent
char *if_name = strtok(intf, " "); char *if_name = strtok(intf, " ");
if (NULL != if_name) { if (NULL != if_name) {
char name[250] = {0}; char name[250] = {0};
strncpy(name, if_name, sizeof(name)); strncpy(name, if_name, sizeof(name));
/* Support for both vlans and macvlans. */ /* Support for both vlans and macvlans. */
int macvlan = 0; int macvlan = 0;
char *p = strstr(name, "."); char *p = strstr(name, ".");
if (!p) { if (!p) {
char *t = strstr(name, "_"); char *t = strstr(name, "_");
if (t) { if (t) {
macvlan = 1; macvlan = 1;
} else { } else {
continue; continue;
} }
} }
char *tok, *end; char *tok, *end;
if (macvlan == 1) { if (macvlan == 1) {
tok = strtok_r(name, "_", &end); tok = strtok_r(name, "_", &end);
} else { } else {
tok = strtok_r(name, ".", &end); tok = strtok_r(name, ".", &end);
} }
if (end == NULL) { if (end == NULL) {
continue; continue;
@ -267,8 +262,6 @@ static int browseEthernetVLANTerminationInst(struct dmctx *dmctx, DMNODE *parent
if (macvlan == 0) { if (macvlan == 0) {
char tag[20] = {0}; char tag[20] = {0};
strncpy(tag, end, sizeof(tag)); strncpy(tag, end, sizeof(tag));
if (strncmp(tag, "1", sizeof(tag)) == 0) { if (strncmp(tag, "1", sizeof(tag)) == 0) {
continue; continue;
} }
@ -305,7 +298,7 @@ static int get_linker_interface(char *refparam, struct dmctx *dmctx, void *data,
static int get_linker_link(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) static int get_linker_link(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
{ {
/* Fix: for get linker link */ /* Fix: for get linker link */
dmuci_get_value_by_section_string(((struct dm_args *)data)->section, "mac", linker); dmuci_get_value_by_section_string(((struct dm_args *)data)->section, "mac", linker);
return 0; return 0;
} }
@ -330,7 +323,6 @@ static int addObjEthernetLink(char *refparam, struct dmctx *ctx, void *data, cha
struct uci_section *dmmap_network= NULL; struct uci_section *dmmap_network= NULL;
inst = get_last_instance_bbfdm(DMMAP, "link", "link_instance"); inst = get_last_instance_bbfdm(DMMAP, "link", "link_instance");
dmuci_add_section_bbfdm(DMMAP, "link", &dmmap_network, &v); dmuci_add_section_bbfdm(DMMAP, "link", &dmmap_network, &v);
*instance = update_instance_bbfdm(dmmap_network, inst, "link_instance"); *instance = update_instance_bbfdm(dmmap_network, inst, "link_instance");
return 0; return 0;
@ -340,6 +332,7 @@ static int delObjEthernetLink(char *refparam, struct dmctx *ctx, void *data, cha
{ {
char *sect_name= NULL; char *sect_name= NULL;
struct uci_section *s = NULL; struct uci_section *s = NULL;
switch (del_action) { switch (del_action) {
case DEL_INST: case DEL_INST:
/* Fix : Deletion of EthernetLink to support L2 VLAN deployments. */ /* Fix : Deletion of EthernetLink to support L2 VLAN deployments. */
@ -357,7 +350,6 @@ static int delObjEthernetLink(char *refparam, struct dmctx *ctx, void *data, cha
dmuci_get_value_by_section_string(intf_s, "proto", &proto); dmuci_get_value_by_section_string(intf_s, "proto", &proto);
dmuci_delete_by_section(intf_s, "proto", proto); dmuci_delete_by_section(intf_s, "proto", proto);
break; break;
} }
} }
/* Remove the Link section from dmmap. */ /* Remove the Link section from dmmap. */
@ -439,7 +431,7 @@ static int delObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void
break; break;
case DEL_ALL: case DEL_ALL:
return FAULT_9005; return FAULT_9005;
break; break;
} }
return 0; return 0;
} }
@ -521,7 +513,6 @@ static int get_Ethernet_VLANTerminationNumberOfEntries(char *refparam, struct dm
} }
} }
char *tok, *end; char *tok, *end;
if (macvlan == 1) { if (macvlan == 1) {
tok = strtok_r(name, "_", &end); tok = strtok_r(name, "_", &end);
@ -536,13 +527,11 @@ static int get_Ethernet_VLANTerminationNumberOfEntries(char *refparam, struct dm
if (macvlan == 0) { if (macvlan == 0) {
char tag[20] = {0}; char tag[20] = {0};
strncpy(tag, end, sizeof(tag)); strncpy(tag, end, sizeof(tag));
if (strncmp(tag, "1", sizeof(tag)) == 0) { if (strncmp(tag, "1", sizeof(tag)) == 0) {
continue; continue;
} }
} }
} }
cnt++; cnt++;
} }
dmasprintf(value, "%d", cnt); dmasprintf(value, "%d", cnt);
@ -1067,7 +1056,6 @@ static int set_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
/* Set the value of proto to the section. */ /* Set the value of proto to the section. */
dmuci_set_value_by_section(intf_s, "proto", "dhcp"); dmuci_set_value_by_section(intf_s, "proto", "dhcp");
} }
} }
} }

File diff suppressed because it is too large Load diff