Feature #10819: Support top down stack configuration

This commit is contained in:
Amin Ben Romdhane 2023-10-30 08:27:44 +00:00
parent 9c13699204
commit ec9ba2fab3
30 changed files with 2446 additions and 1558 deletions

File diff suppressed because it is too large Load diff

View file

@ -991,6 +991,40 @@ void dmentry_instance_lookup_inparam(struct dmctx *ctx)
ctx->nbrof_instance = i;
}
static void get_reference_paramater_value(struct dmctx *dmctx, char *in_value, char *str, size_t size)
{
char *pch = NULL, *pchr = NULL;
char buf[2048] = {0};
unsigned int pos = 0;
if (!in_value || !str || !size)
return;
memset(str, 0, size);
if (DM_STRLEN(in_value) == 0) {
DM_STRNCPY(str, "=>", size);
return;
}
DM_STRNCPY(buf, in_value, sizeof(buf));
for (pch = strtok_r(buf, ",", &pchr); pch != NULL; pch = strtok_r(NULL, ",", &pchr)) {
uint32_t len = DM_STRLEN(pch);
char *linker = NULL;
if (len && pch[len - 1] == '.')
pch[len - 1] = 0;
adm_entry_get_reference_value(dmctx, pch, &linker);
pos += snprintf((char *)str + pos, size - pos, "%s=>%s,", pch, linker ? linker : "");
}
if (pos)
str[pos - 1] = 0;
}
static int get_ubus_value(struct dmctx *dmctx, struct dmnode *node)
{
json_object *res = NULL, *res_obj = NULL;
@ -1357,7 +1391,7 @@ static int set_ubus_value(struct dmctx *dmctx, struct dmnode *node)
{
json_object *res = NULL, *res_obj = NULL;
char *ubus_name = node->obj->checkdep;
char param_value[512] = {0};
char param_value[2048] = {0};
json_object *in_args = json_object_new_object();
json_object_object_add(in_args, "proto", json_object_new_string((dmctx->dm_type == BBFDM_BOTH) ? "both" : (dmctx->dm_type == BBFDM_CWMP) ? "cwmp" : "usp"));
@ -1365,11 +1399,7 @@ static int set_ubus_value(struct dmctx *dmctx, struct dmnode *node)
json_object_object_add(in_args, "format", json_object_new_string("raw"));
if (is_reference_parameter(ubus_name, dmctx->in_param, in_args)) {
char *linker = NULL;
adm_entry_get_reference_value(dmctx, dmctx->in_value, &linker);
snprintf(param_value, sizeof(param_value), "%s=>%s", dmctx->in_value, linker ? linker : "");
get_reference_paramater_value(dmctx, dmctx->in_value, param_value, sizeof(param_value));
} else {
snprintf(param_value, sizeof(param_value), "%s", dmctx->in_value);
}
@ -2135,7 +2165,7 @@ static int mparam_set_value(DMPARAM_ARGS)
return set_ubus_value(dmctx, node);
} else {
char refparam[MAX_DM_PATH] = {0};
char param_value[512] = {0};
char param_value[2048] = {0};
char *value = "";
snprintf(refparam, MAX_DM_PATH, "%s%s", node->current_object, leaf->parameter);
@ -2171,11 +2201,7 @@ static int mparam_set_value(DMPARAM_ARGS)
}
if ((leaf->dm_falgs & DM_FLAG_REFERENCE) && !DM_STRSTR(dmctx->in_value, "=>")) {
char *linker = NULL;
adm_entry_get_reference_value(dmctx, dmctx->in_value, &linker);
snprintf(param_value, sizeof(param_value), "%s=>%s", dmctx->in_value, linker ? linker : "");
get_reference_paramater_value(dmctx, dmctx->in_value, param_value, sizeof(param_value));
} else {
snprintf(param_value, sizeof(param_value), "%s", dmctx->in_value);
}

View file

@ -442,7 +442,7 @@ struct uci_section *get_dup_section_in_dmmap_eq(char *dmmap_package, char* secti
uci_path_foreach_option_eq(bbfdm, dmmap_package, section_type, "section_name", sect_name, s) {
dmuci_get_value_by_section_string(s, opt_name, &v);
if (opt_value && DM_STRCMP(v, opt_value) == 0)
if (DM_STRCMP(v, opt_value) == 0)
return s;
}
return NULL;
@ -456,7 +456,7 @@ struct uci_section *get_section_in_dmmap_with_options_eq(char *dmmap_package, ch
char *value = NULL;
dmuci_get_value_by_section_string(s, opt2_name, &value);
if (opt2_value && value && DM_STRCMP(value, opt2_value) == 0)
if (DM_STRCMP(value, opt2_value) == 0)
return s;
}

View file

@ -313,7 +313,7 @@ int dm_validate_allowed_objects(struct dmctx *ctx, struct dm_reference *referenc
if (match(reference->path, *objects, 0, NULL)) {
if (DM_STRLEN(reference->value))
if (adm_entry_object_exists(ctx, reference->path))
return 0;
}
}

View file

@ -21,7 +21,7 @@ IF(NOT WITH_WOLFSSL AND NOT WITH_OPENSSL AND NOT WITH_MBEDTLS)
MESSAGE(FATAL_ERROR "You must enable one of the SSL libraries: {'WOLFSSL','OPENSSL','MBEDTLS'}")
ENDIF()
SET(BBF_DM_SOURCES dmdiagnostics.c)
SET(BBF_DM_SOURCES dmcommon.c)
IF(BBF_TR181)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr181")

View file

@ -1,11 +1,11 @@
/*
* Copyright (C) 2019 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>
*
*/
@ -27,7 +27,7 @@
#include <mbedtls/md.h>
#endif
#include "dmdiagnostics.h"
#include "dmcommon.h"
#define READ_BUF_SIZE (1024 * 16)
@ -509,3 +509,450 @@ end:
return res;
}
void ppp___update_sections(struct uci_section *s_from, struct uci_section *s_to)
{
char *proto = NULL;
char *device = NULL;
char *username = NULL;
char *password = NULL;
char *pppd_options = NULL;
char *service = NULL;
char *ac = NULL;
dmuci_get_value_by_section_string(s_from, "proto", &proto);
dmuci_get_value_by_section_string(s_from, "device", &device);
dmuci_get_value_by_section_string(s_from, "username", &username);
dmuci_get_value_by_section_string(s_from, "password", &password);
dmuci_get_value_by_section_string(s_from, "pppd_options", &pppd_options);
dmuci_get_value_by_section_string(s_from, "service", &service);
dmuci_get_value_by_section_string(s_from, "ac", &ac);
dmuci_set_value_by_section(s_to, "proto", proto);
dmuci_set_value_by_section(s_to, "device", DM_STRLEN(device) ? device : section_name(s_to));
dmuci_set_value_by_section(s_to, "username", username);
dmuci_set_value_by_section(s_to, "password", password);
dmuci_set_value_by_section(s_to, "pppd_options", pppd_options);
dmuci_set_value_by_section(s_to, "service", service);
dmuci_set_value_by_section(s_to, "ac", ac);
}
void ppp___reset_options(struct uci_section *ppp_s)
{
dmuci_set_value_by_section(ppp_s, "device", section_name(ppp_s));
dmuci_set_value_by_section(ppp_s, "username", "");
dmuci_set_value_by_section(ppp_s, "password", "");
dmuci_set_value_by_section(ppp_s, "pppd_options", "");
dmuci_set_value_by_section(ppp_s, "service", "");
dmuci_set_value_by_section(ppp_s, "ac", "");
}
void firewall__create_zone_section(char *s_name)
{
struct uci_section *s = NULL;
char *input = NULL;
char *output = NULL;
char *forward = NULL;
dmuci_get_option_value_string("firewall", "@defaults[0]", "input", &input);
dmuci_get_option_value_string("firewall", "@defaults[0]", "output", &output);
dmuci_get_option_value_string("firewall", "@defaults[0]", "forward", &forward);
dmuci_add_section("firewall", "zone", &s);
dmuci_rename_section_by_section(s, s_name);
dmuci_set_value_by_section(s, "name", s_name);
dmuci_set_value_by_section(s, "input", input);
dmuci_set_value_by_section(s, "output", output);
dmuci_set_value_by_section(s, "forward", forward);
dmuci_add_list_value_by_section(s, "network", s_name);
}
bool ip___is_ip_interface_instance_exists(const char *sec_name, const char *device)
{
struct uci_section *s = NULL;
char *curr_dev = NULL;
if (DM_STRLEN(sec_name) == 0 ||
DM_STRLEN(device) == 0)
return false;
uci_foreach_sections("network", "interface", s) {
dmuci_get_value_by_section_string(s, "device", &curr_dev);
if (DM_STRLEN(curr_dev) == 0 ||
DM_STRCMP(curr_dev, device) != 0)
continue;
struct uci_section *dmmap_s = NULL;
char *ip_inst = NULL;
if ((dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(s))) != NULL) {
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_inst);
if (strcmp(sec_name, section_name(s)) != 0 &&
DM_STRLEN(ip_inst) != 0)
return true;
}
}
return false;
}
void ip___update_child_interfaces(char *device, char *option_name, char *option_value)
{
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);
}
}
static void ip___Update_IP_Interface_Layer(char *path, char *linker)
{
struct uci_section *dmmap_s = NULL;
uci_path_foreach_option_eq(bbfdm, "dmmap_network", "interface", "LowerLayers", path, dmmap_s) {
struct uci_section *iface_s = NULL;
char *sec_name = NULL;
char *instance = NULL;
char *curr_device = NULL;
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &instance);
if (!DM_STRLEN(instance))
continue;
dmuci_get_value_by_section_string(dmmap_s, "section_name", &sec_name);
if (!DM_STRLEN(sec_name))
continue;
iface_s = get_origin_section_from_config("network", "interface", sec_name);
if (!iface_s)
continue;
dmuci_get_value_by_section_string(iface_s, "device", &curr_device);
ip___update_child_interfaces(curr_device, "device", DM_STRLEN(linker) ? linker : section_name(iface_s));
}
}
static void ppp___Update_PPP_Interface_Layer(char *path, char *linker)
{
struct uci_section *dmmap_s = NULL;
uci_path_foreach_option_eq(bbfdm, "dmmap_ppp", "interface", "LowerLayers", path, dmmap_s) {
struct uci_section *iface_s = NULL;
char *sec_name = NULL;
char *instance = NULL;
char curr_path[128] = {0};
char proto[8] = {0};
dmuci_get_value_by_section_string(dmmap_s, "ppp_int_instance", &instance);
if (!DM_STRLEN(instance))
continue;
dmuci_get_value_by_section_string(dmmap_s, "iface_name", &sec_name);
if (!DM_STRLEN(sec_name))
continue;
iface_s = get_origin_section_from_config("network", "interface", sec_name);
snprintf(proto, sizeof(proto), "ppp%s", (DM_STRLEN(linker)) ? (!DM_LSTRNCMP(linker, "atm", 3) || !DM_LSTRNCMP(linker, "ptm", 3)) ? "oa" : "oe" : "");
// Update proto option
dmuci_set_value_by_section(dmmap_s, "proto", proto);
if (iface_s) dmuci_set_value_by_section(iface_s, "proto", proto);
// Update device option
dmuci_set_value_by_section(dmmap_s, "device", linker);
if (iface_s) dmuci_set_value_by_section(iface_s, "device", linker);
snprintf(curr_path, sizeof(curr_path), "Device.PPP.Interface.%s", instance);
// Update IP Interface instance if exists
ip___Update_IP_Interface_Layer(curr_path, linker);
}
}
void ppp___Update_PPP_Interface_Top_Layers(char *path, char *linker)
{
char *p = DM_STRRCHR(path, '.');
if (p) *p = 0;
// Update IP Interface instance if exists
ip___Update_IP_Interface_Layer(path, linker);
}
static void ethernet___Update_MAC_VLAN_Layer(char *path, char *linker)
{
struct uci_section *dmmap_s = NULL;
uci_path_foreach_option_eq(bbfdm, "dmmap_network", "device", "LowerLayers", path, dmmap_s) {
struct uci_section *dev_s = NULL;
char *sec_name = NULL;
char *instance = NULL;
char curr_path[128] = {0};
char name[32] = {0};
dmuci_get_value_by_section_string(dmmap_s, "mac_vlan_instance", &instance);
if (!DM_STRLEN(instance))
continue;
dmuci_get_value_by_section_string(dmmap_s, "section_name", &sec_name);
if (!DM_STRLEN(sec_name))
continue;
dev_s = get_origin_section_from_config("network", "device", sec_name);
if (!dev_s)
continue;
if (DM_STRLEN(linker)) {
char *dev_name = ethernet___get_ethernet_interface_name(linker);
snprintf(name, sizeof(name), "%s_%s", dev_name, instance);
}
dmuci_set_value_by_section(dev_s, "ifname", linker);
dmuci_set_value_by_section(dev_s, "name", name);
snprintf(curr_path, sizeof(curr_path), "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.%s", instance);
// Update PPP Interface instance if exists
ppp___Update_PPP_Interface_Layer(curr_path, name);
// Update IP Interface instance if exists
ip___Update_IP_Interface_Layer(curr_path, name);
}
}
void ethernet___Update_MAC_VLAN_Top_Layers(char *path, char *linker)
{
char *p = DM_STRRCHR(path, '.');
if (p) *p = 0;
// Update PPP Interface instance if exists
ppp___Update_PPP_Interface_Layer(path, linker);
// Update IP Interface instance if exists
ip___Update_IP_Interface_Layer(path, linker);
}
static void ethernet___Update_VLAN_Termination_Layer(char *path, char *linker)
{
struct uci_section *dmmap_s = NULL;
uci_path_foreach_option_eq(bbfdm, "dmmap_network", "device", "LowerLayers", path, dmmap_s) {
struct uci_section *dev_s = NULL;
char *sec_name = NULL;
char *instance = NULL;
char curr_path[128] = {0};
char name[32] = {0};
dmuci_get_value_by_section_string(dmmap_s, "vlan_term_instance", &instance);
if (!DM_STRLEN(instance))
continue;
dmuci_get_value_by_section_string(dmmap_s, "section_name", &sec_name);
if (!DM_STRLEN(sec_name))
continue;
dev_s = get_origin_section_from_config("network", "device", sec_name);
if (!dev_s)
continue;
if (DM_STRLEN(linker)) {
char *vid = NULL;
dmuci_get_value_by_section_string(dev_s, "vid", &vid);
snprintf(name, sizeof(name), "%s%s%s", linker, DM_STRLEN(vid) ? "." : "", DM_STRLEN(vid) ? vid : "");
}
dmuci_set_value_by_section(dev_s, "ifname", linker);
dmuci_set_value_by_section(dev_s, "name", name);
snprintf(curr_path, sizeof(curr_path), "Device.Ethernet.VLANTermination.%s", instance);
// Update VLAN Termination instance if exists
ethernet___Update_VLAN_Termination_Layer(curr_path, name);
// Update MACVLAN instance if exists
ethernet___Update_MAC_VLAN_Layer(curr_path, name);
// Update PPP Interface instance if exists
ppp___Update_PPP_Interface_Layer(curr_path, name);
// Update IP Interface instance if exists
ip___Update_IP_Interface_Layer(curr_path, name);
}
}
void ethernet___Update_VLAN_Termination_Top_Layers(char *path, char *linker)
{
char *p = DM_STRRCHR(path, '.');
if (p) *p = 0;
// Update VLAN Termination instance if exists
ethernet___Update_VLAN_Termination_Layer(path, linker);
// Update MACVLAN instance if exists
ethernet___Update_MAC_VLAN_Layer(path, linker);
// Update PPP Interface instance if exists
ppp___Update_PPP_Interface_Layer(path, linker);
// Update IP Interface instance if exists
ip___Update_IP_Interface_Layer(path, linker);
}
void ethernet___Update_Link_Layer(char *path, char *linker)
{
struct uci_section *dmmap_s = NULL;
char *p = DM_STRRCHR(path, '.');
if (p) *p = 0;
uci_path_foreach_option_eq(bbfdm, "dmmap_ethernet", "link", "LowerLayers", path, dmmap_s) {
char *instance = NULL;
char curr_path[128] = {0};
dmuci_get_value_by_section_string(dmmap_s, "link_instance", &instance);
if (!DM_STRLEN(instance))
continue;
dmuci_set_value_by_section(dmmap_s, "device", linker);
if (match(path, "Device.Bridging.Bridge.*.Port.", 0, NULL)) {
// Remove unused Interface section created by Bridge Object if it exists
struct uci_section *s = get_dup_section_in_config_opt("network", "interface", "device", linker);
dmuci_delete_by_section(s, NULL, NULL);
}
snprintf(curr_path, sizeof(curr_path), "Device.Ethernet.Link.%s", instance);
// Update IP Interface instance if exists
ip___Update_IP_Interface_Layer(curr_path, linker);
}
}
void ethernet___Update_Link_Top_Layers(char *path, char *linker)
{
char *p = DM_STRRCHR(path, '.');
if (p) *p = 0;
// Update VLAN Termination instance if exists
ethernet___Update_VLAN_Termination_Layer(path, linker);
// Update MACVLAN instance if exists
ethernet___Update_MAC_VLAN_Layer(path, linker);
// Update PPP Interface instance if exists
ppp___Update_PPP_Interface_Layer(path, linker);
// Update IP Interface instance if exists
ip___Update_IP_Interface_Layer(path, linker);
}
void bridging___get_priority_list(struct uci_section *device_sec, char *uci_opt_name, void *data, char **value)
{
struct uci_list *uci_opt_list = NULL;
struct uci_element *e = NULL;
char uci_value[256] = {0};
unsigned pos = 0;
if (!data || !uci_opt_name)
return;
dmuci_get_value_by_section_list(device_sec, uci_opt_name, &uci_opt_list);
if (uci_opt_list == NULL)
return;
uci_value[0] = '\0';
/* traverse each list value and create comma separated output */
uci_foreach_element(uci_opt_list, e) {
//delimiting priority which is in the form of x:y where y is the priority
char *priority = strchr(e->name, ':');
if (priority)
pos += snprintf(&uci_value[pos], sizeof(uci_value) - pos, "%s,", priority + 1);
}
if (pos)
uci_value[pos - 1] = 0;
dmasprintf(value, "%s", uci_value);
}
void bridging___set_priority_list(struct uci_section *device_sec, char *uci_opt_name, void *data, char *value)
{
char *pch = NULL, *pchr = NULL;
int idx = 0;
if (!data || !uci_opt_name || !value)
return;
/* delete current list values */
dmuci_set_value_by_section(device_sec, uci_opt_name, "");
/* tokenize each value from received comma separated string and add it to uci file in the format x:y
x being priority and y being priority to be mapped to */
for (pch = strtok_r(value, ",", &pchr); pch != NULL; pch = strtok_r(NULL, ",", &pchr), idx++) {
char buf[16] = {0};
/* convert values to uci format (x:y) and add */
snprintf(buf, sizeof(buf), "%d%c%s", idx, ':', pch);
dmuci_add_list_value_by_section(device_sec, uci_opt_name, buf);
}
}
struct uci_section *ethernet___get_ethernet_interface_section(const char *device_name)
{
struct uci_section *s = NULL;
uci_foreach_sections("network", "device", s) {
char *name = NULL;
if (!dmuci_is_option_value_empty(s, "type"))
continue;
dmuci_get_value_by_section_string(s, "name", &name);
if (DM_STRCMP(name, device_name) == 0)
return s;
}
return NULL;
}
char *ethernet___get_ethernet_interface_name(char *device_name)
{
char *dev_name = dmstrdup(device_name);
if (!ethernet___get_ethernet_interface_section(dev_name)) {
struct uci_section *dev_s = NULL;
dev_s = get_dup_section_in_config_opt("network", "device", "name", dev_name);
char *has_vid = DM_STRRCHR(dev_name, '.');
if (has_vid)
*has_vid = '\0';
if (dev_s) { // Verify if the device has dual tags
char *type = NULL;
dmuci_get_value_by_section_string(dev_s, "type", &type);
if (DM_STRCMP(type, "8021ad") == 0) {
char *has_vid = DM_STRRCHR(dev_name, '.');
if (has_vid)
*has_vid = '\0';
}
}
}
return dev_name;
}

View file

@ -1,16 +1,16 @@
/*
* Copyright (C) 2019 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>
*
*/
#ifndef __DMDIAGNOSTICS_H__
#define __DMDIAGNOSTICS_H__
#ifndef __DMCOMMON_H__
#define __DMCOMMON_H__
#include "libbbfdm-api/dmcommon.h"
#include <libubox/uloop.h>
@ -57,4 +57,24 @@ int bbf_fw_image_download(const char *url, const char *auto_activate, const char
const char *file_size, const char *checksum_algorithm, const char *checksum,
const char *bank_id, const char *command, const char *obj_path, const char *commandKey);
#endif
bool ip___is_ip_interface_instance_exists(const char *sec_name, const char *device);
void ip___update_child_interfaces(char *device, char *option_name, char *option_value);
void ppp___update_sections(struct uci_section *s_from, struct uci_section *s_to);
void ppp___reset_options(struct uci_section *ppp_s);
void ppp___Update_PPP_Interface_Top_Layers(char *path, char *linker);
void ethernet___Update_MAC_VLAN_Top_Layers(char *path, char *linker);
void ethernet___Update_VLAN_Termination_Top_Layers(char *path, char *linker);
void ethernet___Update_Link_Layer(char *path, char *linker);
void ethernet___Update_Link_Top_Layers(char *path, char *linker);
void bridging___get_priority_list(struct uci_section *device_sec, char *uci_opt_name, void *data, char **value);
void bridging___set_priority_list(struct uci_section *device_sec, char *uci_opt_name, void *data, char *value);
void firewall__create_zone_section(char *s_name);
struct uci_section *ethernet___get_ethernet_interface_section(const char *device_name);
char *ethernet___get_ethernet_interface_name(char *device_name);
#endif //__DMCOMMON_H__

View file

@ -9,7 +9,7 @@
*
*/
#include "dmdiagnostics.h"
#include "dmcommon.h"
#include "diagnostics.h"
#ifdef BBF_TR471
#include "iplayercap.h"

View file

@ -184,7 +184,7 @@ static int set_atm_destination_address(char *refparam, struct dmctx *ctx, void *
/*#Device.ATM.Link.{i}.Name!UCI:dsl/atm-device,@i-1/name*/
static int get_atm_link_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((((struct atm_args *)data)->sections)->config_section, "name", value);
*value = dmstrdup(((struct atm_args *)data)->device);
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -37,7 +37,4 @@ extern DMOBJ tBridgingBridgePortObj[];
extern DMLEAF tBridgingBridgePortStatsParams[];
extern DMLEAF tBridgingProviderBridgeParams[];
void bridging_get_priority_list(char *uci_opt_name, void *data, char **value);
void bridging_set_priority_list(char *uci_opt_name, void *data, char *value);
#endif

View file

@ -10,7 +10,7 @@
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#include "dmdiagnostics.h"
#include "dmcommon.h"
#include "deviceinfo.h"
#include "sys/statvfs.h"

View file

@ -1215,12 +1215,20 @@ static int delObjDHCPv4Client(char *refparam, struct dmctx *ctx, void *data, cha
dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dmmap_s, "dhcp_client_key", &dhcp_client_key);
if (((struct dhcp_client_args *)data)->iface_s) {
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "proto", "none");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "clientid", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "vendorid", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "hostname", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "sendopts", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "reqopts", "");
char *ip_instance = NULL;
struct uci_section *dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(((struct dhcp_client_args *)data)->iface_s));
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance);
if (dmmap_s && DM_STRLEN(ip_instance) == 0) {
dmuci_delete_by_section(((struct dhcp_client_args *)data)->iface_s, NULL, NULL);
} else {
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "proto", "none");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "clientid", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "vendorid", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "hostname", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "sendopts", "");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->iface_s, "reqopts", "");
}
}
uci_path_foreach_option_eq_safe(bbfdm, "dmmap_dhcp_client", "send_option", "dhcp_client_key", dhcp_client_key, stmp, s) {
@ -1245,12 +1253,20 @@ static int delObjDHCPv4Client(char *refparam, struct dmctx *ctx, void *data, cha
get_config_section_of_dmmap_section("network", "interface", iface_name, &iface_s);
if (iface_s) {
dmuci_set_value_by_section(iface_s, "proto", "none");
dmuci_set_value_by_section(s, "clientid", "");
dmuci_set_value_by_section(s, "vendorid", "");
dmuci_set_value_by_section(s, "hostname", "");
dmuci_set_value_by_section(s, "sendopts", "");
dmuci_set_value_by_section(s, "reqopts", "");
char *ip_instance = NULL;
struct uci_section *dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(iface_s));
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance);
if (dmmap_s && DM_STRLEN(ip_instance) == 0) {
dmuci_delete_by_section(iface_s, NULL, NULL);
} else {
dmuci_set_value_by_section(iface_s, "proto", "none");
dmuci_set_value_by_section(iface_s, "clientid", "");
dmuci_set_value_by_section(iface_s, "vendorid", "");
dmuci_set_value_by_section(iface_s, "hostname", "");
dmuci_set_value_by_section(iface_s, "sendopts", "");
dmuci_set_value_by_section(iface_s, "reqopts", "");
}
}
uci_path_foreach_option_eq_safe(bbfdm, "dmmap_dhcp_client", "send_option", "dhcp_client_key", dhcp_client_key, sstmp, ss) {
@ -2284,6 +2300,20 @@ static int get_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *d
dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dmmap_s, "iface_name", &iface_name);
adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", iface_name, value);
if (DM_STRLEN(*value) == 0 && ((struct dhcp_client_args *)data)->iface_s) {
struct uci_section *s = NULL;
char *device = NULL;
dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->iface_s, "device", &device);
if (DM_STRLEN(device) == 0)
return 0;
s = get_dup_section_in_config_opt("network", "interface", "device", device);
adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", section_name(s), value);
}
return 0;
}
@ -2307,23 +2337,55 @@ static int set_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *d
break;
case VALUESET:
if (dhcpv4_client->iface_s) {
dmuci_set_value_by_section(dhcpv4_client->iface_s, "proto", "none");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "clientid", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "vendorid", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "hostname", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "sendopts", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "reqopts", "");
char *ip_instance = NULL;
struct uci_section *dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(dhcpv4_client->iface_s));
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance);
if (dmmap_s && DM_STRLEN(ip_instance) == 0) {
dmuci_delete_by_section(dhcpv4_client->iface_s, NULL, NULL);
} else {
dmuci_set_value_by_section(dhcpv4_client->iface_s, "proto", "none");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "clientid", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "vendorid", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "hostname", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "sendopts", "");
dmuci_set_value_by_section(dhcpv4_client->iface_s, "reqopts", "");
}
}
if (DM_STRLEN(reference.value) == 0) {
dmuci_set_value_by_section_bbfdm(dhcpv4_client->dmmap_s, "iface_name", "");
} else {
// Update iface_name option
dmuci_set_value_by_section_bbfdm(dhcpv4_client->dmmap_s, "iface_name", reference.value);
if (DM_STRLEN(reference.value)) {
struct uci_section *interface_s = NULL;
char *curr_proto = NULL;
get_config_section_of_dmmap_section("network", "interface", reference.value, &interface_s);
if (interface_s == NULL)
return FAULT_9007;
// Get the current proto
dmuci_get_value_by_section_string(interface_s, "proto", &curr_proto);
if (DM_STRCMP(curr_proto, "dhcpv6") == 0) {
// There is a DHCPv6 Client map to this interface section, therefore create a new interface section
char *curr_device = NULL;
char buf[32] = {0};
snprintf(buf, sizeof(buf), "%s4", section_name(interface_s));
// Get the current device
dmuci_get_value_by_section_string(interface_s, "device", &curr_device);
dmuci_add_section("network", "interface", &interface_s);
dmuci_rename_section_by_section(interface_s, buf);
// Update device option
dmuci_set_value_by_section(interface_s, "device", curr_device);
// Update iface_name option
dmuci_set_value_by_section_bbfdm(dhcpv4_client->dmmap_s, "iface_name", buf);
}
// Update proto option of config section
dmuci_set_value_by_section(interface_s, "proto", "dhcp");
@ -2340,6 +2402,7 @@ static int set_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *d
// Added the enabled options for reqopts
create_dhcp_req_option_list(interface_s, dhcp_client_key);
}
break;
}
return 0;

