mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Ticket refs #6550: Adapt data models to OpenWrt 21.02 network stack
This commit is contained in:
parent
5c1a146fdb
commit
f7c10416b3
18 changed files with 1013 additions and 2061 deletions
|
|
@ -15,7 +15,7 @@
|
|||
struct atm_args
|
||||
{
|
||||
struct uci_section *atm_sec;
|
||||
char *ifname;
|
||||
char *device;
|
||||
};
|
||||
|
||||
/**************************************************************************
|
||||
|
|
@ -23,20 +23,46 @@ struct atm_args
|
|||
***************************************************************************/
|
||||
static int get_atm_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
|
||||
{
|
||||
*linker = (data && ((struct atm_args *)data)->ifname) ? ((struct atm_args *)data)->ifname : "";
|
||||
*linker = (data && ((struct atm_args *)data)->device) ? ((struct atm_args *)data)->device : "";
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* INIT
|
||||
***************************************************************************/
|
||||
static inline int init_atm_link(struct atm_args *args, struct uci_section *s, char *ifname)
|
||||
static inline int init_atm_link(struct atm_args *args, struct uci_section *s, char *device)
|
||||
{
|
||||
args->atm_sec = s;
|
||||
args->ifname = ifname;
|
||||
args->device = device;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* COMMON FUNCTIONS
|
||||
**************************************************************/
|
||||
void remove_device_from_interface(struct uci_section *interface_s, char *device)
|
||||
{
|
||||
char *curr_device = NULL, *pch = NULL, *spch = NULL;
|
||||
char new_device[64] = {0};
|
||||
unsigned pos = 0;
|
||||
|
||||
dmuci_get_value_by_section_string(interface_s, "device", &curr_device);
|
||||
|
||||
new_device[0] = '\0';
|
||||
for (pch = strtok_r(curr_device, " ", &spch); pch; pch = strtok_r(NULL, " ", &spch)) {
|
||||
|
||||
if (strcmp(pch, device) == 0)
|
||||
continue;
|
||||
|
||||
pos += snprintf(&new_device[pos], sizeof(new_device) - pos, "%s ", pch);
|
||||
}
|
||||
|
||||
if (pos)
|
||||
new_device[pos - 1] = 0;
|
||||
|
||||
dmuci_set_value_by_section(interface_s, "device", new_device);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* SET & GET DSL LINK PARAMETERS
|
||||
***************************************************************************/
|
||||
|
|
@ -186,7 +212,7 @@ static int set_atm_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
static inline int ubus_atm_stats(char **value, char *stat_mod, void *data)
|
||||
{
|
||||
json_object *res = NULL;
|
||||
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ((struct atm_args *)data)->ifname, String}}, 1, &res);
|
||||
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ((struct atm_args *)data)->device, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
*value = dmjson_get_value(res, 2, "statistics", stat_mod);
|
||||
if ((*value)[0] == '\0')
|
||||
|
|
@ -249,7 +275,7 @@ static int set_atm_enable(char *refparam, struct dmctx *ctx, void *data, char *i
|
|||
/*#Device.ATM.Link.{i}.Status!SYSFS:/sys/class/net/@Name/operstate*/
|
||||
static int get_atm_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return get_net_device_status(((struct atm_args *)data)->ifname, value);
|
||||
return get_net_device_status(((struct atm_args *)data)->device, value);
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
|
|
@ -278,17 +304,17 @@ static int add_atm_link(char *refparam, struct dmctx *ctx, void *data, char **in
|
|||
|
||||
static int delete_atm_link(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
||||
{
|
||||
struct uci_section *s = NULL, *ss = NULL, *ns = NULL, *nss = NULL, *dmmap_section = NULL;
|
||||
struct uci_section *s = NULL, *stmp = NULL, *dmmap_section = NULL;
|
||||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
uci_foreach_option_cont("network", "interface", "ifname", ((struct atm_args *)data)->ifname, s) {
|
||||
if (ss != NULL && ((struct atm_args *)data)->ifname != NULL)
|
||||
wan_remove_dev_interface(ss, ((struct atm_args *)data)->ifname);
|
||||
ss = s;
|
||||
uci_foreach_option_cont("network", "interface", "device", ((struct atm_args *)data)->device, s) {
|
||||
if (stmp != NULL && ((struct atm_args *)data)->device != NULL)
|
||||
remove_device_from_interface(stmp, ((struct atm_args *)data)->device);
|
||||
stmp = s;
|
||||
}
|
||||
if (ss != NULL && ((struct atm_args *)data)->ifname != NULL)
|
||||
wan_remove_dev_interface(ss, ((struct atm_args *)data)->ifname);
|
||||
if (stmp != NULL && ((struct atm_args *)data)->device != NULL)
|
||||
remove_device_from_interface(stmp, ((struct atm_args *)data)->device);
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_dsl", "atm-device", section_name(((struct atm_args *)data)->atm_sec), &dmmap_section);
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
|
|
@ -296,17 +322,18 @@ static int delete_atm_link(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
dmuci_delete_by_section(((struct atm_args *)data)->atm_sec, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_sections_safe("dsl", "atm-device", ss, s) {
|
||||
char *ifname = NULL;
|
||||
uci_foreach_sections_safe("dsl", "atm-device", stmp, s) {
|
||||
struct uci_section *ns = NULL, *nss = NULL;
|
||||
char *device = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "device", &ifname);
|
||||
uci_foreach_option_cont("network", "interface", "ifname", ifname, ns) {
|
||||
if (nss != NULL && ifname != NULL)
|
||||
wan_remove_dev_interface(nss, ifname);
|
||||
dmuci_get_value_by_section_string(s, "device", &device);
|
||||
uci_foreach_option_cont("network", "interface", "device", device, ns) {
|
||||
if (nss != NULL && device != NULL)
|
||||
remove_device_from_interface(nss, device);
|
||||
nss = ns;
|
||||
}
|
||||
if (nss != NULL && ifname != NULL)
|
||||
wan_remove_dev_interface(nss, ifname);
|
||||
if (nss != NULL && device != NULL)
|
||||
remove_device_from_interface(nss, device);
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_dsl", "atm-device", section_name(s), &dmmap_section);
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
|
|
@ -356,7 +383,7 @@ static int set_atm_alias(char *refparam, struct dmctx *ctx, void *data, char *in
|
|||
/*#Device.ATM.Link.{i}.!UCI:dsl/atm-device/dmmap_dsl*/
|
||||
static int browseAtmLinkInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
char *inst = NULL, *max_inst = NULL, *ifname;
|
||||
char *inst = NULL, *max_inst = NULL, *device;
|
||||
struct atm_args curr_atm_args = {0};
|
||||
struct dmmap_dup *p = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
|
|
@ -364,8 +391,8 @@ static int browseAtmLinkInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
synchronize_specific_config_sections_with_dmmap("dsl", "atm-device", "dmmap_dsl", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "device", &ifname);
|
||||
init_atm_link(&curr_atm_args, p->config_section, ifname);
|
||||
dmuci_get_value_by_section_string(p->config_section, "device", &device);
|
||||
init_atm_link(&curr_atm_args, p->config_section, device);
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 3,
|
||||
p->dmmap_section, "atmlinkinstance", "atmlinkalias");
|
||||
|
|
|
|||
|
|
@ -19,4 +19,6 @@ extern DMOBJ tATMLinkObj[];
|
|||
extern DMLEAF tATMLinkParams[];
|
||||
extern DMLEAF tATMLinkStatsParams[];
|
||||
|
||||
void remove_device_from_interface(struct uci_section *interface_s, char *device);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -510,10 +510,10 @@ static int set_DHCPv6Client_Alias(char *refparam, struct dmctx *ctx, void *data,
|
|||
static int get_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section *dhcpv6_s = ((struct dhcpv6_client_args *)data)->dhcp_client_conf;
|
||||
char *ifname = NULL;
|
||||
char *device = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(dhcpv6_s, "ifname", &ifname);
|
||||
char *parent_s = (ifname && *ifname) ? strchr(ifname, '@') : NULL;
|
||||
dmuci_get_value_by_section_string(dhcpv6_s, "device", &device);
|
||||
char *parent_s = (device && *device) ? strchr(device, '@') : NULL;
|
||||
|
||||
char *linker = dmstrdup(parent_s ? parent_s + 1 : dhcpv6_s ? section_name(dhcpv6_s) : "");
|
||||
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value);
|
||||
|
|
|
|||
|
|
@ -45,48 +45,36 @@ static inline int init_eth_rmon(struct eth_rmon_args *args, struct uci_section *
|
|||
/*************************************************************
|
||||
* COMMON FUNCTIONS
|
||||
**************************************************************/
|
||||
int is_vlan_termination_section(const char *name)
|
||||
struct uci_section *get_device_section(char *dev_name)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
|
||||
// check ifname is not empty
|
||||
char *ifname;
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifname);
|
||||
if (*ifname == '\0')
|
||||
continue;
|
||||
|
||||
// check if ifname list contains the device name
|
||||
if (strstr(ifname, name)) {
|
||||
char *type;
|
||||
// check type is not bridge
|
||||
|
||||
dmuci_get_value_by_section_string(s, "type", &type);
|
||||
if (strcmp(type, "bridge") == 0)
|
||||
return 0;
|
||||
|
||||
break;
|
||||
}
|
||||
uci_foreach_option_eq("network", "device", "name", dev_name, s) {
|
||||
return s;
|
||||
}
|
||||
return 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void get_bridge_port_linker(struct dmctx *ctx, char *intf_name, char **value)
|
||||
static void get_bridge_port_linker(struct dmctx *ctx, char *device_s_name, char **value)
|
||||
{
|
||||
struct uci_section *dmmap_section = NULL, *bridge_port = NULL;
|
||||
|
||||
*value = NULL;
|
||||
get_dmmap_section_of_config_section("dmmap_bridge", "bridge", intf_name, &dmmap_section);
|
||||
get_dmmap_section_of_config_section("dmmap_bridge", "device", device_s_name, &dmmap_section);
|
||||
if (dmmap_section != NULL) {
|
||||
char *br_inst, *mg;
|
||||
char *br_inst = NULL;
|
||||
|
||||
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, bridge_port) {
|
||||
dmuci_get_value_by_section_string(bridge_port, "management", &mg);
|
||||
if (strcmp(mg, "1") == 0) {
|
||||
char *device, linker[512] = "";
|
||||
dmuci_get_value_by_section_string(bridge_port, "device", &device);
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+%s", br_inst, section_name(bridge_port), device);
|
||||
char *management = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(bridge_port, "management", &management);
|
||||
if (management && strcmp(management, "1") == 0) {
|
||||
char linker[512] = {0};
|
||||
char *port = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(bridge_port, "port", &port);
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+%s", br_inst, section_name(bridge_port), port);
|
||||
adm_entry_get_linker_param(ctx, "Device.Bridging.Bridge.", linker, value);
|
||||
break;
|
||||
}
|
||||
|
|
@ -120,16 +108,16 @@ static struct uci_section *is_device_section_exist(char *device)
|
|||
return s;
|
||||
}
|
||||
|
||||
int ethernet_check_section_in_curr_section(char *curr_section, char *section)
|
||||
bool ethernet_check_section_in_curr_section(char *curr_section, char *section)
|
||||
{
|
||||
char *pch = NULL, *pchr = NULL, section_list[256] = {0};
|
||||
|
||||
DM_STRNCPY(section_list, curr_section, sizeof(section_list));
|
||||
for (pch = strtok_r(section_list, ",", &pchr); pch != NULL; pch = strtok_r(NULL, ",", &pchr)) {
|
||||
if (strcmp(pch, section) == 0)
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void add_section_in_curr_section(struct uci_section *dmmap_section, char *curr_section, char *section)
|
||||
|
|
@ -143,14 +131,14 @@ static void add_section_in_curr_section(struct uci_section *dmmap_section, char
|
|||
dmuci_set_value_by_section(dmmap_section, "section_name", section_list);
|
||||
}
|
||||
|
||||
int ethernet_name_exists_in_devices(char *name)
|
||||
bool ethernet_name_exists_in_devices(char *name)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
|
||||
uci_foreach_option_eq("network", "device", "name", name, s) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void add_new_dmmap_section(char *macaddr, char*interface, char *section_name)
|
||||
|
|
@ -216,7 +204,7 @@ static void create_link(char *sec_name, char *mac_addr)
|
|||
static int dmmap_synchronizeEthernetLink(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
char *ifname, *macaddr, *type, *proto;
|
||||
char *device, *macaddr;
|
||||
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
|
||||
|
|
@ -224,15 +212,9 @@ static int dmmap_synchronizeEthernetLink(struct dmctx *dmctx, DMNODE *parent_nod
|
|||
if (strcmp(section_name(s), "loopback") == 0)
|
||||
continue;
|
||||
|
||||
// Skip this interface section if type=bridge and proto is empty
|
||||
dmuci_get_value_by_section_string(s, "type", &type);
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if ((strcmp(type, "bridge") == 0) && *proto == '\0')
|
||||
continue;
|
||||
|
||||
// Skip this interface section if its ifname option contains '@'
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifname);
|
||||
if (strchr(ifname, '@'))
|
||||
dmuci_get_value_by_section_string(s, "device", &device);
|
||||
if (strchr(device, '@'))
|
||||
continue;
|
||||
|
||||
// If the section belong to provider bridge (section name: pr_br_{i}) then skip adding to dmmap_package
|
||||
|
|
@ -255,7 +237,7 @@ static char *get_vlan_last_instance_bbfdm(char *package, char *section, char *op
|
|||
get_config_section_of_dmmap_section("network", "device", sect_name, &confsect);
|
||||
dmuci_get_value_by_section_string(confsect, "type", &type);
|
||||
dmuci_get_value_by_section_string(confsect, "name", &name);
|
||||
if (strcmp(type, "untagged") == 0 || (*name != '\0' && !is_vlan_termination_section(name))) {
|
||||
if (strcmp(type, "bridge") == 0 || strcmp(type, "untagged") == 0) {
|
||||
dmuci_set_value_by_section(s, "vlan_term_instance", "");
|
||||
continue;
|
||||
}
|
||||
|
|
@ -280,7 +262,9 @@ static int browseEthernetInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
|
||||
synchronize_specific_config_sections_with_dmmap("ports", "ethport", "dmmap_ports", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "ifname", &ifname);
|
||||
|
||||
init_eth_port(&curr_eth_port_args, p->config_section, ifname);
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 3,
|
||||
|
|
@ -322,7 +306,7 @@ static int browseEthernetVLANTerminationInst(struct dmctx *dmctx, DMNODE *parent
|
|||
|
||||
dmuci_get_value_by_section_string(p->config_section, "type", &type);
|
||||
dmuci_get_value_by_section_string(p->config_section, "name", &name);
|
||||
if (strcmp(type, "untagged") == 0 || (*name != '\0' && !is_vlan_termination_section(name)))
|
||||
if (strcmp(type, "bridge") == 0 || strcmp(type, "untagged") == 0)
|
||||
continue;
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 3,
|
||||
|
|
@ -345,9 +329,12 @@ static int browseEthernetRMONStatsInst(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
|
||||
synchronize_specific_config_sections_with_dmmap("ports", "ethport", "dmmap_eth_rmon", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "ifname", &ifname);
|
||||
|
||||
dmubus_call("ethernet", "rmonstats", UBUS_ARGS{{"ifname", ifname, String}}, 1, &res);
|
||||
if (!res) continue;
|
||||
|
||||
init_eth_rmon(&curr_eth_rmon_args, p->config_section, res);
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 3,
|
||||
|
|
@ -489,7 +476,7 @@ static int delObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void
|
|||
uci_foreach_sections_safe("network", "device", sdevtmp, s_dev) {
|
||||
dmuci_get_value_by_section_string(s_dev, "type", &type);
|
||||
dmuci_get_value_by_section_string(s_dev, "name", &name);
|
||||
if (strcmp(type, "untagged") == 0 || (*name != '\0' && !is_vlan_termination_section(name)))
|
||||
if (strcmp(type, "bridge") == 0 || strcmp(type, "untagged") == 0)
|
||||
continue;
|
||||
|
||||
// Remove device section in dmmap_network file
|
||||
|
|
@ -543,7 +530,7 @@ static int get_Ethernet_VLANTerminationNumberOfEntries(char *refparam, struct dm
|
|||
uci_foreach_sections("network", "device", s) {
|
||||
dmuci_get_value_by_section_string(s, "type", &type);
|
||||
dmuci_get_value_by_section_string(s, "name", &name);
|
||||
if (strcmp(type, "untagged") == 0 || (*name != '\0' && !is_vlan_termination_section(name)))
|
||||
if (strcmp(type, "bridge") == 0 || strcmp(type, "untagged") == 0)
|
||||
continue;
|
||||
cnt++;
|
||||
}
|
||||
|
|
@ -639,14 +626,14 @@ static int get_EthernetInterface_Name(char *refparam, struct dmctx *ctx, void *d
|
|||
/*#Device.Ethernet.Interface.{i}.LastChange!UBUS:network.interface/status/interface,@Name/uptime*/
|
||||
static int get_EthernetInterface_LastChange(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
json_object *res;
|
||||
json_object *res = NULL;
|
||||
struct uci_section *s = NULL;
|
||||
char *ifname;
|
||||
char *device;
|
||||
|
||||
*value ="0";
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifname);
|
||||
if (strstr(ifname, ((struct eth_port_args *)data)->ifname)) {
|
||||
dmuci_get_value_by_section_string(s, "device", &device);
|
||||
if (strstr(device, ((struct eth_port_args *)data)->ifname)) {
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
*value = dmjson_get_value(res, 1, "uptime");
|
||||
|
|
@ -978,13 +965,20 @@ static int get_EthernetLink_LastChange(char *refparam, struct dmctx *ctx, void *
|
|||
|
||||
static int get_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *linker;
|
||||
char *linker = NULL;
|
||||
char *device_s_type = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &linker);
|
||||
char *bridge = strstr(linker, "br-");
|
||||
if (bridge) {
|
||||
char *int_name;
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "section_name", &int_name);
|
||||
get_bridge_port_linker(ctx, int_name, value);
|
||||
if (linker && *linker == '\0')
|
||||
return 0;
|
||||
|
||||
// get device section mapped to this device name
|
||||
struct uci_section *br_device_s = get_device_section(linker);
|
||||
|
||||
if (br_device_s) dmuci_get_value_by_section_string(br_device_s, "type", &device_s_type);
|
||||
|
||||
if (br_device_s && strcmp(device_s_type, "bridge") == 0) {
|
||||
get_bridge_port_linker(ctx, section_name(br_device_s), value);
|
||||
} else {
|
||||
char *vid = strchr(linker, '.');
|
||||
if (vid) *vid = '\0';
|
||||
|
|
@ -1021,7 +1015,7 @@ static int set_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
if (strcmp(section_name(s), int_name) == 0) {
|
||||
dmuci_set_value_by_section(s, "ifname", link_linker);
|
||||
dmuci_set_value_by_section(s, "device", link_linker);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1032,40 +1026,45 @@ static int set_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
char *bridge = strchr(br_linker, ':');
|
||||
if (bridge) {
|
||||
*bridge = '\0';
|
||||
struct uci_section *s = NULL;
|
||||
char br_inst[8] = {0};
|
||||
char device[32] = {0};
|
||||
char *int_name = NULL;
|
||||
char *dev_s_name = NULL;
|
||||
|
||||
*bridge = '\0';
|
||||
DM_STRNCPY(br_inst, br_linker+3, sizeof(br_inst));
|
||||
|
||||
struct uci_section *port = NULL;
|
||||
char *interface, *curr_interface;
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "section_name", &int_name);
|
||||
|
||||
// Remove the network section corresponding to this dmmap interface if exists
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "section_name", &curr_interface);
|
||||
struct uci_section *s = NULL, *tmp = NULL;
|
||||
uci_foreach_sections_safe("network", "interface", tmp, s) {
|
||||
if (strcmp(section_name(s), curr_interface) == 0) {
|
||||
char *proto;
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if (*proto == '\0') dmuci_delete_by_section(s, NULL, NULL);
|
||||
//Generate the device name for bridge as br-<NETWORK>
|
||||
snprintf(device, sizeof(device), "br-%s", int_name);
|
||||
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
if (int_name && strcmp(section_name(s), int_name) == 0) {
|
||||
dmuci_set_value_by_section(s, "device", device);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the interface bridge name
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", br_inst, port) {
|
||||
dmuci_get_value_by_section_string(port, "interface", &interface);
|
||||
break;
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", br_inst, s) {
|
||||
|
||||
if (dev_s_name == NULL || *dev_s_name == '\0')
|
||||
dmuci_get_value_by_section_string(s, "device_section_name", &dev_s_name);
|
||||
|
||||
dmuci_set_value_by_section(s, "device", device);
|
||||
}
|
||||
|
||||
// Get the device name
|
||||
char *device = get_device(interface);
|
||||
if (dev_s_name && *dev_s_name) {
|
||||
uci_foreach_sections("network", "device", s) {
|
||||
if (dev_s_name && strcmp(section_name(s), dev_s_name) == 0) {
|
||||
dmuci_set_value_by_section(s, "name", device);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Generate the device name for bridge as br-<NETWORK> if it is not available via ubus yet.
|
||||
if (*device == '\0')
|
||||
dmasprintf(&device, "br-%s", interface);
|
||||
// Get dmmap section
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "device", device);
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "section_name", interface);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -1249,7 +1248,7 @@ static int get_EthernetVLANTermination_LastChange(char *refparam, struct dmctx *
|
|||
|
||||
*value = "0";
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "name", &devname);
|
||||
uci_foreach_option_eq("network", "interface", "ifname", devname, s) {
|
||||
uci_foreach_option_eq("network", "interface", "device", devname, s) {
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
*value = dmjson_get_value(res, 1, "uptime");
|
||||
|
|
@ -1315,8 +1314,8 @@ static int set_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx
|
|||
if (ethernet_name_exists_in_devices(new_name))
|
||||
return -1;
|
||||
|
||||
uci_foreach_option_eq("network", "interface", "ifname", vlan_linker, s) {
|
||||
dmuci_set_value_by_section(s, "ifname", new_name);
|
||||
uci_foreach_option_eq("network", "interface", "device", vlan_linker, s) {
|
||||
dmuci_set_value_by_section(s, "device", new_name);
|
||||
DM_STRNCPY(sec_name, section_name(s), sizeof(sec_name));
|
||||
break;
|
||||
}
|
||||
|
|
@ -1342,8 +1341,8 @@ static int set_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx
|
|||
|
||||
// if device is lowerlayer to an ip interface, then
|
||||
// the ifname of the ip interface also needs to be updated
|
||||
uci_foreach_option_eq("network", "interface", "ifname", old_name, s) {
|
||||
dmuci_set_value_by_section(s, "ifname", new_name);
|
||||
uci_foreach_option_eq("network", "interface", "device", old_name, s) {
|
||||
dmuci_set_value_by_section(s, "device", new_name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1417,8 +1416,8 @@ static int set_EthernetVLANTermination_VLANID(char *refparam, struct dmctx *ctx,
|
|||
|
||||
// set ifname option of the corresponding interface section
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "name", &curr_ifname);
|
||||
uci_foreach_option_eq("network", "interface", "ifname", curr_ifname, s) {
|
||||
dmuci_set_value_by_section(s, "ifname", name);
|
||||
uci_foreach_option_eq("network", "interface", "device", curr_ifname, s) {
|
||||
dmuci_set_value_by_section(s, "device", name);
|
||||
}
|
||||
|
||||
if (strncmp(type, "8021q", 5) == 0) {
|
||||
|
|
@ -1436,8 +1435,8 @@ static int set_EthernetVLANTermination_VLANID(char *refparam, struct dmctx *ctx,
|
|||
dmuci_set_value_by_section(d_sec, "name", ad_itf_ifname);
|
||||
// if this 8021ad instance is lowerlayer to an ip interface, then
|
||||
// the ifname of the ip interface also needs to be updated
|
||||
uci_foreach_option_eq("network", "interface", "ifname", old_name, s) {
|
||||
dmuci_set_value_by_section(s, "ifname", ad_itf_ifname);
|
||||
uci_foreach_option_eq("network", "interface", "device", old_name, s) {
|
||||
dmuci_set_value_by_section(s, "device", ad_itf_ifname);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ extern DMLEAF tEthernetVLANTerminationParams[];
|
|||
extern DMLEAF tEthernetVLANTerminationStatsParams[];
|
||||
extern DMLEAF tEthernetRMONStatsParams[];
|
||||
|
||||
int is_vlan_termination_section(const char *name);
|
||||
int ethernet_check_section_in_curr_section(char *curr_section, char *section);
|
||||
int ethernet_name_exists_in_devices(char *name);
|
||||
struct uci_section *get_device_section(char *dev_name);
|
||||
bool ethernet_check_section_in_curr_section(char *curr_section, char *section);
|
||||
bool ethernet_name_exists_in_devices(char *name);
|
||||
|
||||
#endif //__ETHERNET_H
|
||||
|
|
|
|||
|
|
@ -45,14 +45,14 @@ struct uci_section *has_tunnel_interface_route(char *interface)
|
|||
|
||||
static int browseGRETunnelInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
char *inst = NULL, *max_inst = NULL, *ifname= NULL;
|
||||
char *inst = NULL, *max_inst = NULL, *device = NULL;
|
||||
struct dmmap_dup *p = NULL, *dm = (struct dmmap_dup *)prev_data;
|
||||
struct uci_section *s = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
|
||||
LIST_HEAD(dup_list);
|
||||
dmasprintf(&ifname, "@%s", section_name(dm->config_section));
|
||||
synchronize_specific_config_sections_with_dmmap_eq("network", "interface", "dmmap_network", "ifname", ifname, &dup_list);
|
||||
|
||||
dmasprintf(&device, "@%s", section_name(dm->config_section));
|
||||
synchronize_specific_config_sections_with_dmmap_eq("network", "interface", "dmmap_network", "device", device, &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
if ((s = has_tunnel_interface_route(section_name(p->config_section))) == NULL)
|
||||
continue;
|
||||
|
|
@ -135,13 +135,13 @@ static int addObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *dat
|
|||
{
|
||||
struct uci_section *greiface_sec = NULL, *dmmap_sec = NULL, *route_sec = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
char ifname[32];
|
||||
char device_buf[32];
|
||||
|
||||
char *instance = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_network", "interface", "greiface_instance", "gre_tunnel_sect", section_name(((struct dmmap_dup *)data)->config_section));
|
||||
|
||||
dmuci_add_section("network", "interface", &greiface_sec);
|
||||
snprintf(ifname, sizeof(ifname), "@%s", section_name(((struct dmmap_dup *)data)->config_section));
|
||||
dmuci_set_value_by_section(greiface_sec, "ifname", ifname);
|
||||
snprintf(device_buf, sizeof(device_buf), "@%s", section_name(((struct dmmap_dup *)data)->config_section));
|
||||
dmuci_set_value_by_section(greiface_sec, "device", device_buf);
|
||||
|
||||
dmuci_add_section("network", "route", &route_sec);
|
||||
dmuci_set_value_by_section(route_sec, "interface", section_name(greiface_sec));
|
||||
|
|
@ -158,9 +158,7 @@ static int addObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *dat
|
|||
|
||||
static int delObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
||||
{
|
||||
struct uci_section *s = NULL, *ss = NULL, *s1 = NULL, *dmmap_section = NULL;
|
||||
int found = 0;
|
||||
char *iface = NULL, *atiface = NULL;
|
||||
struct uci_section *s = NULL, *stmp = NULL, *dmmap_section = NULL;
|
||||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
|
|
@ -169,39 +167,33 @@ static int delObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *dat
|
|||
dmuci_set_value_by_section(dmmap_section, "greiface_instance", "");
|
||||
dmuci_set_value_by_section(dmmap_section, "greiface_alias", "");
|
||||
}
|
||||
|
||||
if ((s = has_tunnel_interface_route(section_name(((struct dmmap_dup *)data)->config_section))) != NULL)
|
||||
dmuci_delete_by_section(s, NULL, NULL);
|
||||
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
dmuci_get_value_by_section_string(s, "ifname", &iface);
|
||||
dmasprintf(&atiface, "@%s", section_name(((struct dmmap_dup *)data)->config_section));
|
||||
uci_foreach_sections_safe("network", "interface", stmp, s) {
|
||||
struct uci_section *ss = NULL;
|
||||
char device_buf[32] = {0};
|
||||
char *device = NULL;
|
||||
|
||||
if(!iface || strcmp(iface, atiface) != 0)
|
||||
dmuci_get_value_by_section_string(s, "device", &device);
|
||||
snprintf(device_buf, sizeof(device_buf), "@%s", section_name(((struct dmmap_dup *)data)->config_section));
|
||||
|
||||
if (!device || strcmp(device, device_buf) != 0)
|
||||
continue;
|
||||
if (found != 0){
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(ss), &dmmap_section);
|
||||
if (dmmap_section != NULL) {
|
||||
dmuci_set_value_by_section(dmmap_section, "greiface_instance", "");
|
||||
dmuci_set_value_by_section(dmmap_section, "greiface_alias", "");
|
||||
}
|
||||
if ((s1 = has_tunnel_interface_route(section_name(ss))) != NULL)
|
||||
dmuci_delete_by_section(s1, NULL, NULL);
|
||||
dmuci_delete_by_section(ss, NULL, NULL);
|
||||
}
|
||||
ss = s;
|
||||
found++;
|
||||
}
|
||||
if (ss != NULL){
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(ss), &dmmap_section);
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(s), &dmmap_section);
|
||||
if (dmmap_section != NULL) {
|
||||
dmuci_set_value_by_section(dmmap_section, "greiface_instance", "");
|
||||
dmuci_set_value_by_section(dmmap_section, "greiface_alias", "");
|
||||
}
|
||||
if ((s1 = has_tunnel_interface_route(section_name(ss))) != NULL)
|
||||
dmuci_delete_by_section(s1, NULL, NULL);
|
||||
dmuci_delete_by_section(ss, NULL, NULL);
|
||||
|
||||
if ((ss = has_tunnel_interface_route(section_name(s))) != NULL)
|
||||
dmuci_delete_by_section(ss, NULL, NULL);
|
||||
|
||||
dmuci_delete_by_section(s, NULL, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -296,11 +288,11 @@ static int get_GRETunnel_ConnectedRemoteEndpoint(char *refparam, struct dmctx *c
|
|||
static int get_GRETunnel_InterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
char *ifname;
|
||||
char device_buf[32] = {0};
|
||||
int i = 0;
|
||||
|
||||
dmasprintf(&ifname, "@%s", section_name(((struct dmmap_dup *)data)->config_section));
|
||||
uci_foreach_option_eq("network", "interface", "ifname", ifname, s) {
|
||||
snprintf(device_buf, sizeof(device_buf), "@%s", section_name(((struct dmmap_dup *)data)->config_section));
|
||||
uci_foreach_option_eq("network", "interface", "device", device_buf, s) {
|
||||
i++;
|
||||
}
|
||||
dmasprintf(value, "%d", i);
|
||||
|
|
|
|||
|
|
@ -126,14 +126,14 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
|
||||
/* Higher layers are Device.IP.Interface.{i}. */
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
char *proto, *ifname;
|
||||
char *proto, *device;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifname);
|
||||
dmuci_get_value_by_section_string(s, "device", &device);
|
||||
|
||||
if (strcmp(section_name(s), "loopback") == 0 ||
|
||||
*proto == '\0' ||
|
||||
strchr(ifname, '@'))
|
||||
strchr(device, '@'))
|
||||
continue;
|
||||
|
||||
// Skip if its a provider bridge configuration
|
||||
|
|
@ -262,7 +262,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
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 || (*name != '\0' && !is_vlan_termination_section(name)))
|
||||
if (strcmp(type, "bridge") == 0 || strcmp(type, "untagged") == 0)
|
||||
continue;
|
||||
|
||||
// The higher layer is Device.Ethernet.VLANTermination.{i}.
|
||||
|
|
@ -307,25 +307,28 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
dmuci_get_value_by_section_string(s, "link_alias", &higheralias);
|
||||
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s%s", *higheralias ? higheralias : *layer_inst ? "cpe-" : "", (*higheralias == '\0' && *layer_inst) ? layer_inst : "");
|
||||
|
||||
char *linker, *value = NULL;
|
||||
char *linker, *value = NULL, *device_s_type = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "device", &linker);
|
||||
char *bridge = strstr(linker, "br-");
|
||||
if (bridge) {
|
||||
struct uci_section *br_device_s = get_device_section(linker);
|
||||
if (br_device_s) dmuci_get_value_by_section_string(br_device_s, "type", &device_s_type);
|
||||
|
||||
if (br_device_s && strcmp(device_s_type, "bridge") == 0) {
|
||||
// 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 = NULL;
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_bridge", "bridge", int_name, &dmmap_section);
|
||||
get_dmmap_section_of_config_section("dmmap_bridge", "device", section_name(br_device_s), &dmmap_section);
|
||||
|
||||
if (dmmap_section != NULL) {
|
||||
char *br_inst, *mg;
|
||||
char *br_inst, *mg = NULL;
|
||||
|
||||
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);
|
||||
if (mg && strcmp(mg, "1") == 0) {
|
||||
char *device, linker[512] = {0};
|
||||
|
||||
dmuci_get_value_by_section_string(port, "port", &device);
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+%s", br_inst, section_name(port), device);
|
||||
adm_entry_get_linker_param(dmctx, "Device.Bridging.Bridge.", linker, &value);
|
||||
dmuci_get_value_by_section_string(port, "bridge_port_alias", &loweralias);
|
||||
|
|
@ -366,12 +369,12 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
}
|
||||
|
||||
/* Higher layers are Device.Bridging.Bridge.{i}.Port.{i}.*/
|
||||
uci_path_foreach_sections(bbfdm, "dmmap_bridge", "bridge", s) {
|
||||
uci_path_foreach_sections(bbfdm, "dmmap_bridge", "device", s) {
|
||||
char *br_inst = NULL;
|
||||
|
||||
char *br_inst;
|
||||
dmuci_get_value_by_section_string(s, "bridge_instance", &br_inst);
|
||||
|
||||
if (*br_inst == '\0')
|
||||
if (br_inst && *br_inst == '\0')
|
||||
continue;
|
||||
|
||||
// The higher layer is Device.Bridging.Bridge.{i}.Port.{i}.
|
||||
|
|
@ -379,11 +382,13 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
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;
|
||||
char *mg = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(port, "management", &mg);
|
||||
if (strcmp(mg, "1") == 0) {
|
||||
if (mg && strcmp(mg, "1") == 0) {
|
||||
char *device, linker[512] = {0};
|
||||
dmuci_get_value_by_section_string(port, "device", &device);
|
||||
|
||||
dmuci_get_value_by_section_string(port, "port", &device);
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+%s", br_inst, section_name(port), device);
|
||||
adm_entry_get_linker_param(dmctx, "Device.Bridging.Bridge.", linker, &mg_value);
|
||||
dmuci_get_value_by_section_string(port, "bridge_port_alias", &higheralias);
|
||||
|
|
@ -399,13 +404,13 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
|
||||
struct uci_section *sd = NULL;
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", br_inst, sd) {
|
||||
char *mg;
|
||||
char *mg = NULL;
|
||||
dmuci_get_value_by_section_string(sd, "management", &mg);
|
||||
if (strcmp(mg, "1") == 0)
|
||||
if (mg && strcmp(mg, "1") == 0)
|
||||
continue;
|
||||
|
||||
char *vb = NULL, *device, linker[512] = {0};
|
||||
dmuci_get_value_by_section_string(sd, "device", &device);
|
||||
dmuci_get_value_by_section_string(sd, "port", &device);
|
||||
|
||||
// The lower layer is Device.Bridging.Bridge.{i}.Port.{i}.
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+%s", br_inst, section_name(sd), device);
|
||||
|
|
|
|||
|
|
@ -333,16 +333,16 @@ static void synchronize_intf_ipv6_prefix_sections_with_dmmap(void)
|
|||
static char *get_ip_interface_last_instance(char *package, char *section, char* dmmap_package, char *opt_inst)
|
||||
{
|
||||
struct uci_section *s = NULL, *dmmap_section = NULL;
|
||||
char *instance = NULL, *last_inst = NULL, *proto, *ifname;
|
||||
char *instance = NULL, *last_inst = NULL, *proto, *device;
|
||||
|
||||
uci_foreach_sections(package, section, s) {
|
||||
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifname);
|
||||
dmuci_get_value_by_section_string(s, "device", &device);
|
||||
|
||||
if (strcmp(section_name(s), "loopback") == 0 ||
|
||||
*proto == '\0' ||
|
||||
strchr(ifname, '@'))
|
||||
strchr(device, '@'))
|
||||
continue;
|
||||
|
||||
// skip dhcpv4 sections added by controller
|
||||
|
|
@ -383,27 +383,23 @@ static char *get_ip_interface_last_instance(char *package, char *section, char*
|
|||
static int delete_ip_intertace_instance(struct uci_section *s)
|
||||
{
|
||||
struct uci_section *int_ss = NULL, *int_stmp = NULL;
|
||||
char buf[32], *ifname, *int_sec_name = dmstrdup(section_name(s));
|
||||
char buf[32], *int_device, *int_sec_name = dmstrdup(section_name(s));
|
||||
|
||||
snprintf(buf, sizeof(buf), "@%s", int_sec_name);
|
||||
|
||||
uci_foreach_sections_safe("network", "interface", int_stmp, int_ss) {
|
||||
|
||||
dmuci_get_value_by_section_string(int_ss, "ifname", &ifname);
|
||||
if (strcmp(section_name(int_ss), int_sec_name) != 0 && strcmp(ifname, buf) != 0)
|
||||
dmuci_get_value_by_section_string(int_ss, "device", &int_device);
|
||||
if (strcmp(section_name(int_ss), int_sec_name) != 0 && strcmp(int_device, buf) != 0)
|
||||
continue;
|
||||
|
||||
// Get dmmap section related to this interface section
|
||||
struct uci_section *dmmap_section = NULL;
|
||||
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(int_ss), &dmmap_section);
|
||||
|
||||
// Read the type option from interface section
|
||||
char *type;
|
||||
dmuci_get_value_by_section_string(int_ss, "type", &type);
|
||||
|
||||
// Check the type value ==> if bridge : there is a Bridging.Bridge. object mapped to this interface, remove only proto option from the section
|
||||
// Check the device value ==> if it starts with 'br-' so it is a bridge section : there is a Bridging.Bridge. object mapped to this interface, remove only proto option from the section
|
||||
// Check the type value ==> else : there is no Bridging.Bridge. object mapped to this interface, remove the section
|
||||
if (strcmp(type, "bridge") == 0) {
|
||||
if (int_device && strncmp(int_device, "br-", 3) == 0) {
|
||||
/* type is bridge */
|
||||
|
||||
/* remove only proto option from the interface section and ip instance option from dmmap section */
|
||||
|
|
@ -420,8 +416,8 @@ static int delete_ip_intertace_instance(struct uci_section *s)
|
|||
bool device_found = false;
|
||||
|
||||
uci_foreach_sections("network", "interface", ss) {
|
||||
dmuci_get_value_by_section_string(ss, "ifname", &ifname);
|
||||
if (strcmp(section_name(ss), section_name(int_ss)) != 0 && strcmp(ifname, buf) != 0 && strstr(ifname, device)) {
|
||||
dmuci_get_value_by_section_string(ss, "device", &int_device);
|
||||
if (strcmp(section_name(ss), section_name(int_ss)) != 0 && strcmp(int_device, buf) != 0 && strstr(int_device, device)) {
|
||||
device_found = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -472,9 +468,9 @@ static bool interface_section_with_dhcpv6_exists(const char *sec_name)
|
|||
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
|
||||
char *ifname;
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifname);
|
||||
if (strcmp(ifname, buf) == 0) {
|
||||
char *device;
|
||||
dmuci_get_value_by_section_string(s, "device", &device);
|
||||
if (strcmp(device, buf) == 0) {
|
||||
char *proto;
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
if (strcmp(proto, "dhcpv6") == 0)
|
||||
|
|
@ -489,17 +485,17 @@ static void set_ip_interface_ifname_option(struct uci_section *section, char *li
|
|||
{
|
||||
struct uci_section *s = NULL;
|
||||
bool device_exists = false;
|
||||
char ifname[64];
|
||||
char int_device[64];
|
||||
|
||||
if (is_br_sec) {
|
||||
snprintf(ifname, sizeof(ifname), "%s", linker);
|
||||
snprintf(int_device, sizeof(int_device), "%s", linker);
|
||||
goto end;
|
||||
} else {
|
||||
snprintf(ifname, sizeof(ifname), "%s.1", linker);
|
||||
snprintf(int_device, sizeof(int_device), "%s.1", linker);
|
||||
}
|
||||
|
||||
// Check if device exists
|
||||
uci_foreach_option_eq("network", "device", "name", ifname, s) {
|
||||
uci_foreach_option_eq("network", "device", "name", int_device, s) {
|
||||
device_exists = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -514,17 +510,17 @@ static void set_ip_interface_ifname_option(struct uci_section *section, char *li
|
|||
dmuci_rename_section_by_section(s, device_name);
|
||||
dmuci_set_value_by_section(s, "type", "untagged");
|
||||
dmuci_set_value_by_section(s, "ifname", linker);
|
||||
dmuci_set_value_by_section(s, "name", ifname);
|
||||
dmuci_set_value_by_section(s, "name", int_device);
|
||||
}
|
||||
|
||||
end:
|
||||
dmuci_set_value_by_section(section, "ifname", ifname);
|
||||
dmuci_set_value_by_section(section, "device", int_device);
|
||||
}
|
||||
|
||||
static int delObjIPInterfaceIPv6(void *data, unsigned char del_action, char *dmmap_file_name, char *section_type, char *option_name)
|
||||
{
|
||||
struct uci_section *s = NULL, *stmp = NULL, *dmmap_s = NULL;
|
||||
char *proto, *ifname, buf[32] = {0};
|
||||
char *proto, *device, buf[32] = {0};
|
||||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
|
|
@ -532,8 +528,8 @@ static int delObjIPInterfaceIPv6(void *data, unsigned char del_action, char *dmm
|
|||
if (strcmp(proto, "static") != 0 || interface_section_with_dhcpv6_exists(section_name(((struct intf_ip_args *)data)->interface_sec)))
|
||||
return FAULT_9001;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "ifname", &ifname);
|
||||
if (strchr(ifname, '@')) {
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "device", &device);
|
||||
if (strchr(device, '@')) {
|
||||
dmuci_delete_by_section(((struct intf_ip_args *)data)->interface_sec, NULL, NULL);
|
||||
} else {
|
||||
dmuci_set_value_by_section(((struct intf_ip_args *)data)->interface_sec, option_name, "");
|
||||
|
|
@ -550,14 +546,14 @@ static int delObjIPInterfaceIPv6(void *data, unsigned char del_action, char *dmm
|
|||
|
||||
uci_foreach_sections_safe("network", "interface", stmp, s) {
|
||||
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifname);
|
||||
dmuci_get_value_by_section_string(s, "device", &device);
|
||||
|
||||
if (strcmp(section_name(s), section_name((struct uci_section *)data)) == 0) {
|
||||
dmuci_set_value_by_section(s, option_name, "");
|
||||
|
||||
get_dmmap_section_of_config_section(dmmap_file_name, section_type, section_name(s), &dmmap_s);
|
||||
dmuci_delete_by_section(dmmap_s, NULL, NULL);
|
||||
} else if (strcmp(ifname, buf) == 0) {
|
||||
} else if (strcmp(device, buf) == 0) {
|
||||
get_dmmap_section_of_config_section(dmmap_file_name, section_type, section_name(s), &dmmap_s);
|
||||
dmuci_delete_by_section(dmmap_s, NULL, NULL);
|
||||
|
||||
|
|
@ -578,7 +574,7 @@ static int delObjIPInterfaceIPv6(void *data, unsigned char del_action, char *dmm
|
|||
static int browseIPInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
char *inst = NULL, *max_inst = NULL;
|
||||
char *proto, *ifname;
|
||||
char *proto, *device;
|
||||
struct dmmap_dup *p = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
|
|
@ -586,11 +582,11 @@ static int browseIPInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
list_for_each_entry(p, &dup_list, list) {
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "proto", &proto);
|
||||
dmuci_get_value_by_section_string(p->config_section, "ifname", &ifname);
|
||||
dmuci_get_value_by_section_string(p->config_section, "device", &device);
|
||||
|
||||
if (strcmp(section_name(p->config_section), "loopback") == 0 ||
|
||||
*proto == '\0' ||
|
||||
strchr(ifname, '@'))
|
||||
strchr(device, '@'))
|
||||
continue;
|
||||
|
||||
// skip dhcpv4 sections added by controller
|
||||
|
|
@ -628,7 +624,7 @@ static int browseIPInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
static int browseIPInterfaceIPv4AddressInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct uci_section *parent_sec = (struct uci_section *)prev_data, *intf_s = NULL, *dmmap_s = NULL;
|
||||
char *inst = NULL, *max_inst = NULL, *ipaddr, *added_by_controller = NULL, *ifname, buf[32] = {0};
|
||||
char *inst = NULL, *max_inst = NULL, *ipaddr, *added_by_controller = NULL, *device, buf[32] = {0};
|
||||
json_object *res = NULL, *ipv4_obj = NULL;
|
||||
struct intf_ip_args curr_intf_ip_args = {0};
|
||||
struct browse_args browse_args = {0};
|
||||
|
|
@ -637,8 +633,8 @@ static int browseIPInterfaceIPv4AddressInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
|
||||
uci_foreach_sections("network", "interface", intf_s) {
|
||||
|
||||
dmuci_get_value_by_section_string(intf_s, "ifname", &ifname);
|
||||
if (strcmp(section_name(intf_s), section_name(parent_sec)) != 0 && strcmp(ifname, buf) != 0)
|
||||
dmuci_get_value_by_section_string(intf_s, "device", &device);
|
||||
if (strcmp(section_name(intf_s), section_name(parent_sec)) != 0 && strcmp(device, buf) != 0)
|
||||
continue;
|
||||
|
||||
dmmap_s = check_dmmap_network_interface_ipv4("dmmap_network_ipv4", "intf_ipv4", section_name(parent_sec), section_name(intf_s));
|
||||
|
|
@ -675,7 +671,7 @@ static int browseIPInterfaceIPv4AddressInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
static int browseIPInterfaceIPv6AddressInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct uci_section *parent_sec = (struct uci_section *)prev_data, *intf_s = NULL, *dmmap_s = NULL;
|
||||
char *inst = NULL, *max_inst = NULL, *ifname, *ip6addr, buf[32] = {0};
|
||||
char *inst = NULL, *max_inst = NULL, *device, *ip6addr, buf[32] = {0};
|
||||
json_object *res = NULL, *ipv6_obj = NULL, *arrobj = NULL;
|
||||
struct intf_ip_args curr_intf_ip_args = {0};
|
||||
struct browse_args browse_args = {0};
|
||||
|
|
@ -686,8 +682,8 @@ static int browseIPInterfaceIPv6AddressInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
synchronize_intf_ipv6_sections_with_dmmap();
|
||||
uci_foreach_sections("network", "interface", intf_s) {
|
||||
|
||||
dmuci_get_value_by_section_string(intf_s, "ifname", &ifname);
|
||||
if (strcmp(section_name(intf_s), section_name(parent_sec)) != 0 && strcmp(ifname, buf) != 0)
|
||||
dmuci_get_value_by_section_string(intf_s, "device", &device);
|
||||
if (strcmp(section_name(intf_s), section_name(parent_sec)) != 0 && strcmp(device, buf) != 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(intf_s, "ip6addr", &ip6addr);
|
||||
|
|
@ -757,7 +753,7 @@ static int browseIPInterfaceIPv6AddressInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
}
|
||||
|
||||
// Get ipv6 LinkLocal address
|
||||
if (!strchr(ifname, '@')) {
|
||||
if (!strchr(device, '@')) {
|
||||
|
||||
dmmap_synchronize_ipv6_address_link_local(section_name(parent_sec));
|
||||
|
||||
|
|
@ -790,7 +786,7 @@ end:
|
|||
static int browseIPInterfaceIPv6PrefixInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct uci_section *parent_sec = (struct uci_section *)prev_data, *intf_s = NULL, *dmmap_s = NULL;
|
||||
char *inst = NULL, *max_inst = NULL, *ifname, *ip6prefix, buf[32] = {0}, ipv6_prefix[256] = {0};
|
||||
char *inst = NULL, *max_inst = NULL, *device, *ip6prefix, buf[32] = {0}, ipv6_prefix[256] = {0};
|
||||
json_object *res = NULL, *ipv6_prefix_obj = NULL, *arrobj = NULL;
|
||||
struct intf_ip_args curr_intf_ip_args = {0};
|
||||
struct browse_args browse_args = {0};
|
||||
|
|
@ -801,8 +797,8 @@ static int browseIPInterfaceIPv6PrefixInst(struct dmctx *dmctx, DMNODE *parent_n
|
|||
synchronize_intf_ipv6_prefix_sections_with_dmmap();
|
||||
uci_foreach_sections("network", "interface", intf_s) {
|
||||
|
||||
dmuci_get_value_by_section_string(intf_s, "ifname", &ifname);
|
||||
if (strcmp(section_name(intf_s), section_name(parent_sec)) != 0 && strcmp(ifname, buf) != 0)
|
||||
dmuci_get_value_by_section_string(intf_s, "device", &device);
|
||||
if (strcmp(section_name(intf_s), section_name(parent_sec)) != 0 && strcmp(device, buf) != 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(intf_s, "ip6prefix", &ip6prefix);
|
||||
|
|
@ -911,13 +907,13 @@ static int delObjIPInterface(char *refparam, struct dmctx *ctx, void *data, char
|
|||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_sections_safe("network", "interface", stmp, s) {
|
||||
char *proto, *ifname;
|
||||
char *proto, *device;
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifname);
|
||||
dmuci_get_value_by_section_string(s, "device", &device);
|
||||
|
||||
if (strcmp(section_name(s), "loopback") == 0 ||
|
||||
*proto == '\0' ||
|
||||
strchr(ifname, '@'))
|
||||
strchr(device, '@'))
|
||||
continue;
|
||||
|
||||
delete_ip_intertace_instance(s);
|
||||
|
|
@ -939,13 +935,13 @@ static int addObjIPInterfaceIPv4Address(char *refparam, struct dmctx *ctx, void
|
|||
char *last_inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_network_ipv4", "intf_ipv4", "ipv4_instance", "parent_section", section_name((struct uci_section *)data));
|
||||
|
||||
if (last_inst) {
|
||||
char buf[32] = {0};
|
||||
char device_buf[32] = {0};
|
||||
|
||||
snprintf(ipv4_name, sizeof(ipv4_name), "ip_interface_%s_ipv4_%d", ip_inst, atoi(last_inst) + 1);
|
||||
snprintf(buf, sizeof(buf), "@%s", section_name((struct uci_section *)data));
|
||||
snprintf(device_buf, sizeof(device_buf), "@%s", section_name((struct uci_section *)data));
|
||||
|
||||
dmuci_set_value("network", ipv4_name, "", "interface");
|
||||
dmuci_set_value("network", ipv4_name, "ifname", buf);
|
||||
dmuci_set_value("network", ipv4_name, "device", device_buf);
|
||||
dmuci_set_value("network", ipv4_name, "proto", "static");
|
||||
} else {
|
||||
char *proto;
|
||||
|
|
@ -969,7 +965,7 @@ static int addObjIPInterfaceIPv4Address(char *refparam, struct dmctx *ctx, void
|
|||
static int delObjIPInterfaceIPv4Address(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
||||
{
|
||||
struct uci_section *s = NULL, *stmp = NULL, *dmmap_s = NULL;
|
||||
char *proto, *ifname, buf[32] = {0};
|
||||
char *proto, *device, buf[32] = {0};
|
||||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
|
|
@ -977,8 +973,8 @@ static int delObjIPInterfaceIPv4Address(char *refparam, struct dmctx *ctx, void
|
|||
if (strcmp(proto, "static") != 0)
|
||||
return FAULT_9001;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "ifname", &ifname);
|
||||
if (strchr(ifname, '@')) {
|
||||
dmuci_get_value_by_section_string(((struct intf_ip_args *)data)->interface_sec, "device", &device);
|
||||
if (strchr(device, '@')) {
|
||||
dmuci_delete_by_section(((struct intf_ip_args *)data)->interface_sec, NULL, NULL);
|
||||
} else {
|
||||
dmuci_set_value_by_section(((struct intf_ip_args *)data)->interface_sec, "ipaddr", "");
|
||||
|
|
@ -996,7 +992,7 @@ static int delObjIPInterfaceIPv4Address(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
uci_foreach_sections_safe("network", "interface", stmp, s) {
|
||||
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifname);
|
||||
dmuci_get_value_by_section_string(s, "device", &device);
|
||||
|
||||
if (strcmp(section_name(s), section_name((struct uci_section *)data)) == 0) {
|
||||
dmuci_set_value_by_section(s, "ipaddr", "");
|
||||
|
|
@ -1004,7 +1000,7 @@ static int delObjIPInterfaceIPv4Address(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
get_dmmap_section_of_config_section("dmmap_network_ipv4", "intf_ipv4", section_name(s), &dmmap_s);
|
||||
dmuci_delete_by_section(dmmap_s, NULL, NULL);
|
||||
} else if (strcmp(ifname, buf) == 0) {
|
||||
} else if (strcmp(device, buf) == 0) {
|
||||
get_dmmap_section_of_config_section("dmmap_network_ipv4", "intf_ipv4", section_name(s), &dmmap_s);
|
||||
dmuci_delete_by_section(dmmap_s, NULL, NULL);
|
||||
|
||||
|
|
@ -1020,7 +1016,7 @@ static int delObjIPInterfaceIPv4Address(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
static int addObjIPInterfaceIPv6Address(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *ip_inst = NULL, ipv6_name[64] = {0}, buf[32] = {0};
|
||||
char *ip_inst = NULL, ipv6_name[64] = {0}, device_buf[32] = {0};
|
||||
struct uci_section *dmmap_ip_interface = NULL, *dmmap_ip_interface_ipv6 = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
|
||||
|
|
@ -1029,10 +1025,10 @@ static int addObjIPInterfaceIPv6Address(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
char *last_inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_network_ipv6", "intf_ipv6", "ipv6_instance", "parent_section", section_name((struct uci_section *)data));
|
||||
snprintf(ipv6_name, sizeof(ipv6_name), "ip_interface_%s_ipv6_%d", ip_inst, last_inst ? atoi(last_inst) + 1 : 1);
|
||||
snprintf(buf, sizeof(buf), "@%s", section_name((struct uci_section *)data));
|
||||
snprintf(device_buf, sizeof(device_buf), "@%s", section_name((struct uci_section *)data));
|
||||
|
||||
dmuci_set_value("network", ipv6_name, "", "interface");
|
||||
dmuci_set_value("network", ipv6_name, "ifname", buf);
|
||||
dmuci_set_value("network", ipv6_name, "device", device_buf);
|
||||
dmuci_set_value("network", ipv6_name, "proto", "static");
|
||||
dmuci_set_value("network", ipv6_name, "ip6addr", "::");
|
||||
|
||||
|
|
@ -1055,7 +1051,7 @@ static int delObjIPInterfaceIPv6Address(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
static int addObjIPInterfaceIPv6Prefix(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *ip_inst = NULL, ipv6_prefix_name[64] = {0}, buf[32] = {0};
|
||||
char *ip_inst = NULL, ipv6_prefix_name[64] = {0}, device_buf[32] = {0};
|
||||
struct uci_section *dmmap_ip_interface = NULL, *dmmap_ip_interface_ipv6_prefix = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
|
||||
|
|
@ -1064,10 +1060,10 @@ static int addObjIPInterfaceIPv6Prefix(char *refparam, struct dmctx *ctx, void *
|
|||
|
||||
char *last_inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_network_ipv6_prefix", "intf_ipv6_prefix", "ipv6_prefix_instance", "parent_section", section_name((struct uci_section *)data));
|
||||
snprintf(ipv6_prefix_name, sizeof(ipv6_prefix_name), "ip_interface_%s_ipv6_prefix_%d", ip_inst, last_inst ? atoi(last_inst) + 1 : 1);
|
||||
snprintf(buf, sizeof(buf), "@%s", section_name((struct uci_section *)data));
|
||||
snprintf(device_buf, sizeof(device_buf), "@%s", section_name((struct uci_section *)data));
|
||||
|
||||
dmuci_set_value("network", ipv6_prefix_name, "", "interface");
|
||||
dmuci_set_value("network", ipv6_prefix_name, "ifname", buf);
|
||||
dmuci_set_value("network", ipv6_prefix_name, "device", device_buf);
|
||||
dmuci_set_value("network", ipv6_prefix_name, "proto", "static");
|
||||
dmuci_set_value("network", ipv6_prefix_name, "ip6prefix", "::/64");
|
||||
|
||||
|
|
@ -1219,15 +1215,15 @@ static int get_IP_InterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, vo
|
|||
{
|
||||
struct uci_section *s = NULL;
|
||||
int cnt = 0;
|
||||
char *proto, *ifname;
|
||||
char *proto, *device;
|
||||
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifname);
|
||||
dmuci_get_value_by_section_string(s, "device", &device);
|
||||
|
||||
if (strcmp(section_name(s), "loopback") == 0 ||
|
||||
*proto == '\0' ||
|
||||
strchr(ifname, '@'))
|
||||
strchr(device, '@'))
|
||||
continue;
|
||||
|
||||
cnt++;
|
||||
|
|
@ -1469,7 +1465,7 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
|
|||
char *mac_vlan = strchr(ip_linker, '_');
|
||||
if (mac_vlan) {
|
||||
// Check if there is an interface that has the same ifname ==> if yes, remove it
|
||||
uci_foreach_option_eq_safe("network", "interface", "ifname", ip_linker, stmp, s) {
|
||||
uci_foreach_option_eq_safe("network", "interface", "device", ip_linker, stmp, s) {
|
||||
dmuci_delete_by_section(s, NULL, NULL);
|
||||
}
|
||||
|
||||
|
|
@ -1484,14 +1480,14 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
|
|||
char *vid = strchr(device, '.');
|
||||
if (vid) {
|
||||
*vid = '\0';
|
||||
uci_foreach_option_eq_safe("network", "interface", "ifname", device, stmp, s) {
|
||||
uci_foreach_option_eq_safe("network", "interface", "device", device, stmp, s) {
|
||||
dmuci_delete_by_section(s, NULL, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update ifname list
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "ifname", ip_linker);
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "device", ip_linker);
|
||||
|
||||
} else if (strncmp(value, "Device.Ethernet.Link.", 21) == 0) {
|
||||
|
||||
|
|
@ -1518,16 +1514,16 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
|
|||
// Update the new interface section with proto=none if its proto is empty
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
if (strcmp(section_name(s), interface_list) == 0) {
|
||||
char *proto, *type;
|
||||
char *proto, *device;
|
||||
dmuci_get_value_by_section_string(s, "proto", &proto);
|
||||
dmuci_get_value_by_section_string(s, "type", &type);
|
||||
dmuci_get_value_by_section_string(s, "device", &device);
|
||||
if (*proto == '\0') {
|
||||
dmuci_set_value_by_section(s, "proto", "none");
|
||||
if (!new_eth_link_s && strcmp(type, "bridge") != 0)
|
||||
if (!new_eth_link_s && device && strncmp(device, "br-", 3) != 0)
|
||||
set_ip_interface_ifname_option(s, ip_linker, instance, false);
|
||||
} else {
|
||||
ip_interface_s = true;
|
||||
is_br_sec = (strcmp(type, "bridge") == 0) ? true : false;
|
||||
is_br_sec = (device && strncmp(device, "br-", 3) == 0) ? true : false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ static int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
struct uci_section *ss = NULL;
|
||||
char *dev = "0";
|
||||
|
||||
dmuci_get_value_by_section_string(((struct uci_section *)data), "ifname", &linker);
|
||||
dmuci_get_value_by_section_string(((struct uci_section *)data), "device", &linker);
|
||||
|
||||
// Get wan interface
|
||||
dev = get_device(section_name(((struct uci_section *)data)));
|
||||
|
|
@ -383,7 +383,7 @@ static int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
case VALUESET:
|
||||
adm_entry_get_linker_value(ctx, value, &ppp_linker);
|
||||
if (ppp_linker && *ppp_linker) {
|
||||
dmuci_set_value_by_section(((struct uci_section *)data), "ifname", ppp_linker);
|
||||
dmuci_set_value_by_section(((struct uci_section *)data), "device", ppp_linker);
|
||||
dmfree(ppp_linker);
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -544,6 +544,7 @@ static int browseInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *p
|
|||
|
||||
synchronize_specific_config_sections_with_dmmap("network", "interface", "dmmap_network", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
|
||||
dmuci_get_value_by_section_string(p->config_section, "proto", &proto);
|
||||
if (!strstr(proto, "ppp"))
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -10,12 +10,13 @@
|
|||
*/
|
||||
|
||||
#include "dmentry.h"
|
||||
#include "atm.h"
|
||||
#include "ptm.h"
|
||||
|
||||
struct ptm_args
|
||||
{
|
||||
struct uci_section *ptm_sec;
|
||||
char *ifname;
|
||||
char *device;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -24,17 +25,17 @@ struct ptm_args
|
|||
***************************************************************************/
|
||||
static int get_ptm_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
|
||||
{
|
||||
*linker = (data && ((struct ptm_args *)data)->ifname) ? ((struct ptm_args *)data)->ifname : "";
|
||||
*linker = (data && ((struct ptm_args *)data)->device) ? ((struct ptm_args *)data)->device : "";
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* INIT
|
||||
***************************************************************************/
|
||||
static inline int init_ptm_link(struct ptm_args *args, struct uci_section *s, char *ifname)
|
||||
static inline int init_ptm_link(struct ptm_args *args, struct uci_section *s, char *device)
|
||||
{
|
||||
args->ptm_sec = s;
|
||||
args->ifname = ifname;
|
||||
args->device = device;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +69,7 @@ static int set_ptm_enable(char *refparam, struct dmctx *ctx, void *data, char *i
|
|||
/*#Device.PTM.Link.{i}.Status!SYSFS:/sys/class/net/@Name/operstate*/
|
||||
static int get_ptm_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return get_net_device_status(((struct ptm_args *)data)->ifname, value);
|
||||
return get_net_device_status(((struct ptm_args *)data)->device, value);
|
||||
}
|
||||
|
||||
/*#Device.PTM.Link.{i}.Alias!UCI:dmmap_dsl/ptm-device,@i-1/ptmlinkalias*/
|
||||
|
|
@ -190,7 +191,7 @@ static int set_ptm_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
static inline int ubus_ptm_stats(char **value, const char *stat_mod, void *data)
|
||||
{
|
||||
json_object *res = NULL;
|
||||
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ((struct ptm_args *)data)->ifname, String}}, 1, &res);
|
||||
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ((struct ptm_args *)data)->device, String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "0");
|
||||
*value = dmjson_get_value(res, 2, "statistics", stat_mod);
|
||||
if ((*value)[0] == '\0')
|
||||
|
|
@ -246,54 +247,41 @@ static int add_ptm_link(char *refparam, struct dmctx *ctx, void *data, char **in
|
|||
|
||||
static int delete_ptm_link(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
|
||||
{
|
||||
char *ifname;
|
||||
struct uci_section *s = NULL, *ss = NULL, *ns = NULL, *nss = NULL, *dmmap_section= NULL;
|
||||
struct uci_section *s = NULL, *stmp = NULL, *dmmap_section = NULL;
|
||||
|
||||
switch (del_action) {
|
||||
case DEL_INST:
|
||||
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(((struct ptm_args *)data)->ptm_sec), &dmmap_section);
|
||||
if (dmmap_section != NULL)
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
|
||||
dmuci_delete_by_section(((struct ptm_args *)data)->ptm_sec, NULL, NULL);
|
||||
uci_foreach_option_cont("network", "interface", "ifname", ((struct ptm_args *)data)->ifname, s) {
|
||||
if (ss && ifname!=NULL)
|
||||
wan_remove_dev_interface(ss, ((struct ptm_args *)data)->ifname);
|
||||
ss = s;
|
||||
|
||||
uci_foreach_option_cont("network", "interface", "device", ((struct ptm_args *)data)->device, s) {
|
||||
if (stmp && ((struct ptm_args *)data)->device != NULL)
|
||||
remove_device_from_interface(stmp, ((struct ptm_args *)data)->device);
|
||||
stmp = s;
|
||||
}
|
||||
if (ss != NULL && ifname!=NULL)
|
||||
wan_remove_dev_interface(ss, ((struct ptm_args *)data)->ifname);
|
||||
if (stmp != NULL && ((struct ptm_args *)data)->device != NULL)
|
||||
remove_device_from_interface(stmp, ((struct ptm_args *)data)->device);
|
||||
break;
|
||||
case DEL_ALL:
|
||||
uci_foreach_sections("dsl", "ptm-device", s) {
|
||||
if (ss){
|
||||
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(ss), &dmmap_section);
|
||||
if (dmmap_section != NULL)
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
dmuci_get_value_by_section_string(ss, "device", &ifname);
|
||||
dmuci_delete_by_section(ss, NULL, NULL);
|
||||
uci_foreach_option_cont("network", "interface", "ifname", ifname, ns) {
|
||||
if (nss)
|
||||
wan_remove_dev_interface(nss, ifname);
|
||||
nss = ns;
|
||||
}
|
||||
if (nss != NULL && ifname!=NULL)
|
||||
wan_remove_dev_interface(nss, ifname);
|
||||
}
|
||||
ss = s;
|
||||
}
|
||||
if (ss != NULL) {
|
||||
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(ss), &dmmap_section);
|
||||
if (dmmap_section != NULL)
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
dmuci_get_value_by_section_string(ss, "device", &ifname);
|
||||
dmuci_delete_by_section(ss, NULL, NULL);
|
||||
uci_foreach_option_cont("network", "interface", "ifname", ifname, ns) {
|
||||
if (nss && ifname!=NULL)
|
||||
wan_remove_dev_interface(nss, ifname);
|
||||
uci_foreach_sections_safe("dsl", "ptm-device", stmp, s) {
|
||||
struct uci_section *ns = NULL, *nss = NULL;
|
||||
char *device = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "device", &device);
|
||||
uci_foreach_option_cont("network", "interface", "device", device, ns) {
|
||||
if (nss != NULL && device != NULL)
|
||||
remove_device_from_interface(nss, device);
|
||||
nss = ns;
|
||||
}
|
||||
if (nss != NULL && ifname!=NULL)
|
||||
wan_remove_dev_interface(nss, ifname);
|
||||
if (nss != NULL && device != NULL)
|
||||
remove_device_from_interface(nss, device);
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(s), &dmmap_section);
|
||||
dmuci_delete_by_section(dmmap_section, NULL, NULL);
|
||||
|
||||
dmuci_delete_by_section(s, NULL, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -306,15 +294,15 @@ static int delete_ptm_link(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
/*#Device.PTM.Link.{i}.!UCI:dsl/ptm-device/dmmap_dsl*/
|
||||
static int browsePtmLinkInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
char *inst = NULL, *max_inst = NULL, *ifname;
|
||||
char *inst = NULL, *max_inst = NULL, *device;
|
||||
struct ptm_args curr_ptm_args = {0};
|
||||
struct dmmap_dup *p = NULL;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
synchronize_specific_config_sections_with_dmmap("dsl", "ptm-device", "dmmap_dsl", &dup_list);
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
dmuci_get_value_by_section_string(p->config_section, "device", &ifname);
|
||||
init_ptm_link(&curr_ptm_args, p->config_section, ifname);
|
||||
dmuci_get_value_by_section_string(p->config_section, "device", &device);
|
||||
init_ptm_link(&curr_ptm_args, p->config_section, device);
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 3,
|
||||
p->dmmap_section, "ptmlinkinstance", "ptmlinkalias");
|
||||
|
|
|
|||
8
dmtree/vendor/iopsys/tr181/ethernet.c
vendored
8
dmtree/vendor/iopsys/tr181/ethernet.c
vendored
|
|
@ -38,7 +38,7 @@ static int set_EthernetVLANTermination_MACVLAN(char *refparam, struct dmctx *ctx
|
|||
char *link_instance = NULL, new_name[16] = {0};
|
||||
int name_found = 0;
|
||||
|
||||
uci_foreach_option_eq("network", "interface", "ifname", name, s) {
|
||||
uci_foreach_option_eq("network", "interface", "device", name, s) {
|
||||
|
||||
get_dmmap_section_of_config_section_eq("dmmap", "link", "device", ifname, &dmmap_s);
|
||||
if (dmmap_s) {
|
||||
|
|
@ -53,7 +53,7 @@ static int set_EthernetVLANTermination_MACVLAN(char *refparam, struct dmctx *ctx
|
|||
|
||||
}
|
||||
|
||||
dmuci_set_value_by_section(s, "ifname", new_name);
|
||||
dmuci_set_value_by_section(s, "device", new_name);
|
||||
|
||||
name_found = 1;
|
||||
break;
|
||||
|
|
@ -63,7 +63,7 @@ static int set_EthernetVLANTermination_MACVLAN(char *refparam, struct dmctx *ctx
|
|||
int ifname_found = 0;
|
||||
struct uci_section *ss = NULL;
|
||||
|
||||
uci_foreach_option_eq("network", "interface", "ifname", ifname, ss) {
|
||||
uci_foreach_option_eq("network", "interface", "device", ifname, ss) {
|
||||
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap", "link", "device", ifname, dmmap_s) {
|
||||
char *sec_name;
|
||||
|
|
@ -82,7 +82,7 @@ static int set_EthernetVLANTermination_MACVLAN(char *refparam, struct dmctx *ctx
|
|||
dmuci_set_value_by_section(dmmap_s, "section_name", section_name(ss));
|
||||
}
|
||||
|
||||
dmuci_set_value_by_section(ss, "ifname", new_name);
|
||||
dmuci_set_value_by_section(ss, "device", new_name);
|
||||
|
||||
ifname_found = 1;
|
||||
break;
|
||||
|
|
|
|||
84
dmtree/vendor/iopsys/tr181/x_iopsys_eu_igmp.c
vendored
84
dmtree/vendor/iopsys/tr181/x_iopsys_eu_igmp.c
vendored
|
|
@ -14,27 +14,21 @@
|
|||
|
||||
static void get_mcast_iface_key(char *p_ifname, char *key, size_t key_size)
|
||||
{
|
||||
struct uci_section *n_sec = NULL;
|
||||
char *intf_name;
|
||||
struct uci_section *s = NULL;
|
||||
|
||||
uci_foreach_sections("network", "interface", n_sec) {
|
||||
bool itf_found = 0;
|
||||
dmuci_get_value_by_section_string(n_sec, "ifname", &intf_name);
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
char *intf_device = NULL, *pch = NULL, *spch = NULL;
|
||||
|
||||
intf_name = dmstrdup(intf_name);
|
||||
char *pch, *spch;
|
||||
pch = strtok_r(intf_name, " ", &spch);
|
||||
dmuci_get_value_by_section_string(s, "device", &intf_device);
|
||||
|
||||
pch = strtok_r(intf_device, " ", &spch);
|
||||
while (pch != NULL) {
|
||||
if (strcmp(pch, p_ifname) == 0) {
|
||||
DM_STRNCPY(key, section_name(n_sec), key_size);
|
||||
itf_found = 1;
|
||||
break;
|
||||
DM_STRNCPY(key, section_name(s), key_size);
|
||||
return;
|
||||
}
|
||||
pch = strtok_r(NULL, " ", &spch);
|
||||
}
|
||||
|
||||
if (itf_found)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -84,30 +78,35 @@ static void add_empty_mcast_iface_to_list(char *dmmap_package, char *dmmap_sec,
|
|||
struct uci_section *s, struct list_head *dup_list)
|
||||
{
|
||||
struct uci_section *dmmap_sect = NULL;
|
||||
char *f_ifname;
|
||||
|
||||
uci_path_foreach_option_eq(bbfdm, dmmap_package, dmmap_sec, "section_name", section_name(s), dmmap_sect) {
|
||||
char *f_ifname = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(dmmap_sect, "ifname", &f_ifname);
|
||||
|
||||
if (strcmp(f_ifname, "") == 0)
|
||||
if (f_ifname && *f_ifname == '\0')
|
||||
add_dmmap_config_dup_list(dup_list, s, dmmap_sect, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void get_mcast_bridge_port_linker(struct dmctx *ctx, char *intf_name, char **value)
|
||||
void get_mcast_bridge_port_linker(struct dmctx *ctx, char *device_name, char **value)
|
||||
{
|
||||
struct uci_section *dmmap_br_section = NULL, *bridge_port_s = NULL;
|
||||
|
||||
*value = NULL;
|
||||
get_dmmap_section_of_config_section("dmmap_bridge", "bridge", intf_name, &dmmap_br_section);
|
||||
get_dmmap_section_of_config_section("dmmap_bridge", "device", device_name, &dmmap_br_section);
|
||||
if (dmmap_br_section != NULL) {
|
||||
char *br_inst, *mg;
|
||||
char *br_inst;
|
||||
|
||||
dmuci_get_value_by_section_string(dmmap_br_section, "bridge_instance", &br_inst);
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", br_inst, bridge_port_s) {
|
||||
char *mg = NULL;
|
||||
|
||||
dmuci_get_value_by_section_string(bridge_port_s, "management", &mg);
|
||||
if (strcmp(mg, "1") == 0) {
|
||||
if (mg && strcmp(mg, "1") == 0) {
|
||||
char *device, linker[512] = "";
|
||||
dmuci_get_value_by_section_string(bridge_port_s, "device", &device);
|
||||
|
||||
dmuci_get_value_by_section_string(bridge_port_s, "port", &device);
|
||||
snprintf(linker, sizeof(linker), "br_%s:%s+%s", br_inst, section_name(bridge_port_s), device);
|
||||
adm_entry_get_linker_param(ctx, "Device.Bridging.Bridge.", linker, value);
|
||||
break;
|
||||
|
|
@ -256,27 +255,31 @@ int get_mcast_snooping_interface_val(char *value, char *ifname, size_t s_ifname)
|
|||
|
||||
/* Find out bridge section name using bridge key. */
|
||||
struct uci_section *s = NULL;
|
||||
char *sec_name;
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge", "bridge", "bridge_instance", key, s) {
|
||||
dmuci_get_value_by_section_string(s, "section_name", &sec_name);
|
||||
char *device_sec_name = NULL;
|
||||
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge", "device", "bridge_instance", key, s) {
|
||||
dmuci_get_value_by_section_string(s, "section_name", &device_sec_name);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!device_sec_name)
|
||||
return -1;
|
||||
|
||||
// Check if network uci file has this section, if yes, then
|
||||
// update the snooping interface with value as br-<section name>
|
||||
struct uci_section *intf_s = NULL;
|
||||
uci_foreach_sections("network", "interface", intf_s) {
|
||||
char sec[20] = {0};
|
||||
DM_STRNCPY(sec, section_name(intf_s), sizeof(sec));
|
||||
if (strncmp(sec, sec_name, sizeof(sec)) != 0)
|
||||
struct uci_section *device_s = NULL;
|
||||
uci_foreach_sections("network", "device", device_s) {
|
||||
|
||||
if (strcmp(section_name(device_s), device_sec_name) != 0)
|
||||
continue;
|
||||
|
||||
char *type;
|
||||
dmuci_get_value_by_section_string(intf_s, "type", &type);
|
||||
char *type, *name;
|
||||
dmuci_get_value_by_section_string(device_s, "type", &type);
|
||||
if (*type == '\0' || strcmp(type, "bridge") != 0)
|
||||
continue;
|
||||
|
||||
snprintf(ifname, s_ifname, "br-%s", sec_name);
|
||||
dmuci_get_value_by_section_string(device_s, "name", &name);
|
||||
snprintf(ifname, s_ifname, "%s", name);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1065,7 +1068,7 @@ static void get_igmpp_iface_del_key_val(char *key, size_t key_size, char *if_nam
|
|||
} else {
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
if(strcmp(section_name(s), if_name) == 0) {
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifval);
|
||||
dmuci_get_value_by_section_string(s, "device", &ifval);
|
||||
DM_STRNCPY(key, ifval, key_size);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1777,11 +1780,7 @@ static void set_igmpp_iface_val(void *data, char *instance, char *linker, char *
|
|||
"section_name", section_name((struct uci_section *)data), d_sec) {
|
||||
dmuci_get_value_by_section_string(d_sec, "iface_instance", &f_inst);
|
||||
if (strcmp(instance, f_inst) == 0) {
|
||||
if (is_br)
|
||||
dmuci_set_value_by_section(d_sec, "ifname", interface_linker);
|
||||
else
|
||||
dmuci_set_value_by_section(d_sec, "ifname", linker);
|
||||
|
||||
dmuci_set_value_by_section(d_sec, "ifname", is_br ? interface_linker : linker);
|
||||
dmuci_get_value_by_section_string(d_sec, "upstream", &up);
|
||||
string_to_bool(up, &b);
|
||||
sync_proxy_interface_sections((struct uci_section *)data,
|
||||
|
|
@ -1818,7 +1817,8 @@ static int set_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *da
|
|||
adm_entry_get_linker_value(ctx, value, &linker);
|
||||
if (linker && *linker) {
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
if(strcmp(section_name(s), linker) != 0)
|
||||
|
||||
if (strcmp(section_name(s), linker) != 0)
|
||||
continue;
|
||||
|
||||
dmuci_get_value_by_section_string(s, "type", &if_type);
|
||||
|
|
@ -1826,7 +1826,7 @@ static int set_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *da
|
|||
dmasprintf(&interface_linker, "br-%s", linker);
|
||||
is_br = true;
|
||||
} else {
|
||||
dmuci_get_value_by_section_string(s, "ifname", &interface_linker);
|
||||
dmuci_get_value_by_section_string(s, "device", &interface_linker);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -1936,8 +1936,8 @@ static int set_igmpp_interface_upstream(char *refparam, struct dmctx *ctx, void
|
|||
DM_STRNCPY(key, ifname, sizeof(key));
|
||||
} else {
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
if(strcmp(section_name(s), ifname) == 0) {
|
||||
dmuci_get_value_by_section_string(s, "ifname", &ifval);
|
||||
if (strcmp(section_name(s), ifname) == 0) {
|
||||
dmuci_get_value_by_section_string(s, "device", &ifval);
|
||||
DM_STRNCPY(key, ifval, sizeof(key));
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
4
dmtree/vendor/iopsys/tr181/x_iopsys_eu_mld.c
vendored
4
dmtree/vendor/iopsys/tr181/x_iopsys_eu_mld.c
vendored
|
|
@ -505,7 +505,7 @@ static int set_mldp_interface_iface(char *refparam, struct dmctx *ctx, void *dat
|
|||
if (strcmp(if_type, "bridge") == 0)
|
||||
dmasprintf(&interface_linker, "br-%s", linker);
|
||||
else
|
||||
dmuci_get_value_by_section_string(s, "ifname", &interface_linker);
|
||||
dmuci_get_value_by_section_string(s, "device", &interface_linker);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -587,7 +587,7 @@ static int get_mldp_interface_iface(char *refparam, struct dmctx *ctx, void *dat
|
|||
// it is a L3 interface, get the section name from device name to construct the linker
|
||||
struct uci_section *intf_s = NULL;
|
||||
uci_foreach_sections("network", "interface", intf_s) {
|
||||
dmuci_get_value_by_section_string(intf_s, "ifname", &device_name);
|
||||
dmuci_get_value_by_section_string(intf_s, "device", &device_name);
|
||||
if (strcmp(device_name, mldp_ifname) == 0) {
|
||||
tmp_linker = dmstrdup(section_name(intf_s));
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -259,28 +259,6 @@ void update_section_list(char *config, char *section, char *option, int number,
|
|||
}
|
||||
}
|
||||
|
||||
int wan_remove_dev_interface(struct uci_section *interface_setion, char *dev)
|
||||
{
|
||||
char *ifname, new_ifname[64], *p, *pch = NULL, *spch = NULL;
|
||||
new_ifname[0] = '\0';
|
||||
p = new_ifname;
|
||||
dmuci_get_value_by_section_string(interface_setion, "ifname", &ifname);
|
||||
for (pch = strtok_r(ifname, " ", &spch); pch; pch = strtok_r(NULL, " ", &spch)) {
|
||||
if (!strstr(pch, dev)) {
|
||||
if (new_ifname[0] != '\0') {
|
||||
dmstrappendchr(p, ' ');
|
||||
}
|
||||
dmstrappendstr(p, pch);
|
||||
}
|
||||
}
|
||||
dmstrappendend(p);
|
||||
if (new_ifname[0] == '\0')
|
||||
dmuci_delete_by_section(interface_setion, NULL, NULL);
|
||||
else
|
||||
dmuci_set_value_by_section(interface_setion, "ifname", new_ifname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hex_to_ip(char *address, char *ret)
|
||||
{
|
||||
unsigned int ip[4] = {0};
|
||||
|
|
|
|||
|
|
@ -228,7 +228,6 @@ void remove_new_line(char *buf);
|
|||
int dmcmd(char *cmd, int n, ...);
|
||||
int dmcmd_no_wait(char *cmd, int n, ...);
|
||||
void update_section_list(char *config, char *section, char *option, int number, char *filter, char *option1, char *val1, char *option2, char *val2);
|
||||
int wan_remove_dev_interface(struct uci_section *interface_setion, char *dev);
|
||||
void hex_to_ip(char *address, char *ret);
|
||||
void add_dmmap_config_dup_list(struct list_head *dup_list, struct uci_section *config_section, struct uci_section *dmmap_section, void* additional_attribute);
|
||||
void free_dmmap_config_dup_list(struct list_head *dup_list);
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ static void test_bbf_api_uci(void **state)
|
|||
assert_string_equal(value, "");
|
||||
|
||||
// dmuci_get_value_by_section_string: test with correct option name
|
||||
uci_res = dmuci_get_value_by_section_string(uci_s, "ifname", &value);
|
||||
uci_res = dmuci_get_value_by_section_string(uci_s, "device", &value);
|
||||
assert_int_equal(uci_res, 0);
|
||||
assert_string_equal(value, "lo");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
config interface 'loopback'
|
||||
option ifname 'lo'
|
||||
option device 'lo'
|
||||
option proto 'static'
|
||||
option ipaddr '127.0.0.1'
|
||||
option netmask '255.0.0.0'
|
||||
|
|
@ -8,10 +8,10 @@ config interface 'wan'
|
|||
option proto 'dhcp'
|
||||
option hostname 'iopsysWrt-00220775DC6C'
|
||||
option vendorid 'eg400'
|
||||
option ifname 'eth0'
|
||||
option device 'eth0'
|
||||
option reqopts '43'
|
||||
|
||||
config interface 'wan6'
|
||||
option proto 'dhcpv6'
|
||||
option ifname '@wan'
|
||||
option device '@wan'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue