T#9830: deprecate support for vid in macvlan and add a vendor extension object to handle MACVLAN

This commit is contained in:
Amin Ben Romdhane 2023-03-22 15:19:03 +00:00
parent b969a0c491
commit cd0f907fbf
12 changed files with 1217 additions and 1055 deletions

View file

@ -45,19 +45,22 @@ void remove_device_from_interface(struct uci_section *interface_s, char *device)
char new_device[64] = {0};
unsigned pos = 0;
if (!interface_s || !device)
return;
dmuci_get_value_by_section_string(interface_s, "device", &curr_device);
if (DM_STRLEN(curr_device) == 0)
return;
new_device[0] = '\0';
if (device != NULL) {
char *pch = NULL, *spch = NULL;
for (pch = strtok_r(curr_device, " ", &spch); pch; pch = strtok_r(NULL, " ", &spch)) {
char *pch = NULL, *spch = NULL;
for (pch = strtok_r(curr_device, " ", &spch); pch; pch = strtok_r(NULL, " ", &spch)) {
if (strcmp(pch, device) == 0)
continue;
if (strcmp(pch, device) == 0)
continue;
pos += snprintf(&new_device[pos], sizeof(new_device) - pos, "%s ", pch);
}
pos += snprintf(&new_device[pos], sizeof(new_device) - pos, "%s ", pch);
}
if (pos)
@ -122,32 +125,27 @@ static int delete_atm_link(char *refparam, struct dmctx *ctx, void *data, char *
switch (del_action) {
case DEL_INST:
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 (stmp != NULL && ((struct atm_args *)data)->device != NULL)
remove_device_from_interface(stmp, ((struct atm_args *)data)->device);
}
dmuci_delete_by_section((((struct atm_args *)data)->sections)->dmmap_section, NULL, NULL);
dmuci_delete_by_section((((struct atm_args *)data)->sections)->config_section, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections_safe("dsl", "atm-device", stmp, s) {
struct uci_section *ns = NULL, *nss = NULL, *dmmap_section = NULL;
struct uci_section *ns = 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 && device != NULL)
remove_device_from_interface(nss, device);
if (DM_STRLEN(device) == 0)
continue;
get_dmmap_section_of_config_section("dmmap_dsl", "atm-device", section_name(s), &dmmap_section);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
uci_foreach_option_cont("network", "interface", "device", device, ns) {
remove_device_from_interface(ns, device);
}
get_dmmap_section_of_config_section("dmmap_dsl", "atm-device", section_name(s), &ns);
dmuci_delete_by_section(ns, NULL, NULL);
dmuci_delete_by_section(s, NULL, NULL);
}

File diff suppressed because it is too large Load diff

View file

@ -28,9 +28,6 @@ extern DMLEAF tEthernetVLANTerminationParams[];
extern DMLEAF tEthernetVLANTerminationStatsParams[];
extern DMLEAF tEthernetRMONStatsParams[];
struct uci_section *ethernet___get_device_section(char *dev_name);
bool ethernet___check_vlan_termination_section(const char *name);
bool ethernet___check_section_in_curr_section(const char *curr_section, const char *section);
bool ethernet___name_exists_in_devices(char *name);
#endif //__ETHERNET_H

View file

@ -37,7 +37,7 @@ static char *get_instance_by_section(int mode, char *dmmap_config, char *section
return instance;
}
static char *get_instance_by_section_option_condition(int mode, char *dmmap_config, char *section, struct uci_section *s, char *option, char *value, char *instance_option, char *alias_option)
static char *get_instance_by_section_option_condition(int mode, char *dmmap_config, char *section, char *option, char *value, char *instance_option, char *alias_option)
{
struct uci_section *dmmap_section = NULL;
char *instance = "";
@ -124,7 +124,11 @@ 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, *device_s;
char *proto = NULL;
char *device_s = NULL;
char *value = NULL;
bool found = false;
char *device = get_device(section_name(s));
dmuci_get_value_by_section_string(s, "proto", &proto);
dmuci_get_value_by_section_string(s, "device", &device_s);
@ -139,123 +143,153 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "interface", "section_name", section_name(s), "ip_int_instance", "ip_int_alias");
if (*layer_inst == '\0')
continue;
snprintf(buf_higherlayer, sizeof(buf_higherlayer), "Device.IP.Interface.%s", layer_inst);
higheralias = get_alias_by_section("dmmap_network", "interface", s, "ip_int_alias");
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s%s", *higheralias ? higheralias : *layer_inst ? "cpe-" : "", (*higheralias == '\0' && *layer_inst) ? layer_inst : "");
if (DM_LSTRSTR(proto, "ppp")) {
// The lower layer is Device.PPP.Interface.{i}.
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "interface", "section_name", section_name(s), "ppp_int_instance", "ppp_int_alias");
if (*layer_inst == '\0')
continue;
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "Device.PPP.Interface.%s", layer_inst);
loweralias = get_alias_by_section("dmmap_network", "interface", s, "ppp_int_alias");
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s%s", *loweralias ? loweralias : "cpe-", (*loweralias == '\0') ? layer_inst : "");
} else {
// The lower layer is Device.Ethernet.VLANTermination.{i}.
char *value = NULL;
int found = 0;
char *device = get_device(section_name(s));
/* If the device value is empty, then get its value directly from device option */
if (DM_STRLEN(device) == 0) device = device_s;
/* If the device value is empty, then get its value directly from device option */
if (*device == '\0')
dmuci_get_value_by_section_string(s, "device", &device);
if (DM_STRLEN(device) == 0)
continue;
if (device[0] != '\0') {
struct uci_section *vlan_sect = NULL;
adm_entry_get_linker_param(dmctx, "Device.Ethernet.VLANTermination.", device, &value);
uci_foreach_option_eq("network", "device", "name", device, vlan_sect) {
loweralias = get_alias_by_section("dmmap_network", "device", vlan_sect, "vlan_term_alias");
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "device", "section_name", section_name(vlan_sect), "vlan_term_instance", "vlan_term_alias");
break;
}
if (value != NULL)
found = 1;
}
struct uci_section *dev_s = get_dup_section_in_config_opt("network", "device", "name", device);
if (found == 0) {
// The lower layer is Device.Ethernet.Link.{i}.
char linker[32] = {0};
if (device[0] != '\0') {
DM_STRNCPY(linker, device, sizeof(linker));
char *vid = DM_STRCHR(linker, '.');
if (vid) *vid = '\0';
} else {
struct uci_section *ss = NULL;
get_dmmap_section_of_config_section_eq("dmmap", "link", "section_name", section_name(s), &ss);
dmuci_get_value_by_section_string(ss, "linker", &device);
DM_STRNCPY(linker, device, sizeof(linker));
}
adm_entry_get_linker_param(dmctx, "Device.Ethernet.Link.", linker, &value);
loweralias = get_alias_by_section_option_condition("dmmap", "link", "section_name", section_name(s), "link_alias");
layer_inst = get_instance_by_section_option_condition(dmctx->instance_mode, "dmmap", "link", s, "section_name", section_name(s), "link_instance", "link_alias");
if (value == NULL)
value = "";
}
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value ? value : "");
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s%s", *loweralias ? loweralias : *layer_inst ? "cpe-" : "", (*loweralias == '\0' && *layer_inst) ? layer_inst : "");
// The lower layer is Device.PPP.Interface.{i}.
adm_entry_get_linker_param(dmctx, "Device.PPP.Interface.", device, &value);
if (DM_STRLEN(value)) {
found = true;
loweralias = get_alias_by_section_option_condition("dmmap_ppp", "interface", "iface_name", section_name(s), "ppp_int_alias");
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_ppp", "interface", "iface_name", section_name(s), "ppp_int_instance", "ppp_int_alias");
}
// The lower layer is Device.Ethernet.X_IOPSYS_EU_MACVLAN.{i}.
if (found == false) {
adm_entry_get_linker_param(dmctx, "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN", device, &value);
if (DM_STRLEN(value)) {
found = true;
loweralias = get_alias_by_section("dmmap_network", "device", dev_s, "mac_vlan_alias");
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "device", "section_name", section_name(dev_s), "mac_vlan_instance", "mac_vlan_alias");
}
}
// The lower layer is Device.Ethernet.VLANTermination.{i}.
if (found == false) {
adm_entry_get_linker_param(dmctx, "Device.Ethernet.VLANTermination.", device, &value);
if (DM_STRLEN(value)) {
found = true;
loweralias = get_alias_by_section("dmmap_network", "device", dev_s, "vlan_term_alias");
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "device", "section_name", section_name(dev_s), "vlan_term_instance", "vlan_term_alias");
}
}
// The lower layer is Device.Ethernet.Link.{i}.
if (found == false) {
adm_entry_get_linker_param(dmctx, "Device.Ethernet.Link.", device, &value);
loweralias = get_alias_by_section_option_condition("dmmap_ethernet", "link", "device", device, "link_alias");
layer_inst = get_instance_by_section_option_condition(dmctx->instance_mode, "dmmap_ethernet", "link", "device", device, "link_instance", "link_alias");
}
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value ? value : "");
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s%s", *loweralias ? loweralias : *layer_inst ? "cpe-" : "", (*loweralias == '\0' && *layer_inst) ? layer_inst : "");
if (create_and_link_interface_stack_instance(dmctx, parent_node, buf_higherlayer, buf_lowerlayer, buf_higheralias, buf_loweralias, &instance))
goto end;
}
/* Higher layers are Device.PPP.Interface.{i}. */
uci_foreach_sections("network", "interface", s) {
char *proto;
dmuci_get_value_by_section_string(s, "proto", &proto);
if (!DM_LSTRSTR(proto, "ppp"))
uci_path_foreach_sections(bbfdm, "dmmap_ppp", "interface", s) {
char *ppp_device = NULL;
char *value = NULL;
bool found = false;
dmuci_get_value_by_section_string(s, "device", &ppp_device);
if (DM_STRLEN(ppp_device) == 0)
continue;
// The higher layer is Device.PPP.Interface.{i}.
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "interface", "section_name", section_name(s), "ppp_int_instance", "ppp_int_alias");
dmuci_get_value_by_section_string(s, "ppp_int_instance", &layer_inst);
if (*layer_inst == '\0')
continue;
snprintf(buf_higherlayer, sizeof(buf_higherlayer), "Device.PPP.Interface.%s", layer_inst);
higheralias = get_alias_by_section("dmmap_network", "interface", s, "ppp_int_alias");
dmuci_get_value_by_section_string(s, "ppp_int_alias", &higheralias);
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s%s", *higheralias ? higheralias : *layer_inst ? "cpe-" : "", (*higheralias == '\0' && *layer_inst) ? layer_inst : "");
char *value = NULL;
int found = 0;
struct uci_section *dev_s = get_dup_section_in_config_opt("network", "device", "name", ppp_device);
// The lower layer is Device.Ethernet.X_IOPSYS_EU_MACVLAN.{i}.
adm_entry_get_linker_param(dmctx, "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN", ppp_device, &value);
if (DM_STRLEN(value)) {
found = true;
loweralias = get_alias_by_section("dmmap_network", "device", dev_s, "mac_vlan_alias");
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "device", "section_name", section_name(dev_s), "mac_vlan_instance", "mac_vlan_alias");
}
// The lower layer is Device.Ethernet.VLANTermination.{i}.
char *ppp_device = get_device(section_name(s));
/* If the device value is empty, then get its value directly from device option */
if (*ppp_device == '\0')
dmuci_get_value_by_section_string(s, "device", &ppp_device);
if (ppp_device[0] != '\0') {
struct uci_section *vlan_sect = NULL;
if (found == 0) {
adm_entry_get_linker_param(dmctx, "Device.Ethernet.VLANTermination.", ppp_device, &value);
uci_foreach_option_eq("network", "device", "name", ppp_device, vlan_sect) {
loweralias = get_alias_by_section("dmmap_network", "device", vlan_sect, "vlan_term_alias");
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "device", "section_name", section_name(vlan_sect), "vlan_term_instance", "vlan_term_alias");
break;
if (DM_STRLEN(value)) {
found = true;
loweralias = get_alias_by_section("dmmap_network", "device", dev_s, "vlan_term_alias");
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "device", "section_name", section_name(dev_s), "vlan_term_instance", "vlan_term_alias");
}
if (value != NULL)
found = 1;
}
if (found == 0) {
// The lower layer is Device.Ethernet.Link.{i}.
char linker[32] = {0};
DM_STRNCPY(linker, ppp_device, sizeof(linker));
char *vid = DM_STRCHR(linker, '.');
if (vid) *vid = '\0';
adm_entry_get_linker_param(dmctx, "Device.Ethernet.Link.", linker, &value);
loweralias = get_alias_by_section("dmmap", "link", s, "link_alias");
layer_inst = get_instance_by_section_option_condition(dmctx->instance_mode, "dmmap", "link", s, "section_name", section_name(s), "link_instance", "link_alias");
if (value == NULL)
value = "";
adm_entry_get_linker_param(dmctx, "Device.Ethernet.Link.", ppp_device, &value);
loweralias = get_alias_by_section_option_condition("dmmap_ethernet", "link", "device", ppp_device, "link_alias");
layer_inst = get_instance_by_section_option_condition(dmctx->instance_mode, "dmmap_ethernet", "link", "device", ppp_device, "link_instance", "link_alias");
}
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value);
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value ? value : "");
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s%s", *loweralias ? loweralias : *layer_inst ? "cpe-" : "", (*loweralias == '\0' && *layer_inst) ? layer_inst : "");
if (create_and_link_interface_stack_instance(dmctx, parent_node, buf_higherlayer, buf_lowerlayer, buf_higheralias, buf_loweralias, &instance))
goto end;
}
/* Higher layers are Device.Ethernet.X_IOPSYS_EU_MACVLAN.{i}. */
uci_foreach_option_eq("network", "device", "type", "macvlan", s) {
char *value = NULL;
char *ifname = NULL;
bool found = false;
// The higher layer is Device.Ethernet.X_IOPSYS_EU_MACVLAN.{i}.
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "device", "section_name", section_name(s), "mac_vlan_instance", "mac_vlan_alias");
if (*layer_inst == '\0')
continue;
dmuci_get_value_by_section_string(s, "ifname", &ifname);
if (DM_STRLEN(ifname) == 0)
continue;
snprintf(buf_higherlayer, sizeof(buf_higherlayer), "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.%s", layer_inst);
higheralias = get_alias_by_section("dmmap_network", "device", s, "mac_vlan_alias");
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s%s", *higheralias ? higheralias : *layer_inst ? "cpe-" : "", (*higheralias == '\0' && *layer_inst) ? layer_inst : "");
// The lower layer is Device.Ethernet.VLANTermination.{i}.
adm_entry_get_linker_param(dmctx, "Device.Ethernet.VLANTermination.", ifname, &value);
if (DM_STRLEN(value)) {
found = true;
struct uci_section *dev_s = get_dup_section_in_config_opt("network", "device", "name", ifname);
loweralias = get_alias_by_section("dmmap_network", "device", dev_s, "vlan_term_alias");
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "device", "section_name", section_name(dev_s), "vlan_term_instance", "vlan_term_alias");
}
if (found == 0) {
// The lower layer is Device.Ethernet.Link.{i}.
adm_entry_get_linker_param(dmctx, "Device.Ethernet.Link.", ifname, &value);
loweralias = get_alias_by_section_option_condition("dmmap_ethernet", "link", "device", ifname, "link_alias");
layer_inst = get_instance_by_section_option_condition(dmctx->instance_mode, "dmmap_ethernet", "link", "device", ifname, "link_instance", "link_alias");
}
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value ? value : "");
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s%s", *loweralias ? loweralias : *layer_inst ? "cpe-" : "", (*loweralias == '\0' && *layer_inst) ? layer_inst : "");
if (create_and_link_interface_stack_instance(dmctx, parent_node, buf_higherlayer, buf_lowerlayer, buf_higheralias, buf_loweralias, &instance))
@ -265,7 +299,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
/* Higher layers are Device.Ethernet.VLANTermination.{i}. */
uci_foreach_sections("network", "device", s) {
struct uci_section *dmmap_section = NULL;
char *type, *name, *ifname, *is_vlan, *value = NULL;
char *type = NULL, *name = NULL, *ifname = NULL, *is_vlan = NULL, *value = NULL;
get_dmmap_section_of_config_section("dmmap_network", "device", section_name(s), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "is_vlan_ter", &is_vlan);
@ -274,6 +308,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
dmuci_get_value_by_section_string(s, "name", &name);
dmuci_get_value_by_section_string(s, "ifname", &ifname);
if (DM_LSTRCMP(type, "bridge") == 0 ||
DM_LSTRCMP(type, "macvlan") == 0 ||
(*name == 0 && DM_LSTRCMP(is_vlan, "1") != 0) ||
(*name != 0 && !ethernet___check_vlan_termination_section(name)))
continue;
@ -288,32 +323,18 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
higheralias = get_alias_by_section("dmmap_network", "device", s, "vlan_term_alias");
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s%s", *higheralias ? higheralias : *layer_inst ? "cpe-" : "", (*higheralias == '\0' && *layer_inst) ? layer_inst : "");
// The lower layer can be Device.Ethernet.VLANTermination.{i}. or Device.Ethernet.Link.{i}.
if (DM_LSTRNCMP(type, "8021ad", 6) == 0) {
// The lower layer is Device.Ethernet.VLANTermination.{i}.
struct uci_section *vlan_sect = NULL;
struct uci_section *dev_s = get_dup_section_in_config_opt("network", "device", "name", ifname);
adm_entry_get_linker_param(dmctx, "Device.Ethernet.VLANTermination.", ifname, &value);
uci_foreach_option_eq("network", "device", "name", ifname, vlan_sect) {
loweralias = get_alias_by_section("dmmap_network", "device", vlan_sect, "vlan_term_alias");
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "device", "section_name", section_name(vlan_sect), "vlan_term_instance", "vlan_term_alias");
break;
}
loweralias = get_alias_by_section("dmmap_network", "device", dev_s, "vlan_term_alias");
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "device", "section_name", section_name(dev_s), "vlan_term_instance", "vlan_term_alias");
} else {
// The lower layer is Device.Ethernet.Link.{i}.
struct uci_section *link_s = NULL;
bool is_ifname = false;
adm_entry_get_linker_param(dmctx, "Device.Ethernet.Link.", name, &value);
if (!value || *value == 0) {
is_ifname = true;
adm_entry_get_linker_param(dmctx, "Device.Ethernet.Link.", ifname, &value);
}
get_dmmap_section_of_config_section_eq("dmmap", "link", "device", is_ifname ? ifname : name, &link_s);
dmuci_get_value_by_section_string(link_s, "link_instance", &layer_inst);
dmuci_get_value_by_section_string(link_s, "link_alias", &loweralias);
adm_entry_get_linker_param(dmctx, "Device.Ethernet.Link.", ifname, &value);
loweralias = get_alias_by_section_option_condition("dmmap_ethernet", "link", "device", ifname, "link_alias");
layer_inst = get_instance_by_section_option_condition(dmctx->instance_mode, "dmmap_ethernet", "link", "device", ifname, "link_instance", "link_alias");
}
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value ? value : "");
@ -324,7 +345,10 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
}
/* Higher layers are Device.Ethernet.Link.{i}. */
uci_path_foreach_sections(bbfdm, DMMAP, "link", s) {
uci_path_foreach_sections(bbfdm, "dmmap_ethernet", "link", s) {
char *linker = NULL;
char *value = NULL;
bool found = false;
// The higher layer is Device.Ethernet.Link.{i}.
dmuci_get_value_by_section_string(s, "link_instance", &layer_inst);
@ -336,45 +360,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, *device_s_type = NULL;
dmuci_get_value_by_section_string(s, "device", &linker);
struct uci_section *br_device_s = ethernet___get_device_section(linker);
if (br_device_s) dmuci_get_value_by_section_string(br_device_s, "type", &device_s_type);
if (DM_STRLEN(linker) == 0)
continue;
if (br_device_s && DM_LSTRCMP(device_s_type, "bridge") == 0) {
// The lower layer is Device.Bridging.Bridge.{i}.Port.{i}.
struct uci_section *port = get_dup_section_in_dmmap_opt("dmmap_bridge_port", "bridge_port", "port", linker);
if (port != NULL) {
adm_entry_get_linker_param(dmctx, "Device.Bridging.Bridge.", linker, &value);
dmuci_get_value_by_section_string(port, "bridge_port_alias", &loweralias);
dmuci_get_value_by_section_string(port, "bridge_port_instance", &layer_inst);
}
} else {
// The lower layer is Device.Ethernet.Interface.{i}.
char *vid = DM_STRCHR(linker, '.');
if (vid) *vid = '\0';
char *macvlan = DM_STRCHR(linker, '_');
if (macvlan)
*macvlan = '\0';
struct uci_section *eth_port_sect = NULL, *eth_port_dmms = NULL;
uci_foreach_option_eq("ports", "ethport", "ifname", linker, eth_port_sect) {
break;
}
if (eth_port_sect != NULL) {
get_dmmap_section_of_config_section_eq("dmmap_ports", "ethport", "section_name", section_name(eth_port_sect), &eth_port_dmms);
if (eth_port_dmms) {
dmuci_get_value_by_section_string(eth_port_dmms, "eth_port_alias", &loweralias);
dmuci_get_value_by_section_string(eth_port_dmms, "eth_port_instance", &layer_inst);
}
}
adm_entry_get_linker_param(dmctx, "Device.Ethernet.Interface.", linker, &value);
// The lower layer is Device.Bridging.Bridge.{i}.Port.{i}.
adm_entry_get_linker_param(dmctx, "Device.Bridging.Bridge.", linker, &value);
if (DM_STRLEN(value)) {
found = true;
struct uci_section *port_s = get_dup_section_in_dmmap_opt("dmmap_bridge_port", "bridge_port", "port", linker);
dmuci_get_value_by_section_string(port_s, "bridge_port_alias", &loweralias);
dmuci_get_value_by_section_string(port_s, "bridge_port_instance", &layer_inst);
}
if (value == NULL)
value = "";
// The lower layer is Device.Ethernet.Interface.{i}.
if (found == false) {
adm_entry_get_linker_param(dmctx, "Device.Ethernet.Interface.", linker, &value);
struct uci_section *port_s = get_dup_section_in_config_opt("ports", "ethport", "ifname", linker);
loweralias = get_alias_by_section("dmmap_ports", "ethport", port_s, "eth_port_alias");
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_ports", "ethport", "section_name", section_name(port_s), "eth_port_instance", "eth_port_alias");
}
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value);
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value ? value : "");
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s%s", *loweralias ? loweralias : *layer_inst ? "cpe-" : "", (*loweralias == '\0' && *layer_inst) ? layer_inst : "");
if (create_and_link_interface_stack_instance(dmctx, parent_node, buf_higherlayer, buf_lowerlayer, buf_higheralias, buf_loweralias, &instance))

View file

@ -164,6 +164,9 @@ static void update_child_interfaces(char *device, char *option_name, char *optio
{
struct uci_section *s = NULL;
if (DM_STRLEN(device) == 0)
return;
uci_foreach_option_eq("network", "interface", "device", device, s) {
dmuci_set_value_by_section(s, option_name, option_value);
}
@ -1286,42 +1289,23 @@ static int get_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
dmuci_get_value_by_section_string(dmmap_section, "LowerLayers", value);
if ((*value)[0] == '\0') {
char linker[64] = {0};
char *proto;
dmuci_get_value_by_section_string((struct uci_section *)data, "proto", &proto);
if (DM_LSTRNCMP(proto, "ppp", 3) == 0) {
snprintf(linker, sizeof(linker), "%s", section_name((struct uci_section *)data));
adm_entry_get_linker_param(ctx, "Device.PPP.Interface.", linker, value);
if (*value != NULL && (*value)[0] != 0)
return 0;
}
char *device = get_device(section_name((struct uci_section *)data));
if (DM_STRLEN(device) == 0)
return 0;
/* If the device value is empty, then get its value directly from device option */
if (*device == '\0')
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device);
adm_entry_get_linker_param(ctx, "Device.PPP.Interface.", device, value);
if (*value != NULL && (*value)[0] != 0)
return 0;
if (device[0] != '\0') {
adm_entry_get_linker_param(ctx, "Device.Ethernet.VLANTermination.", device, value);
if (*value != NULL && (*value)[0] != 0)
return 0;
}
adm_entry_get_linker_param(ctx, "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN", device, value);
if (*value != NULL && (*value)[0] != 0)
return 0;
if (device[0] != '\0') {
DM_STRNCPY(linker, device, sizeof(linker));
char *vid = DM_STRCHR(linker, '.');
if (vid) *vid = '\0';
} else {
struct uci_section *s = NULL;
adm_entry_get_linker_param(ctx, "Device.Ethernet.VLANTermination.", device, value);
if (*value != NULL && (*value)[0] != 0)
return 0;
get_dmmap_section_of_config_section_eq("dmmap", "link", "section_name", section_name((struct uci_section *)data), &s);
dmuci_get_value_by_section_string(s, "linker", &device);
DM_STRNCPY(linker, device, sizeof(linker));
}
adm_entry_get_linker_param(ctx, "Device.Ethernet.Link.", linker, value);
adm_entry_get_linker_param(ctx, "Device.Ethernet.Link.", device, value);
} else {
char *linker = NULL;
@ -1335,16 +1319,14 @@ static int get_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section = NULL;
char eth_vlan_term[64] = "Device.Ethernet.VLANTermination.";
char eth_link[32] = "Device.Ethernet.Link.";
char ppp_iface[32] = "Device.PPP.Interface.";
char eth_mac_vlan[] = "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN";
char *allowed_objects[] = {
eth_vlan_term,
eth_link,
ppp_iface,
"Device.PPP.Interface.",
eth_mac_vlan,
"Device.Ethernet.VLANTermination.",
"Device.Ethernet.Link.",
NULL};
char linker_buf[32] = {0};
char *ip_linker = NULL;
char *linker = NULL;
char *curr_device = NULL;
switch (action) {
@ -1357,13 +1339,13 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
break;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &ip_linker);
adm_entry_get_linker_value(ctx, value, &linker);
// Store LowerLayers value under dmmap_network section
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name((struct uci_section *)data), &dmmap_section);
dmuci_set_value_by_section(dmmap_section, "LowerLayers", value);
if (!ip_linker || *ip_linker == 0) {
if (DM_STRLEN(linker) == 0) {
char *curr_proto = NULL;
// Update device option
@ -1383,116 +1365,11 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
}
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &curr_device);
update_child_interfaces(curr_device, "device", linker);
DM_STRNCPY(linker_buf, ip_linker, sizeof(linker_buf));
if (DM_STRNCMP(value, eth_vlan_term, DM_STRLEN(eth_vlan_term)) == 0) {
struct uci_section *s = NULL, *stmp = NULL;
// Check linker value
struct uci_section *vlan_ter_s = get_dup_section_in_config_opt("network", "device", "name", linker_buf);
if (vlan_ter_s == NULL) {
vlan_ter_s = get_dup_section_in_dmmap_opt("dmmap_network", "device", "default_linker", linker_buf);
dmuci_set_value_by_section_bbfdm(vlan_ter_s, "iface_name", section_name((struct uci_section *)data));
return 0;
}
char *mac_vlan = DM_STRCHR(linker_buf, '_');
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", "device", linker_buf, stmp, s) {
dmuci_delete_by_section(s, NULL, NULL);
}
// Check if there is an dmmap link section that has the same device ==> if yes, update section name
get_dmmap_section_of_config_section_eq("dmmap", "link", "device", linker_buf, &s);
dmuci_set_value_by_section_bbfdm(s, "section_name", section_name((struct uci_section *)data));
} else {
// Check if there is an interface that has the same name of device ==> if yes, remove it
char dev_buf[32] = {0};
DM_STRNCPY(dev_buf, linker_buf, sizeof(dev_buf));
char *vid = DM_STRCHR(dev_buf, '.');
if (vid) {
*vid = '\0';
uci_foreach_option_eq_safe("network", "interface", "device", dev_buf, stmp, s) {
dmuci_delete_by_section(s, NULL, NULL);
}
// Check if there is an dmmap link section that has the same device ==> if yes, update section name
get_dmmap_section_of_config_section_eq("dmmap", "link", "device", dev_buf, &s);
dmuci_set_value_by_section_bbfdm(s, "section_name", section_name((struct uci_section *)data));
}
}
// Update all child interfaces
update_child_interfaces(curr_device, "device", linker_buf);
} else if (DM_STRNCMP(value, eth_link, DM_STRLEN(eth_link)) == 0) {
// Get interface name from Ethernet.Link. object
struct uci_section *eth_link_s = NULL;
bool eth_link_without_dev = false;
get_dmmap_section_of_config_section_eq("dmmap", "link", "device", linker_buf, &eth_link_s);
if (eth_link_s == NULL) {
// There is no dmmap section that maps to this device, so we get the requested section using section_name
// option instead of device because it is a new Eternet.Link. object without settings its LowerLayers
get_dmmap_section_of_config_section_eq("dmmap", "link", "linker", linker_buf, &eth_link_s);
eth_link_without_dev = true;
}
dmuci_set_value_by_section(eth_link_s, "section_name", section_name((struct uci_section *)data));
if (!eth_link_without_dev) {
bool is_br_sec = (DM_LSTRNCMP(linker_buf, "br-", 3) == 0) ? true : false;
// Check if the Ethernet.Link. maps to bridge, if yes then check the device name
if (is_br_sec) {
char device[32] = {0};
snprintf(device, sizeof(device), "br-%s", section_name((struct uci_section *)data));
if (DM_STRCMP(device, linker_buf) != 0) {
struct uci_section *s = NULL;
// Remove unused Interface section created by Bridge Object if it exists
s = get_dup_section_in_config_opt("network", "interface", "device", linker_buf);
dmuci_delete_by_section(s, NULL, NULL);
// Update amanagement port section with the new port value if it exists
s = get_dup_section_in_dmmap_opt("dmmap_bridge_port", "bridge_port", "port", linker_buf);
dmuci_set_value_by_section(s, "port", device);
// Update device section with the new name value
s = get_dup_section_in_config_opt("network", "device", "name", linker_buf);
dmuci_set_value_by_section(s, "name", device);
// Update device option in dmmap section related to this Interface section
dmuci_set_value_by_section(eth_link_s, "device", device);
DM_STRNCPY(linker_buf, device, sizeof(linker_buf));
}
}
update_child_interfaces(curr_device, "device", linker_buf);
// Check if the Ethernet.Link. maps to macvlan, if yes then keep only device name
char *mac_vlan = DM_STRCHR(linker_buf, '_');
if (!is_br_sec && mac_vlan) {
*mac_vlan = 0;
dmuci_set_value_by_section(eth_link_s, "device", linker_buf);
}
}
} else if (DM_STRNCMP(value, ppp_iface, DM_STRLEN(ppp_iface)) == 0) {
struct uci_section *ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "name", linker_buf);
if (ppp_s == NULL)
ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "iface_name", linker_buf);
if (ppp_s == NULL)
break;
if (DM_STRNCMP(value, "Device.PPP.Interface.", strlen("Device.PPP.Interface.")) == 0) {
struct uci_section *ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "device", linker);
dmuci_set_value_by_section_bbfdm(ppp_s, "iface_name", section_name((struct uci_section *)data));
ppp___update_sections(ppp_s, (struct uci_section *)data);
}
break;