View file

@ -345,10 +345,18 @@ static int delObjDHCPv6Client(char *refparam, struct dmctx *ctx, void *data, cha
dmuci_delete_by_section(((struct dhcpv6_client_args *)data)->dmmap_s, NULL, NULL);
if (((struct dhcpv6_client_args *)data)->iface_s) {
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "proto", "none");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqaddress", "");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqprefix", "");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqopts", "");
char *ip_instance = NULL;
struct uci_section *dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(((struct dhcpv6_client_args *)data)->iface_s));
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance);
if (dmmap_s && DM_STRLEN(ip_instance) == 0) {
dmuci_delete_by_section(((struct dhcpv6_client_args *)data)->iface_s, NULL, NULL);
} else {
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "proto", "none");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqaddress", "");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqprefix", "");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqopts", "");
}
}
break;
case DEL_ALL:
@ -361,10 +369,18 @@ static int delObjDHCPv6Client(char *refparam, struct dmctx *ctx, void *data, cha
get_config_section_of_dmmap_section("network", "interface", iface_name, &iface_s);
if (iface_s) {
dmuci_set_value_by_section(iface_s, "proto", "none");
dmuci_set_value_by_section(iface_s, "reqaddress", "");
dmuci_set_value_by_section(iface_s, "reqprefix", "");
dmuci_set_value_by_section(iface_s, "reqopts", "");
char *ip_instance = NULL;
struct uci_section *dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(iface_s));
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance);
if (dmmap_s && DM_STRLEN(ip_instance) == 0) {
dmuci_delete_by_section(iface_s, NULL, NULL);
} else {
dmuci_set_value_by_section(iface_s, "proto", "none");
dmuci_set_value_by_section(iface_s, "reqaddress", "");
dmuci_set_value_by_section(iface_s, "reqprefix", "");
dmuci_set_value_by_section(iface_s, "reqopts", "");
}
}
dmuci_delete_by_section(s, NULL, NULL);
@ -554,16 +570,26 @@ static int set_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *d
break;
case VALUESET:
if (dhcpv6_client->iface_s) {
dmuci_set_value_by_section(dhcpv6_client->iface_s, "proto", "none");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqaddress", "");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqprefix", "");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqopts", "");
char *ip_instance = NULL;
struct uci_section *dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(dhcpv6_client->iface_s));
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance);
if (dmmap_s && DM_STRLEN(ip_instance) == 0) {
dmuci_delete_by_section(dhcpv6_client->iface_s, NULL, NULL);
} else {
dmuci_set_value_by_section(dhcpv6_client->iface_s, "proto", "none");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqaddress", "");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqprefix", "");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqopts", "");
}
}
if (DM_STRLEN(reference.value) == 0) {
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "iface_name", "");
} else {
// Update iface_name option
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "iface_name", reference.value);
if (DM_STRLEN(reference.value)) {
struct uci_section *interface_s = NULL;
char *curr_proto = NULL;
char *reqaddress = NULL;
char *reqprefix = NULL;
char *reqopts = NULL;
@ -572,12 +598,31 @@ static int set_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *d
if (interface_s == NULL)
return FAULT_9007;
// Get the current proto
dmuci_get_value_by_section_string(interface_s, "proto", &curr_proto);
if (DM_STRCMP(curr_proto, "dhcp") == 0) {
// There is a DHCPv4 Client map to this interface section, therefore create a new interface section
char *curr_device = NULL;
char buf[32] = {0};
snprintf(buf, sizeof(buf), "%s6", section_name(interface_s));
// Get the current device
dmuci_get_value_by_section_string(interface_s, "device", &curr_device);
dmuci_add_section("network", "interface", &interface_s);
dmuci_rename_section_by_section(interface_s, buf);
// Update device option
dmuci_set_value_by_section(interface_s, "device", curr_device);
// Update iface_name option
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "iface_name", buf);
}
// Update proto option of config section
dmuci_set_value_by_section(interface_s, "proto", "dhcpv6");
// Update dmmap section
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "iface_name", reference.value);
// Get the current value of requested parameters
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "reqaddress", &reqaddress);
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "reqprefix", &reqprefix);

