Update docs and align the remaining objects to generic data structure

This commit is contained in:
Amin Ben Romdhane 2024-03-08 12:21:04 +01:00
parent 4d11d3deea
commit db6d7395f4
8 changed files with 871 additions and 803 deletions

View file

@ -45,6 +45,7 @@ inputs
|BBF_OPERATE |path | NA | NA | NA | |BBF_OPERATE |path | NA | NA | NA |
|BBF_SCHEMA |paramter ||$ref(type) |writable(0/1) |unique keys | |BBF_SCHEMA |paramter ||$ref(type) |writable(0/1) |unique keys |
|BBF_INSTANCES |parameter | NA |NA |NA | |BBF_INSTANCES |parameter | NA |NA |NA |
|BBF_EVENT |path | NA | NA | NA |
int cmd int cmd
command to API to tell how the data model is to be read, possible values are command to API to tell how the data model is to be read, possible values are
@ -53,9 +54,10 @@ inputs
BBF_SET_VALUE - Set value of specified parameters in the data model BBF_SET_VALUE - Set value of specified parameters in the data model
BBF_ADD_OBJECT - Add object in a multi instance parameter in the data model BBF_ADD_OBJECT - Add object in a multi instance parameter in the data model
BBF_DEL_OBJECT - Delete object from a multi instance parameter in the data model BBF_DEL_OBJECT - Delete object from a multi instance parameter in the data model
BBF_OPERATE - execute the specified command BBF_OPERATE - execute the specified command
BBF_SCHEMA - Read all the parameter type parameter from data model. BBF_SCHEMA - Read all the parameter type parameter from data model.
BBF_INSTANCES - Read all the instance of multi instance parameter from data model. BBF_INSTANCES - Read all the instance of multi instance parameter from data model.
BBF_EVENT - execute the specified event
return return
int fault int fault
@ -201,11 +203,11 @@ Example:
```bash ```bash
static int get_WiFiEndPoint_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_WiFiEndPoint_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return bbf_get_alias(ctx, (((struct wifi_enp_args *)data)->sections)->dmmap_section, "endpointalias", instance, value); return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "endpointalias", instance, value);
} }
static int set_WiFiEndPoint_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) static int set_WiFiEndPoint_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{ {
return bbf_set_alias(ctx, (((struct wifi_enp_args *)data)->sections)->dmmap_section, "endpointalias", instance, value); return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "endpointalias", instance, value);
} }
``` ```

View file

@ -110,10 +110,9 @@ Each object in the **DMOBJ** table contains the following arguments:
| `dynamicleaf` | Pointer to the next of **DMLEAF** which contains a list of the child parameters using json files, shared libraries and vendor extension | | `dynamicleaf` | Pointer to the next of **DMLEAF** which contains a list of the child parameters using json files, shared libraries and vendor extension |
| `nextobj` | Pointer to a **DMOBJ** array which contains a list of the child objects | | `nextobj` | Pointer to a **DMOBJ** array which contains a list of the child objects |
| `leaf` | Pointer to a **DMLEAF** array which contains a list of the child parameters | | `leaf` | Pointer to a **DMLEAF** array which contains a list of the child parameters |
| `linker` | This argument is used for LowerLayer parameters or to make reference to other instance object in the tree | | `linker` | This argument is deprecated and should be `NULL` |
| `bbfdm_type` | The bbfdm type of the object. Could be **BBFDM_CWMP**, **BBFDM_USP**, **BBFDM_BOTH** or **BBFDM_NONE**.If it's **BBFDM_BOTH** then we can see this object in all protocols (CWMP, USP,...) | | `bbfdm_type` | The bbfdm type of the object. Could be **BBFDM_CWMP**, **BBFDM_USP**, **BBFDM_BOTH** or **BBFDM_NONE**.If it's **BBFDM_BOTH** then we can see this object in all protocols (CWMP, USP,...) |
| `uniqueKeys` | The unique key parameters defined for the object. | | `uniqueKeys` | This argument is deprecated and should be `NULL` |
### Leaf definition ### Leaf definition
@ -130,7 +129,7 @@ Each leaf in the **DMLEAF** table can be a **Parameter**, **Command** or **Event
| `getvalue` | The function which return the value of this parameter | | `getvalue` | The function which return the value of this parameter |
| `setvalue` | The function which set the value of this parameter | | `setvalue` | The function which set the value of this parameter |
| `bbfdm_type` | The bbfdm type of the parameter. Could be **BBFDM_CWMP**, **BBFDM_USP**, **BBFDM_BOTH** or **BBFDM_NONE**.If it's **BBFDM_BOTH** then we can see this parameter in all protocols (CWMP, USP,...) | | `bbfdm_type` | The bbfdm type of the parameter. Could be **BBFDM_CWMP**, **BBFDM_USP**, **BBFDM_BOTH** or **BBFDM_NONE**.If it's **BBFDM_BOTH** then we can see this parameter in all protocols (CWMP, USP,...) |
| `dm_falgs` | An enumeration value used to specify the displayed parameter value. Could be **DM_FLAG_REFERENCE**, **DM_FLAG_UNIQUE**, **DM_FLAG_LINKER** or **DM_FLAG_SECURE**. |
#### 2.Command definition #### 2.Command definition
@ -152,7 +151,7 @@ Each leaf in the **DMLEAF** table can be a **Parameter**, **Command** or **Event
| `permission` | The permission of the event. It should be **DMREAD** | | `permission` | The permission of the event. It should be **DMREAD** |
| `type` | Type of the event, It should be **DMT_EVENT** | | `type` | Type of the event, It should be **DMT_EVENT** |
| `getvalue` | The function which return the parameter arguments of the event | | `getvalue` | The function which return the parameter arguments of the event |
| `setvalue` | The function which call the operation of the event, It should be **NULL** | | `setvalue` | The function which call the operation of the event |
| `bbfdm_type` | The bbfdm type of the event. It should be **BBFDM_USP** as long as events are only defined in USP protocol. | | `bbfdm_type` | The bbfdm type of the event. It should be **BBFDM_USP** as long as events are only defined in USP protocol. |
@ -162,17 +161,205 @@ The browse function allow to go over all instances of the current object and lin
In this function, there are two functions that need to be defined: In this function, there are two functions that need to be defined:
- function to retrieve the instances: it can be - function to retrieve the instances: it can be:
* `handle_instance` function: allow to retrieve/attribute the instances number/alias from uci config sections depending of the request and the instance mode. * `handle_instance` function: allow to retrieve/attribute the instances number/alias from uci config sections depending of the request and the instance mode.
* `handle_instance_without_section` function: allow to attribute the instances number/alias with constant values. * `handle_instance_without_section` function: allow to attribute the instances number/alias with constant values.
- function to link the instances: we need to call `DM_LINK_INST_OBJ()` function for each instance in order to link the instance to the data model tree. we also need to specify the `data`of this instance level. This `data` could be use later in the sub object and parameters functions (Get/Set/Add/Delete/Operate/Event). - function to link the instances: To link each instance to the data model tree, it's necessary to call `DM_LINK_INST_OBJ()` API for every instance. Additionally, it's recommended to utilize the generic structure `(struct dm_data *)` as the passed `data` at each instance level. This structure will be utilized later in functions related to sub-objects and parameters (Get/Set/Add/Delete/Operate/Event).
> Note1: the browse function is only developed for multi-instances objects. > Note1: the browse function is only developed for multi-instances objects.
> Note2: you can read the next section `BBF API` below to find the definition of the functions used in the browse. > Note2: you can use [bbf_test plugin](../../test/bbf_test/bbf_test.c) as a reference in order to develop any new object/leaf/browse.
> Note3: you can use [bbf_test plugin](../../test/bbf_test/bbf_test.c) as a reference in order to develop any new object/leaf/browse. > Note3: Extending the object list below using `JSON` Plugin is prohibited because the `data` passed in `DM_LINK_INST_OBJ()` API differs from the generic structure `(struct dm_data *)`. To accomplish this task, you have two options: either update the required object to utilize the generic structure in the passed data, or alternatively, use the `DotSo` plugin.
- Device.ATM.Link.{i}.
- Device.ATM.Link.{i}.Stats.
- Device.Bridging.Bridge.{i}.
- Device.Bridging.Bridge.{i}.Port.{i}.
- Device.Bridging.Bridge.{i}.Port.{i}.Stats.
- Device.Bridging.Bridge.{i}.STP.
- Device.Bridging.Bridge.{i}.VLAN.{i}.
- Device.Bridging.Bridge.{i}.VLANPort.{i}.
- Device.Bridging.ProviderBridge.{i}.
- Device.DHCPv4.Server.Pool.{i}.
- Device.DHCPv4.Server.Pool.{i}.Client.{i}.
- Device.DHCPv4.Server.Pool.{i}.Client.{i}.IPv4Address.{i}.
- Device.DHCPv4.Server.Pool.{i}.Client.{i}.Option.{i}.
- Device.DHCPv4.Server.Pool.{i}.StaticAddress.{i}.
- Device.DHCPv6.Server.Pool.{i}.Client.{i}.
- Device.DHCPv6.Server.Pool.{i}.Client.{i}.IPv6Address.{i}.
- Device.DHCPv6.Server.Pool.{i}.Client.{i}.IPv6Prefix.{i}.
- Device.DNS.Client.Server.{i}.
- Device.DNS.Relay.Forwarding.{i}.
- Device.DNS.SD.Service.{i}.
- Device.DNS.SD.Service.{i}.TextRecord.{i}.
- Device.DSL.Channel.{i}.
- Device.DSL.Channel.{i}.Stats.
- Device.DSL.Channel.{i}.Stats.CurrentDay.
- Device.DSL.Channel.{i}.Stats.LastShowtime.
- Device.DSL.Channel.{i}.Stats.QuarterHour.
- Device.DSL.Channel.{i}.Stats.Showtime.
- Device.DSL.Channel.{i}.Stats.Total.
- Device.DSL.Line.{i}.
- Device.DSL.Line.{i}.Stats.
- Device.DSL.Line.{i}.Stats.CurrentDay.
- Device.DSL.Line.{i}.Stats.LastShowtime.
- Device.DSL.Line.{i}.Stats.QuarterHour.
- Device.DSL.Line.{i}.Stats.Showtime.
- Device.DSL.Line.{i}.Stats.Total.
- Device.DeviceInfo.FirmwareImage.{i}.
- Device.DeviceInfo.MemoryStatus.
- Device.DeviceInfo.ProcessStatus.
- Device.DeviceInfo.ProcessStatus.Process.{i}.
- Device.DeviceInfo.Processor.{i}.
- Device.DeviceInfo.VendorConfigFile.{i}.
- Device.DynamicDNS.Client.{i}.
- Device.DynamicDNS.Client.{i}.Hostname.{i}.
- Device.DynamicDNS.Server.{i}.
- Device.Ethernet.Interface.{i}.
- Device.Ethernet.Interface.{i}.Stats.
- Device.Ethernet.Link.{i}.
- Device.Ethernet.Link.{i}.Stats.
- Device.Ethernet.RMONStats.{i}.
- Device.Ethernet.VLANTermination.{i}.
- Device.Ethernet.VLANTermination.{i}.Stats.
- Device.Ethernet.X_IOPSYS_EU_MACVLAN.{i}.
- Device.Ethernet.X_IOPSYS_EU_MACVLAN.{i}.Stats.
- Device.FAST.Line.{i}.
- Device.FAST.Line.{i}.Stats.
- Device.FAST.Line.{i}.Stats.CurrentDay.
- Device.FAST.Line.{i}.Stats.LastShowtime.
- Device.FAST.Line.{i}.Stats.QuarterHour.
- Device.FAST.Line.{i}.Stats.Showtime.
- Device.FAST.Line.{i}.Stats.Total.
- Device.Firewall.Chain.{i}.
- Device.Firewall.Chain.{i}.Rule.{i}.
- Device.Firewall.Level.{i}.
- Device.Hosts.AccessControl.{i}.
- Device.Hosts.AccessControl.{i}.Schedule.{i}.
- Device.Hosts.Host.{i}.
- Device.Hosts.Host.{i}.IPv4Address.{i}.
- Device.Hosts.Host.{i}.IPv6Address.{i}.
- Device.Hosts.Host.{i}.WANStats.
- Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.
- Device.IEEE1905.AL.Interface.{i}.
- Device.IEEE1905.AL.Interface.{i}.Link.{i}.
- Device.IEEE1905.AL.Interface.{i}.Link.{i}.Metric.
- Device.IEEE1905.AL.Interface.{i}.VendorProperties.{i}.
- Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.
- Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.BridgingTuple.{i}.
- Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.
- Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.Metric.{i}.
- Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv4Address.{i}.
- Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv6Address.{i}.
- Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.Interface.{i}.
- Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.NonIEEE1905Neighbor.{i}.
- Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.VendorProperties.{i}.
- Device.IP.Interface.{i}.
- Device.IP.Interface.{i}.IPv4Address.{i}.
- Device.IP.Interface.{i}.IPv6Address.{i}.
- Device.IP.Interface.{i}.IPv6Prefix.{i}.
- Device.IP.Interface.{i}.Stats.
- Device.IP.Interface.{i}.TWAMPReflector.{i}.
- Device.InterfaceStack.{i}.
- Device.NAT.PortTrigger.{i}.
- Device.NAT.PortTrigger.{i}.Rule.{i}.
- Device.PPP.Interface.{i}.
- Device.PPP.Interface.{i}.IPCP.
- Device.PPP.Interface.{i}.IPv6CP.
- Device.PPP.Interface.{i}.PPPoE.
- Device.PPP.Interface.{i}.Stats.
- Device.PTM.Link.{i}.
- Device.PTM.Link.{i}.Stats.
- Device.PeriodicStatistics.SampleSet.{i}.
- Device.PeriodicStatistics.SampleSet.{i}.Parameter.{i}.
- Device.QoS.QueueStats.{i}.
- Device.Routing.RouteInformation.InterfaceSetting.{i}.
- Device.Routing.Router.{i}.
- Device.Routing.Router.{i}.IPv4Forwarding.{i}.
- Device.Routing.Router.{i}.IPv6Forwarding.{i}.
- Device.SSH.AuthorizedKey.{i}.
- Device.SSH.Server.{i}.Session.{i}.
- Device.Security.Certificate.{i}.
- Device.Services.VoiceService.{i}.
- Device.Services.VoiceService.{i}.CallControl.
- Device.Services.VoiceService.{i}.CallControl.CallingFeatures.
- Device.Services.VoiceService.{i}.CallControl.CallingFeatures.Set.{i}.
- Device.Services.VoiceService.{i}.CallControl.CallingFeatures.Set.{i}.SCREJ.{i}.
- Device.Services.VoiceService.{i}.CallControl.Extension.{i}.
- Device.Services.VoiceService.{i}.CallControl.Group.{i}.
- Device.Services.VoiceService.{i}.CallControl.IncomingMap.{i}.
- Device.Services.VoiceService.{i}.CallControl.Line.{i}.
- Device.Services.VoiceService.{i}.CallControl.Line.{i}.Stats.
- Device.Services.VoiceService.{i}.CallControl.Line.{i}.Stats.DSP.
- Device.Services.VoiceService.{i}.CallControl.Line.{i}.Stats.IncomingCalls.
- Device.Services.VoiceService.{i}.CallControl.Line.{i}.Stats.OutgoingCalls.
- Device.Services.VoiceService.{i}.CallControl.Line.{i}.Stats.RTP.
- Device.Services.VoiceService.{i}.CallControl.NumberingPlan.{i}.
- Device.Services.VoiceService.{i}.CallControl.NumberingPlan.{i}.PrefixInfo.{i}.
- Device.Services.VoiceService.{i}.CallControl.OutgoingMap.{i}.
- Device.Services.VoiceService.{i}.CallLog.{i}.
- Device.Services.VoiceService.{i}.CallLog.{i}.Session.{i}.
- Device.Services.VoiceService.{i}.CallLog.{i}.Session.{i}.Destination.
- Device.Services.VoiceService.{i}.CallLog.{i}.Session.{i}.Destination.DSP.
- Device.Services.VoiceService.{i}.CallLog.{i}.Session.{i}.Destination.DSP.ReceiveCodec.
- Device.Services.VoiceService.{i}.CallLog.{i}.Session.{i}.Destination.DSP.TransmitCodec.
- Device.Services.VoiceService.{i}.CallLog.{i}.Session.{i}.Destination.RTP.
- Device.Services.VoiceService.{i}.CallLog.{i}.Session.{i}.Source.
- Device.Services.VoiceService.{i}.CallLog.{i}.Session.{i}.Source.DSP.
- Device.Services.VoiceService.{i}.CallLog.{i}.Session.{i}.Source.DSP.ReceiveCodec.
- Device.Services.VoiceService.{i}.CallLog.{i}.Session.{i}.Source.DSP.TransmitCodec.
- Device.Services.VoiceService.{i}.CallLog.{i}.Session.{i}.Source.RTP.
- Device.Services.VoiceService.{i}.Capabilities.
- Device.Services.VoiceService.{i}.Capabilities.Codec.{i}.
- Device.Services.VoiceService.{i}.Capabilities.POTS.
- Device.Services.VoiceService.{i}.Capabilities.SIP.
- Device.Services.VoiceService.{i}.Capabilities.SIP.Client.
- Device.Services.VoiceService.{i}.CodecProfile.{i}.
- Device.Services.VoiceService.{i}.DECT.
- Device.Services.VoiceService.{i}.DECT.Base.{i}.
- Device.Services.VoiceService.{i}.DECT.Portable.{i}.
- Device.Services.VoiceService.{i}.POTS.
- Device.Services.VoiceService.{i}.POTS.FXS.{i}.
- Device.Services.VoiceService.{i}.POTS.FXS.{i}.VoiceProcessing.
- Device.Services.VoiceService.{i}.ReservedPorts.
- Device.Services.VoiceService.{i}.SIP.
- Device.Services.VoiceService.{i}.SIP.Client.{i}.
- Device.Services.VoiceService.{i}.SIP.Network.{i}.
- Device.Services.VoiceService.{i}.SIP.Network.{i}.FQDNServer.{i}.
- Device.Services.VoiceService.{i}.VoIPProfile.{i}.
- Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.
- Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.RTCP.
- Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.SRTP.
- Device.SoftwareModules.DeploymentUnit.{i}.
- Device.SoftwareModules.ExecEnv.{i}.
- Device.SoftwareModules.ExecutionUnit.{i}.
- Device.Time.Client.{i}.
- Device.Time.Client.{i}.Stats.
- Device.Time.Server.{i}.
- Device.Time.Server.{i}.Stats.
- Device.UPnP.Description.DeviceDescription.{i}.
- Device.UPnP.Description.DeviceInstance.{i}.
- Device.UPnP.Description.ServiceInstance.{i}.
- Device.UPnP.Discovery.Device.{i}.
- Device.UPnP.Discovery.RootDevice.{i}.
- Device.UPnP.Discovery.Service.{i}.
- Device.USB.Interface.{i}.
- Device.USB.Interface.{i}.Stats.
- Device.USB.Port.{i}.
- Device.USB.USBHosts.Host.{i}.
- Device.USB.USBHosts.Host.{i}.Device.{i}.
- Device.USB.USBHosts.Host.{i}.Device.{i}.Configuration.{i}.
- Device.USB.USBHosts.Host.{i}.Device.{i}.Configuration.{i}.Interface.{i}.
- Device.UserInterface.HTTPAccess.{i}.
- Device.UserInterface.HTTPAccess.{i}.Session.{i}.
- Device.Users.Group.{i}.
- Device.Users.Role.{i}.
- Device.Users.SupportedShell.{i}.
- Device.Users.User.{i}.
- Device.XMPP.Connection.{i}.
- Device.XMPP.Connection.{i}.Server.{i}.
- Device.XMPP.Connection.{i}.Stats.