View file

@ -996,31 +996,19 @@ static int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
if ((*value)[0] == '\0') {
char *device = NULL;
if (ppp->iface_s) {
device = get_device(section_name(ppp->iface_s));
dmuci_get_value_by_section_string(ppp->dmmap_s, "device", &device);
if (DM_STRLEN(device) == 0)
return 0;
/* If the device value is empty, then get its value directly from device option */
if (*device == '\0')
dmuci_get_value_by_section_string(ppp->iface_s, "device", &device);
} else {
dmuci_get_value_by_section_string(ppp->dmmap_s, "device", &device);
}
adm_entry_get_linker_param(ctx, "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN", device, value);
if (*value != NULL && (*value)[0] != 0)
return 0;
if (device[0] != '\0') {
adm_entry_get_linker_param(ctx, "Device.Ethernet.VLANTermination.", device, value);
if (*value != NULL && (*value)[0] != 0)
return 0;
}
adm_entry_get_linker_param(ctx, "Device.Ethernet.VLANTermination.", device, value);
if (*value != NULL && (*value)[0] != 0)
return 0;
if (device[0] != '\0') {
char linker[64] = {0};
DM_STRNCPY(linker, device, sizeof(linker));
char *vid = DM_STRCHR(linker, '.');
if (vid) *vid = '\0';
adm_entry_get_linker_param(ctx, "Device.Ethernet.Link.", linker, value);
}
adm_entry_get_linker_param(ctx, "Device.Ethernet.Link.", device, value);
} else {
char *linker = NULL;
@ -1034,13 +1022,13 @@ static int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
static int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct ppp_args *ppp = (struct ppp_args *)data;
char eth_vlan_term[64] = "Device.Ethernet.VLANTermination.";
char eth_link[32] = "Device.Ethernet.Link.";
char eth_mac_vlan[] = "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN";
char *allowed_objects[] = {
eth_vlan_term,
eth_link,
eth_mac_vlan,
"Device.Ethernet.VLANTermination.",
"Device.Ethernet.Link.",
NULL};
char *ppp_linker = NULL;
char *linker = NULL;
switch (action) {
case VALUECHECK:
@ -1052,59 +1040,30 @@ static int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
return 0;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &ppp_linker);
adm_entry_get_linker_value(ctx, value, &linker);
// Store LowerLayers value under dmmap_ppp section
dmuci_set_value_by_section(ppp->dmmap_s, "LowerLayers", value);
if (!ppp_linker || ppp_linker[0] == 0) {
dmuci_set_value_by_section(ppp->dmmap_s, "vlan_ter_linker", "");
dmuci_set_value_by_section(ppp->dmmap_s, "eth_link_linker", "");
// Update proto option
dmuci_set_value_by_section(ppp->dmmap_s, "proto", "pppoe");
if (ppp->iface_s) dmuci_set_value_by_section(ppp->iface_s, "proto", "pppoe");
dmuci_set_value_by_section(ppp->dmmap_s, "device", "");
if (ppp->iface_s)
dmuci_set_value_by_section(ppp->iface_s, "device", "");
} else if (DM_STRNCMP(value, eth_vlan_term, DM_STRLEN(eth_vlan_term)) == 0) {
if (DM_STRNCMP(value, "Device.Ethernet.Link.", DM_STRLEN("Device.Ethernet.Link.")) == 0) {
struct uci_section *eth_link_s = NULL;
char *is_eth = NULL;
// Check VLANTremination linker and required options
struct uci_section *vlan_ter_s = get_dup_section_in_config_opt("network", "device", "name", ppp_linker);
if (vlan_ter_s) {
dmuci_set_value_by_section(ppp->dmmap_s, "device", ppp_linker);
if (ppp->iface_s)
dmuci_set_value_by_section(ppp->iface_s, "device", ppp_linker);
} else {
dmuci_set_value_by_section(ppp->dmmap_s, "vlan_ter_linker", ppp_linker);
}
get_dmmap_section_of_config_section_eq("dmmap_ethernet", "link", "device", linker, &eth_link_s);
if (eth_link_s) dmuci_get_value_by_section_string(eth_link_s, "is_eth", &is_eth);
// Update proto option
dmuci_set_value_by_section(ppp->dmmap_s, "proto", "pppoe");
if (ppp->iface_s)
dmuci_set_value_by_section(ppp->iface_s, "proto", "pppoe");
} else if (DM_STRNCMP(value, eth_link, DM_STRLEN(eth_link)) == 0) {
struct uci_section *eth_link_s = NULL;
// Check Ethernet.Link linker and required options
get_dmmap_section_of_config_section_eq("dmmap", "link", "device", ppp_linker, &eth_link_s);
if (eth_link_s) {
dmuci_set_value_by_section(ppp->dmmap_s, "device", ppp_linker);
if (ppp->iface_s)
dmuci_set_value_by_section(ppp->iface_s, "device", ppp_linker);
} else {
get_dmmap_section_of_config_section_eq("dmmap", "link", "linker", ppp_linker, &eth_link_s);
dmuci_set_value_by_section(ppp->dmmap_s, "eth_link_linker", ppp_linker);
}
if (eth_link_s) {
char *is_eth = NULL;
dmuci_get_value_by_section_string(eth_link_s, "is_eth", &is_eth);
// Update proto option
dmuci_set_value_by_section(ppp->dmmap_s, "proto", !DM_LSTRCMP(is_eth, "1") ? "pppoe" : "pppoa");
if (ppp->iface_s)
dmuci_set_value_by_section(ppp->iface_s, "proto", !DM_LSTRCMP(is_eth, "1") ? "pppoe" : "pppoa");
}
dmuci_set_value_by_section(ppp->dmmap_s, "proto", !DM_LSTRCMP(is_eth, "1") ? "pppoe" : "pppoa");
if (ppp->iface_s) dmuci_set_value_by_section(ppp->iface_s, "proto", !DM_LSTRCMP(is_eth, "1") ? "pppoe" : "pppoa");
}
// Update device option
dmuci_set_value_by_section(ppp->dmmap_s, "device", DM_STRLEN(linker) ? linker : "");
if (ppp->iface_s) dmuci_set_value_by_section(ppp->iface_s, "device", DM_STRLEN(linker) ? linker : "");
return 0;
}
return 0;
@ -1202,12 +1161,7 @@ static int set_PPPInterfacePPPoE_ServiceName(char *refparam, struct dmctx *ctx,
***************************************************************************/
static int get_linker_ppp_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
{
struct ppp_args *ppp = (struct ppp_args *)data;
if (ppp->iface_s)
*linker = dmstrdup(section_name(ppp->iface_s));
else
dmuci_get_value_by_section_string(ppp->dmmap_s, "name", linker);
dmuci_get_value_by_section_string(((struct ppp_args *)data)->dmmap_s, "device", linker);
return 0;
}

View file

@ -90,32 +90,27 @@ static int delete_ptm_link(char *refparam, struct dmctx *ctx, void *data, char *
switch (del_action) {
case DEL_INST:
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 (stmp != NULL && ((struct ptm_args *)data)->device != NULL)
remove_device_from_interface(stmp, ((struct ptm_args *)data)->device);
}
dmuci_delete_by_section((((struct ptm_args *)data)->sections)->dmmap_section, NULL, NULL);
dmuci_delete_by_section((((struct ptm_args *)data)->sections)->config_section, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections_safe("dsl", "ptm-device", stmp, s) {
struct uci_section *ns = NULL, *nss = NULL, *dmmap_section = NULL;
struct uci_section *ns = 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 && device != NULL)
remove_device_from_interface(nss, device);
if (DM_STRLEN(device) == 0)
continue;
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(s), &dmmap_section);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
uci_foreach_option_cont("network", "interface", "device", device, ns) {
remove_device_from_interface(ns, device);
}
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(s), &ns);
dmuci_delete_by_section(ns, NULL, NULL);
dmuci_delete_by_section(s, NULL, NULL);
}

View file

@ -1,27 +1,107 @@
/*
* Copyright (C) 2021 iopsys Software Solutions AB
* Copyright (C) 2023 iopsys Software Solutions AB
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation
*
* Author Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
* Author Amin Ben Romdhane <amin.benromdhane@iopsys.eu>
*
*/
#include "tr181/ethernet.h"
#include "ethernet.h"
static int get_EthernetVLANTermination_MACVLAN(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
/*************************************************************
* ENTRY METHOD
**************************************************************/
static int browseEthernetMACVLANInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "type", value);
*value = (DM_LSTRCMP(*value, "macvlan") == 0) ? "1" : "0";
struct dmmap_dup *p = NULL;
LIST_HEAD(dup_list);
char *inst = NULL;
synchronize_specific_config_sections_with_dmmap_eq("network", "device", "dmmap_network", "type", "macvlan", &dup_list);
list_for_each_entry(p, &dup_list, list) {
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "mac_vlan_instance", "mac_vlan_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
break;
}
free_dmmap_config_dup_list(&dup_list);
return 0;
}
static int set_EthernetVLANTermination_MACVLAN(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
/*************************************************************
* LINKER
**************************************************************/
static int get_linker_mac_vlan(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
{
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", linker);
return 0;
}
/*************************************************************
* ADD & DEL OBJ
**************************************************************/
static int addObjEthernetMACVLAN(char *refparam, struct dmctx *ctx, void *data, char **instance)
{
struct uci_section *s = NULL, *dmmap_network = NULL;
char device_name[32];
snprintf(device_name, sizeof(device_name), "mac_vlan_%s", *instance);
// Add device section
dmuci_add_section("network", "device", &s);
dmuci_rename_section_by_section(s, device_name);
dmuci_set_value_by_section(s, "type", "macvlan");
// Add device section in dmmap_network file
dmuci_add_section_bbfdm("dmmap_network", "device", &dmmap_network);
dmuci_set_value_by_section(dmmap_network, "section_name", device_name);
dmuci_set_value_by_section(dmmap_network, "mac_vlan_instance", *instance);
return 0;
}
static int delObjEthernetMACVLAN(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *stmp = NULL;
switch (del_action) {
case DEL_INST:
// Remove device section
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
// Remove device section in dmmap_network file
dmuci_delete_by_section(((struct dmmap_dup *)data)->dmmap_section, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_option_eq_safe("network", "device", "type", "macvlan", stmp, s) {
// Remove dmmap section
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_network", "device", section_name(s), &dmmap_section);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
// Remove device section
dmuci_delete_by_section(s, NULL, NULL);
}
break;
}
return 0;
}
/*************************************************************
* GET & SET PARAM
**************************************************************/
static int get_EthernetMACVLAN_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "enabled", "1");
return 0;
}
static int set_EthernetMACVLAN_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *name, *ifname;
bool b;
switch (action) {
@ -31,119 +111,224 @@ static int set_EthernetVLANTermination_MACVLAN(char *refparam, struct dmctx *ctx
break;
case VALUESET:
string_to_bool(value, &b);
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ifname", &ifname);
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", &name);
struct uci_section *s = NULL, *dmmap_s = NULL;
if (b && *name != '\0') {
char *link_instance = NULL, new_name[16] = {0};
int name_found = 0;
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "enabled", b ? "1" : "0");
break;
}
return 0;
}
uci_foreach_option_eq("network", "interface", "device", name, s) {
static int get_EthernetMACVLAN_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *device = NULL;
get_dmmap_section_of_config_section_eq("dmmap", "link", "device", name, &dmmap_s);
if (dmmap_s) {
dmuci_get_value_by_section_string(dmmap_s, "link_instance", &link_instance);
snprintf(new_name, sizeof(new_name), "%s_%s", ifname, link_instance);
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", &device);
return get_net_device_status(device, value);
}
if (ethernet___name_exists_in_devices(new_name))
return -1;
static int get_EthernetMACVLAN_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "mac_vlan_alias", value);
if ((*value)[0] == '\0')
dmasprintf(value, "cpe-%s", instance);
return 0;
}
dmuci_set_value_by_section(dmmap_s, "device", new_name);
dmuci_set_value_by_section(dmmap_s, "section_name", section_name(s));
static int set_EthernetMACVLAN_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 64, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "mac_vlan_alias", value);
break;
}
return 0;
}
}
static int get_EthernetMACVLAN_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", value);
return 0;
}
dmuci_set_value_by_section(s, "device", new_name);
static int get_EthernetMACVLAN_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker = NULL;
name_found = 1;
break;
}
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "LowerLayers", value);
if (name_found == 0) {
int ifname_found = 0;
struct uci_section *ss = NULL;
if ((*value)[0] == '\0') {
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ifname", &linker);
if (!linker || *linker == '\0')
return 0;
uci_foreach_option_eq("network", "interface", "device", ifname, ss) {
adm_entry_get_linker_param(ctx, "Device.Ethernet.VLANTermination.", linker, value);
if (*value != NULL && (*value)[0] != 0)
return 0;
uci_path_foreach_option_eq(bbfdm, "dmmap", "link", "device", ifname, dmmap_s) {
char *sec_name;
dmuci_get_value_by_section_string(dmmap_s, "section_name", &sec_name);
/* Check section name exist => if yes, continue*/
if (!ethernet___check_section_in_curr_section(sec_name, section_name(ss)))
continue;
adm_entry_get_linker_param(ctx, "Device.Ethernet.Link.", linker, value);
} else {
adm_entry_get_linker_value(ctx, *value, &linker);
if (!linker || *linker == 0)
*value = "";
}
return 0;
}
dmuci_get_value_by_section_string(dmmap_s, "link_instance", &link_instance);
snprintf(new_name, sizeof(new_name), "%s_%s", ifname, link_instance);
static int set_EthernetMACVLAN_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *allowed_objects[] = {
"Device.Ethernet.VLANTermination.",
"Device.Ethernet.Link.",
NULL};
char *linker = NULL;
if (ethernet___name_exists_in_devices(new_name))
return -1;
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, -1, -1, 1024, -1, -1, NULL, NULL))
return FAULT_9007;
dmuci_set_value_by_section(dmmap_s, "device", new_name);
dmuci_set_value_by_section(dmmap_s, "section_name", section_name(ss));
}
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
dmuci_set_value_by_section(ss, "device", new_name);
break;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &linker);
ifname_found = 1;
break;
}
// Store LowerLayers value under dmmap section
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "LowerLayers", value);
if (ifname_found == 0) {
get_dmmap_section_of_config_section_eq("dmmap", "link", "device", ifname, &dmmap_s);
if (dmmap_s) {
dmuci_get_value_by_section_string(dmmap_s, "link_instance", &link_instance);
snprintf(new_name, sizeof(new_name), "%s_%s", ifname, link_instance);
if (DM_STRLEN(linker)) {
char name[16] = {0};
if (ethernet___name_exists_in_devices(new_name))
return -1;
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ifname", linker);
dmuci_set_value_by_section(dmmap_s, "device", new_name);
dmuci_set_value_by_section(dmmap_s, "section_name", "");
char *vid = DM_STRCHR(linker, '.');
if (vid) *vid = 0;
}
}
}
snprintf(name, sizeof(name), "%s_%s", linker, instance);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", new_name);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "type", "macvlan");
} else if (!b && *name != '\0') {
char *vid = NULL, new_name[16] = {0};
uci_foreach_option_eq("network", "interface", "device", name, s) {
get_dmmap_section_of_config_section_eq("dmmap", "link", "device", name, &dmmap_s);
if (dmmap_s) {
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "vid", &vid);
if (vid && *vid)
snprintf(new_name, sizeof(new_name), "%s.%s", ifname, vid);
else
snprintf(new_name, sizeof(new_name), "%s", ifname);
if (ethernet___name_exists_in_devices(new_name))
return -1;
dmuci_set_value_by_section(dmmap_s, "device", new_name);
}
dmuci_set_value_by_section(s, "device", new_name);
break;
}
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", new_name);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "type", "8021q");
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", name);
} else {
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "type", b ? "macvlan" : "8021q");
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ifname", "");
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", "");
}
break;
}
return 0;
}
static int get_EthernetMACVLAN_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "macaddr", value);
return 0;
}
static int set_EthernetMACVLAN_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 17, NULL, MACAddress))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "macaddr", value);
break;
}
return 0;
}
static int eth_macvlan_sysfs(const struct uci_section *data, const char *name, char **value)
{
char *device;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", &device);
return get_net_device_sysfs(device, name, value);
}
static int get_EthernetMACVLANStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return eth_macvlan_sysfs(data, "statistics/tx_bytes", value);
}
static int get_EthernetMACVLANStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return eth_macvlan_sysfs(data, "statistics/rx_bytes", value);
}
static int get_EthernetMACVLANStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return eth_macvlan_sysfs(data, "statistics/tx_packets", value);
}
static int get_EthernetMACVLANStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return eth_macvlan_sysfs(data, "statistics/rx_packets", value);
}
static int get_EthernetMACVLANStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return eth_macvlan_sysfs(data, "statistics/tx_errors", value);
}
static int get_EthernetMACVLANStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return eth_macvlan_sysfs(data, "statistics/rx_errors", value);
}
static int get_EthernetMACVLANStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return eth_macvlan_sysfs(data, "statistics/tx_dropped", value);
}
static int get_EthernetMACVLANStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return eth_macvlan_sysfs(data, "statistics/rx_dropped", value);
}
static int get_EthernetMACVLANStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return eth_macvlan_sysfs(data, "statistics/multicast", value);
}
/**********************************************************************************************************************************
* OBJ & PARAM DEFINITION
***********************************************************************************************************************************/
DMLEAF tIOPSYS_EthernetVLANTerminationParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{BBF_VENDOR_PREFIX"MACVLAN", &DMWRITE, DMT_BOOL, get_EthernetVLANTermination_MACVLAN, set_EthernetVLANTermination_MACVLAN, BBFDM_BOTH},
DMOBJ tIOPSYS_EthernetObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{BBF_VENDOR_PREFIX"MACVLAN", &DMWRITE, addObjEthernetMACVLAN, delObjEthernetMACVLAN, NULL, browseEthernetMACVLANInst, NULL, NULL, tEthernetMACVLANObj, tEthernetMACVLANParams, get_linker_mac_vlan, BBFDM_BOTH, NULL, "2.16"},
{0}
};
DMLEAF tEthernetMACVLANParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_EthernetMACVLAN_Enable, set_EthernetMACVLAN_Enable, BBFDM_BOTH, "2.16"},
{"Status", &DMREAD, DMT_STRING, get_EthernetMACVLAN_Status, NULL, BBFDM_BOTH, "2.16"},
{"Alias", &DMWRITE, DMT_STRING, get_EthernetMACVLAN_Alias, set_EthernetMACVLAN_Alias, BBFDM_BOTH, "2.16"},
{"Name", &DMREAD, DMT_STRING, get_EthernetMACVLAN_Name, NULL, BBFDM_BOTH, "2.16"},
{"LowerLayers", &DMWRITE, DMT_STRING, get_EthernetMACVLAN_LowerLayers, set_EthernetMACVLAN_LowerLayers, BBFDM_BOTH, "2.16"},
{"MACAddress", &DMWRITE, DMT_STRING, get_EthernetMACVLAN_MACAddress, set_EthernetMACVLAN_MACAddress, BBFDM_BOTH, "2.16"},
{0}
};
DMOBJ tEthernetMACVLANObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tEthernetMACVLANStatsParams, NULL, BBFDM_BOTH, NULL, "2.16"},
{0}
};
DMLEAF tEthernetMACVLANStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"BytesSent", &DMREAD, DMT_UNLONG, get_EthernetMACVLANStats_BytesSent, NULL, BBFDM_BOTH, "2.16"},
{"BytesReceived", &DMREAD, DMT_UNLONG, get_EthernetMACVLANStats_BytesReceived, NULL, BBFDM_BOTH, "2.16"},
{"PacketsSent", &DMREAD, DMT_UNLONG, get_EthernetMACVLANStats_PacketsSent, NULL, BBFDM_BOTH, "2.16"},
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_EthernetMACVLANStats_PacketsReceived, NULL, BBFDM_BOTH, "2.16"},
{"ErrorsSent", &DMREAD, DMT_UNINT, get_EthernetMACVLANStats_ErrorsSent, NULL, BBFDM_BOTH, "2.16"},
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_EthernetMACVLANStats_ErrorsReceived, NULL, BBFDM_BOTH, "2.16"},
{"DiscardPacketsSent", &DMREAD, DMT_UNINT, get_EthernetMACVLANStats_DiscardPacketsSent, NULL, BBFDM_BOTH, "2.16"},
{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, get_EthernetMACVLANStats_DiscardPacketsReceived, NULL, BBFDM_BOTH, "2.16"},
{"MulticastPacketsReceived", &DMREAD, DMT_UNLONG, get_EthernetMACVLANStats_MulticastPacketsReceived, NULL, BBFDM_BOTH, "2.16"},
{0}
};