View file

@ -8,7 +8,7 @@
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#include "dmdiagnostics.h"
#include "dmcommon.h"
#include "dns.h"
/* Returns dnsmasq section name belongs to LAN network */

View file

@ -44,25 +44,6 @@ static inline int init_eth_rmon(struct eth_rmon_args *args, struct dmmap_dup *s,
/*************************************************************
* COMMON FUNCTIONS
**************************************************************/
struct uci_section *ethernet___get_ethernet_interface_section(const char *device_name)
{
struct uci_section *s = NULL;
uci_foreach_sections("network", "device", s) {
char *name = NULL;
if (!dmuci_is_option_value_empty(s, "type"))
continue;
dmuci_get_value_by_section_string(s, "name", &name);
if (DM_STRCMP(name, device_name) == 0)
return s;
}
return NULL;
}
static bool check_vlan_termination_section(const char *name)
{
struct uci_section *s = NULL;
@ -109,16 +90,6 @@ static struct uci_section *is_ethernet_link_exist(char *device)
return NULL;
}
static bool name_exists_in_devices(char *name)
{
struct uci_section *s = NULL;
uci_foreach_option_eq("network", "device", "name", name, s) {
return true;
}
return false;
}
static bool is_mac_vlan_interface(char *device_name)
{
struct uci_section *s = NULL;
@ -144,16 +115,16 @@ static void add_ethernet_link_section(char *device, char *macaddr)
dmuci_set_value_by_section(dmmap_s, "mac", macaddr);
dmuci_set_value_by_section(dmmap_s, "device", device);
dmuci_set_value_by_section(dmmap_s, "is_eth", (!DM_LSTRNCMP(device, "atm", 3) || !DM_LSTRNCMP(device, "ptm", 3)) ? "0" : "1");
}
static void dmmap_synchronizeEthernetLink(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct uci_section *s = NULL;
struct uci_section *s = NULL, *dmmap_s = NULL;
char *ip_instance = NULL;
char *proto = NULL;
char *macaddr = NULL;
char *device = NULL;
char dev_name[32] = {0};
char *dev_name = NULL;
uci_foreach_sections("network", "interface", s) {
@ -166,9 +137,15 @@ static void dmmap_synchronizeEthernetLink(struct dmctx *dmctx, DMNODE *parent_no
if (strcmp(section_name(s), "loopback") == 0)
continue;
// Skip this interface section if its device starts with prfix 'link_'
// Skip this interface section if there is no IP.Interface instance map on it
dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(s));
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance);
if (!dmmap_s || DM_STRLEN(ip_instance) == 0)
continue;
// Skip this interface section if its device option has the section_name value
dmuci_get_value_by_section_string(s, "device", &device);
if (DM_STRNCMP(device, "link_", 5) == 0 || DM_STRNCMP(device, "iface", 5) == 0)
if (strcmp(section_name(s), device) == 0)
continue;
// Skip this interface section if its device is empty
@ -178,28 +155,7 @@ static void dmmap_synchronizeEthernetLink(struct dmctx *dmctx, DMNODE *parent_no
get_net_device_sysfs(device, "address", &macaddr);
DM_STRNCPY(dev_name, device, sizeof(dev_name));
if (!ethernet___get_ethernet_interface_section(dev_name)) {
struct uci_section *dev_s = NULL;
dev_s = get_dup_section_in_config_opt("network", "device", "name", dev_name);
char *has_vid = DM_STRRCHR(dev_name, '.');
if (has_vid)
*has_vid = '\0';
if (dev_s) { // Verify if the device has dual tags
char *type = NULL;
dmuci_get_value_by_section_string(dev_s, "type", &type);
if (DM_STRCMP(type, "8021ad") == 0) {
char *has_vid = DM_STRRCHR(dev_name, '.');
if (has_vid)
*has_vid = '\0';
}
}
}
dev_name = ethernet___get_ethernet_interface_name(device);
if (is_mac_vlan_interface(dev_name)) {
char *p = DM_STRRCHR(dev_name, '_');
@ -334,59 +290,22 @@ static int addObjEthernetLink(char *refparam, struct dmctx *ctx, void *data, cha
/* Add link section in dmmap_ethernet file */
dmuci_add_section_bbfdm("dmmap_ethernet", "link", &dmmap_link);
dmuci_set_value_by_section(dmmap_link, "is_eth", "1");
dmuci_set_value_by_section(dmmap_link, "link_instance", *instance);
return 0;
}
static void update_all_interfaces(char *old_device)
{
struct uci_section *s = NULL;
char buf[32] = {0};
if (DM_STRLEN(old_device) == 0)
return;
snprintf(buf, sizeof(buf), "link_%s", old_device);
replace_special_char(buf, '_');
uci_foreach_option_eq("network", "interface", "device", old_device, s) {
dmuci_set_value_by_section(s, "device", buf);
}
}
static int delObjEthernetLink(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *stmp = NULL;
char *device_iface = NULL;
char *device = NULL;
switch (del_action) {
case DEL_INST:
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device);
if (DM_STRLEN(device)) {
uci_foreach_option_cont("network", "interface", "device", device, s) {
dmuci_get_value_by_section_string(s, "device", &device_iface);
update_all_interfaces(device_iface);
}
}
// Update Ethernet Link Top Layers
ethernet___Update_Link_Top_Layers(refparam, "");
// Remove link section
dmuci_delete_by_section((struct uci_section *)data, NULL, NULL);
return 0;
case DEL_ALL:
uci_path_foreach_sections_safe(bbfdm, "dmmap_ethernet", "link", stmp, s) {
dmuci_get_value_by_section_string(s, "device", &device);
if (DM_STRLEN(device)) {
uci_foreach_option_cont("network", "interface", "device", device, s) {
dmuci_get_value_by_section_string(s, "device", &device_iface);
update_all_interfaces(device_iface);
}
}
// Remove link section
dmuci_delete_by_section(s, NULL, NULL);
}
break;
}
return 0;
}
@ -412,11 +331,11 @@ static int addObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void
static int delObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s_dev = NULL, *sdevtmp = NULL;
char *name, *type;
switch (del_action) {
case DEL_INST:
// Update Ethernet VLAN Termination Top Layers
ethernet___Update_VLAN_Termination_Top_Layers(refparam, "");
// Remove device section
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
@ -424,26 +343,6 @@ static int delObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void
dmuci_delete_by_section(((struct dmmap_dup *)data)->dmmap_section, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections_safe("network", "device", sdevtmp, s_dev) {
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_network", "device", section_name(s_dev), &dmmap_section);
dmuci_get_value_by_section_string(s_dev, "type", &type);
dmuci_get_value_by_section_string(s_dev, "name", &name);
if (DM_STRLEN(type) == 0 ||
DM_LSTRCMP(type, "bridge") == 0 ||
DM_LSTRCMP(type, "macvlan") == 0 ||
(*name != 0 && !check_vlan_termination_section(name)) ||
(*name == 0 && strncmp(section_name(s_dev), "br_", 3) == 0))
continue;
// Remove device section in dmmap_network file
dmuci_delete_by_section(dmmap_section, NULL, NULL);
// Remove device section
dmuci_delete_by_section(s_dev, NULL, NULL);
}
break;
}
return 0;
@ -989,17 +888,17 @@ static int set_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void
// Store LowerLayers value under dmmap section
dmuci_set_value_by_section((struct uci_section *)data, "LowerLayers", reference.path);
dmuci_set_value_by_section((struct uci_section *)data, "is_eth", !DM_STRNCMP(reference.path, "Device.Ethernet.", strlen("Device.Ethernet.")) ? "1" : "0");
// Update device option
dmuci_set_value_by_section((struct uci_section *)data, "device", reference.value);
if (match(reference.path, "Device.Bridging.Bridge.*.Port.", 0, NULL)) {
dmuci_set_value_by_section((struct uci_section *)data, "is_eth", "1");
// Remove unused Interface section created by Bridge Object if it exists
struct uci_section *s = get_dup_section_in_config_opt("network", "interface", "device", reference.value);
dmuci_delete_by_section(s, NULL, NULL);
}
dmuci_set_value_by_section((struct uci_section *)data, "device", reference.value);
// Update Ethernet Link Top Layers
ethernet___Update_Link_Top_Layers(refparam, reference.value);
break;
}
return 0;
@ -1014,16 +913,15 @@ static int get_EthernetLink_MACAddress(char *refparam, struct dmctx *ctx, void *
static int get_EthernetLink_FlowControl(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *port_s = NULL;
char *device = NULL, *is_eth = NULL;
dmuci_get_value_by_section_string((struct uci_section *)data, "is_eth", &is_eth);
if (!is_eth || *is_eth == '0')
goto end;
char *device = NULL;
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device);
if (!DM_STRLEN(device))
goto end;
if (!DM_LSTRNCMP(device, "atm", 3) || !DM_LSTRNCMP(device, "ptm", 3))
goto end;
char *is_bridge = DM_LSTRSTR(device, "br-");
if (is_bridge) {
/* Ethernet.Link.{i}. ---> Bridging.Bridge.{i}.Port.{i}. */
@ -1079,7 +977,7 @@ end:
static int set_EthernetLink_FlowControl(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *port_s = NULL;
char *device = NULL, *is_eth = NULL;
char *device = NULL;
bool b;
switch (action) {
@ -1090,14 +988,13 @@ static int set_EthernetLink_FlowControl(char *refparam, struct dmctx *ctx, void
case VALUESET:
string_to_bool(value, &b);
dmuci_get_value_by_section_string((struct uci_section *)data, "is_eth", &is_eth);
if (!is_eth || *is_eth == '0')
break;
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device);
if (!DM_STRLEN(device))
break;
if (!DM_LSTRNCMP(device, "atm", 3) || !DM_LSTRNCMP(device, "ptm", 3))
break;
char *is_bridge = DM_LSTRSTR(device, "br-");
if (is_bridge) {
/* Ethernet.Link.{i}. ---> Bridging.Bridge.{i}.Port.{i}. */
@ -1308,6 +1205,7 @@ static int set_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx
"Device.Ethernet.Link.",
NULL};
struct dm_reference reference = {0};
char name[32] = {0};
bbf_get_reference_args(value, &reference);
@ -1324,82 +1222,20 @@ static int set_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx
// Store LowerLayers value under dmmap section
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "LowerLayers", reference.path);
if (DM_STRLEN(reference.value) == 0) {
// Set ifname and name options of device section to empty value
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ifname", "");
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", "");
}
if (DM_STRNCMP(reference.path, "Device.Ethernet.Link.", DM_STRLEN("Device.Ethernet.Link.")) == 0) {
char new_name[16] = {0};
char *old_name = NULL;
char *vid = NULL;
// Get name and vid options from the current device section
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", &old_name);
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "vid", &vid);
snprintf(new_name, sizeof(new_name), "%s%s%s", reference.value, DM_STRLEN(vid) ? "." : "", DM_STRLEN(vid) ? vid : "");
if (name_exists_in_devices(new_name))
return -1;
if (DM_STRLEN(old_name)) {
{ // Check if there is a X_IOPSYS_EU_MACVLAN linked to this VLANTermination
struct uci_section *macvlan_s = NULL;
char *ifname = NULL;
uci_foreach_option_eq("network", "device", "type", "macvlan", macvlan_s) {
dmuci_set_value_by_section(macvlan_s, "ifname", ifname);
if (DM_STRLEN(ifname) == 0 || DM_STRCMP(ifname, old_name) != 0)
continue;
dmuci_set_value_by_section(macvlan_s, "ifname", new_name);
dmuci_set_value_by_section(macvlan_s, "name", new_name);
}
}
{ // Check if there is a PPP.Interface linked to this VLANTermination
struct uci_section *ppp_s = get_dup_section_in_dmmap_opt("dmmap_ppp", "interface", "device", old_name);
if (ppp_s) {
char *iface_name = NULL;
dmuci_get_value_by_section_string(ppp_s, "iface_name", &iface_name);
if (DM_STRLEN(iface_name)) {
struct uci_section *s = get_origin_section_from_config("network", "interface", iface_name);
dmuci_set_value_by_section(s, "device", new_name);
}
dmuci_set_value_by_section(ppp_s, "device", new_name);
}
}
{ // Check if there is an IP.Interface linked to this VLANTermination
struct uci_section *iface_s = get_dup_section_in_config_opt("network", "interface", "device", old_name);
dmuci_set_value_by_section(iface_s, "device", new_name);
}
}
// Set ifname and name options of device section
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ifname", reference.value);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", new_name);
}
if (DM_STRNCMP(reference.path, "Device.Ethernet.VLANTermination.", DM_STRLEN("Device.Ethernet.VLANTermination.")) == 0) {
char new_name[32] = {0};
if (DM_STRLEN(reference.value)) {
char *vid = NULL;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "vid", &vid);
snprintf(new_name, sizeof(new_name), "%s%s%s", reference.value, DM_STRLEN(vid) ? "." : "", DM_STRLEN(vid) ? vid : "");
if (name_exists_in_devices(new_name))
return -1;
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ifname", reference.value);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", new_name);
snprintf(name, sizeof(name), "%s%s%s", reference.value, DM_STRLEN(vid) ? "." : "", DM_STRLEN(vid) ? vid : "");
}
// Update ifname and name options
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ifname", reference.value);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", name);
// Update Ethernet VLAN Termination Top Layers
ethernet___Update_VLAN_Termination_Top_Layers(refparam, name);
break;
}
return 0;
@ -1415,7 +1251,7 @@ static int get_EthernetVLANTermination_VLANID(char *refparam, struct dmctx *ctx,
static int set_EthernetVLANTermination_VLANID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *ifname = NULL;
char *vid = NULL;
char name[32] = {0};
switch (action) {
case VALUECHECK:
@ -1423,57 +1259,15 @@ static int set_EthernetVLANTermination_VLANID(char *refparam, struct dmctx *ctx,
return FAULT_9007;
return 0;
case VALUESET:
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, "vid", &vid);
if (DM_STRLEN(ifname) != 0 && DM_STRLEN(vid) != 0) {
struct uci_section *uci_s = NULL;
char old_name[32] = {0};
char new_name[32] = {0};
char *name = NULL;
snprintf(old_name, sizeof(old_name), "%s.%s", ifname, vid);
snprintf(new_name, sizeof(new_name), "%s.%s", ifname, value);
if (name_exists_in_devices(new_name))
return 0;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", &name);
uci_foreach_option_eq("network", "device", "type", "8021ad", uci_s) {
char *curr_ifname = NULL;
dmuci_get_value_by_section_string(uci_s, "ifname", &curr_ifname);
if (DM_STRCMP(curr_ifname, name) == 0) {
char __new_name[32] = {0};
char *curr_name = NULL;
char *curr_vid = NULL;
dmuci_get_value_by_section_string(uci_s, "name", &curr_name);
dmuci_get_value_by_section_string(uci_s, "vid", &curr_vid);
snprintf(__new_name, sizeof(__new_name), "%s.%s.%s", ifname, value, curr_vid);
dmuci_set_value_by_section(uci_s, "ifname", new_name);
dmuci_set_value_by_section(uci_s, "name", __new_name);
struct uci_section *iface_s = get_dup_section_in_config_opt("network", "interface", "device", curr_name);
dmuci_set_value_by_section(iface_s, "device", __new_name);
}
}
// set device option of the corresponding interface section
uci_s = get_dup_section_in_config_opt("network", "interface", "device", old_name);
dmuci_set_value_by_section(uci_s, "device", new_name);
// set name option of the device section
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", new_name);
}
// set vid option of the device section
// Update vid option
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "vid", value);
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ifname", &ifname);
snprintf(name, sizeof(name), "%s%s%s", DM_STRLEN(ifname) ? ifname : "", DM_STRLEN(ifname) ? "." : "", DM_STRLEN(ifname) ? value : "");
// Update Ethernet VLAN Termination Top Layers
ethernet___Update_VLAN_Termination_Top_Layers(refparam, name);
return 0;
}
return 0;

View file

@ -13,7 +13,7 @@
#ifndef __ETHERNET_H
#define __ETHERNET_H
#include "libbbfdm-api/dmcommon.h"
#include "dmcommon.h"
extern DMOBJ tEthernetObj[];
extern DMLEAF tEthernetParams[];
@ -28,6 +28,4 @@ extern DMLEAF tEthernetVLANTerminationParams[];
extern DMLEAF tEthernetVLANTerminationStatsParams[];
extern DMLEAF tEthernetRMONStatsParams[];
struct uci_section *ethernet___get_ethernet_interface_section(const char *device_name);
#endif //__ETHERNET_H

View file

@ -24,27 +24,6 @@ struct rule_sec
/*************************************************************
* COMMON FUNCTIONS
**************************************************************/
void firewall__create_zone_section(char *s_name)
{
struct uci_section *s = NULL;
char *input = NULL;
char *output = NULL;
char *forward = NULL;
dmuci_get_option_value_string("firewall", "@defaults[0]", "input", &input);
dmuci_get_option_value_string("firewall", "@defaults[0]", "output", &output);
dmuci_get_option_value_string("firewall", "@defaults[0]", "forward", &forward);
dmuci_add_section("firewall", "zone", &s);
dmuci_rename_section_by_section(s, s_name);
dmuci_set_value_by_section(s, "name", s_name);
dmuci_set_value_by_section(s, "input", input);
dmuci_set_value_by_section(s, "output", output);
dmuci_set_value_by_section(s, "forward", forward);
dmuci_add_list_value_by_section(s, "network", s_name);
}
static bool firewall_zone_exists(char *s_name)
{
struct uci_section *s = NULL;

View file

@ -11,7 +11,7 @@
#ifndef _FIREWALL_H
#define _FIREWALL_H
#include "libbbfdm-api/dmcommon.h"
#include "dmcommon.h"
extern DMOBJ tFirewallObj[];
extern DMLEAF tFirewallParams[];
@ -22,6 +22,4 @@ extern DMLEAF tFirewallChainRuleParams[];
extern DMLEAF tFirewallDMZParams[];
extern DMLEAF tFirewallServiceParams[];
void firewall__create_zone_section(char *s_name);
#endif

View file

@ -10,8 +10,6 @@
*
*/
#include "ppp.h"
#include "firewall.h"
#include "ip.h"
#if defined(BBF_TR143) || defined(BBF_TR471)
#include "diagnostics.h"
@ -40,37 +38,6 @@ static int init_interface_ip_args(struct intf_ip_args *args, struct uci_section
/*************************************************************
* COMMON Functions
**************************************************************/
bool ip___is_ipinterface_exists(const char *sec_name, const char *device)
{
struct uci_section *s = NULL;
char *curr_dev = NULL;
if (DM_STRLEN(sec_name) == 0 ||
DM_STRLEN(device) == 0)
return false;
uci_foreach_sections("network", "interface", s) {
dmuci_get_value_by_section_string(s, "device", &curr_dev);
if (DM_STRLEN(curr_dev) == 0 ||
DM_STRCMP(curr_dev, device) != 0)
continue;
struct uci_section *dmmap_s = NULL;
char *ip_inst = NULL;
if ((dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(s))) != NULL) {
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_inst);
if (strcmp(sec_name, section_name(s)) != 0 &&
DM_STRLEN(ip_inst) != 0)
return true;
}
}
return false;
}
static int get_sysctl_disable_ipv6_per_device(const char *device, char **value)
{
char file[256];
@ -138,18 +105,6 @@ static int set_sysctl_disable_ipv6_per_device(const char *device, bool value)
return 0;
}
static void update_child_interfaces(char *device, char *option_name, char *option_value)
{
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);
}
}
static int get_ip_iface_sysfs(const struct uci_section *data, const char *name, char **value)
{
return get_net_iface_sysfs(section_name((struct uci_section *)data), name, value);
@ -600,7 +555,7 @@ static int browseIPInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void
if (strcmp(section_name(p->config_section), "loopback") == 0 ||
*proto == '\0' ||
DM_STRCHR(device, '@') ||
ip___is_ipinterface_exists(section_name(p->config_section), device))
ip___is_ip_interface_instance_exists(section_name(p->config_section), device))
continue;
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "ip_int_instance", "ip_int_alias");
@ -895,7 +850,7 @@ static int delObjIPInterface(char *refparam, struct dmctx *ctx, void *data, char
if (strcmp(section_name(s), "loopback") == 0 ||
*proto == '\0' ||
DM_STRCHR(device, '@') ||
ip___is_ipinterface_exists(section_name(s), device))
ip___is_ip_interface_instance_exists(section_name(s), device))
continue;
delete_ip_intertace_instance(s);
@ -1170,7 +1125,7 @@ static int set_IPInterface_Enable(char *refparam, struct dmctx *ctx, void *data,
case VALUESET:
string_to_bool(value, &b);
dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device);
update_child_interfaces(device, "disabled", b ? "0" : "1");
ip___update_child_interfaces(device, "disabled", b ? "0" : "1");
break;
}
return 0;
@ -1366,13 +1321,14 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
char *new_device = NULL;
dmuci_get_value_by_section_string(ppp_s, "device", &new_device);
update_child_interfaces(curr_device, "device", new_device);
if (DM_STRLEN(new_device))
ip___update_child_interfaces(curr_device, "device", new_device);
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);
}
} else {
update_child_interfaces(curr_device, "device", reference.value);
ip___update_child_interfaces(curr_device, "device", reference.value);
}
break;

