AddressSpace embedded loader: allow use of Node management services
Description
Add the possibility to have access to Node services when using address space as a C structure when it is not constant.
When using the embedded loader which load the address space as a C structure with SOPC_Embedded_AddressSpace_Load, the Node management services (AddNode, etc.) cannot be used even if S2OPC_NODE_MANAGEMENT compilation option has been activated.
This is due to the fact the nodes are not allocated and due to the difficulty to manage memory for a mix of statically declared and allocated nodes. We should provide an API allowing to still allocate the nodes (copy of the statically declared nodes) and then allow the use of Node management services use.
Code version identification
789a297a / 1.6.0
The current behavior is the original one since embedded loader exists.
Current behavior
When calling SOPC_Embedded_AddressSpace_Load, use of Node management services is forbidden because the nodes used are the one statically defined.
Expected behavior
When calling SOPC_Embedded_AddressSpace_LoadWithAlloc(allocNodes=true) with a statically defined address space as C structure that is not const, the defined nodes are copied/allocated to allow use of Node management services.
Note 1: the address space C structure should have been generated from XML representation using the scripts/generate-s2opc-address-space.py WITHOUT --const_addspace option otherwise the allocNodes parameter is ignored. When --const_addspace is used, the whole address space is constant (<=> read-only memory) except for value Variant of variables and thus Node management services will never be available.
Note 2: S2OPC_NODE_MANAGEMENT compilation option shall be set to allow OPC UA clients access to the Node management services, for server local node management services only this is not necessary.
When using SOPC_Embedded_AddressSpace_LoadWithAlloc(allocNodes=false) has the same behavior as legacy SOPC_Embedded_AddressSpace_Load function.
Security impact
No security impact identified.
Implementation
- Make
SOPC_Embedded_AddressSpace_Loaddeprecated and provide new APISOPC_Embedded_AddressSpace_LoadWithAlloc(allocNodes=true). - Add copy operator for
SOPC_AddressSpace_Node - When
SOPC_Embedded_AddressSpace_LoadWithAlloc(allocNodes=true)is used:- declare the node shall be freed (which allow node management services to be supported)
- copy the nodes statically defined before adding it to the server address space
- Use
SOPC_Embedded_AddressSpace_LoadWithAllocin all samples