View file

@ -1,11 +1,11 @@
/*
* Copyright (C) 2021 iopsys Software Solutions AB
* Copyright (C) 2023 iopsys Software Solutions AB
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation
*
* Author Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
* Author Amin Ben Romdhane <amin.benromdhane@iopsys.eu>
*
*/
@ -14,6 +14,9 @@
#include "libbbf_api/dmcommon.h"
extern DMLEAF tIOPSYS_EthernetVLANTerminationParams[];
extern DMOBJ tIOPSYS_EthernetObj[];
extern DMLEAF tEthernetMACVLANParams[];
extern DMOBJ tEthernetMACVLANObj[];
extern DMLEAF tEthernetMACVLANStatsParams[];
#endif //__IOPSYS_ETHERNET_H

View file

@ -25,7 +25,7 @@ DM_MAP_OBJ tVendorExtensionIOPSYS[] = {
/* parentobj, nextobject, parameter */
{"Device.", tIOPSYS_DeviceObj, NULL},
{"Device.DeviceInfo.", NULL, tIOPSYS_DeviceInfoParams},
{"Device.Ethernet.VLANTermination.{i}.", NULL, tIOPSYS_EthernetVLANTerminationParams},
{"Device.Ethernet.", tIOPSYS_EthernetObj, NULL},
{"Device.Time.", NULL, tIOPSYS_TimeParams},
{"Device.Bridging.Bridge.{i}.Port.{i}.", NULL, tIOPSYS_BridgingBridgePortParams},
{"Device.Services.VoiceService.{i}.CallLog.{i}.", NULL, tIOPSYS_VoiceServiceCallLogParams},

View file

@ -543,27 +543,239 @@
"description": "Ethernet object. This object models several Ethernet interface objects, each representing a different stack layer, including: <<object|Interface>>, <<object|Link>>, and <<object|VLANTermination>>. <<object|Interface>> is media-specific and models a port, the PHY layer, and the Channel Access Method (CAM) part of the MAC layer. <<object|Link>> is media-independent and models the Logical Link Control (LLC) layer. An outer <<object|VLANTermination>>, when present, is expected to be stacked on top of <<object|Link>> objects to receive and send frames with a configured VLANID.",
"access": false,
"array": false,
"Device.Ethernet.VLANTermination.{i}.": {
"Device.Ethernet.{BBF_VENDOR_PREFIX}MACVLAN.{i}.": {
"type": "object",
"version": "2.5",
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "VLAN Termination table (a stackable interface object as described in <<bibref|TR-181i2|Section 4.2>>). A VLAN Termination entry is typically stacked on top of a <<object|#.Link>> object to receive and send frames with the configured <<param|VLANID>>.",
"description": "A MACVLAN entry is typically stacked on top of a <<object|#.Link>> object or <<object|#.VLANTermination>> to receive and send frames with the configured <<param|MACAddress>>.",
"access": true,
"array": true,
"{BBF_VENDOR_PREFIX}MACVLAN": {
"Enable": {
"type": "boolean",
"read": true,
"write": true,
"version": "2.5",
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "Specifies if the object is macvlan or not",
"description": "Enables or disables the MACVLAN entry",
"default": "false",
"datatype": "boolean"
},
"Status": {
"type": "string",
"read": true,
"write": false,
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "The current operational state of the MACVLAN entry. Enumeration of: Up, Down, Unknown, Dormant, NotPresent, LowerLayerDown, Error. When <<param|Enable>> is <<false>> then <<param>> SHOULD normally be <<enum|Down>> (or <<enum|NotPresent>> or <<enum|Error>> if there is a fault condition on the interface). When <<param|Enable>> is changed to <<true>> then <<param>> SHOULD change to <<enum|Up>> if and only if the interface is able to transmit and receive network traffic; it SHOULD change to <<enum|Dormant>> if and only if the interface is operable but is waiting for external actions before it can transmit and receive network traffic (and subsequently change to <<enum|Up>> if still operable when the expected actions have completed); it SHOULD change to <<enum|LowerLayerDown>> if and only if the interface is prevented from entering the <<enum|Up>> state because one or more of the interfaces beneath it is down; it SHOULD remain in the <<enum|Error>> state if there is an error or other fault condition detected on the interface; it SHOULD remain in the <<enum|NotPresent>> state if the interface has missing (typically hardware) components; it SHOULD change to <<enum|Unknown>> if the state of the interface can not be determined for some reason. This parameter is based on ifOperStatus from <<bibref|RFC2863>>.",
"default": "Down",
"datatype": "string",
"enumerations": [
"Up",
"Down",
"Unknown",
"Dormant",
"NotPresent",
"LowerLayerDown",
"Error"
]
},
"Alias": {
"type": "string",
"read": true,
"write": true,
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "A non-volatile handle used to reference this instance. Alias provides a mechanism for an ACS to label this instance for future reference. If the CPE supports the Alias-based Addressing feature as defined in <<bibref|TR-069|3.6.1>> and described in <<bibref|TR-069|Appendix II>>, the following mandatory constraints MUST be enforced: * Its value MUST NOT be empty. * Its value MUST start with a letter. * If its value is not assigned by the ACS, it MUST start with a cpe- prefix. * The CPE MUST NOT change the parameter value. | A non-volatile handle used to reference this instance. Alias provides a mechanism for an ACS to label this instance for future reference. If the CPE supports the Alias-based Addressing feature as defined in <<bibref|TR-069|3.6.1>> and described in <<bibref|TR-069|Appendix II>>, the following mandatory constraints MUST be enforced: * Its value MUST NOT be empty. * Its value MUST start with a letter. * If its value is not assigned by the ACS, it MUST start with a cpe- prefix. * The CPE MUST NOT change the parameter value.",
"datatype": "Alias",
"range": [
{
"max": 64
}
]
},
"Name": {
"type": "string",
"read": true,
"write": false,
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "The textual name of the MACVLAN entry as assigned by the CPE.",
"datatype": "string",
"range": [
{
"max": 64
}
]
},
"LowerLayers": {
"type": "string",
"read": true,
"write": true,
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "<<list>> <<reference|an interface object that is stacked immediately below this interface object>> See <<bibref|TR-181i2|Section 4.2.1>>.",
"list": {
"datatype": "string",
"maxsize": 1024
}
},
"MACAddress": {
"type": "string",
"read": true,
"write": true,
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "The MAC address used for packets sent via this interface. Provides the source MAC address for outgoing traffic and the destination MAC address for incoming traffic.",
"datatype": "MACAddress",
"range": [
{
"max": 17
}
],
"pattern": [
"",
"([0-9A-Fa-f][0-9A-Fa-f]:){5}([0-9A-Fa-f][0-9A-Fa-f])"
]
},
"Device.Ethernet.{BBF_VENDOR_PREFIX}MACVLAN.{i}.Stats.": {
"type": "object",
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "Throughput statistics for this MACVLAN entry. The CPE MUST reset the links Stats parameters (unless otherwise stated in individual object or parameter descriptions) either when the link becomes operationally down due to a previous administrative down (i.e. the links <<param|#.Status>> parameter transitions to a down state after the link is disabled) or when the link becomes administratively up (i.e. the links <<param|#.Enable>> parameter transitions from <<false>> to <<true>>). Administrative and operational link status is discussed in <<bibref|TR-181i2|section 4.2.2>>.",
"access": false,
"array": false,
"BytesSent": {
"type": "unsignedLong",
"read": true,
"write": false,
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "The total number of bytes transmitted out of the MACVLAN entry, including framing characters.",
"datatype": "unsignedLong"
},
"BytesReceived": {
"type": "unsignedLong",
"read": true,
"write": false,
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "The total number of bytes received on the MACVLAN entry, including framing characters.",
"datatype": "unsignedLong"
},
"PacketsSent": {
"type": "unsignedLong",
"read": true,
"write": false,
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "The total number of Ethernet frames transmitted out of the MACVLAN entry.",
"datatype": "unsignedLong"
},
"PacketsReceived": {
"type": "unsignedLong",
"read": true,
"write": false,
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "The total number of Ethernet frames received on the MACVLAN entry.",
"datatype": "unsignedLong"
},
"ErrorsSent": {
"type": "unsignedInt",
"read": true,
"write": false,
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "The total number of outbound Ethernet frames that could not be transmitted because of errors.",
"datatype": "unsignedInt"
},
"ErrorsReceived": {
"type": "unsignedInt",
"read": true,
"write": false,
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "The total number of inbound Ethernet frames that contained errors preventing them from being delivered to a higher-layer protocol.",
"datatype": "unsignedInt"
},
"DiscardPacketsSent": {
"type": "unsignedInt",
"read": true,
"write": false,
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "The total number of outbound Ethernet frames which were chosen to be discarded even though no errors had been detected to prevent their being transmitted. One possible reason for discarding such a packet could be to free up buffer space.",
"datatype": "unsignedInt"
},
"DiscardPacketsReceived": {
"type": "unsignedInt",
"read": true,
"write": false,
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "The total number of inbound Ethernet frames which were chosen to be discarded even though no errors had been detected to prevent their being delivered. One possible reason for discarding such a packet could be to free up buffer space.",
"datatype": "unsignedInt"
},
"MulticastPacketsReceived": {
"type": "unsignedLong",
"read": true,
"write": false,
"version": "2.16",
"protocols": [
"cwmp",
"usp"
],
"description": "The total number of received Ethernet frames, delivered by this layer to a higher layer, which were addressed to a multicast address at this layer.",
"datatype": "unsignedLong"
}
}
}
},

View file

@ -761,27 +761,206 @@ Device.Bridging.Bridge.2.VLAN.1.Name => br_2_vlan_1
Device.Bridging.Bridge.2.VLAN.1.VLANID => 200
```
### 5. One VLAN per Customer
### 5. One VLAN per Customer(MACVLAN over tagged interface)
- **TR-181 Commands**
```bash
obuspa -c del Device.DHCPv4.Client.*
obuspa -c del Device.DHCPv6.Client.*
obuspa -c del Device.Ethernet.Link.*
obuspa -c del Device.Bridging.Bridge.*
obuspa -c del Device.IP.Interface.*
obuspa -c add Device.Ethernet.Link.
obuspa -c set Device.Ethernet.Link.1.LowerLayers Device.Ethernet.Interface.3
obuspa -c add Device.Ethernet.VLANTermination
obuspa -c set Device.Ethernet.VLANTermination.1.VLANID 100
obuspa -c set Device.Ethernet.VLANTermination.1.LowerLayers Device.Ethernet.Link.1
obuspa -c add Device.Ethernet.X_IOPSYS_EU_MACVLAN
obuspa -c set Device.Ethernet.X_IOPSYS_EU_MACVLAN.1.LowerLayers Device.Ethernet.VLANTermination.1
obuspa -c add Device.Ethernet.X_IOPSYS_EU_MACVLAN
obuspa -c set Device.Ethernet.X_IOPSYS_EU_MACVLAN.2.LowerLayers Device.Ethernet.VLANTermination.1
obuspa -c add Device.IP.Interface.
obuspa -c set Device.IP.Interface.1.Enable 1
obuspa -c set Device.IP.Interface.1.LowerLayers Device.Ethernet.X_IOPSYS_EU_MACVLAN.1
obuspa -c add Device.IP.Interface.
obuspa -c set Device.IP.Interface.2.Enable 1
obuspa -c set Device.IP.Interface.2.LowerLayers Device.Ethernet.X_IOPSYS_EU_MACVLAN.2
obuspa -c add Device.DHCPv4.Client.
obuspa -c set Device.DHCPv4.Client.1.Enable 1
obuspa -c set Device.DHCPv4.Client.1.Interface Device.IP.Interface.1
obuspa -c add Device.DHCPv4.Client.
obuspa -c set Device.DHCPv4.Client.2.Enable 1
obuspa -c set Device.DHCPv4.Client.2.Interface Device.IP.Interface.2
```
- **Network UCI Config**
```bash
config interface 'loopback'
option device 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd32:1646:1526::/48'
config device 'vlan_ter_1'
option type '8021q'
option vid '100'
option ifname 'eth4'
option name 'eth4.100'
config device 'mac_vlan_1'
option type 'macvlan'
option ifname 'eth4.100'
option name 'eth4_1'
option macaddr 'EC:6C:9A:79:FD:7E'
config device 'mac_vlan_2'
option type 'macvlan'
option ifname 'eth4.100'
option name 'eth4_2'
config interface 'iface1'
option disabled '0'
option macaddr 'EC:6C:9A:79:FD:7E'
option device 'eth4_1'
option proto 'dhcp'
config interface 'iface2'
option disabled '0'
option device 'eth4_2'
option proto 'dhcp'
```
- **TR-181 Data Model**
```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.X_IOPSYS_EU_MACVLAN.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.X_IOPSYS_EU_MACVLAN.2
$ obuspa -c get Device.Ethernet.X_IOPSYS_EU_MACVLAN.*.LowerLayers
Device.Ethernet.X_IOPSYS_EU_MACVLAN.1.LowerLayers => Device.Ethernet.VLANTermination.1
Device.Ethernet.X_IOPSYS_EU_MACVLAN.2.LowerLayers => Device.Ethernet.VLANTermination.1
$ obuspa -c get Device.Ethernet.VLANTermination.*.LowerLayers
Device.Ethernet.VLANTermination.1.LowerLayers => Device.Ethernet.Link.1
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.1
Device.DHCPv4.Client.2.Interface => Device.IP.Interface.2
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
$ obuspa -c get Device.Bridging.Bridge.*.VLAN.
$ obuspa -c get Device.Bridging.Bridge.*.VLANPort.
```
### 6. One VLAN per Customer(MACVLAN over untagged interface)
- **TR-181 Commands**
```bash
obuspa -c del Device.DHCPv4.Client.*
obuspa -c del Device.DHCPv6.Client.*
obuspa -c del Device.Ethernet.Link.*
obuspa -c del Device.Bridging.Bridge.*
obuspa -c del Device.IP.Interface.*
obuspa -c add Device.Ethernet.Link.
obuspa -c set Device.Ethernet.Link.1.LowerLayers Device.Ethernet.Interface.3
obuspa -c add Device.Ethernet.X_IOPSYS_EU_MACVLAN
obuspa -c set Device.Ethernet.X_IOPSYS_EU_MACVLAN.1.LowerLayers Device.Ethernet.Link.1
obuspa -c add Device.Ethernet.X_IOPSYS_EU_MACVLAN
obuspa -c set Device.Ethernet.X_IOPSYS_EU_MACVLAN.2.LowerLayers Device.Ethernet.Link.1
obuspa -c add Device.IP.Interface.
obuspa -c set Device.IP.Interface.1.Enable 1
obuspa -c set Device.IP.Interface.1.LowerLayers Device.Ethernet.X_IOPSYS_EU_MACVLAN.1
obuspa -c add Device.IP.Interface.
obuspa -c set Device.IP.Interface.2.Enable 1
obuspa -c set Device.IP.Interface.2.LowerLayers Device.Ethernet.X_IOPSYS_EU_MACVLAN.2
obuspa -c add Device.DHCPv4.Client.
obuspa -c set Device.DHCPv4.Client.1.Enable 1
obuspa -c set Device.DHCPv4.Client.1.Interface Device.IP.Interface.1
obuspa -c add Device.DHCPv4.Client.
obuspa -c set Device.DHCPv4.Client.2.Enable 1
obuspa -c set Device.DHCPv4.Client.2.Interface Device.IP.Interface.2
```
- **Network UCI Config**
```bash
config interface 'loopback'
option device 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fd34:97b4:c0ff::/48'
config device 'mac_vlan_1'
option type 'macvlan'
option ifname 'eth4'
option name 'eth4_1'
option macaddr 'EC:6C:9A:79:FD:7E'
config device 'mac_vlan_2'
option type 'macvlan'
option ifname 'eth4'
option name 'eth4_2'
config interface 'iface1'
option disabled '0'
option device 'eth4_1'
option macaddr 'EC:6C:9A:79:FD:7E'
option proto 'dhcp'
config interface 'iface2'
option disabled '0'
option device 'eth4_2'
option proto 'dhcp'
```
### 6. VLAN Translation
- **TR-181 Data Model**
```bash
$ obuspa -c get Device.IP.Interface.*.LowerLayers
Device.IP.Interface.1.LowerLayers => Device.Ethernet.X_IOPSYS_EU_MACVLAN.1
Device.IP.Interface.2.LowerLayers => Device.Ethernet.X_IOPSYS_EU_MACVLAN.2
$ obuspa -c get Device.Ethernet.X_IOPSYS_EU_MACVLAN.*.LowerLayers
Device.Ethernet.X_IOPSYS_EU_MACVLAN.1.LowerLayers => Device.Ethernet.Link.1
Device.Ethernet.X_IOPSYS_EU_MACVLAN.2.LowerLayers => Device.Ethernet.Link.1
$ obuspa -c get Device.Ethernet.VLANTermination.*.LowerLayers
$ obuspa -c get Device.Ethernet.Link.*.LowerLayers
Device.Ethernet.Link.1.LowerLayers => Device.Ethernet.Interface.3
$ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.1
Device.DHCPv4.Client.2.Interface => Device.IP.Interface.2
$ obuspa -c get Device.Bridging.Bridge.*.Port.*.LowerLayers
$ obuspa -c get Device.Bridging.Bridge.*.VLAN.
$ obuspa -c get Device.Bridging.Bridge.*.VLANPort.
```
### 7. VLAN Translation
- **TR-181 Commands**
@ -957,7 +1136,7 @@ $ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.2
```
### 7. Managed Bridge
### 8. Managed Bridge
- **TR-181 Commands**
@ -1111,7 +1290,7 @@ $ obuspa -c get Device.DHCPv4.Client.*.Interface
Device.DHCPv4.Client.1.Interface => Device.IP.Interface.1
```
### 8. QinQ lan untagged to wan double tagged (Bridge mode)
### 9. QinQ lan untagged to wan double tagged (Bridge mode)
- **TR-181 Commands**
@ -1264,7 +1443,7 @@ Device.Bridging.ProviderBridge.1.SVLANcomponent => Device.Bridging.Bridge.4
Device.Bridging.ProviderBridge.1.CVLANcomponents => Device.Bridging.Bridge.1,Device.Bridging.Bridge.2
```
### 9. QinQ lan single tagged to wan double tagged (Bridge mode)
### 10. QinQ lan single tagged to wan double tagged (Bridge mode)
- **TR-181 Commands**
@ -1467,7 +1646,7 @@ Device.Bridging.ProviderBridge.1.SVLANcomponent => Device.Bridging.Bridge.4
Device.Bridging.ProviderBridge.1.CVLANcomponents => Device.Bridging.Bridge.1,Device.Bridging.Bridge.2
```
### 10. QinQ (Route mode)
### 11. QinQ (Route mode)
- **TR-181 Commands**