View file

@ -13,7 +13,7 @@
#ifndef __IP_H
#define __IP_H
#include "libbbfdm-api/dmcommon.h"
#include "dmcommon.h"
extern DMOBJ tIPObj[];
extern DMLEAF tIPParams[];
@ -24,7 +24,5 @@ extern DMLEAF tIPInterfaceIPv6AddressParams[];
extern DMLEAF tIPInterfaceIPv6PrefixParams[];
extern DMLEAF tIPInterfaceStatsParams[];
bool ip___is_ipinterface_exists(const char *sec_name, const char *device);
#endif //__IP_H

View file

@ -9,7 +9,7 @@
*
*/
#include "dmdiagnostics.h"
#include "dmcommon.h"
#include "packetcapture.h"
#define PACKET_CAPTURE_DIAGNOSTIC_PATH "/usr/share/bbfdm/packetcapture"

View file

@ -20,43 +20,6 @@ struct ppp_args
/*************************************************************
* COMMON FUNCTIONS
**************************************************************/
void ppp___update_sections(struct uci_section *s_from, struct uci_section *s_to)
{
char *proto = NULL;
char *device = NULL;
char *username = NULL;
char *password = NULL;
char *pppd_options = NULL;
char *service = NULL;
char *ac = NULL;
dmuci_get_value_by_section_string(s_from, "proto", &proto);
dmuci_get_value_by_section_string(s_from, "device", &device);
dmuci_get_value_by_section_string(s_from, "username", &username);
dmuci_get_value_by_section_string(s_from, "password", &password);
dmuci_get_value_by_section_string(s_from, "pppd_options", &pppd_options);
dmuci_get_value_by_section_string(s_from, "service", &service);
dmuci_get_value_by_section_string(s_from, "ac", &ac);
dmuci_set_value_by_section(s_to, "proto", proto);
dmuci_set_value_by_section(s_to, "device", device);
dmuci_set_value_by_section(s_to, "username", username);
dmuci_set_value_by_section(s_to, "password", password);
dmuci_set_value_by_section(s_to, "pppd_options", pppd_options);
dmuci_set_value_by_section(s_to, "service", service);
dmuci_set_value_by_section(s_to, "ac", ac);
}
void ppp___reset_options(struct uci_section *ppp_s)
{
dmuci_set_value_by_section(ppp_s, "device", "");
dmuci_set_value_by_section(ppp_s, "username", "");
dmuci_set_value_by_section(ppp_s, "password", "");
dmuci_set_value_by_section(ppp_s, "pppd_options", "");
dmuci_set_value_by_section(ppp_s, "service", "");
dmuci_set_value_by_section(ppp_s, "ac", "");
}
static bool is_ppp_section_exist(char *sec_name)
{
struct uci_section *s = NULL;
@ -167,33 +130,20 @@ static int add_ppp_interface(char *refparam, struct dmctx *ctx, void *data, char
static int delete_ppp_interface(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:
dmuci_delete_by_section(((struct ppp_args *)data)->dmmap_s, NULL, NULL);
if (((struct ppp_args *)data)->iface_s) {
dmuci_set_value_by_section(((struct ppp_args *)data)->iface_s, "proto", "none");
ppp___reset_options(((struct ppp_args *)data)->iface_s);
}
// Update PPP Interface Top Layers
ppp___Update_PPP_Interface_Top_Layers(refparam, "");
// Remove dmmap section
dmuci_delete_by_section(((struct ppp_args *)data)->dmmap_s, NULL, NULL);
break;
case DEL_ALL:
uci_path_foreach_sections_safe(bbfdm, "dmmap_ppp", "interface", stmp, s) {
struct uci_section *iface_s = NULL;
char *iface_name = NULL;
dmuci_get_value_by_section_string(s, "iface_name", &iface_name);
if (DM_STRLEN(iface_name))
get_config_section_of_dmmap_section("network", "interface", iface_name, &iface_s);
dmuci_delete_by_section(s, NULL, NULL);
if (iface_s) {
dmuci_set_value_by_section(iface_s, "proto", "none");
ppp___reset_options(iface_s);
}
}
break;
}
return 0;
@ -1035,6 +985,7 @@ static int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
"Device.Ethernet.Link.",
NULL};
struct dm_reference reference = {0};
char proto[8] = {0};
bbf_get_reference_args(value, &reference);
@ -1051,25 +1002,18 @@ static int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
// Store LowerLayers value under dmmap_ppp section
dmuci_set_value_by_section(ppp->dmmap_s, "LowerLayers", reference.path);
snprintf(proto, sizeof(proto), "ppp%s", (DM_STRLEN(reference.value)) ? (!DM_LSTRNCMP(reference.value, "atm", 3) || !DM_LSTRNCMP(reference.value, "ptm", 3)) ? "oa" : "oe" : "");
// 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");
if (DM_STRNCMP(reference.path, "Device.Ethernet.Link.", DM_STRLEN("Device.Ethernet.Link.")) == 0) {
struct uci_section *eth_link_s = NULL;
char *is_eth = NULL;
get_dmmap_section_of_config_section_eq("dmmap_ethernet", "link", "device", reference.value, &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", !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", proto);
if (ppp->iface_s) dmuci_set_value_by_section(ppp->iface_s, "proto", proto);
// Update device option
dmuci_set_value_by_section(ppp->dmmap_s, "device", reference.value);
if (ppp->iface_s) dmuci_set_value_by_section(ppp->iface_s, "device", reference.value);
if (ppp->iface_s) dmuci_set_value_by_section(ppp->iface_s, "device", DM_STRLEN(reference.value) ? reference.value : section_name(ppp->iface_s));
// Update PPP Interface Top Layers
ppp___Update_PPP_Interface_Top_Layers(refparam, reference.value);
return 0;
}
return 0;

View file

@ -12,7 +12,7 @@
#ifndef __PPP_H
#define __PPP_H
#include "libbbfdm-api/dmcommon.h"
#include "dmcommon.h"
#define IPCP 0
#define IPCPv6 1
@ -26,7 +26,4 @@ extern DMLEAF tPPPInterfaceIPCPParams[];
extern DMLEAF tPPPInterfaceIPv6CPParams[];
extern DMLEAF tPPPInterfaceStatsParams[];
void ppp___update_sections(struct uci_section *s_from, struct uci_section *s_to);
void ppp___reset_options(struct uci_section *ppp_s);
#endif

View file

@ -157,7 +157,7 @@ static int set_ptm_alias(char *refparam, struct dmctx *ctx, void *data, char *in
/*#Device.PTM.Link.{i}.Name!UCI:dsl/ptm-device,@i-1/name*/
static int get_ptm_link_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((((struct ptm_args *)data)->sections)->config_section, "name", value);
*value = dmstrdup(((struct ptm_args *)data)->device);
return 0;
}

View file

@ -380,7 +380,7 @@ static int browseRouterInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev
if (strcmp(section_name(s), "loopback") == 0 ||
*proto == '\0' ||
DM_STRCHR(device, '@') ||
ip___is_ipinterface_exists(section_name(s), device))
ip___is_ip_interface_instance_exists(section_name(s), device))
continue;
if (DM_STRLEN(idx))