File diff suppressed because it is too large Load diff

View file

@ -37,6 +37,12 @@ extern DMOBJ tDHCPv4RelayObj[];
extern DMLEAF tDHCPv4RelayParams[]; extern DMLEAF tDHCPv4RelayParams[];
extern DMLEAF tDHCPv4RelayForwardingParams[]; extern DMLEAF tDHCPv4RelayForwardingParams[];
struct option_args
{
char *tag;
char *value;
};
int set_section_order(char *package, char *dmpackage, char* sect_type, struct uci_section *dmmap_sect, struct uci_section *conf, int set_force, char* order); int set_section_order(char *package, char *dmpackage, char* sect_type, struct uci_section *dmmap_sect, struct uci_section *conf, int set_force, char* order);
int get_value_in_mac_format(struct uci_section *s, char *option_name, bool type, char **value); int get_value_in_mac_format(struct uci_section *s, char *option_name, bool type, char **value);
bool tag_option_exists(char *dmmap_package, char *section, char *opt_check, char *value_check, char *tag_name, char *tag_value); bool tag_option_exists(char *dmmap_package, char *section, char *opt_check, char *value_check, char *tag_name, char *tag_value);

View file

@ -12,19 +12,6 @@
#include "dhcpv4.h" #include "dhcpv4.h"
#include "dhcpv6.h" #include "dhcpv6.h"
struct dhcpv6_client_args
{
struct uci_section *iface_s;
struct uci_section *dmmap_s;
};
struct dhcpv6_args
{
struct dmmap_dup *dhcp_sections;
char *interface;
};
struct clientv6_args struct clientv6_args
{ {
json_object *client; json_object *client;
@ -32,13 +19,6 @@ struct clientv6_args
int idx; int idx;
}; };
struct dhcpv6_client_option_args {
struct uci_section *client_sect;
struct uci_section *dmmap_sect;
char *option_tag;
char *value;
};
/************************************************************* /*************************************************************
* COMMON FUNCTIONS * COMMON FUNCTIONS
**************************************************************/ **************************************************************/
@ -129,21 +109,14 @@ static inline int init_dhcpv6_client_args(struct clientv6_args *args, json_objec
return 0; return 0;
} }
static inline int init_dhcpv6_args(struct dhcpv6_args *args, struct dmmap_dup *s, char *interface)
{
args->dhcp_sections = s;
args->interface = interface;
return 0;
}
/************************************************************* /*************************************************************
* ENTRY METHOD * ENTRY METHOD
**************************************************************/ **************************************************************/
/*#Device.DHCPv6.Client.{i}.!UCI:network/interface/dmmap_dhcpv6*/ /*#Device.DHCPv6.Client.{i}.!UCI:network/interface/dmmap_dhcpv6*/
static int browseDHCPv6ClientInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) static int browseDHCPv6ClientInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{ {
struct dhcpv6_client_args curr_dhcpv6_client_args = {0};
struct uci_section *dmmap_s = NULL; struct uci_section *dmmap_s = NULL;
struct dm_data curr_data = {0};
char *inst = NULL; char *inst = NULL;
dmmap_synchronizeDHCPv6Client(dmctx, parent_node, prev_data, prev_instance); dmmap_synchronizeDHCPv6Client(dmctx, parent_node, prev_data, prev_instance);
@ -155,12 +128,12 @@ static int browseDHCPv6ClientInst(struct dmctx *dmctx, DMNODE *parent_node, void
if (DM_STRLEN(iface_name)) if (DM_STRLEN(iface_name))
get_config_section_of_dmmap_section("network", "interface", iface_name, &iface_s); get_config_section_of_dmmap_section("network", "interface", iface_name, &iface_s);
curr_dhcpv6_client_args.iface_s = iface_s; curr_data.config_section = iface_s;
curr_dhcpv6_client_args.dmmap_s = dmmap_s; curr_data.dmmap_section = dmmap_s;
inst = handle_instance(dmctx, parent_node, dmmap_s, "bbf_dhcpv6client_instance", "bbf_dhcpv6client_alias"); inst = handle_instance(dmctx, parent_node, dmmap_s, "bbf_dhcpv6client_instance", "bbf_dhcpv6client_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_dhcpv6_client_args, inst) == DM_STOP) if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_data, inst) == DM_STOP)
break; break;
} }
return 0; return 0;
@ -170,28 +143,27 @@ static int browseDHCPv6ClientInst(struct dmctx *dmctx, DMNODE *parent_node, void
static int browseDHCPv6ServerPoolInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) static int browseDHCPv6ServerPoolInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{ {
char *ignore = NULL, *interface, *inst = NULL, *v; char *ignore = NULL, *interface, *inst = NULL, *v;
struct dhcpv6_args curr_dhcp6_args = {0}; struct dm_data *curr_data = NULL;
struct dmmap_dup *p = NULL;
LIST_HEAD(dup_list); LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap("dhcp", "dhcp", "dmmap_dhcpv6", &dup_list); synchronize_specific_config_sections_with_dmmap("dhcp", "dhcp", "dmmap_dhcpv6", &dup_list);
list_for_each_entry(p, &dup_list, list) { list_for_each_entry(curr_data, &dup_list, list) {
// skip the section if option ignore = '1' // skip the section if option ignore = '1'
dmuci_get_value_by_section_string(p->config_section, "ignore", &ignore); dmuci_get_value_by_section_string(curr_data->config_section, "ignore", &ignore);
if (ignore && DM_LSTRCMP(ignore, "1") == 0) if (ignore && DM_LSTRCMP(ignore, "1") == 0)
continue; continue;
dmuci_get_value_by_section_string(p->config_section, "interface", &interface); dmuci_get_value_by_section_string(curr_data->config_section, "interface", &interface);
init_dhcpv6_args(&curr_dhcp6_args, p, interface); curr_data->additional_data = (void *)interface;
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "dhcpv6_serv_pool_instance", "dhcpv6_serv_pool_alias"); inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "dhcpv6_serv_pool_instance", "dhcpv6_serv_pool_alias");
dmuci_get_value_by_section_string(p->dmmap_section, "order", &v); dmuci_get_value_by_section_string(curr_data->dmmap_section, "order", &v);
if (v == NULL || DM_STRLEN(v) == 0) if (v == NULL || DM_STRLEN(v) == 0)
set_section_order("dhcp", "dmmap_dhcpv6", "dhcp", p->dmmap_section, p->config_section, 0, inst); set_section_order("dhcp", "dmmap_dhcpv6", "dhcp", curr_data->dmmap_section, curr_data->config_section, 0, inst);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_dhcp6_args, inst) == DM_STOP) if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
break; break;
} }
free_dmmap_config_dup_list(&dup_list); free_dmmap_config_dup_list(&dup_list);
@ -201,13 +173,13 @@ static int browseDHCPv6ServerPoolInst(struct dmctx *dmctx, DMNODE *parent_node,
static int browseDHCPv6ServerPoolClientInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) static int browseDHCPv6ServerPoolClientInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{ {
struct dhcpv6_args *dhcp_arg= (struct dhcpv6_args *)prev_data; struct dm_data *dhcp_arg= (struct dm_data *)prev_data;
json_object *res = NULL, *res1 = NULL, *jobj = NULL, *dev_obj = NULL, *net_obj = NULL; json_object *res = NULL, *res1 = NULL, *jobj = NULL, *dev_obj = NULL, *net_obj = NULL;
struct clientv6_args curr_dhcp_client_args = {0}; struct clientv6_args curr_dhcp_client_args = {0};
int i = 0; int i = 0;
char *inst = NULL, *device; char *inst = NULL, *device;
char *if_name = section_name(dhcp_arg->dhcp_sections->config_section); char *if_name = section_name(dhcp_arg->config_section);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res1); dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res1);
if (!res1) return 0; if (!res1) return 0;
device = dmjson_get_value(res1, 1, "device"); device = dmjson_get_value(res1, 1, "device");
@ -232,44 +204,44 @@ static int browseDHCPv6ServerPoolClientInst(struct dmctx *dmctx, DMNODE *parent_
static int browseDHCPv6ServerPoolOptionInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) static int browseDHCPv6ServerPoolOptionInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{ {
struct dhcpv6_args *curr_dhcp_args = (struct dhcpv6_args *)prev_data; struct option_args curr_option_args = {0};
struct uci_list *dhcp_options_list = NULL; struct uci_list *options_list = NULL;
struct dm_data curr_data = {0};
struct uci_element *e = NULL; struct uci_element *e = NULL;
struct uci_section *dmmap_sect = NULL; struct uci_section *dmmap_s = NULL;
char **dhcpv6_option = NULL, *inst = NULL, *dhcpv6_tag, *dhcpv6_value; char **option = NULL, *inst = NULL;
size_t length = 0; size_t length = 0;
struct dhcpv6_client_option_args dhcpv6_client_opt_args = {0};
dmuci_get_value_by_section_list(curr_dhcp_args->dhcp_sections->config_section, "dhcp_option", &dhcp_options_list); dmuci_get_value_by_section_list(((struct dm_data *)prev_data)->config_section, "dhcp_option", &options_list);
if (dhcp_options_list != NULL) { if (options_list != NULL) {
uci_foreach_element(dhcp_options_list, e) { uci_foreach_element(options_list, e) {
dhcpv6_option = strsplit(e->name, ",", &length); option = strsplit(e->name, ",", &length);
if (!dhcpv6_option) if (!option)
continue; continue;
if ((dmmap_sect = get_dup_section_in_dmmap_eq("dmmap_dhcpv6", "servpool_option", section_name(curr_dhcp_args->dhcp_sections->config_section), "option_tag", dhcpv6_option[0])) == NULL) { if ((dmmap_s = get_dup_section_in_dmmap_eq("dmmap_dhcpv6", "servpool_option", section_name(((struct dm_data *)prev_data)->config_section), "option_tag", option[0])) == NULL) {
dmuci_add_section_bbfdm("dmmap_dhcpv6", "servpool_option", &dmmap_sect); dmuci_add_section_bbfdm("dmmap_dhcpv6", "servpool_option", &dmmap_s);
dmuci_set_value_by_section_bbfdm(dmmap_sect, "option_tag", dhcpv6_option[0]); dmuci_set_value_by_section_bbfdm(dmmap_s, "option_tag", option[0]);
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(curr_dhcp_args->dhcp_sections->config_section)); dmuci_set_value_by_section_bbfdm(dmmap_s, "section_name", section_name(((struct dm_data *)prev_data)->config_section));
dmuci_set_value_by_section_bbfdm(dmmap_sect, "option_value", length > 1 ? dhcpv6_option[1] : ""); dmuci_set_value_by_section_bbfdm(dmmap_s, "option_value", length > 1 ? option[1] : "");
} }
} }
} }
uci_path_foreach_option_eq(bbfdm, "dmmap_dhcpv6", "servpool_option", "section_name", section_name(curr_dhcp_args->dhcp_sections->config_section), dmmap_sect) { uci_path_foreach_option_eq(bbfdm, "dmmap_dhcpv6", "servpool_option", "section_name", section_name(((struct dm_data *)prev_data)->config_section), dmmap_s) {
dmuci_get_value_by_section_string(dmmap_sect, "option_tag", &dhcpv6_tag);
dmuci_get_value_by_section_string(dmmap_sect, "option_value", &dhcpv6_value);
dhcpv6_client_opt_args.client_sect = curr_dhcp_args->dhcp_sections->config_section; dmuci_get_value_by_section_string(dmmap_s, "option_tag", &curr_option_args.tag);
dhcpv6_client_opt_args.dmmap_sect = dmmap_sect; dmuci_get_value_by_section_string(dmmap_s, "option_value", &curr_option_args.value);
dhcpv6_client_opt_args.option_tag = dhcpv6_tag;
dhcpv6_client_opt_args.value = dhcpv6_value;
inst = handle_instance(dmctx, parent_node, dmmap_sect, "bbf_dhcpv6_servpool_option_instance", "bbf_dhcpv6_servpool_option_alias"); curr_data.config_section = ((struct dm_data *)prev_data)->config_section;
curr_data.dmmap_section = dmmap_s;
curr_data.additional_data = &curr_option_args;
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&dhcpv6_client_opt_args, inst) == DM_STOP) inst = handle_instance(dmctx, parent_node, dmmap_s, "bbf_dhcpv6_servpool_option_instance", "bbf_dhcpv6_servpool_option_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_data, inst) == DM_STOP)
break; break;
} }
return 0; return 0;
@ -342,20 +314,20 @@ static int delObjDHCPv6Client(char *refparam, struct dmctx *ctx, void *data, cha
switch (del_action) { switch (del_action) {
case DEL_INST: case DEL_INST:
dmuci_delete_by_section(((struct dhcpv6_client_args *)data)->dmmap_s, NULL, NULL); dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
if (((struct dhcpv6_client_args *)data)->iface_s) { if (((struct dm_data *)data)->config_section) {
char *ip_instance = NULL; 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)); struct uci_section *dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(((struct dm_data *)data)->config_section));
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance); dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance);
if (dmmap_s && DM_STRLEN(ip_instance) == 0) { if (dmmap_s && DM_STRLEN(ip_instance) == 0) {
dmuci_delete_by_section(((struct dhcpv6_client_args *)data)->iface_s, NULL, NULL); dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
} else { } else {
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "proto", "none"); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "proto", "none");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqaddress", ""); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "reqaddress", "");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqprefix", ""); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "reqprefix", "");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqopts", ""); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "reqopts", "");
} }
} }
break; break;
@ -414,8 +386,8 @@ static int delObjDHCPv6ServerPool(char *refparam, struct dmctx *ctx, void *data,
switch (del_action) { switch (del_action) {
case DEL_INST: case DEL_INST:
dmuci_delete_by_section((((struct dhcpv6_args *)data)->dhcp_sections)->config_section, NULL, NULL); dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
dmuci_delete_by_section((((struct dhcpv6_args *)data)->dhcp_sections)->dmmap_section, NULL, NULL); dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
break; break;
case DEL_ALL: case DEL_ALL:
uci_foreach_sections_safe("dhcp", "dhcp", stmp, s) { uci_foreach_sections_safe("dhcp", "dhcp", stmp, s) {
@ -438,12 +410,12 @@ static int delObjDHCPv6ServerPool(char *refparam, struct dmctx *ctx, void *data,
static int addObjDHCPv6ServerPoolOption(char *refparam, struct dmctx *ctx, void *data, char **instance) static int addObjDHCPv6ServerPoolOption(char *refparam, struct dmctx *ctx, void *data, char **instance)
{ {
struct dhcpv6_args *dhcpv6_arg = (struct dhcpv6_args *)data; struct dm_data *dhcpv6_arg = (struct dm_data *)data;
struct uci_section *dmmap_sect; struct uci_section *dmmap_sect;
dmuci_add_section_bbfdm("dmmap_dhcpv6", "servpool_option", &dmmap_sect); dmuci_add_section_bbfdm("dmmap_dhcpv6", "servpool_option", &dmmap_sect);
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(dhcpv6_arg->dhcp_sections->config_section)); dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(dhcpv6_arg->config_section));
char *option_tag = generate_tag_option("dmmap_dhcpv6", "servpool_option", "section_name", section_name(dhcpv6_arg->dhcp_sections->config_section), "option_tag"); char *option_tag = generate_tag_option("dmmap_dhcpv6", "servpool_option", "section_name", section_name(dhcpv6_arg->config_section), "option_tag");
dmuci_set_value_by_section_bbfdm(dmmap_sect, "option_tag", option_tag); dmuci_set_value_by_section_bbfdm(dmmap_sect, "option_tag", option_tag);
dmuci_set_value_by_section_bbfdm(dmmap_sect, "bbf_dhcpv6_servpool_option_instance", *instance); dmuci_set_value_by_section_bbfdm(dmmap_sect, "bbf_dhcpv6_servpool_option_instance", *instance);
return 0; return 0;
@ -456,18 +428,19 @@ static int delObjDHCPv6ServerPoolOption(char *refparam, struct dmctx *ctx, void
switch (del_action) { switch (del_action) {
case DEL_INST: case DEL_INST:
dmuci_get_value_by_section_list(((struct dhcpv6_client_option_args *)data)->client_sect, "dhcp_option", &dhcp_options_list); dmuci_get_value_by_section_list(((struct dm_data *)data)->config_section, "dhcp_option", &dhcp_options_list);
if (dhcp_options_list != NULL) { if (dhcp_options_list != NULL) {
struct option_args *option = (struct option_args *)((struct dm_data *)data)->additional_data;
char tag_value[128] = {0}; char tag_value[128] = {0};
snprintf(tag_value, sizeof(tag_value), "%s,%s", ((struct dhcpv6_client_option_args *)data)->option_tag, ((struct dhcpv6_client_option_args *)data)->value); snprintf(tag_value, sizeof(tag_value), "%s,%s", option->tag, option->value);
dmuci_del_list_value_by_section(((struct dhcpv6_client_option_args *)data)->client_sect, "dhcp_option", tag_value); dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section, "dhcp_option", tag_value);
} }
dmuci_delete_by_section(((struct dhcpv6_client_option_args *)data)->dmmap_sect, NULL, NULL); dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
break; break;
case DEL_ALL: case DEL_ALL:
dmuci_set_value_by_section((((struct dhcpv6_args *)data)->dhcp_sections)->config_section, "dhcp_option", ""); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "dhcp_option", "");
uci_path_foreach_sections_safe(bbfdm, "dmmap_dhcpv6", "servpool_option", stmp, s) { uci_path_foreach_sections_safe(bbfdm, "dmmap_dhcpv6", "servpool_option", stmp, s) {
dmuci_delete_by_section(s, NULL, NULL); dmuci_delete_by_section(s, NULL, NULL);
} }
@ -489,17 +462,17 @@ static int get_DHCPv6_ClientNumberOfEntries(char *refparam, struct dmctx *ctx, v
/*#Device.DHCPv6.Client.{i}.Enable!UCI:network/interface,@i-1/disabled*/ /*#Device.DHCPv6.Client.{i}.Enable!UCI:network/interface,@i-1/disabled*/
static int get_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data; struct dm_data *dhcpv6_client = (struct dm_data *)data;
char *disabled = NULL; char *disabled = NULL;
dmuci_get_value_by_section_string(dhcpv6_client->iface_s ? dhcpv6_client->iface_s : dhcpv6_client->dmmap_s, "disabled", &disabled); dmuci_get_value_by_section_string(dhcpv6_client->config_section ? dhcpv6_client->config_section : dhcpv6_client->dmmap_section, "disabled", &disabled);
*value = (disabled[0] == '1') ? "0" : "1"; *value = (disabled[0] == '1') ? "0" : "1";
return 0; return 0;
} }
static int set_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) static int set_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{ {
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data; struct dm_data *dhcpv6_client = (struct dm_data *)data;
bool b; bool b;
switch (action) { switch (action) {
@ -509,9 +482,9 @@ static int set_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data
return 0; return 0;
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
dmuci_set_value_by_section(dhcpv6_client->dmmap_s, "disabled", b ? "0" : "1"); dmuci_set_value_by_section(dhcpv6_client->dmmap_section, "disabled", b ? "0" : "1");
if (dhcpv6_client->iface_s) if (dhcpv6_client->config_section)
dmuci_set_value_by_section(dhcpv6_client->iface_s, "disabled", b ? "0" : "1"); dmuci_set_value_by_section(dhcpv6_client->config_section, "disabled", b ? "0" : "1");
return 0; return 0;
} }
return 0; return 0;
@ -519,27 +492,27 @@ static int set_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data
static int get_DHCPv6Client_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6Client_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return bbf_get_alias(ctx, ((struct dhcpv6_client_args *)data)->dmmap_s, "bbf_dhcpv6client_alias", instance, value); return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "bbf_dhcpv6client_alias", instance, value);
} }
static int set_DHCPv6Client_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) static int set_DHCPv6Client_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{ {
return bbf_set_alias(ctx, ((struct dhcpv6_client_args *)data)->dmmap_s, "bbf_dhcpv6client_alias", instance, value); return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "bbf_dhcpv6client_alias", instance, value);
} }
static int get_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
char *iface_name = NULL; char *iface_name = NULL;
dmuci_get_value_by_section_string(((struct dhcpv6_client_args *)data)->dmmap_s, "iface_name", &iface_name); dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "iface_name", &iface_name);
adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", iface_name, value); adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", iface_name, value);
if (DM_STRLEN(*value) == 0 && ((struct dhcpv6_client_args *)data)->iface_s) { if (DM_STRLEN(*value) == 0 && ((struct dm_data *)data)->config_section) {
struct uci_section *s = NULL; struct uci_section *s = NULL;
char *device = NULL; char *device = NULL;
dmuci_get_value_by_section_string(((struct dhcpv6_client_args *)data)->iface_s, "device", &device); dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "device", &device);
if (DM_STRLEN(device) == 0) if (DM_STRLEN(device) == 0)
return 0; return 0;
@ -553,7 +526,7 @@ static int get_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *d
static int set_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) static int set_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{ {
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data; struct dm_data *dhcpv6_client = (struct dm_data *)data;
char *allowed_objects[] = {"Device.IP.Interface.", NULL}; char *allowed_objects[] = {"Device.IP.Interface.", NULL};
struct dm_reference reference = {0}; struct dm_reference reference = {0};
@ -569,23 +542,23 @@ static int set_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *d
break; break;
case VALUESET: case VALUESET:
if (dhcpv6_client->iface_s) { if (dhcpv6_client->config_section) {
char *ip_instance = NULL; char *ip_instance = NULL;
struct uci_section *dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(dhcpv6_client->iface_s)); struct uci_section *dmmap_s = get_dup_section_in_dmmap("dmmap_network", "interface", section_name(dhcpv6_client->config_section));
dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance); dmuci_get_value_by_section_string(dmmap_s, "ip_int_instance", &ip_instance);
if (dmmap_s && DM_STRLEN(ip_instance) == 0) { if (dmmap_s && DM_STRLEN(ip_instance) == 0) {
dmuci_delete_by_section(dhcpv6_client->iface_s, NULL, NULL); dmuci_delete_by_section(dhcpv6_client->config_section, NULL, NULL);
} else { } else {
dmuci_set_value_by_section(dhcpv6_client->iface_s, "proto", "none"); dmuci_set_value_by_section(dhcpv6_client->config_section, "proto", "none");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqaddress", ""); dmuci_set_value_by_section(dhcpv6_client->config_section, "reqaddress", "");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqprefix", ""); dmuci_set_value_by_section(dhcpv6_client->config_section, "reqprefix", "");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqopts", ""); dmuci_set_value_by_section(dhcpv6_client->config_section, "reqopts", "");
} }
} }
// Update iface_name option // Update iface_name option
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "iface_name", reference.value); dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_section, "iface_name", reference.value);
if (DM_STRLEN(reference.value)) { if (DM_STRLEN(reference.value)) {
struct uci_section *interface_s = NULL; struct uci_section *interface_s = NULL;
@ -617,16 +590,16 @@ static int set_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *d
dmuci_set_value_by_section(interface_s, "device", curr_device); dmuci_set_value_by_section(interface_s, "device", curr_device);
// Update iface_name option // Update iface_name option
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "iface_name", buf); dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_section, "iface_name", buf);
} }
// Update proto option of config section // Update proto option of config section
dmuci_set_value_by_section(interface_s, "proto", "dhcpv6"); dmuci_set_value_by_section(interface_s, "proto", "dhcpv6");
// Get the current value of requested parameters // 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_section, "reqaddress", &reqaddress);
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "reqprefix", &reqprefix); dmuci_get_value_by_section_string(dhcpv6_client->dmmap_section, "reqprefix", &reqprefix);
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "reqopts", &reqopts); dmuci_get_value_by_section_string(dhcpv6_client->dmmap_section, "reqopts", &reqopts);
// Set requested parameters // Set requested parameters
dmuci_set_value_by_section(interface_s, "reqaddress", reqaddress); dmuci_set_value_by_section(interface_s, "reqaddress", reqaddress);
@ -649,7 +622,7 @@ static int get_DHCPv6Client_Status(char *refparam, struct dmctx *ctx, void *data
/*#Device.DHCPv6.Client.{i}.DUID!UBUS:network.interface/status/interface,@Name/data.passthru*/ /*#Device.DHCPv6.Client.{i}.DUID!UBUS:network.interface/status/interface,@Name/data.passthru*/
static int get_DHCPv6Client_DUID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6Client_DUID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct uci_section *dhcpv6_s = ((struct dhcpv6_client_args *)data)->iface_s; struct uci_section *dhcpv6_s = ((struct dm_data *)data)->config_section;
if (dhcpv6_s) { if (dhcpv6_s) {
json_object *res = NULL; json_object *res = NULL;
@ -663,17 +636,17 @@ static int get_DHCPv6Client_DUID(char *refparam, struct dmctx *ctx, void *data,
/*#Device.DHCPv6.Client.{i}.RequestAddresses!UCI:network/interface,@i-1/reqaddress*/ /*#Device.DHCPv6.Client.{i}.RequestAddresses!UCI:network/interface,@i-1/reqaddress*/
static int get_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data; struct dm_data *dhcpv6_client = (struct dm_data *)data;
char *reqaddress = NULL; char *reqaddress = NULL;
dmuci_get_value_by_section_string(dhcpv6_client->iface_s ? dhcpv6_client->iface_s : dhcpv6_client->dmmap_s, "reqaddress", &reqaddress); dmuci_get_value_by_section_string(dhcpv6_client->config_section ? dhcpv6_client->config_section : dhcpv6_client->dmmap_section, "reqaddress", &reqaddress);
*value = (reqaddress && DM_LSTRCMP(reqaddress, "none") == 0) ? "0" : "1"; *value = (reqaddress && DM_LSTRCMP(reqaddress, "none") == 0) ? "0" : "1";
return 0; return 0;
} }
static int set_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) static int set_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{ {
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data; struct dm_data *dhcpv6_client = (struct dm_data *)data;
bool b; bool b;
switch (action) { switch (action) {
@ -683,9 +656,9 @@ static int set_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx,
return 0; return 0;
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
dmuci_set_value_by_section(dhcpv6_client->dmmap_s, "reqaddress", b ? "force" : "none"); dmuci_set_value_by_section(dhcpv6_client->dmmap_section, "reqaddress", b ? "force" : "none");
if (dhcpv6_client->iface_s) if (dhcpv6_client->config_section)
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqaddress", b ? "force" : "none"); dmuci_set_value_by_section(dhcpv6_client->config_section, "reqaddress", b ? "force" : "none");
break; break;
} }
return 0; return 0;
@ -694,17 +667,17 @@ static int set_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx,
/*#Device.DHCPv6.Client.{i}.RequestPrefixes!UCI:network/interface,@i-1/reqprefix*/ /*#Device.DHCPv6.Client.{i}.RequestPrefixes!UCI:network/interface,@i-1/reqprefix*/
static int get_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data; struct dm_data *dhcpv6_client = (struct dm_data *)data;
char *reqprefix = NULL; char *reqprefix = NULL;
dmuci_get_value_by_section_string(dhcpv6_client->iface_s ? dhcpv6_client->iface_s : dhcpv6_client->dmmap_s, "reqprefix", &reqprefix); dmuci_get_value_by_section_string(dhcpv6_client->config_section ? dhcpv6_client->config_section : dhcpv6_client->dmmap_section, "reqprefix", &reqprefix);
*value = (reqprefix && DM_LSTRCMP(reqprefix, "auto") == 0) ? "1" : "0"; *value = (reqprefix && DM_LSTRCMP(reqprefix, "auto") == 0) ? "1" : "0";
return 0; return 0;
} }
static int set_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) static int set_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{ {
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data; struct dm_data *dhcpv6_client = (struct dm_data *)data;
bool b; bool b;
switch (action) { switch (action) {
@ -714,9 +687,9 @@ static int set_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, v
return 0; return 0;
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
dmuci_set_value_by_section(dhcpv6_client->dmmap_s, "reqprefix", b ? "auto" : "no"); dmuci_set_value_by_section(dhcpv6_client->dmmap_section, "reqprefix", b ? "auto" : "no");
if (dhcpv6_client->iface_s) if (dhcpv6_client->config_section)
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqprefix", b ? "auto" : "no"); dmuci_set_value_by_section(dhcpv6_client->config_section, "reqprefix", b ? "auto" : "no");
return 0; return 0;
} }
return 0; return 0;
@ -730,7 +703,7 @@ static int get_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data,
static int set_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) static int set_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{ {
struct uci_section *dhcpv6_s = ((struct dhcpv6_client_args *)data)->iface_s; struct uci_section *dhcpv6_s = ((struct dm_data *)data)->config_section;
bool b; bool b;
switch (action) { switch (action) {
@ -753,15 +726,15 @@ static int set_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data,
/*#Device.DHCPv6.Client.{i}.RequestedOptions!UCI:network/interface,@i-1/reqopts*/ /*#Device.DHCPv6.Client.{i}.RequestedOptions!UCI:network/interface,@i-1/reqopts*/
static int get_DHCPv6Client_RequestedOptions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6Client_RequestedOptions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data; struct dm_data *dhcpv6_client = (struct dm_data *)data;
dmuci_get_value_by_section_string(dhcpv6_client->iface_s ? dhcpv6_client->iface_s : dhcpv6_client->dmmap_s, "reqopts", value); dmuci_get_value_by_section_string(dhcpv6_client->config_section ? dhcpv6_client->config_section : dhcpv6_client->dmmap_section, "reqopts", value);
return 0; return 0;
} }
static int set_DHCPv6Client_RequestedOptions(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) static int set_DHCPv6Client_RequestedOptions(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{ {
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data; struct dm_data *dhcpv6_client = (struct dm_data *)data;
switch (action) { switch (action) {
case VALUECHECK: case VALUECHECK:
@ -769,9 +742,9 @@ static int set_DHCPv6Client_RequestedOptions(char *refparam, struct dmctx *ctx,
return FAULT_9007; return FAULT_9007;
break; break;
case VALUESET: case VALUESET:
dmuci_set_value_by_section(dhcpv6_client->dmmap_s, "reqopts", value); dmuci_set_value_by_section(dhcpv6_client->dmmap_section, "reqopts", value);
if (dhcpv6_client->iface_s) if (dhcpv6_client->config_section)
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqopts", value); dmuci_set_value_by_section(dhcpv6_client->config_section, "reqopts", value);
break; break;
} }
return 0; return 0;
@ -814,7 +787,7 @@ static int get_DHCPv6Server_PoolNumberOfEntries(char *refparam, struct dmctx *ct
/*#Device.DHCPv6.Server.Pool.{i}.Enable!UCI:dhcp/dhcp,@i-1/dhcpv6*/ /*#Device.DHCPv6.Server.Pool.{i}.Enable!UCI:dhcp/dhcp,@i-1/dhcpv6*/
static int get_DHCPv6ServerPool_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6ServerPool_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
dmuci_get_value_by_section_string((((struct dhcpv6_args *)data)->dhcp_sections)->config_section, "dhcpv6", value); dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "dhcpv6", value);
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "0" : "1"; *value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "0" : "1";
return 0; return 0;
} }
@ -830,7 +803,7 @@ static int set_DHCPv6ServerPool_Enable(char *refparam, struct dmctx *ctx, void *
return 0; return 0;
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
dmuci_set_value_by_section((((struct dhcpv6_args *)data)->dhcp_sections)->config_section, "dhcpv6", b ? "server" : "disabled"); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "dhcpv6", b ? "server" : "disabled");
return 0; return 0;
} }
return 0; return 0;
@ -839,7 +812,7 @@ static int set_DHCPv6ServerPool_Enable(char *refparam, struct dmctx *ctx, void *
/*#Device.DHCPv6.Server.Pool.{i}.Status!UCI:dhcp/dhcp,@i-1/dhcpv6*/ /*#Device.DHCPv6.Server.Pool.{i}.Status!UCI:dhcp/dhcp,@i-1/dhcpv6*/
static int get_DHCPv6ServerPool_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6ServerPool_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
dmuci_get_value_by_section_string((((struct dhcpv6_args *)data)->dhcp_sections)->config_section, "dhcpv6", value); dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "dhcpv6", value);
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "Disabled" : "Enabled"; *value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "Disabled" : "Enabled";
return 0; return 0;
} }
@ -847,17 +820,17 @@ static int get_DHCPv6ServerPool_Status(char *refparam, struct dmctx *ctx, void *
/*#Device.DHCPv6.Server.Pool.{i}.Alias!UCI:dmmap_dhcpv6/dhcp,@i-1/dhcpv6_serv_pool_alias*/ /*#Device.DHCPv6.Server.Pool.{i}.Alias!UCI:dmmap_dhcpv6/dhcp,@i-1/dhcpv6_serv_pool_alias*/
static int get_DHCPv6ServerPool_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6ServerPool_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return bbf_get_alias(ctx, (((struct dhcpv6_args *)data)->dhcp_sections)->dmmap_section, "dhcpv6_serv_pool_alias", instance, value); return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "dhcpv6_serv_pool_alias", instance, value);
} }
static int set_DHCPv6ServerPool_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) static int set_DHCPv6ServerPool_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{ {
return bbf_set_alias(ctx, (((struct dhcpv6_args *)data)->dhcp_sections)->dmmap_section, "dhcpv6_serv_pool_alias", instance, value); return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "dhcpv6_serv_pool_alias", instance, value);
} }
static int get_DHCPv6ServerPool_Order(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6ServerPool_Order(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
dmuci_get_value_by_section_string((((struct dhcpv6_args *)data)->dhcp_sections)->dmmap_section, "order", value); dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "order", value);
return 0; return 0;
} }
@ -869,7 +842,7 @@ static int set_DHCPv6ServerPool_Order(char *refparam, struct dmctx *ctx, void *d
return FAULT_9007; return FAULT_9007;
break; break;
case VALUESET: case VALUESET:
set_section_order("dhcp", "dmmap_dhcpv6", "dhcp", (((struct dhcpv6_args *)data)->dhcp_sections)->dmmap_section, (((struct dhcpv6_args *)data)->dhcp_sections)->config_section, 1, value); set_section_order("dhcp", "dmmap_dhcpv6", "dhcp", ((struct dm_data *)data)->dmmap_section, ((struct dm_data *)data)->config_section, 1, value);
break; break;
} }
return 0; return 0;
@ -877,7 +850,7 @@ static int set_DHCPv6ServerPool_Order(char *refparam, struct dmctx *ctx, void *d
static int get_DHCPv6ServerPool_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6ServerPool_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", ((struct dhcpv6_args *)data)->interface, value); adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", (char *)((struct dm_data *)data)->additional_data, value);
return 0; return 0;
} }
@ -898,7 +871,7 @@ static int set_DHCPv6ServerPool_Interface(char *refparam, struct dmctx *ctx, voi
break; break;
case VALUESET: case VALUESET:
dmuci_set_value_by_section((((struct dhcpv6_args *)data)->dhcp_sections)->config_section, "interface", reference.value); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "interface", reference.value);
break; break;
} }
return 0; return 0;
@ -909,7 +882,7 @@ static int get_DHCPv6ServerPool_VendorClassID(char *refparam, struct dmctx *ctx,
{ {
char hex[256] = {0}, *vcid = NULL; char hex[256] = {0}, *vcid = NULL;
struct uci_section *vendorclassidclassifier = get_dhcpv6_classifier("vendorclass", ((struct dhcpv6_args *)data)->interface); struct uci_section *vendorclassidclassifier = get_dhcpv6_classifier("vendorclass", (char *)((struct dm_data *)data)->additional_data);
dmuci_get_value_by_section_string(vendorclassidclassifier, "vendorclass", &vcid); dmuci_get_value_by_section_string(vendorclassidclassifier, "vendorclass", &vcid);
if (vcid && *vcid) if (vcid && *vcid)
@ -932,10 +905,10 @@ static int set_DHCPv6ServerPool_VendorClassID(char *refparam, struct dmctx *ctx,
case VALUESET: case VALUESET:
convert_hex_to_string(value, res, sizeof(res)); convert_hex_to_string(value, res, sizeof(res));
vendorclassidclassifier = get_dhcpv6_classifier("vendorclass", ((struct dhcpv6_args *)data)->interface); vendorclassidclassifier = get_dhcpv6_classifier("vendorclass", (char *)((struct dm_data *)data)->additional_data);
if (!vendorclassidclassifier) { if (!vendorclassidclassifier) {
dmuci_add_section("dhcp", "vendorclass", &vendorclassidclassifier); dmuci_add_section("dhcp", "vendorclass", &vendorclassidclassifier);
dmuci_set_value_by_section(vendorclassidclassifier, "networkid", ((struct dhcpv6_args *)data)->interface); dmuci_set_value_by_section(vendorclassidclassifier, "networkid", (char *)((struct dm_data *)data)->additional_data);
} }
dmuci_set_value_by_section(vendorclassidclassifier, "vendorclass", res); dmuci_set_value_by_section(vendorclassidclassifier, "vendorclass", res);
break; break;
@ -948,7 +921,7 @@ static int get_DHCPv6ServerPool_UserClassID(char *refparam, struct dmctx *ctx, v
{ {
char hex[256] = {0}, *ucid = NULL; char hex[256] = {0}, *ucid = NULL;
struct uci_section *userclassidclassifier = get_dhcpv6_classifier("userclass", ((struct dhcpv6_args *)data)->interface); struct uci_section *userclassidclassifier = get_dhcpv6_classifier("userclass", (char *)((struct dm_data *)data)->additional_data);
dmuci_get_value_by_section_string(userclassidclassifier, "userclass", &ucid); dmuci_get_value_by_section_string(userclassidclassifier, "userclass", &ucid);
if (ucid && *ucid) if (ucid && *ucid)
@ -971,10 +944,10 @@ static int set_DHCPv6ServerPool_UserClassID(char *refparam, struct dmctx *ctx, v
case VALUESET: case VALUESET:
convert_hex_to_string(value, res, sizeof(res)); convert_hex_to_string(value, res, sizeof(res));
userclassidclassifier = get_dhcpv6_classifier("userclass", ((struct dhcpv6_args *)data)->interface); userclassidclassifier = get_dhcpv6_classifier("userclass", (char *)((struct dm_data *)data)->additional_data);
if (!userclassidclassifier) { if (!userclassidclassifier) {
dmuci_add_section("dhcp", "userclass", &userclassidclassifier); dmuci_add_section("dhcp", "userclass", &userclassidclassifier);
dmuci_set_value_by_section(userclassidclassifier, "networkid", ((struct dhcpv6_args *)data)->interface); dmuci_set_value_by_section(userclassidclassifier, "networkid", (char *)((struct dm_data *)data)->additional_data);
} }
dmuci_set_value_by_section(userclassidclassifier, "userclass", res); dmuci_set_value_by_section(userclassidclassifier, "userclass", res);
break; break;
@ -984,7 +957,7 @@ static int set_DHCPv6ServerPool_UserClassID(char *refparam, struct dmctx *ctx, v
static int get_DHCPv6ServerPool_SourceAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6ServerPool_SourceAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct uci_section *classifier_s = get_dhcpv6_classifier("mac", ((struct dhcpv6_args *)data)->interface); struct uci_section *classifier_s = get_dhcpv6_classifier("mac", (char *)((struct dm_data *)data)->additional_data);
if (classifier_s == NULL) { if (classifier_s == NULL) {
*value = ""; *value = "";
return 0; return 0;
@ -1008,7 +981,7 @@ static int set_DHCPv6ServerPool_SourceAddress(char *refparam, struct dmctx *ctx,
static int get_DHCPv6ServerPool_SourceAddressMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6ServerPool_SourceAddressMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct uci_section *classifier_s = get_dhcpv6_classifier("mac", ((struct dhcpv6_args *)data)->interface); struct uci_section *classifier_s = get_dhcpv6_classifier("mac", (char *)((struct dm_data *)data)->additional_data);
if (classifier_s == NULL) { if (classifier_s == NULL) {
*value = ""; *value = "";
return 0; return 0;
@ -1155,29 +1128,30 @@ static int get_DHCPv6ServerPoolClientIPv6Prefix_ValidLifetime(char *refparam, st
static int get_DHCPv6ServerPoolOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6ServerPoolOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct dhcpv6_client_option_args *dhcpv6_client_s = (struct dhcpv6_client_option_args *)data; struct uci_list *option_list;
struct uci_list *dhcp_option_list;
dmuci_get_value_by_section_list(dhcpv6_client_s->client_sect, "dhcp_option", &dhcp_option_list); dmuci_get_value_by_section_list(((struct dm_data *)data)->config_section, "dhcp_option", &option_list);
if (dhcp_option_list != NULL) { if (option_list != NULL) {
struct option_args *option = (struct option_args *)((struct dm_data *)data)->additional_data;
struct uci_element *e = NULL; struct uci_element *e = NULL;
size_t length; size_t length;
uci_foreach_element(dhcp_option_list, e) { uci_foreach_element(option_list, e) {
char **buf = strsplit(e->name, ",", &length); char **buf = strsplit(e->name, ",", &length);
if (buf && *buf && DM_STRCMP(buf[0], dhcpv6_client_s->option_tag) == 0) { if (buf && *buf && DM_STRCMP(buf[0], option->tag) == 0) {
*value = "1"; *value = "1";
return 0; return 0;
} }
} }
} }
*value= "0";
*value = "0";
return 0; return 0;
} }
static int set_DHCPv6ServerPoolOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) static int set_DHCPv6ServerPoolOption_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{ {
struct dhcpv6_client_option_args *dhcpv6_client_s = (struct dhcpv6_client_option_args *)data; struct option_args *option = (struct option_args *)((struct dm_data *)data)->additional_data;
struct uci_list *dhcp_option_list = NULL; struct uci_list *dhcp_option_list = NULL;
char opt_value[128] = {0}; char opt_value[128] = {0};
bool option_enabled = false, b; bool option_enabled = false, b;
@ -1189,8 +1163,8 @@ static int set_DHCPv6ServerPoolOption_Enable(char *refparam, struct dmctx *ctx,
break; break;
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
dmuci_get_value_by_section_list(dhcpv6_client_s->client_sect, "dhcp_option", &dhcp_option_list); dmuci_get_value_by_section_list(((struct dm_data *)data)->config_section, "dhcp_option", &dhcp_option_list);
snprintf(opt_value, sizeof(opt_value), "%s,%s", dhcpv6_client_s->option_tag, dhcpv6_client_s->value); snprintf(opt_value, sizeof(opt_value), "%s,%s", option->tag, option->value);
if (dhcp_option_list != NULL) { if (dhcp_option_list != NULL) {
struct uci_element *e = NULL; struct uci_element *e = NULL;
@ -1198,40 +1172,40 @@ static int set_DHCPv6ServerPoolOption_Enable(char *refparam, struct dmctx *ctx,
uci_foreach_element(dhcp_option_list, e) { uci_foreach_element(dhcp_option_list, e) {
char **buf = strsplit(e->name, ",", &length); char **buf = strsplit(e->name, ",", &length);
if (buf && *buf && DM_STRCMP(buf[0], dhcpv6_client_s->option_tag) == 0) { if (buf && *buf && DM_STRCMP(buf[0], option->tag) == 0) {
option_enabled = true; option_enabled = true;
if (!b) if (!b)
dmuci_del_list_value_by_section(dhcpv6_client_s->client_sect, "dhcp_option", opt_value); dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section, "dhcp_option", opt_value);
break; break;
} }
} }
} }
if(!option_enabled && b) if(!option_enabled && b)
dmuci_add_list_value_by_section(dhcpv6_client_s->client_sect, "dhcp_option", opt_value); dmuci_add_list_value_by_section(((struct dm_data *)data)->config_section, "dhcp_option", opt_value);
} }
return 0; return 0;
} }
static int get_DHCPv6ServerPoolOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6ServerPoolOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return bbf_get_alias(ctx, ((struct dhcpv6_client_option_args *)data)->dmmap_sect, "bbf_dhcpv6_servpool_option_alias", instance, value); return bbf_get_alias(ctx, ((struct dm_data *)data)->dmmap_section, "bbf_dhcpv6_servpool_option_alias", instance, value);
} }
static int set_DHCPv6ServerPoolOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) static int set_DHCPv6ServerPoolOption_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{ {
return bbf_set_alias(ctx, ((struct dhcpv6_client_option_args *)data)->dmmap_sect, "bbf_dhcpv6_servpool_option_alias", instance, value); return bbf_set_alias(ctx, ((struct dm_data *)data)->dmmap_section, "bbf_dhcpv6_servpool_option_alias", instance, value);
} }
static int get_DHCPv6ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
*value = dmstrdup(((struct dhcpv6_client_option_args *)data)->option_tag); *value = dmstrdup(((struct option_args *)((struct dm_data *)data)->additional_data)->tag);
return 0; return 0;
} }
static int set_DHCPv6ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) static int set_DHCPv6ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{ {
struct dhcpv6_client_option_args *dhcpv6_client_s = (struct dhcpv6_client_option_args *)data; struct option_args *option = (struct option_args *)((struct dm_data *)data)->additional_data;
struct uci_list *dhcp_option_list = NULL; struct uci_list *dhcp_option_list = NULL;
bool option_enabled = false; bool option_enabled = false;
@ -1240,16 +1214,16 @@ static int set_DHCPv6ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, voi
if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"0","65535"}}, 1)) if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"0","65535"}}, 1))
return FAULT_9007; return FAULT_9007;
if (dhcpv6_client_s->option_tag && DM_STRCMP(dhcpv6_client_s->option_tag, value) == 0) if (option->tag && DM_STRCMP(option->tag, value) == 0)
break; break;
char *name = section_name(dhcpv6_client_s->client_sect); char *name = section_name(((struct dm_data *)data)->config_section);
if (tag_option_exists("dmmap_dhcpv6", "servpool_option", "section_name", name, "option_tag", value)) if (tag_option_exists("dmmap_dhcpv6", "servpool_option", "section_name", name, "option_tag", value))
return FAULT_9007; return FAULT_9007;
break; break;
case VALUESET: case VALUESET:
dmuci_get_value_by_section_list(dhcpv6_client_s->client_sect, "dhcp_option", &dhcp_option_list); dmuci_get_value_by_section_list(((struct dm_data *)data)->config_section, "dhcp_option", &dhcp_option_list);
if (dhcp_option_list != NULL) { if (dhcp_option_list != NULL) {
struct uci_element *e = NULL; struct uci_element *e = NULL;
@ -1257,7 +1231,7 @@ static int set_DHCPv6ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, voi
uci_foreach_element(dhcp_option_list, e) { uci_foreach_element(dhcp_option_list, e) {
char **buf = strsplit(e->name, ",", &length); char **buf = strsplit(e->name, ",", &length);
if (buf && *buf && DM_STRCMP(buf[0], dhcpv6_client_s->option_tag) == 0) { if (buf && *buf && DM_STRCMP(buf[0], option->tag) == 0) {
option_enabled = true; option_enabled = true;
break; break;
} }
@ -1267,13 +1241,13 @@ static int set_DHCPv6ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, voi
if (option_enabled) { if (option_enabled) {
char new_tag_value[128] = {0}, old_tag_value[128] = {0}; char new_tag_value[128] = {0}, old_tag_value[128] = {0};
snprintf(old_tag_value, sizeof(old_tag_value), "%s,%s", dhcpv6_client_s->option_tag, dhcpv6_client_s->value); snprintf(old_tag_value, sizeof(old_tag_value), "%s,%s", option->tag, option->value);
snprintf(new_tag_value, sizeof(new_tag_value), "%s,%s", value, dhcpv6_client_s->value); snprintf(new_tag_value, sizeof(new_tag_value), "%s,%s", value, option->value);
dmuci_del_list_value_by_section(dhcpv6_client_s->client_sect, "dhcp_option", old_tag_value); dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section, "dhcp_option", old_tag_value);
dmuci_add_list_value_by_section(dhcpv6_client_s->client_sect, "dhcp_option", new_tag_value); dmuci_add_list_value_by_section(((struct dm_data *)data)->config_section, "dhcp_option", new_tag_value);
} }
dmuci_set_value_by_section_bbfdm(dhcpv6_client_s->dmmap_sect, "option_tag", value); dmuci_set_value_by_section_bbfdm(((struct dm_data *)data)->dmmap_section, "option_tag", value);
break; break;
} }
return 0; return 0;
@ -1281,7 +1255,7 @@ static int set_DHCPv6ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, voi
static int get_DHCPv6ServerPoolOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_DHCPv6ServerPoolOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
const char *tag_value = ((struct dhcpv6_client_option_args *)data)->value; const char *tag_value = ((struct option_args *)((struct dm_data *)data)->additional_data)->value;
char hex[256] = {0}; char hex[256] = {0};
if (tag_value && *tag_value) if (tag_value && *tag_value)
@ -1293,8 +1267,8 @@ static int get_DHCPv6ServerPoolOption_Value(char *refparam, struct dmctx *ctx, v
static int set_DHCPv6ServerPoolOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) static int set_DHCPv6ServerPoolOption_Value(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{ {
struct dhcpv6_client_option_args *dhcpv6_client_s = (struct dhcpv6_client_option_args *)data; struct option_args *option = (struct option_args *)((struct dm_data *)data)->additional_data;
struct uci_list *dhcp_option_list = NULL; struct uci_list *option_list = NULL;
char res[256] = {0}; char res[256] = {0};
bool option_enabled = false; bool option_enabled = false;
@ -1304,15 +1278,15 @@ static int set_DHCPv6ServerPoolOption_Value(char *refparam, struct dmctx *ctx, v
return FAULT_9007; return FAULT_9007;
break; break;
case VALUESET: case VALUESET:
dmuci_get_value_by_section_list(dhcpv6_client_s->client_sect, "dhcp_option", &dhcp_option_list); dmuci_get_value_by_section_list(((struct dm_data *)data)->config_section, "dhcp_option", &option_list);
if (dhcp_option_list != NULL) { if (option_list != NULL) {
struct uci_element *e = NULL; struct uci_element *e = NULL;
size_t length; size_t length;
uci_foreach_element(dhcp_option_list, e) { uci_foreach_element(option_list, e) {
char **buf = strsplit(e->name, ",", &length); char **buf = strsplit(e->name, ",", &length);
if (buf && *buf && DM_STRCMP(buf[0], dhcpv6_client_s->option_tag) == 0) { if (buf && *buf && DM_STRCMP(buf[0], option->tag) == 0) {
option_enabled = true; option_enabled = true;
break; break;
} }
@ -1324,13 +1298,13 @@ static int set_DHCPv6ServerPoolOption_Value(char *refparam, struct dmctx *ctx, v
if (option_enabled) { if (option_enabled) {
char new_tag_value[512] = {0}, old_tag_value[128] = {0}; char new_tag_value[512] = {0}, old_tag_value[128] = {0};
snprintf(old_tag_value, sizeof(old_tag_value), "%s,%s", dhcpv6_client_s->option_tag, dhcpv6_client_s->value); snprintf(old_tag_value, sizeof(old_tag_value), "%s,%s", option->tag, option->value);
snprintf(new_tag_value, sizeof(new_tag_value), "%s,%s", dhcpv6_client_s->option_tag, res); snprintf(new_tag_value, sizeof(new_tag_value), "%s,%s", option->tag, res);
dmuci_del_list_value_by_section(dhcpv6_client_s->client_sect, "dhcp_option", old_tag_value); dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section, "dhcp_option", old_tag_value);
dmuci_add_list_value_by_section(dhcpv6_client_s->client_sect, "dhcp_option", new_tag_value); dmuci_add_list_value_by_section(((struct dm_data *)data)->config_section, "dhcp_option", new_tag_value);
} }
dmuci_set_value_by_section_bbfdm(dhcpv6_client_s->dmmap_sect, "option_value", res); dmuci_set_value_by_section_bbfdm(((struct dm_data *)data)->dmmap_section, "option_value", res);
break; break;
} }
return 0; return 0;
@ -1341,7 +1315,7 @@ static int set_DHCPv6ServerPoolOption_Value(char *refparam, struct dmctx *ctx, v
*************************************************************/ *************************************************************/
static int operate_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) static int operate_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{ {
struct uci_section *dhcpv6_s = ((struct dhcpv6_client_args *)data)->iface_s; struct uci_section *dhcpv6_s = ((struct dm_data *)data)->config_section;
if (dhcpv6_s) { if (dhcpv6_s) {
char *if_name = section_name(dhcpv6_s); char *if_name = section_name(dhcpv6_s);

View file

@ -117,7 +117,7 @@ void synchronize_specific_config_sections_with_dmmap_mcast_iface(char *package,
char *v; char *v;
uci_foreach_option_eq(package, section_type, "proto", proto, s) { uci_foreach_option_eq(package, section_type, "proto", proto, s) {
if (strcmp(section_name(s), section_name((struct uci_section *)data)) != 0) if (strcmp(section_name(s), section_name(((struct dm_data *)data)->config_section)) != 0)
continue; continue;
// The list snooping_interface and proxy_interface in the uci file corresponds to the // The list snooping_interface and proxy_interface in the uci file corresponds to the
@ -160,7 +160,7 @@ void synchronize_specific_config_sections_with_dmmap_mcast_filter(char *package,
char *v, *s_name; char *v, *s_name;
uci_foreach_option_eq(package, section_type, "proto", proto, s) { uci_foreach_option_eq(package, section_type, "proto", proto, s) {
if (strcmp(section_name(s), section_name((struct uci_section *)data)) != 0) if (strcmp(section_name(s), section_name(((struct dm_data *)data)->config_section)) != 0)
continue; continue;
/* /*
* create/update corresponding dmmap section that have same config_section link and using param_value_array * create/update corresponding dmmap section that have same config_section link and using param_value_array
@ -296,41 +296,29 @@ void sync_dmmap_bool_to_uci_list(struct uci_section *s, char *section, char *val
int del_proxy_obj(void *data, char *proto, unsigned char del_action) int del_proxy_obj(void *data, char *proto, unsigned char del_action)
{ {
struct uci_section *s = NULL, *ss = NULL, *dmmap_section = NULL; struct uci_section *s = NULL, *stmp = NULL, *dmmap_section = NULL;
int found = 0;
switch (del_action) { switch (del_action) {
case DEL_INST: case DEL_INST:
// first delete all filter child nodes related to this object // first delete all filter child nodes related to this object
del_dmmap_sec_with_opt_eq("dmmap_mcast", "proxy_filter", "section_name", section_name((struct uci_section *)data)); del_dmmap_sec_with_opt_eq("dmmap_mcast", "proxy_filter", "section_name", section_name(((struct dm_data *)data)->config_section));
// Now delete all interface child nodes related to this object // Now delete all interface child nodes related to this object
del_dmmap_sec_with_opt_eq("dmmap_mcast", "proxy_interface", "section_name", section_name((struct uci_section *)data)); del_dmmap_sec_with_opt_eq("dmmap_mcast", "proxy_interface", "section_name", section_name(((struct dm_data *)data)->config_section));
// Now delete the proxy node // Now delete the proxy node
get_dmmap_section_of_config_section("dmmap_mcast", "proxy", section_name((struct uci_section *)data), &dmmap_section); dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section((struct uci_section *)data, NULL, NULL); dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
break; break;
case DEL_ALL: case DEL_ALL:
uci_foreach_option_eq("mcast", "proxy", "proto", proto, s) { uci_foreach_option_eq_safe("mcast", "proxy", "proto", proto, stmp, s) {
if (found != 0) {
get_dmmap_section_of_config_section("dmmap_mcast", "proxy", section_name(s), &dmmap_section);
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
found++;
}
if (ss != NULL) {
get_dmmap_section_of_config_section("dmmap_mcast", "proxy", section_name(ss), &dmmap_section);
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
get_dmmap_section_of_config_section("dmmap_mcast", "proxy", section_name(s), &dmmap_section);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(s, NULL, NULL);
}
break; break;
} }
return 0; return 0;
@ -338,13 +326,14 @@ int del_proxy_obj(void *data, char *proto, unsigned char del_action)
static int add_igmp_proxy_obj(char *refparam, struct dmctx *ctx, void *data, char **instance) static int add_igmp_proxy_obj(char *refparam, struct dmctx *ctx, void *data, char **instance)
{ {
struct uci_section *dmmap = NULL, *s = NULL; struct uci_section *dmmap = NULL, *s = NULL;
char s_name[32]; char s_name[32];
snprintf(s_name, sizeof(s_name), "igmp_proxy_%s", *instance); snprintf(s_name, sizeof(s_name), "igmp_proxy_%s", *instance);
dmuci_add_section("mcast", "proxy", &s); dmuci_add_section("mcast", "proxy", &s);
dmuci_rename_section_by_section(s, s_name); dmuci_rename_section_by_section(s, s_name);
dmuci_set_value_by_section(s, "enable", "0"); dmuci_set_value_by_section(s, "enable", "0");
dmuci_set_value_by_section(s, "proto", "igmp"); dmuci_set_value_by_section(s, "proto", "igmp");
dmuci_set_value_by_section(s, "last_member_query_interval", "10"); dmuci_set_value_by_section(s, "last_member_query_interval", "10");
@ -368,16 +357,16 @@ static int del_igmp_proxy_obj(char *refparam, struct dmctx *ctx, void *data, cha
static int browse_igmp_proxy_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) static int browse_igmp_proxy_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{ {
char *inst = NULL; struct dm_data *curr_data = NULL;
struct dmmap_dup *p = NULL;
LIST_HEAD(dup_list); LIST_HEAD(dup_list);
char *inst = NULL;
synchronize_specific_config_sections_with_dmmap_cont("mcast", "proxy", "dmmap_mcast", "proto", "igmp", &dup_list); synchronize_specific_config_sections_with_dmmap_cont("mcast", "proxy", "dmmap_mcast", "proto", "igmp", &dup_list);
list_for_each_entry(p, &dup_list, list) { list_for_each_entry(curr_data, &dup_list, list) {
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "proxy_instance", "proxy_alias"); inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "proxy_instance", "proxy_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, inst) == DM_STOP) if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
break; break;
} }
@ -394,6 +383,7 @@ static int add_igmp_snooping_obj(char *refparam, struct dmctx *ctx, void *data,
dmuci_add_section("mcast", "snooping", &s); dmuci_add_section("mcast", "snooping", &s);
dmuci_rename_section_by_section(s, s_name); dmuci_rename_section_by_section(s, s_name);
dmuci_set_value_by_section(s, "enable", "0"); dmuci_set_value_by_section(s, "enable", "0");
dmuci_set_value_by_section(s, "proto", "igmp"); dmuci_set_value_by_section(s, "proto", "igmp");
dmuci_set_value_by_section(s, "last_member_query_interval", "10"); dmuci_set_value_by_section(s, "last_member_query_interval", "10");
@ -411,40 +401,28 @@ static int add_igmp_snooping_obj(char *refparam, struct dmctx *ctx, void *data,
int del_snooping_obj(void *data, char *proto, unsigned char del_action) int del_snooping_obj(void *data, char *proto, unsigned char del_action)
{ {
struct uci_section *s = NULL, *ss = NULL, *dmmap_section = NULL; struct uci_section *s = NULL, *stmp = NULL, *dmmap_section = NULL;
int found = 0;
switch (del_action) { switch (del_action) {
case DEL_INST: case DEL_INST:
// first delete all filter child nodes related to this object // first delete all filter child nodes related to this object
del_dmmap_sec_with_opt_eq("dmmap_mcast", "snooping_filter", "section_name", section_name((struct uci_section *)data)); del_dmmap_sec_with_opt_eq("dmmap_mcast", "snooping_filter", "section_name", section_name(((struct dm_data *)data)->config_section));
// Now delete all interface child nodes related to this object // Now delete all interface child nodes related to this object
del_dmmap_sec_with_opt_eq("dmmap_mcast", "snooping_interface", "section_name", section_name((struct uci_section *)data)); del_dmmap_sec_with_opt_eq("dmmap_mcast", "snooping_interface", "section_name", section_name(((struct dm_data *)data)->config_section));
get_dmmap_section_of_config_section("dmmap_mcast", "snooping", section_name((struct uci_section *)data), &dmmap_section); dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section((struct uci_section *)data, NULL, NULL); dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
break; break;
case DEL_ALL: case DEL_ALL:
uci_foreach_option_eq("mcast", "snooping", "proto", proto, s) { uci_foreach_option_eq_safe("mcast", "snooping", "proto", proto, stmp, s) {
if (found != 0) {
get_dmmap_section_of_config_section("dmmap_mcast", "snooping", section_name(s), &dmmap_section);
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
found++;
}
if (ss != NULL) {
get_dmmap_section_of_config_section("dmmap_mcast", "snooping", section_name(ss), &dmmap_section);
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
get_dmmap_section_of_config_section("dmmap_mcast", "snooping", section_name(s), &dmmap_section);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(s, NULL, NULL);
}
break; break;
} }
return 0; return 0;
@ -457,16 +435,16 @@ static int del_igmp_snooping_obj(char *refparam, struct dmctx *ctx, void *data,
static int browse_igmp_snooping_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) static int browse_igmp_snooping_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{ {
char *inst = NULL; struct dm_data *curr_data = NULL;
struct dmmap_dup *p = NULL;
LIST_HEAD(dup_list); LIST_HEAD(dup_list);
char *inst = NULL;
synchronize_specific_config_sections_with_dmmap_cont("mcast", "snooping", "dmmap_mcast", "proto", "igmp", &dup_list); synchronize_specific_config_sections_with_dmmap_cont("mcast", "snooping", "dmmap_mcast", "proto", "igmp", &dup_list);
list_for_each_entry(p, &dup_list, list) { list_for_each_entry(curr_data, &dup_list, list) {
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "snooping_instance", "snooping_alias"); inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "snooping_instance", "snooping_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, inst) == DM_STOP) if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
break; break;
} }
free_dmmap_config_dup_list(&dup_list); free_dmmap_config_dup_list(&dup_list);
@ -475,44 +453,37 @@ static int browse_igmp_snooping_inst(struct dmctx *dmctx, DMNODE *parent_node, v
static int get_igmps_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_igmps_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct uci_section *s = NULL; int cnt = get_number_of_entries(ctx, data, instance, browse_igmp_snooping_inst);
int cnt = 0;
uci_foreach_option_eq("mcast", "snooping", "proto", "igmp", s) {
cnt++;
}
dmasprintf(value, "%d", cnt); dmasprintf(value, "%d", cnt);
return 0; return 0;
} }
static int get_igmpp_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_igmpp_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct uci_section *s = NULL; int cnt = get_number_of_entries(ctx, data, instance, browse_igmp_proxy_inst);
int cnt = 0;
uci_foreach_option_eq("mcast", "proxy", "proto", "igmp", s) {
cnt++;
}
dmasprintf(value, "%d", cnt); dmasprintf(value, "%d", cnt);
return 0; return 0;
} }
static int browse_igmp_cgrp_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) static int browse_igmp_cgrp_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{ {
//perform ubus call to mcast stats and browse through each igmp group json object json_object *res = NULL;
json_object *res = NULL, *jobj = NULL, *arrobj = NULL, *group_obj = NULL;
char *inst = NULL;
dmubus_call("mcast", "stats", UBUS_ARGS{0}, 0, &res); dmubus_call("mcast", "stats", UBUS_ARGS{0}, 0, &res);
if (res) { if (res) {
json_object *jobj = NULL, *arrobj = NULL, *group_obj = NULL;
struct dm_data curr_data = {0};
char *inst = NULL;
int i = 0, id = 0; int i = 0, id = 0;
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "snooping"); jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "snooping");
dmjson_foreach_obj_in_array(jobj, arrobj, group_obj, i, 1, "groups") { dmjson_foreach_obj_in_array(jobj, arrobj, group_obj, i, 1, "groups") {
curr_data.json_object = group_obj;
inst = handle_instance_without_section(dmctx, parent_node, ++id); inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)group_obj, inst) == DM_STOP)
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_data, inst) == DM_STOP)
break; break;
} }
} }
@ -524,7 +495,7 @@ static int add_igmps_filter_obj(char *refparam, struct dmctx *ctx, void *data, c
struct uci_section *dmmap_igmps_filter = NULL; struct uci_section *dmmap_igmps_filter = NULL;
dmuci_add_section_bbfdm("dmmap_mcast", "snooping_filter", &dmmap_igmps_filter); dmuci_add_section_bbfdm("dmmap_mcast", "snooping_filter", &dmmap_igmps_filter);
dmuci_set_value_by_section(dmmap_igmps_filter, "section_name", section_name((struct uci_section *)data)); dmuci_set_value_by_section(dmmap_igmps_filter, "section_name", section_name(((struct dm_data *)data)->config_section));
dmuci_set_value_by_section(dmmap_igmps_filter, "enable", "0"); dmuci_set_value_by_section(dmmap_igmps_filter, "enable", "0");
dmuci_set_value_by_section(dmmap_igmps_filter, "filter_instance", *instance); dmuci_set_value_by_section(dmmap_igmps_filter, "filter_instance", *instance);
return 0; return 0;
@ -539,7 +510,7 @@ int del_mcasts_filter_obj(char *refparam, struct dmctx *ctx, void *data, char *i
switch (del_action) { switch (del_action) {
case DEL_INST: case DEL_INST:
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "snooping_filter", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "snooping_filter",
"section_name", section_name((struct uci_section *)data), d_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), d_sec) {
dmuci_get_value_by_section_string(d_sec, "filter_instance", &f_inst); dmuci_get_value_by_section_string(d_sec, "filter_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
@ -549,7 +520,7 @@ int del_mcasts_filter_obj(char *refparam, struct dmctx *ctx, void *data, char *i
} }
if (found) { if (found) {
dmuci_del_list_value_by_section((struct uci_section *)data, "filter", ip_addr); dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section, "filter", ip_addr);
break; break;
} }
} }
@ -557,14 +528,14 @@ int del_mcasts_filter_obj(char *refparam, struct dmctx *ctx, void *data, char *i
break; break;
case DEL_ALL: case DEL_ALL:
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "snooping_filter", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "snooping_filter",
"section_name", section_name((struct uci_section *)data), d_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), d_sec) {
dmuci_get_value_by_section_string(d_sec, "ipaddr", &ip_addr); dmuci_get_value_by_section_string(d_sec, "ipaddr", &ip_addr);
if (ip_addr[0] != '\0') { if (ip_addr[0] != '\0') {
dmuci_del_list_value_by_section((struct uci_section *)data, "filter", ip_addr); dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section, "filter", ip_addr);
} }
} }
del_dmmap_sec_with_opt_eq("dmmap_mcast", "snooping_filter", "section_name", section_name((struct uci_section *)data)); del_dmmap_sec_with_opt_eq("dmmap_mcast", "snooping_filter", "section_name", section_name(((struct dm_data *)data)->config_section));
break; break;
} }
@ -573,18 +544,16 @@ int del_mcasts_filter_obj(char *refparam, struct dmctx *ctx, void *data, char *i
int browse_filter_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *section_type, char *option_name, char *option_value) int browse_filter_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *section_type, char *option_name, char *option_value)
{ {
struct dmmap_dup *p = NULL; struct dm_data *curr_data = NULL;
char *inst = NULL;
LIST_HEAD(dup_list); LIST_HEAD(dup_list);
char *inst = NULL;
synchronize_specific_config_sections_with_dmmap_mcast_filter("mcast", section_type, prev_data, "dmmap_mcast", option_name, option_value, &dup_list); synchronize_specific_config_sections_with_dmmap_mcast_filter("mcast", section_type, prev_data, "dmmap_mcast", option_name, option_value, &dup_list);
list_for_each_entry(p, &dup_list, list) { list_for_each_entry(curr_data, &dup_list, list) {
if (!p->config_section)
break;
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "filter_instance", "filter_alias"); inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "filter_instance", "filter_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, inst) == DM_STOP) if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
break; break;
} }
@ -599,32 +568,14 @@ static int browse_igmps_filter_inst(struct dmctx *dmctx, DMNODE *parent_node, vo
int get_mcasts_filter_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcasts_filter_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct uci_section *s = NULL; int cnt = get_number_of_entries(ctx, data, instance, browse_mlds_filter_inst);
int cnt = 0;
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "snooping_filter", "section_name",
section_name((struct uci_section *)data), s) {
cnt++;
}
dmasprintf(value, "%d", cnt); dmasprintf(value, "%d", cnt);
return 0; return 0;
} }
static int get_igmp_cgrps_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_igmp_cgrps_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
int cnt = 0; int cnt = get_number_of_entries(ctx, data, instance, browse_igmp_cgrp_inst);
json_object *res = NULL, *jobj = NULL, *arrobj = NULL, *group_obj = NULL;
dmubus_call("mcast", "stats", UBUS_ARGS{0}, 0, &res);
if (res) {
int i = 0;
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "snooping");
dmjson_foreach_obj_in_array(jobj, arrobj, group_obj, i, 1, "groups") {
cnt++;
}
}
dmasprintf(value, "%d", cnt); dmasprintf(value, "%d", cnt);
return 0; return 0;
} }
@ -635,7 +586,7 @@ int get_mcasts_filter_enable(char *refparam, struct dmctx *ctx, void *data, char
char *f_inst, *f_enable = NULL; char *f_inst, *f_enable = NULL;
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "snooping_filter", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "snooping_filter",
"section_name", section_name((struct uci_section *)data), f_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), f_sec) {
dmuci_get_value_by_section_string(f_sec, "filter_instance", &f_inst); dmuci_get_value_by_section_string(f_sec, "filter_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
dmuci_get_value_by_section_string(f_sec, "enable", &f_enable); dmuci_get_value_by_section_string(f_sec, "enable", &f_enable);
@ -665,13 +616,13 @@ int set_mcasts_filter_enable(char *refparam, struct dmctx *ctx, void *data, char
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "snooping_filter", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "snooping_filter",
"section_name", section_name((struct uci_section *)data), f_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), f_sec) {
dmuci_get_value_by_section_string(f_sec, "filter_instance", &f_inst); dmuci_get_value_by_section_string(f_sec, "filter_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
dmuci_get_value_by_section_string(f_sec, "ipaddr", &ip_addr); dmuci_get_value_by_section_string(f_sec, "ipaddr", &ip_addr);
dmuci_set_value_by_section(f_sec, "enable", (b) ? "1" : "0"); dmuci_set_value_by_section(f_sec, "enable", (b) ? "1" : "0");
if (ip_addr[0] != '\0') { if (ip_addr[0] != '\0') {
sync_dmmap_bool_to_uci_list((struct uci_section *)data, sync_dmmap_bool_to_uci_list(((struct dm_data *)data)->config_section,
"filter", ip_addr, b); "filter", ip_addr, b);
} }
break; break;
@ -689,7 +640,7 @@ int get_mcasts_filter_address(char *refparam, struct dmctx *ctx, void *data, cha
char *f_inst, *ip_addr = NULL; char *f_inst, *ip_addr = NULL;
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "snooping_filter", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "snooping_filter",
"section_name", section_name((struct uci_section *)data), d_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), d_sec) {
dmuci_get_value_by_section_string(d_sec, "filter_instance", &f_inst); dmuci_get_value_by_section_string(d_sec, "filter_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
dmuci_get_value_by_section_string(d_sec, "ipaddr", &ip_addr); dmuci_get_value_by_section_string(d_sec, "ipaddr", &ip_addr);
@ -720,13 +671,13 @@ int set_mcasts_filter_address(char *refparam, struct dmctx *ctx, void *data, cha
break; break;
case VALUESET: case VALUESET:
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "snooping_filter", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "snooping_filter",
"section_name", section_name((struct uci_section *)data), s) { "section_name", section_name(((struct dm_data *)data)->config_section), s) {
dmuci_get_value_by_section_string(s, "filter_instance", &s_inst); dmuci_get_value_by_section_string(s, "filter_instance", &s_inst);
if (DM_STRCMP(s_inst, instance) == 0) { if (DM_STRCMP(s_inst, instance) == 0) {
dmuci_set_value_by_section(s, "ipaddr", value); dmuci_set_value_by_section(s, "ipaddr", value);
dmuci_get_value_by_section_string(s, "enable", &up); dmuci_get_value_by_section_string(s, "enable", &up);
string_to_bool(up, &b); string_to_bool(up, &b);
sync_dmmap_bool_to_uci_list((struct uci_section *)data, sync_dmmap_bool_to_uci_list(((struct dm_data *)data)->config_section,
"filter", value, b); "filter", value, b);
break; break;
} }
@ -740,7 +691,7 @@ int set_mcasts_filter_address(char *refparam, struct dmctx *ctx, void *data, cha
int get_mcast_snooping_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcast_snooping_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "enable", "0"); *value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "enable", "0");
return 0; return 0;
} }
@ -755,7 +706,7 @@ int set_mcast_snooping_enable(char *refparam, struct dmctx *ctx, void *data, cha
break; break;
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
dmuci_set_value_by_section((struct uci_section *)data, "enable", (b) ? "1" : "0"); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "enable", (b) ? "1" : "0");
break; break;
} }
@ -765,7 +716,7 @@ int set_mcast_snooping_enable(char *refparam, struct dmctx *ctx, void *data, cha
static int get_igmp_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_igmp_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
char *val; char *val;
dmuci_get_value_by_section_string((struct uci_section *)data, "version", &val); dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "version", &val);
*value = (DM_LSTRCMP(val, "3") == 0) ? "V3" : "V2"; *value = (DM_LSTRCMP(val, "3") == 0) ? "V3" : "V2";
return 0; return 0;
} }
@ -778,7 +729,7 @@ static int set_igmp_version(char *refparam, struct dmctx *ctx, void *data, char
return FAULT_9007; return FAULT_9007;
break; break;
case VALUESET: case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "version", (DM_LSTRCMP(value, "V2") == 0) ? "2" : "3"); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "version", (DM_LSTRCMP(value, "V2") == 0) ? "2" : "3");
break; break;
} }
@ -788,7 +739,7 @@ static int set_igmp_version(char *refparam, struct dmctx *ctx, void *data, char
int get_mcast_snooping_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcast_snooping_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
char *val; char *val;
dmuci_get_value_by_section_string((struct uci_section *)data, "snooping_mode", &val); dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "snooping_mode", &val);
if (DM_LSTRCMP(val, "1") == 0) if (DM_LSTRCMP(val, "1") == 0)
*value = "Standard"; *value = "Standard";
@ -819,7 +770,7 @@ int set_mcast_snooping_mode(char *refparam, struct dmctx *ctx, void *data, char
else else
DM_STRNCPY(val, "0", sizeof(val)); DM_STRNCPY(val, "0", sizeof(val));
dmuci_set_value_by_section((struct uci_section *)data, "snooping_mode", val); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "snooping_mode", val);
break; break;
} }
@ -828,7 +779,7 @@ int set_mcast_snooping_mode(char *refparam, struct dmctx *ctx, void *data, char
int get_mcasts_last_mq_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcasts_last_mq_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "last_member_query_interval", "10"); *value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "last_member_query_interval", "10");
return 0; return 0;
} }
@ -840,7 +791,7 @@ int set_mcasts_last_mq_interval(char *refparam, struct dmctx *ctx, void *data, c
return FAULT_9007; return FAULT_9007;
break; break;
case VALUESET: case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "last_member_query_interval", value); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "last_member_query_interval", value);
break; break;
} }
@ -849,7 +800,7 @@ int set_mcasts_last_mq_interval(char *refparam, struct dmctx *ctx, void *data, c
int get_mcasts_fast_leave(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcasts_fast_leave(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "fast_leave", "1"); *value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "fast_leave", "1");
return 0; return 0;
} }
@ -864,7 +815,7 @@ int set_mcasts_fast_leave(char *refparam, struct dmctx *ctx, void *data, char *i
break; break;
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
dmuci_set_value_by_section((struct uci_section *)data, "fast_leave", (b) ? "1" : "0"); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "fast_leave", (b) ? "1" : "0");
break; break;
} }
@ -873,7 +824,7 @@ int set_mcasts_fast_leave(char *refparam, struct dmctx *ctx, void *data, char *i
int get_mcast_snooping_robustness(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcast_snooping_robustness(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "robustness", "2"); *value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "robustness", "2");
return 0; return 0;
} }
@ -886,7 +837,7 @@ int set_mcast_snooping_robustness(char *refparam, struct dmctx *ctx, void *data,
return FAULT_9007; return FAULT_9007;
break; break;
case VALUESET: case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "robustness", value); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "robustness", value);
break; break;
} }
@ -895,7 +846,7 @@ int set_mcast_snooping_robustness(char *refparam, struct dmctx *ctx, void *data,
int get_mcast_snooping_aggregation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcast_snooping_aggregation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "aggregation", "1"); *value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "aggregation", "1");
return 0; return 0;
} }
@ -910,7 +861,7 @@ int set_mcast_snooping_aggregation(char *refparam, struct dmctx *ctx, void *data
break; break;
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
dmuci_set_value_by_section((struct uci_section *)data, "aggregation", (b) ? "1" : "0"); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "aggregation", (b) ? "1" : "0");
break; break;
} }
@ -922,7 +873,7 @@ int get_mcast_snooping_interface(char *refparam, struct dmctx *ctx, void *data,
char val[16] = {0}; // taking 16 here is same as that is size of linux names usually supported char val[16] = {0}; // taking 16 here is same as that is size of linux names usually supported
char *val1; char *val1;
dmuci_get_value_by_section_string((struct uci_section *)data, "interface", &val1); dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "interface", &val1);
// The value is linux interface name so it would be br-wan for example, but the network // The value is linux interface name so it would be br-wan for example, but the network
// section would be wan, so extract wan from br-wan // section would be wan, so extract wan from br-wan
@ -958,7 +909,7 @@ int set_mcast_snooping_interface(char *refparam, struct dmctx *ctx, void *data,
if (get_mcast_snooping_interface_val(&reference, ifname, sizeof(ifname)) != 0) if (get_mcast_snooping_interface_val(&reference, ifname, sizeof(ifname)) != 0)
return -1; return -1;
dmuci_set_value_by_section((struct uci_section *)data, "interface", ifname); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "interface", ifname);
break; break;
} }
@ -970,7 +921,7 @@ static int add_igmpp_interface_obj(char *refparam, struct dmctx *ctx, void *data
struct uci_section *dmmap_igmpp_interface = NULL; struct uci_section *dmmap_igmpp_interface = NULL;
dmuci_add_section_bbfdm("dmmap_mcast", "proxy_interface", &dmmap_igmpp_interface); dmuci_add_section_bbfdm("dmmap_mcast", "proxy_interface", &dmmap_igmpp_interface);
dmuci_set_value_by_section(dmmap_igmpp_interface, "section_name", section_name((struct uci_section *)data)); dmuci_set_value_by_section(dmmap_igmpp_interface, "section_name", section_name(((struct dm_data *)data)->config_section));
dmuci_set_value_by_section(dmmap_igmpp_interface, "upstream", "0"); dmuci_set_value_by_section(dmmap_igmpp_interface, "upstream", "0");
dmuci_set_value_by_section(dmmap_igmpp_interface, "snooping_mode", "0"); dmuci_set_value_by_section(dmmap_igmpp_interface, "snooping_mode", "0");
dmuci_set_value_by_section(dmmap_igmpp_interface, "iface_instance", *instance); dmuci_set_value_by_section(dmmap_igmpp_interface, "iface_instance", *instance);
@ -996,10 +947,10 @@ static void get_igmpp_iface_del_key_val(char *key, size_t key_size, char *if_nam
static void del_igmpp_iface_val(char *upstream, void *data, char *pch) static void del_igmpp_iface_val(char *upstream, void *data, char *pch)
{ {
if (DM_LSTRCMP(upstream, "1") == 0) { if (DM_LSTRCMP(upstream, "1") == 0) {
dmuci_del_list_value_by_section((struct uci_section *)data, dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section,
"upstream_interface", pch); "upstream_interface", pch);
} else { } else {
dmuci_del_list_value_by_section((struct uci_section *)data, dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section,
"downstream_interface", pch); "downstream_interface", pch);
} }
} }
@ -1010,7 +961,7 @@ static int del_igmpp_interface_obj(char *refparam, struct dmctx *ctx, void *data
switch (del_action) { switch (del_action) {
case DEL_INST: case DEL_INST:
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", "section_name", section_name((struct uci_section *)data), igmpp_s) { uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", "section_name", section_name(((struct dm_data *)data)->config_section), igmpp_s) {
char *f_inst = NULL, *if_name = NULL, *upstream = NULL; char *f_inst = NULL, *if_name = NULL, *upstream = NULL;
int found = 0; int found = 0;
@ -1041,7 +992,7 @@ static int del_igmpp_interface_obj(char *refparam, struct dmctx *ctx, void *data
} }
break; break;
case DEL_ALL: case DEL_ALL:
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", "section_name", section_name((struct uci_section *)data), igmpp_s) { uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", "section_name", section_name(((struct dm_data *)data)->config_section), igmpp_s) {
char *if_name = NULL, *upstream = NULL; char *if_name = NULL, *upstream = NULL;
dmuci_get_value_by_section_string(igmpp_s, "ifname", &if_name); dmuci_get_value_by_section_string(igmpp_s, "ifname", &if_name);
@ -1060,7 +1011,7 @@ static int del_igmpp_interface_obj(char *refparam, struct dmctx *ctx, void *data
} }
} }
del_dmmap_sec_with_opt_eq("dmmap_mcast", "proxy_interface", "section_name", section_name((struct uci_section *)data)); del_dmmap_sec_with_opt_eq("dmmap_mcast", "proxy_interface", "section_name", section_name(((struct dm_data *)data)->config_section));
break; break;
} }
@ -1069,18 +1020,16 @@ static int del_igmpp_interface_obj(char *refparam, struct dmctx *ctx, void *data
int browse_proxy_interface_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *proto) int browse_proxy_interface_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *proto)
{ {
struct dmmap_dup *p = NULL; struct dm_data *curr_data = NULL;
char *inst = NULL;
LIST_HEAD(dup_list); LIST_HEAD(dup_list);
char *inst = NULL;
synchronize_specific_config_sections_with_dmmap_mcast_iface("mcast", "proxy", prev_data, "dmmap_mcast", "proxy_interface", proto, &dup_list); synchronize_specific_config_sections_with_dmmap_mcast_iface("mcast", "proxy", prev_data, "dmmap_mcast", "proxy_interface", proto, &dup_list);
list_for_each_entry(p, &dup_list, list) { list_for_each_entry(curr_data, &dup_list, list) {
if (!p->config_section)
break;
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "iface_instance", "iface_alias"); inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "iface_instance", "iface_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, inst) == DM_STOP) if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
break; break;
} }
@ -1098,7 +1047,7 @@ static int add_igmpp_filter_obj(char *refparam, struct dmctx *ctx, void *data, c
struct uci_section *dmmap_igmpp_filter = NULL; struct uci_section *dmmap_igmpp_filter = NULL;
dmuci_add_section_bbfdm("dmmap_mcast", "proxy_filter", &dmmap_igmpp_filter); dmuci_add_section_bbfdm("dmmap_mcast", "proxy_filter", &dmmap_igmpp_filter);
dmuci_set_value_by_section(dmmap_igmpp_filter, "section_name", section_name((struct uci_section *)data)); dmuci_set_value_by_section(dmmap_igmpp_filter, "section_name", section_name(((struct dm_data *)data)->config_section));
dmuci_set_value_by_section(dmmap_igmpp_filter, "enable", "0"); dmuci_set_value_by_section(dmmap_igmpp_filter, "enable", "0");
dmuci_set_value_by_section(dmmap_igmpp_filter, "filter_instance", *instance); dmuci_set_value_by_section(dmmap_igmpp_filter, "filter_instance", *instance);
return 0; return 0;
@ -1113,7 +1062,7 @@ int del_mcastp_filter_obj(char *refparam, struct dmctx *ctx, void *data, char *i
switch (del_action) { switch (del_action) {
case DEL_INST: case DEL_INST:
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter",
"section_name", section_name((struct uci_section *)data), d_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), d_sec) {
dmuci_get_value_by_section_string(d_sec, "filter_instance", &f_inst); dmuci_get_value_by_section_string(d_sec, "filter_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
@ -1123,7 +1072,7 @@ int del_mcastp_filter_obj(char *refparam, struct dmctx *ctx, void *data, char *i
} }
if (found) { if (found) {
dmuci_del_list_value_by_section((struct uci_section *)data, dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section,
"filter", ip_addr); "filter", ip_addr);
break; break;
} }
@ -1132,15 +1081,15 @@ int del_mcastp_filter_obj(char *refparam, struct dmctx *ctx, void *data, char *i
break; break;
case DEL_ALL: case DEL_ALL:
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter",
"section_name", section_name((struct uci_section *)data), d_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), d_sec) {
dmuci_get_value_by_section_string(d_sec, "ipaddr", &ip_addr); dmuci_get_value_by_section_string(d_sec, "ipaddr", &ip_addr);
if (ip_addr[0] != '\0') if (ip_addr[0] != '\0')
dmuci_del_list_value_by_section((struct uci_section *)data, dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section,
"filter", ip_addr); "filter", ip_addr);
} }
del_dmmap_sec_with_opt_eq("dmmap_mcast", "proxy_filter", "section_name", del_dmmap_sec_with_opt_eq("dmmap_mcast", "proxy_filter", "section_name",
section_name((struct uci_section *)data)); section_name(((struct dm_data *)data)->config_section));
break; break;
} }
@ -1155,14 +1104,7 @@ static int browse_igmpp_filter_inst(struct dmctx *dmctx, DMNODE *parent_node, vo
int get_mcastp_interface_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcastp_interface_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct uci_section *s = NULL; int cnt = get_number_of_entries(ctx, data, instance, browse_mldp_interface_inst);
int cnt = 0;
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", "section_name",
section_name((struct uci_section *)data), s) {
cnt++;
}
dmasprintf(value, "%d", cnt); dmasprintf(value, "%d", cnt);
return 0; return 0;
} }
@ -1173,7 +1115,7 @@ int get_mcastp_filter_enable(char *refparam, struct dmctx *ctx, void *data, char
char *f_inst, *f_enable = NULL; char *f_inst, *f_enable = NULL;
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter",
"section_name", section_name((struct uci_section *)data), f_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), f_sec) {
dmuci_get_value_by_section_string(f_sec, "filter_instance", &f_inst); dmuci_get_value_by_section_string(f_sec, "filter_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
dmuci_get_value_by_section_string(f_sec, "enable", &f_enable); dmuci_get_value_by_section_string(f_sec, "enable", &f_enable);
@ -1203,12 +1145,12 @@ int set_mcastp_filter_enable(char *refparam, struct dmctx *ctx, void *data, char
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter",
"section_name", section_name((struct uci_section *)data), f_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), f_sec) {
dmuci_get_value_by_section_string(f_sec, "filter_instance", &f_inst); dmuci_get_value_by_section_string(f_sec, "filter_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
dmuci_get_value_by_section_string(f_sec, "ipaddr", &ip_addr); dmuci_get_value_by_section_string(f_sec, "ipaddr", &ip_addr);
dmuci_set_value_by_section(f_sec, "enable", (b) ? "1" : "0"); dmuci_set_value_by_section(f_sec, "enable", (b) ? "1" : "0");
sync_dmmap_bool_to_uci_list((struct uci_section *)data, sync_dmmap_bool_to_uci_list(((struct dm_data *)data)->config_section,
"filter", ip_addr, b); "filter", ip_addr, b);
break; break;
} }
@ -1225,7 +1167,7 @@ int get_mcastp_filter_address(char *refparam, struct dmctx *ctx, void *data, cha
char *f_inst; char *f_inst;
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter",
"section_name", section_name((struct uci_section *)data), d_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), d_sec) {
dmuci_get_value_by_section_string(d_sec, "filter_instance", &f_inst); dmuci_get_value_by_section_string(d_sec, "filter_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
dmuci_get_value_by_section_string(d_sec, "ipaddr", value); dmuci_get_value_by_section_string(d_sec, "ipaddr", value);
@ -1248,13 +1190,13 @@ static int set_igmpp_filter_address(char *refparam, struct dmctx *ctx, void *dat
return FAULT_9007; return FAULT_9007;
break; break;
case VALUESET: case VALUESET:
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter", "section_name", section_name((struct uci_section *)data), igmp_s) { uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter", "section_name", section_name(((struct dm_data *)data)->config_section), igmp_s) {
dmuci_get_value_by_section_string(igmp_s, "filter_instance", &s_inst); dmuci_get_value_by_section_string(igmp_s, "filter_instance", &s_inst);
if (DM_STRCMP(s_inst, instance) == 0) { if (DM_STRCMP(s_inst, instance) == 0) {
dmuci_set_value_by_section(igmp_s, "ipaddr", value); dmuci_set_value_by_section(igmp_s, "ipaddr", value);
dmuci_get_value_by_section_string(igmp_s, "enable", &up); dmuci_get_value_by_section_string(igmp_s, "enable", &up);
string_to_bool(up, &b); string_to_bool(up, &b);
sync_dmmap_bool_to_uci_list((struct uci_section *)data, "filter", value, b); sync_dmmap_bool_to_uci_list(((struct dm_data *)data)->config_section, "filter", value, b);
break; break;
} }
} }
@ -1266,15 +1208,18 @@ static int set_igmpp_filter_address(char *refparam, struct dmctx *ctx, void *dat
static int browse_igmp_cgrp_assoc_dev_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) static int browse_igmp_cgrp_assoc_dev_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{ {
//parse and browse through prev_data(it will be json object containing group address and details of its clients)
int i = 0, id = 0;
json_object *arrobj = NULL, *client_jobj = NULL; json_object *arrobj = NULL, *client_jobj = NULL;
struct dm_data curr_data = {0};
char *inst = NULL; char *inst = NULL;
int i = 0, id = 0;
dmjson_foreach_obj_in_array(((struct dm_data *)prev_data)->json_object, arrobj, client_jobj, i, 1, "clients") {
curr_data.json_object = client_jobj;
dmjson_foreach_obj_in_array((struct json_object *)prev_data, arrobj, client_jobj, i, 1, "clients") {
inst = handle_instance_without_section(dmctx, parent_node, ++id); inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)client_jobj, inst) == DM_STOP)
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_data, inst) == DM_STOP)
break; break;
} }
return 0; return 0;
@ -1296,32 +1241,27 @@ static int browse_igmpp_cgrp_stats_inst(struct dmctx *dmctx, DMNODE *parent_node
static int get_igmp_cgrp_gaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_igmp_cgrp_gaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
*value = dmjson_get_value((json_object *)data, 1, "groupaddr"); *value = dmjson_get_value(((struct dm_data *)data)->json_object, 1, "groupaddr");
return 0; return 0;
} }
static int get_igmp_cgrp_assoc_dev_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_igmp_cgrp_assoc_dev_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
int i = 0, cnt = 0; int cnt = get_number_of_entries(ctx, data, instance, browse_igmp_cgrp_assoc_dev_inst);
json_object *arrobj = NULL, *client_obj = NULL;
dmjson_foreach_obj_in_array((json_object *)data, arrobj, client_obj, i, 1, "clients") {
cnt++;
}
dmasprintf(value, "%d", cnt); dmasprintf(value, "%d", cnt);
return 0; return 0;
} }
static int get_igmp_cgrp_adev_iface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_igmp_cgrp_adev_iface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
char *ifname = dmjson_get_value((json_object *)data, 1, "device"); char *ifname = dmjson_get_value(((struct dm_data *)data)->json_object, 1, "device");
adm_entry_get_reference_param(ctx, "Device.Ethernet.Interface.*.Name", ifname, value); adm_entry_get_reference_param(ctx, "Device.Ethernet.Interface.*.Name", ifname, value);
return 0; return 0;
} }
static int get_igmp_cgrp_adev_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_igmp_cgrp_adev_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
char *ipaddr = dmjson_get_value((json_object *)data, 1, "ipaddr"); char *ipaddr = dmjson_get_value(((struct dm_data *)data)->json_object, 1, "ipaddr");
char *linker = get_host_linker(ipaddr); char *linker = get_host_linker(ipaddr);
adm_entry_get_reference_param(ctx, "Device.Hosts.Host.*.PhysAddress", linker, value); adm_entry_get_reference_param(ctx, "Device.Hosts.Host.*.PhysAddress", linker, value);
@ -1330,7 +1270,7 @@ static int get_igmp_cgrp_adev_host(char *refparam, struct dmctx *ctx, void *data
static int get_igmp_cgrp_adev_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_igmp_cgrp_adev_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
*value = dmjson_get_value((json_object *)data, 1, "timeout"); *value = dmjson_get_value(((struct dm_data *)data)->json_object, 1, "timeout");
return 0; return 0;
} }
@ -1410,7 +1350,7 @@ static int get_igmpp_cgrp_stats_lrcvd(char *refparam, struct dmctx *ctx, void *d
int get_mcast_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcast_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "enable", "0"); *value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "enable", "0");
return 0; return 0;
} }
int set_mcast_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) int set_mcast_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
@ -1424,7 +1364,7 @@ int set_mcast_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *
break; break;
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
dmuci_set_value_by_section((struct uci_section *)data, "enable", (b) ? "1" : "0"); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "enable", (b) ? "1" : "0");
break; break;
} }
@ -1433,25 +1373,25 @@ int set_mcast_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *
int get_mcast_proxy_robustness(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcast_proxy_robustness(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "robustness", "2"); *value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "robustness", "2");
return 0; return 0;
} }
int get_mcastp_query_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcastp_query_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "query_interval", "125"); *value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "query_interval", "125");
return 0; return 0;
} }
int get_mcastp_q_response_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcastp_q_response_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "query_response_interval", "100"); *value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "query_response_interval", "100");
return 0; return 0;
} }
int get_mcastp_last_mq_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcastp_last_mq_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "last_member_query_interval", "10"); *value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "last_member_query_interval", "10");
return 0; return 0;
} }
@ -1463,7 +1403,7 @@ int set_mcastp_query_interval(char *refparam, struct dmctx *ctx, void *data, cha
return FAULT_9007; return FAULT_9007;
break; break;
case VALUESET: case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "query_interval", value); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "query_interval", value);
break; break;
} }
@ -1479,7 +1419,7 @@ int set_mcastp_q_response_interval(char *refparam, struct dmctx *ctx, void *data
return FAULT_9007; return FAULT_9007;
break; break;
case VALUESET: case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "query_response_interval", value); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "query_response_interval", value);
break; break;
} }
@ -1495,7 +1435,7 @@ int set_mcastp_last_mq_interval(char *refparam, struct dmctx *ctx, void *data, c
return FAULT_9007; return FAULT_9007;
break; break;
case VALUESET: case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "last_member_query_interval", value); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "last_member_query_interval", value);
break; break;
} }
@ -1511,7 +1451,7 @@ int set_mcast_proxy_robustness(char *refparam, struct dmctx *ctx, void *data, ch
return FAULT_9007; return FAULT_9007;
break; break;
case VALUESET: case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "robustness", value); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "robustness", value);
break; break;
} }
@ -1520,13 +1460,13 @@ int set_mcast_proxy_robustness(char *refparam, struct dmctx *ctx, void *data, ch
int get_mcast_proxy_aggregation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcast_proxy_aggregation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "aggregation", "1"); *value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "aggregation", "1");
return 0; return 0;
} }
int get_mcast_proxy_fast_leave(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcast_proxy_fast_leave(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "fast_leave", "1"); *value = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "fast_leave", "1");
return 0; return 0;
} }
@ -1541,7 +1481,7 @@ int set_mcast_proxy_fast_leave(char *refparam, struct dmctx *ctx, void *data, ch
break; break;
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
dmuci_set_value_by_section((struct uci_section *)data, "fast_leave", (b) ? "1" : "0"); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "fast_leave", (b) ? "1" : "0");
break; break;
} }
@ -1559,7 +1499,7 @@ int set_mcast_proxy_aggregation(char *refparam, struct dmctx *ctx, void *data, c
break; break;
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
dmuci_set_value_by_section((struct uci_section *)data, "aggregation", (b) ? "1" : "0"); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "aggregation", (b) ? "1" : "0");
break; break;
} }
@ -1568,14 +1508,7 @@ int set_mcast_proxy_aggregation(char *refparam, struct dmctx *ctx, void *data, c
int get_mcastp_filter_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_mcastp_filter_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct uci_section *s = NULL; int cnt = get_number_of_entries(ctx, data, instance, browse_mldp_filter_inst);
int cnt = 0;
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter", "section_name",
section_name((struct uci_section *)data), s) {
cnt++;
}
dmasprintf(value, "%d", cnt); dmasprintf(value, "%d", cnt);
return 0; return 0;
} }
@ -1675,7 +1608,7 @@ static void set_igmpp_iface_val(void *data, char *instance, char *linker, char *
bool b, is_bridge_interface = false; bool b, is_bridge_interface = false;
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface",
"section_name", section_name((struct uci_section *)data), d_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), d_sec) {
dmuci_get_value_by_section_string(d_sec, "iface_instance", &f_inst); dmuci_get_value_by_section_string(d_sec, "iface_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
@ -1708,16 +1641,16 @@ static void set_igmpp_iface_val(void *data, char *instance, char *linker, char *
// Delete the previous upstream_interface/downstream_interface from the uci // Delete the previous upstream_interface/downstream_interface from the uci
// file as it is updated in dmmap file, and will be updated after sync in // file as it is updated in dmmap file, and will be updated after sync in
// sync_proxy_interface_sections function // sync_proxy_interface_sections function
dmuci_del_list_value_by_section((struct uci_section *)data, dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section,
(b) ? "upstream_interface" : "downstream_interface" , device_name); (b) ? "upstream_interface" : "downstream_interface" , device_name);
sync_proxy_interface_sections((struct uci_section *)data, sync_proxy_interface_sections(((struct dm_data *)data)->config_section,
"downstream_interface", interface_linker, !b); "downstream_interface", interface_linker, !b);
// Now update the proxy_interface list // Now update the proxy_interface list
sync_proxy_interface_sections((struct uci_section *)data, sync_proxy_interface_sections(((struct dm_data *)data)->config_section,
"upstream_interface", interface_linker, b); "upstream_interface", interface_linker, b);
update_snooping_mode((struct uci_section *)data); update_snooping_mode(((struct dm_data *)data)->config_section);
break; break;
} }
} }
@ -1785,7 +1718,7 @@ static int get_igmpp_interface_iface(char *refparam, struct dmctx *ctx, void *da
char sec_name[16] = {0}; char sec_name[16] = {0};
int found = 0; int found = 0;
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", "section_name", section_name((struct uci_section *)data), igmpp_s) { uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", "section_name", section_name(((struct dm_data *)data)->config_section), igmpp_s) {
dmuci_get_value_by_section_string(igmpp_s, "iface_instance", &f_inst); dmuci_get_value_by_section_string(igmpp_s, "iface_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
dmuci_get_value_by_section_string(igmpp_s, "ifname", &igmpp_ifname); dmuci_get_value_by_section_string(igmpp_s, "ifname", &igmpp_ifname);
@ -1853,7 +1786,7 @@ static int set_igmpp_interface_upstream(char *refparam, struct dmctx *ctx, void
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface",
"section_name", section_name((struct uci_section *)data), d_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), d_sec) {
dmuci_get_value_by_section_string(d_sec, "iface_instance", &f_inst); dmuci_get_value_by_section_string(d_sec, "iface_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
// The interface is a part of downstream or upstream list in the // The interface is a part of downstream or upstream list in the
@ -1878,9 +1811,9 @@ static int set_igmpp_interface_upstream(char *refparam, struct dmctx *ctx, void
} }
dmuci_set_value_by_section(d_sec, "upstream", (b) ? "1" : "0"); dmuci_set_value_by_section(d_sec, "upstream", (b) ? "1" : "0");
sync_proxy_interface_sections((struct uci_section *)data, "downstream_interface", key, !b); sync_proxy_interface_sections(((struct dm_data *)data)->config_section, "downstream_interface", key, !b);
sync_proxy_interface_sections((struct uci_section *)data, "upstream_interface", key, b); sync_proxy_interface_sections(((struct dm_data *)data)->config_section, "upstream_interface", key, b);
update_snooping_mode((struct uci_section *)data); update_snooping_mode(((struct dm_data *)data)->config_section);
break; break;
} }
@ -1898,7 +1831,7 @@ int get_mcastp_interface_upstream(char *refparam, struct dmctx *ctx, void *data,
char *f_inst, *up = NULL; char *f_inst, *up = NULL;
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface",
"section_name", section_name((struct uci_section *)data), d_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), d_sec) {
dmuci_get_value_by_section_string(d_sec, "iface_instance", &f_inst); dmuci_get_value_by_section_string(d_sec, "iface_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
dmuci_get_value_by_section_string(d_sec, "upstream", &up); dmuci_get_value_by_section_string(d_sec, "upstream", &up);
@ -1916,7 +1849,7 @@ int get_mcastp_iface_snoop_mode(char *refparam, struct dmctx *ctx, void *data, c
char *f_inst, *val = NULL; char *f_inst, *val = NULL;
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface",
"section_name", section_name((struct uci_section *)data), d_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), d_sec) {
dmuci_get_value_by_section_string(d_sec, "iface_instance", &f_inst); dmuci_get_value_by_section_string(d_sec, "iface_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
dmuci_get_value_by_section_string(d_sec, "snooping_mode", &val); dmuci_get_value_by_section_string(d_sec, "snooping_mode", &val);
@ -1957,7 +1890,7 @@ int set_mcastp_iface_snoop_mode(char *refparam, struct dmctx *ctx, void *data, c
strcpy(val, "0"); strcpy(val, "0");
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface",
"section_name", section_name((struct uci_section *)data), d_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), d_sec) {
dmuci_get_value_by_section_string(d_sec, "iface_instance", &f_inst); dmuci_get_value_by_section_string(d_sec, "iface_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
dmuci_get_value_by_section_string(d_sec, "upstream", &up); dmuci_get_value_by_section_string(d_sec, "upstream", &up);
@ -1965,7 +1898,7 @@ int set_mcastp_iface_snoop_mode(char *refparam, struct dmctx *ctx, void *data, c
string_to_bool(up, &b); string_to_bool(up, &b);
if (!b) { if (!b) {
dmuci_set_value_by_section((struct uci_section *)data, "snooping_mode", val); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "snooping_mode", val);
} }
break; break;
} }

View file

@ -95,5 +95,8 @@ void synchronize_specific_config_sections_with_dmmap_mcast_iface(char *package,
void synchronize_specific_config_sections_with_dmmap_mcast_filter(char *package, char *section_type, void synchronize_specific_config_sections_with_dmmap_mcast_filter(char *package, char *section_type,
void *data, char *dmmap_package, char *dmmap_sec, char *proto, void *data, char *dmmap_package, char *dmmap_sec, char *proto,
struct list_head *dup_list); struct list_head *dup_list);
int browse_mlds_filter_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browse_mldp_interface_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browse_mldp_filter_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
#endif //__IOPSYS_IGMP_H #endif //__IOPSYS_IGMP_H

View file

@ -21,11 +21,12 @@ static int add_mld_proxy_obj(char *refparam, struct dmctx *ctx, void *data, char
dmuci_add_section("mcast", "proxy", &s); dmuci_add_section("mcast", "proxy", &s);
dmuci_rename_section_by_section(s, s_name); dmuci_rename_section_by_section(s, s_name);
dmuci_set_value_by_section(s, "enable", "0"); dmuci_set_value_by_section(s, "enable", "0");
dmuci_set_value_by_section(s, "proto", "mld"); dmuci_set_value_by_section(s, "proto", "mld");
dmuci_set_value_by_section(s, "last_member_query_interval", "10"); dmuci_set_value_by_section(s, "last_member_query_interval", "10");
dmuci_set_value_by_section(s, "query_interval", "125"); dmuci_set_value_by_section(s, "query_interval", "125");
dmuci_set_value_by_section(s, "query_response_interval", "100"); dmuci_set_value_by_section(s, "query_response_interval", "100");
dmuci_set_value_by_section(s, "version", "2"); dmuci_set_value_by_section(s, "version", "2");
dmuci_set_value_by_section(s, "robustness", "2"); dmuci_set_value_by_section(s, "robustness", "2");
dmuci_set_value_by_section(s, "aggregation", "0"); dmuci_set_value_by_section(s, "aggregation", "0");
@ -44,16 +45,16 @@ static int del_mld_proxy_obj(char *refparam, struct dmctx *ctx, void *data, char
static int browse_mld_proxy_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) static int browse_mld_proxy_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{ {
char *inst = NULL; struct dm_data *curr_data = NULL;
struct dmmap_dup *p = NULL;
LIST_HEAD(dup_list); LIST_HEAD(dup_list);
char *inst = NULL;
synchronize_specific_config_sections_with_dmmap_cont("mcast", "proxy", "dmmap_mcast", "proto", "mld", &dup_list); synchronize_specific_config_sections_with_dmmap_cont("mcast", "proxy", "dmmap_mcast", "proto", "mld", &dup_list);
list_for_each_entry(p, &dup_list, list) { list_for_each_entry(curr_data, &dup_list, list) {
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "proxy_instance", "proxy_alias"); inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "proxy_instance", "proxy_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, inst) == DM_STOP) if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
break; break;
} }
@ -63,13 +64,14 @@ static int browse_mld_proxy_inst(struct dmctx *dmctx, DMNODE *parent_node, void
static int add_mld_snooping_obj(char *refparam, struct dmctx *ctx, void *data, char **instance) static int add_mld_snooping_obj(char *refparam, struct dmctx *ctx, void *data, char **instance)
{ {
struct uci_section *dmmap = NULL, *s = NULL; struct uci_section *dmmap = NULL, *s = NULL;
char s_name[32]; char s_name[32];
snprintf(s_name, sizeof(s_name), "mld_snoop_%s", *instance); snprintf(s_name, sizeof(s_name), "mld_snoop_%s", *instance);
dmuci_add_section("mcast", "snooping", &s); dmuci_add_section("mcast", "snooping", &s);
dmuci_rename_section_by_section(s, s_name); dmuci_rename_section_by_section(s, s_name);
dmuci_set_value_by_section(s, "enable", "0"); dmuci_set_value_by_section(s, "enable", "0");
dmuci_set_value_by_section(s, "proto", "mld"); dmuci_set_value_by_section(s, "proto", "mld");
dmuci_set_value_by_section(s, "last_member_query_interval", "10"); dmuci_set_value_by_section(s, "last_member_query_interval", "10");
@ -92,16 +94,16 @@ static int del_mld_snooping_obj(char *refparam, struct dmctx *ctx, void *data, c
static int browse_mld_snooping_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) static int browse_mld_snooping_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{ {
char *inst = NULL; struct dm_data *curr_data = NULL;
struct dmmap_dup *p = NULL;
LIST_HEAD(dup_list); LIST_HEAD(dup_list);
char *inst = NULL;
synchronize_specific_config_sections_with_dmmap_cont("mcast", "snooping", "dmmap_mcast", "proto", "mld", &dup_list); synchronize_specific_config_sections_with_dmmap_cont("mcast", "snooping", "dmmap_mcast", "proto", "mld", &dup_list);
list_for_each_entry(p, &dup_list, list) { list_for_each_entry(curr_data, &dup_list, list) {
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "snooping_instance", "snooping_alias"); inst = handle_instance(dmctx, parent_node, curr_data->dmmap_section, "snooping_instance", "snooping_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, inst) == DM_STOP) if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)curr_data, inst) == DM_STOP)
break; break;
} }
free_dmmap_config_dup_list(&dup_list); free_dmmap_config_dup_list(&dup_list);
@ -110,26 +112,14 @@ static int browse_mld_snooping_inst(struct dmctx *dmctx, DMNODE *parent_node, vo
static int get_mlds_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_mlds_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct uci_section *s = NULL; int cnt = get_number_of_entries(ctx, data, instance, browse_mld_snooping_inst);
int cnt = 0;
uci_foreach_option_eq("mcast", "snooping", "proto", "mld", s) {
cnt++;
}
dmasprintf(value, "%d", cnt); dmasprintf(value, "%d", cnt);
return 0; return 0;
} }
static int get_mldp_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_mldp_no_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct uci_section *s = NULL; int cnt = get_number_of_entries(ctx, data, instance, browse_mld_proxy_inst);
int cnt = 0;
uci_foreach_option_eq("mcast", "proxy", "proto", "mld", s) {
cnt++;
}
dmasprintf(value, "%d", cnt); dmasprintf(value, "%d", cnt);
return 0; return 0;
} }
@ -153,13 +143,13 @@ static int add_mlds_filter_obj(char *refparam, struct dmctx *ctx, void *data, ch
struct uci_section *dmmap_mlds_filter = NULL; struct uci_section *dmmap_mlds_filter = NULL;
dmuci_add_section_bbfdm("dmmap_mcast", "snooping_filter", &dmmap_mlds_filter); dmuci_add_section_bbfdm("dmmap_mcast", "snooping_filter", &dmmap_mlds_filter);
dmuci_set_value_by_section(dmmap_mlds_filter, "section_name", section_name((struct uci_section *)data)); dmuci_set_value_by_section(dmmap_mlds_filter, "section_name", section_name(((struct dm_data *)data)->config_section));
dmuci_set_value_by_section(dmmap_mlds_filter, "enable", "0"); dmuci_set_value_by_section(dmmap_mlds_filter, "enable", "0");
dmuci_set_value_by_section(dmmap_mlds_filter, "filter_instance", *instance); dmuci_set_value_by_section(dmmap_mlds_filter, "filter_instance", *instance);
return 0; return 0;
} }
static int browse_mlds_filter_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) int browse_mlds_filter_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{ {
return browse_filter_inst(dmctx, parent_node, prev_data, "snooping", "snooping_filter", "mld"); return browse_filter_inst(dmctx, parent_node, prev_data, "snooping", "snooping_filter", "mld");
} }
@ -167,7 +157,7 @@ static int browse_mlds_filter_inst(struct dmctx *dmctx, DMNODE *parent_node, voi
static int get_mld_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_mld_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
char *val; char *val;
dmuci_get_value_by_section_string((struct uci_section *)data, "version", &val); dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "version", &val);
*value = (DM_LSTRCMP(val, "1") == 0) ? "V1" : "V2"; *value = (DM_LSTRCMP(val, "1") == 0) ? "V1" : "V2";
return 0; return 0;
} }
@ -180,7 +170,7 @@ static int set_mld_version(char *refparam, struct dmctx *ctx, void *data, char *
return FAULT_9007; return FAULT_9007;
break; break;
case VALUESET: case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "version", (DM_LSTRCMP(value, "V2") == 0) ? "2" : "1"); dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "version", (DM_LSTRCMP(value, "V2") == 0) ? "2" : "1");
break; break;
} }
@ -192,7 +182,7 @@ static int add_mldp_interface_obj(char *refparam, struct dmctx *ctx, void *data,
struct uci_section *dmmap_mldp_interface = NULL; struct uci_section *dmmap_mldp_interface = NULL;
dmuci_add_section_bbfdm("dmmap_mcast", "proxy_interface", &dmmap_mldp_interface); dmuci_add_section_bbfdm("dmmap_mcast", "proxy_interface", &dmmap_mldp_interface);
dmuci_set_value_by_section(dmmap_mldp_interface, "section_name", section_name((struct uci_section *)data)); dmuci_set_value_by_section(dmmap_mldp_interface, "section_name", section_name(((struct dm_data *)data)->config_section));
dmuci_set_value_by_section(dmmap_mldp_interface, "upstream", "0"); dmuci_set_value_by_section(dmmap_mldp_interface, "upstream", "0");
dmuci_set_value_by_section(dmmap_mldp_interface, "snooping_mode", "0"); dmuci_set_value_by_section(dmmap_mldp_interface, "snooping_mode", "0");
dmuci_set_value_by_section(dmmap_mldp_interface, "iface_instance", *instance); dmuci_set_value_by_section(dmmap_mldp_interface, "iface_instance", *instance);
@ -205,7 +195,7 @@ static int del_mldp_interface_obj(char *refparam, struct dmctx *ctx, void *data,
switch (del_action) { switch (del_action) {
case DEL_INST: case DEL_INST:
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", "section_name", section_name((struct uci_section *)data), mldp_s) { uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", "section_name", section_name(((struct dm_data *)data)->config_section), mldp_s) {
char *f_inst = NULL, *if_name = NULL, *upstream = NULL; char *f_inst = NULL, *if_name = NULL, *upstream = NULL;
int found = 0; int found = 0;
@ -220,16 +210,16 @@ static int del_mldp_interface_obj(char *refparam, struct dmctx *ctx, void *data,
if (found) { if (found) {
if (upstream && DM_LSTRCMP(upstream, "1") == 0) if (upstream && DM_LSTRCMP(upstream, "1") == 0)
dmuci_del_list_value_by_section((struct uci_section *)data, "upstream_interface", if_name); dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section, "upstream_interface", if_name);
else else
dmuci_del_list_value_by_section((struct uci_section *)data, "downstream_interface", if_name); dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section, "downstream_interface", if_name);
break; break;
} }
} }
break; break;
case DEL_ALL: case DEL_ALL:
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", "section_name", section_name((struct uci_section *)data), mldp_s) { uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", "section_name", section_name(((struct dm_data *)data)->config_section), mldp_s) {
char *if_name = NULL, *upstream = NULL; char *if_name = NULL, *upstream = NULL;
dmuci_get_value_by_section_string(mldp_s, "ifname", &if_name); dmuci_get_value_by_section_string(mldp_s, "ifname", &if_name);
@ -237,20 +227,20 @@ static int del_mldp_interface_obj(char *refparam, struct dmctx *ctx, void *data,
if (if_name[0] != '\0') { if (if_name[0] != '\0') {
if (DM_LSTRCMP(upstream, "1") == 0) if (DM_LSTRCMP(upstream, "1") == 0)
dmuci_del_list_value_by_section((struct uci_section *)data, "upstream_interface", if_name); dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section, "upstream_interface", if_name);
else else
dmuci_del_list_value_by_section((struct uci_section *)data, "downstream_interface", if_name); dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section, "downstream_interface", if_name);
} }
} }
del_dmmap_sec_with_opt_eq("dmmap_mcast", "proxy_interface", "section_name", section_name((struct uci_section *)data)); del_dmmap_sec_with_opt_eq("dmmap_mcast", "proxy_interface", "section_name", section_name(((struct dm_data *)data)->config_section));
break; break;
} }
return 0; return 0;
} }
static int browse_mldp_interface_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) int browse_mldp_interface_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{ {
return browse_proxy_interface_inst(dmctx, parent_node, prev_data, "mld"); return browse_proxy_interface_inst(dmctx, parent_node, prev_data, "mld");
} }
@ -260,13 +250,13 @@ static int add_mldp_filter_obj(char *refparam, struct dmctx *ctx, void *data, ch
struct uci_section *dmmap_mldp_filter = NULL; struct uci_section *dmmap_mldp_filter = NULL;
dmuci_add_section_bbfdm("dmmap_mcast", "proxy_filter", &dmmap_mldp_filter); dmuci_add_section_bbfdm("dmmap_mcast", "proxy_filter", &dmmap_mldp_filter);
dmuci_set_value_by_section(dmmap_mldp_filter, "section_name", section_name((struct uci_section *)data)); dmuci_set_value_by_section(dmmap_mldp_filter, "section_name", section_name(((struct dm_data *)data)->config_section));
dmuci_set_value_by_section(dmmap_mldp_filter, "enable", "0"); dmuci_set_value_by_section(dmmap_mldp_filter, "enable", "0");
dmuci_set_value_by_section(dmmap_mldp_filter, "filter_instance", *instance); dmuci_set_value_by_section(dmmap_mldp_filter, "filter_instance", *instance);
return 0; return 0;
} }
static int browse_mldp_filter_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) int browse_mldp_filter_inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{ {
return browse_filter_inst(dmctx, parent_node, prev_data, "proxy", "proxy_filter", "mld"); return browse_filter_inst(dmctx, parent_node, prev_data, "proxy", "proxy_filter", "mld");
} }
@ -284,13 +274,13 @@ static int set_mldp_filter_address(char *refparam, struct dmctx *ctx, void *data
break; break;
case VALUESET: case VALUESET:
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_filter",
"section_name", section_name((struct uci_section *)data), s) { "section_name", section_name(((struct dm_data *)data)->config_section), s) {
dmuci_get_value_by_section_string(s, "filter_instance", &s_inst); dmuci_get_value_by_section_string(s, "filter_instance", &s_inst);
if (DM_STRCMP(s_inst, instance) == 0) { if (DM_STRCMP(s_inst, instance) == 0) {
dmuci_set_value_by_section(s, "ipaddr", value); dmuci_set_value_by_section(s, "ipaddr", value);
dmuci_get_value_by_section_string(s, "enable", &up); dmuci_get_value_by_section_string(s, "enable", &up);
string_to_bool(up, &b); string_to_bool(up, &b);
sync_dmmap_bool_to_uci_list((struct uci_section *)data, "filter", value, b); sync_dmmap_bool_to_uci_list(((struct dm_data *)data)->config_section, "filter", value, b);
break; break;
} }
} }
@ -477,17 +467,17 @@ static int set_mldp_interface_iface(char *refparam, struct dmctx *ctx, void *dat
} }
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface",
"section_name", section_name((struct uci_section *)data), d_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), d_sec) {
dmuci_get_value_by_section_string(d_sec, "iface_instance", &f_inst); dmuci_get_value_by_section_string(d_sec, "iface_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
dmuci_set_value_by_section(d_sec, "ifname", interface_linker); dmuci_set_value_by_section(d_sec, "ifname", interface_linker);
dmuci_get_value_by_section_string(d_sec, "upstream", &up); dmuci_get_value_by_section_string(d_sec, "upstream", &up);
string_to_bool(up, &b); string_to_bool(up, &b);
sync_dmmap_bool_to_uci_list((struct uci_section *)data, "downstream_interface", interface_linker, !b); sync_dmmap_bool_to_uci_list(((struct dm_data *)data)->config_section, "downstream_interface", interface_linker, !b);
// Now update the proxy_interface list // Now update the proxy_interface list
sync_dmmap_bool_to_uci_list((struct uci_section *)data, "upstream_interface", interface_linker, b); sync_dmmap_bool_to_uci_list(((struct dm_data *)data)->config_section, "upstream_interface", interface_linker, b);
update_snooping_mode((struct uci_section *)data); update_snooping_mode(((struct dm_data *)data)->config_section);
break; break;
} }
} }
@ -505,7 +495,7 @@ static int get_mldp_interface_iface(char *refparam, struct dmctx *ctx, void *dat
char sec_name[16] = {0}; char sec_name[16] = {0};
int found = 0; int found = 0;
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", "section_name", section_name((struct uci_section *)data), mldp_s) { uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", "section_name", section_name(((struct dm_data *)data)->config_section), mldp_s) {
dmuci_get_value_by_section_string(mldp_s, "iface_instance", &f_inst); dmuci_get_value_by_section_string(mldp_s, "iface_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
dmuci_get_value_by_section_string(mldp_s, "ifname", &mldp_ifname); dmuci_get_value_by_section_string(mldp_s, "ifname", &mldp_ifname);
@ -581,15 +571,15 @@ static int set_mldp_interface_upstream(char *refparam, struct dmctx *ctx, void *
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface", uci_path_foreach_option_eq(bbfdm, "dmmap_mcast", "proxy_interface",
"section_name", section_name((struct uci_section *)data), d_sec) { "section_name", section_name(((struct dm_data *)data)->config_section), d_sec) {
dmuci_get_value_by_section_string(d_sec, "iface_instance", &f_inst); dmuci_get_value_by_section_string(d_sec, "iface_instance", &f_inst);
if (DM_STRCMP(instance, f_inst) == 0) { if (DM_STRCMP(instance, f_inst) == 0) {
dmuci_get_value_by_section_string(d_sec, "ifname", &ifname); dmuci_get_value_by_section_string(d_sec, "ifname", &ifname);
dmuci_set_value_by_section(d_sec, "upstream", (b) ? "1" : "0"); dmuci_set_value_by_section(d_sec, "upstream", (b) ? "1" : "0");
sync_dmmap_bool_to_uci_list((struct uci_section *)data, "downstream_interface", ifname, !b); sync_dmmap_bool_to_uci_list(((struct dm_data *)data)->config_section, "downstream_interface", ifname, !b);
sync_dmmap_bool_to_uci_list((struct uci_section *)data, "upstream_interface", ifname, b); sync_dmmap_bool_to_uci_list(((struct dm_data *)data)->config_section, "upstream_interface", ifname, b);
update_snooping_mode((struct uci_section *)data); update_snooping_mode(((struct dm_data *)data)->config_section);
break; break;
} }