View file

@ -9,7 +9,7 @@
*
*/
#include "dmdiagnostics.h"
#include "dmcommon.h"
#include "iplayercap.h"
#define IPLAYER_CAP_DIAGNOSTIC_PATH "/usr/share/bbfdm/iplayercap"

View file

@ -9,12 +9,22 @@
*
*/
#include "tr181/bridging.h"
#include "dmcommon.h"
#include "bridging.h"
struct bridge_port_args
{
struct uci_section *bridge_sec;
struct uci_section *bridge_dmmap_sec;
struct uci_section *bridge_port_sec;
struct uci_section *bridge_port_dmmap_sec;
bool is_management_port;
char *br_inst;
};
static int get_BridgingBridgePort_Egress_PriorityRegeneration(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
bridging_get_priority_list("egress_qos_mapping", data, value);
bridging___get_priority_list(((struct bridge_port_args *)data)->bridge_port_sec, "egress_qos_mapping", data, value);
return 0;
}
@ -33,7 +43,7 @@ static int set_BridgingBridgePort_Egress_PriorityRegeneration(char *refparam, st
return 0;
case VALUESET:
bridging_set_priority_list("egress_qos_mapping", data, value);
bridging___set_priority_list(((struct bridge_port_args *)data)->bridge_port_sec, "egress_qos_mapping", data, value);
return 0;
}
return 0;

View file

@ -56,10 +56,11 @@ static int addObjEthernetMACVLAN(char *refparam, struct dmctx *ctx, void *data,
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:
// Update Ethernet MAC VLAN Top Layers
ethernet___Update_MAC_VLAN_Top_Layers(refparam, "");
// Remove device section
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
@ -67,16 +68,6 @@ static int delObjEthernetMACVLAN(char *refparam, struct dmctx *ctx, void *data,
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;
@ -167,6 +158,7 @@ static int set_EthernetMACVLAN_LowerLayers(char *refparam, struct dmctx *ctx, vo
"Device.Ethernet.Link.",
NULL};
struct dm_reference reference = {0};
char name[32] = {0};
bbf_get_reference_args(value, &reference);
@ -183,24 +175,20 @@ static int set_EthernetMACVLAN_LowerLayers(char *refparam, struct dmctx *ctx, vo
// Store LowerLayers value under dmmap section
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "LowerLayers", reference.path);
// Update ifname option
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ifname", reference.value);
if (DM_STRLEN(reference.value)) {
char name[16] = {0};
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ifname", reference.value);
if (DM_STRNCMP(reference.path, allowed_objects[0], strlen(allowed_objects[0])) == 0) {
char *vid = DM_STRRCHR(reference.value, '.');
if (vid) *vid = 0;
}
snprintf(name, sizeof(name), "%s_%s", reference.value, instance);
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, "ifname", "");
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", "");
char *dev_name = ethernet___get_ethernet_interface_name(reference.value);
snprintf(name, sizeof(name), "%s_%s", dev_name, instance);
}
// Update name option
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "name", name);
// Update Ethernet MAC VLAN Top Layers
ethernet___Update_MAC_VLAN_Top_Layers(refparam, name);
break;
}
return 0;

View file

@ -12,7 +12,7 @@
#ifndef __IOPSYS_ETHERNET_H
#define __IOPSYS_ETHERNET_H
#include "libbbfdm-api/dmcommon.h"
#include "dmcommon.h"
extern DMOBJ tIOPSYS_EthernetObj[];
extern DMLEAF tEthernetMACVLANParams[];