High Performance OPC UA Server SDK  1.7.1.383

General addressspace management like register/unregister namespaces. More...

Data Structures

struct  ua_addressspace_config
 
struct  ua_pool_stat
 Datatype used in ua_addressspace_pool_stat. More...
 
struct  ua_addressspace_pool_stat
 Datatype used in ua_addressspace_get_stat. More...
 

Enumerations

enum  ua_addressspace_index_type { UA_INDEX_BTREE, UA_INDEX_HASHTABLE, UA_INDEX_HASHTABLEQP }
 Possible index types for nodes in the addressspace. More...
 
enum  ua_addressspace_loading_mode { UA_LOADING_MODE_CREATE, UA_LOADING_MODE_UPDATE, UA_LOADING_MODE_CREATE_OR_UPDATE }
 The loading mode defines how files are loaded in ua_addressspace_load_file. More...
 

Functions

SERVER_EXPORT int ua_addressspace_init (void)
 Allocate resources for addressspace management. More...
 
SERVER_EXPORT void ua_addressspace_clear (void)
 Remove all registered namespaces from the addressspace and free their resources.
 
SERVER_EXPORT void ua_addressspace_config_init (struct ua_addressspace_config *config)
 Initialize the given ua_addressspace_config structure.
 
SERVER_EXPORT void ua_addressspace_config_clear (struct ua_addressspace_config *config)
 Clears the given ua_addressspace_config structure.
 
SERVER_EXPORT void ua_addressspace_config_trace (const char *name, const struct ua_addressspace_config *config)
 
SERVER_EXPORT int ua_addressspace_register (const char *url, const struct ua_addressspace_config *config, enum ua_addressspace_index_type type)
 Registers a new namespace. More...
 
SERVER_EXPORT int ua_addressspace_register_static (const char *url, int hashtablesize, struct mem_objectpool_static *nodepool, struct mem_objectpool_static *varpool, struct mem_objectpool_static *vartypepool, struct mem_objectpool_static *methodpool, struct mem_objectpool_static *refpool, struct mem_objectpool_static *stringpool, const char *const stringtable[], struct mem_objectpool_static *guidpool, struct mem_objectpool_static *dimpool, struct ua_staticstore *dtdef_store, uint16_t nsidx, unsigned int num_placeholders, enum ua_addressspace_index_type type)
 Registers a new namespace. More...
 
SERVER_EXPORT void ua_addressspace_unregister (uint16_t nsidx)
 Unregister a namespace from the addressspace. More...
 
SERVER_EXPORT struct ua_addressspaceua_addressspace_getaddr (uint16_t nsidx)
 Get the pointer to the ua_addressspace struct of a namespace. More...
 
SERVER_EXPORT struct ua_addressspaceua_addressspace_lookup_uri (const char *nsuri)
 Finds address space context by is URI. More...
 
SERVER_EXPORT bool ua_addressspace_is_static (struct ua_addressspace *addr)
 Returns true if the address space is static. More...
 
SERVER_EXPORT uint16_t ua_addressspace_get_nsidx (struct ua_addressspace *addr)
 Returns the namespace index for the given address space. More...
 
SERVER_EXPORT const char * ua_addressspace_get_nsuri (struct ua_addressspace *addr)
 Returns the namespace URI for the given address space. More...
 
SERVER_EXPORT const char * ua_addressspace_get_nsversion (const struct ua_addressspace *addr)
 Returns the namespace version for the given address space. More...
 
SERVER_EXPORT ua_datetime ua_addressspace_get_nspublication_date (const struct ua_addressspace *addr)
 Returns the namespace publication_date for the given address space. More...
 
SERVER_EXPORT void ua_addressspace_get_stat (struct ua_addressspace *addr, struct ua_addressspace_pool_stat *stat)
 Returns statistics of the address space's memory pools. More...
 
SERVER_EXPORT uint16_t ua_addressspace_get_default_accessrestrictions (struct ua_addressspace *addr)
 Returns the namespace default accessrestrictions for the given addressspace object.
 
SERVER_EXPORT int ua_addressspace_set_default_accessrestrictions (struct ua_addressspace *addr, uint16_t accessrestrictions)
 Set the namespace default accessrestrictions for the given addressspace object. More...
 
SERVER_EXPORT const struct ua_nodepermissionua_addressspace_get_default_rolepermissions (struct ua_addressspace *addr, uint16_t *num_perms)
 Get the namespace default rolepermissions for the given addressspace object. More...
 
SERVER_EXPORT int ua_addressspace_set_default_rolepermissions (struct ua_addressspace *addr, const struct ua_nodepermission *perms, uint16_t num_perms)
 Set the namespace default rolepermissions for the given addressspace object. More...
 
SERVER_EXPORT int ua_addressspace_set_default_default_rolepermissions (struct ua_addressspace *addr)
 Sets the namespace default rolepermissions for the given addressspace object to the SDK defaults. More...
 
SERVER_EXPORT int ua_addressspace_foreach_node (uint16_t nsidx, int(*callback)(ua_node_t handle))
 Iterates over all nodes in namespace and calls the given callback. More...
 
SERVER_EXPORT int ua_addressspace_foreach_node_ext (uint16_t nsidx, int(*callback2)(ua_node_t handle, void *userdata), void *userdata)
 Iterates over all nodes in namespace and calls the given callback. More...
 
SERVER_EXPORT void ua_addressspace_set_digest (const unsigned char *digest, size_t len)
 Set the digest which was used to generate NS0. More...
 
SERVER_EXPORT bool ua_addressspace_verify_digest (const unsigned char *digest, size_t len)
 Returns true if the digest is ok, false otherwise. More...
 
SERVER_EXPORT void ua_addressspace_print_stat (uint16_t)
 Print addressspace statistics for a namespace. More...
 

Detailed Description

General addressspace management like register/unregister namespaces.

Enumeration Type Documentation

◆ ua_addressspace_index_type

Possible index types for nodes in the addressspace.

Enumerator
UA_INDEX_BTREE 

Index using a binary tree (not implemented).

UA_INDEX_HASHTABLE 

Index using a hashtable with linked list for collision handling.

UA_INDEX_HASHTABLEQP 

Index using a hashtable with quadratic probing for collision handling.

◆ ua_addressspace_loading_mode

The loading mode defines how files are loaded in ua_addressspace_load_file.

Enumerator
UA_LOADING_MODE_CREATE 

Creates the namespaces that gets loaded.

UA_LOADING_MODE_UPDATE 

Updates the namespace that gets loaded.

The namespaces must already exist.

UA_LOADING_MODE_CREATE_OR_UPDATE 

Updates the namespace that gets loaded.

Creates the namespace if it does not exist yet.

Function Documentation

◆ ua_addressspace_foreach_node()

SERVER_EXPORT int ua_addressspace_foreach_node ( uint16_t  nsidx,
int(*)(ua_node_t handle)  callback 
)

Iterates over all nodes in namespace and calls the given callback.

This functions uses the internal hashtable to iterate efficiently over all nodes without the need of following UA references.

Parameters
nsidxNamespace to iterate through.
callbackCallback to call for each node. This callback will receive the node handle, so you can perform any task on the node. A typical usage of callback is to use simply ua_node_remove as callback, which will remove all nodes of the give namespace.

Example:

Returns
Zero on success or errorcode on failure.

◆ ua_addressspace_foreach_node_ext()

SERVER_EXPORT int ua_addressspace_foreach_node_ext ( uint16_t  nsidx,
int(*)(ua_node_t handle, void *userdata)  callback,
void *  userdata 
)

Iterates over all nodes in namespace and calls the given callback.

This functions uses the internal hashtable to iterate efficiently over all nodes without the need of following UA references.

This version extends the existing ua_addressspace_foreach_node by adding a userdata pointer.

Parameters
nsidxNamespace to iterate through.
callbackCallback to call for each node. This callback will receive the node handle, so you can perform any task on the node. A typical usage of callback is to use simply ua_node_remove as callback, which will remove all nodes of the give namespace.
userdataWill be returned in the callback.

Example:

Returns
Zero on success or errorcode on failure.

◆ ua_addressspace_get_default_rolepermissions()

SERVER_EXPORT const struct ua_nodepermission* ua_addressspace_get_default_rolepermissions ( struct ua_addressspace addr,
uint16_t *  num_perms 
)

Get the namespace default rolepermissions for the given addressspace object.

Parameters
addrAddressspace to get the rolepermissions for.
num_permsThe number of aray entries in the return value are written to this address.
Returns
Pointer to nodepermission array or NULL if authorization support is disabled.

◆ ua_addressspace_get_nsidx()

SERVER_EXPORT uint16_t ua_addressspace_get_nsidx ( struct ua_addressspace addr)

Returns the namespace index for the given address space.

Parameters
addrAddress space context.
Returns
The namespace index this address space was registered for.

◆ ua_addressspace_get_nspublication_date()

SERVER_EXPORT ua_datetime ua_addressspace_get_nspublication_date ( const struct ua_addressspace addr)

Returns the namespace publication_date for the given address space.

Parameters
addrAddress space context.
Returns
The namespace publication date this address space based on. 0 If not set.

◆ ua_addressspace_get_nsuri()

SERVER_EXPORT const char* ua_addressspace_get_nsuri ( struct ua_addressspace addr)

Returns the namespace URI for the given address space.

Parameters
addrAddress space context.
Returns
The namespace URI this address space was registered for.

◆ ua_addressspace_get_nsversion()

SERVER_EXPORT const char* ua_addressspace_get_nsversion ( const struct ua_addressspace addr)

Returns the namespace version for the given address space.

Parameters
addrAddress space context.
Returns
The namespace version this address space based on. NULL if not set.

◆ ua_addressspace_get_stat()

SERVER_EXPORT void ua_addressspace_get_stat ( struct ua_addressspace addr,
struct ua_addressspace_pool_stat stat 
)

Returns statistics of the address space's memory pools.

Parameters
addrAddress space context.
statPointer to statistic structure.

◆ ua_addressspace_getaddr()

SERVER_EXPORT struct ua_addressspace* ua_addressspace_getaddr ( uint16_t  nsidx)

Get the pointer to the ua_addressspace struct of a namespace.

Parameters
nsidxIndex of the namespace.
Returns
Valid pointer on success or NULL on failure.

◆ ua_addressspace_init()

SERVER_EXPORT int ua_addressspace_init ( void  )

Allocate resources for addressspace management.

Returns
Zero on success or errorcode on failure.

◆ ua_addressspace_is_static()

SERVER_EXPORT bool ua_addressspace_is_static ( struct ua_addressspace addr)

Returns true if the address space is static.

Static means it's compiled into the application and is constant. On embedded systems static address space can lie in ROM.

◆ ua_addressspace_lookup_uri()

SERVER_EXPORT struct ua_addressspace* ua_addressspace_lookup_uri ( const char *  nsuri)

Finds address space context by is URI.

Parameters
nsuriNamespace URI of the namespace.
Returns
Valid pointer on success or NULL on failure.

◆ ua_addressspace_print_stat()

SERVER_EXPORT void ua_addressspace_print_stat ( uint16_t  nsidx)

Print addressspace statistics for a namespace.

The statistics are printed to trace at level debug and facility session.

Parameters
nsidxindex of namespace to print statistics for

◆ ua_addressspace_register()

SERVER_EXPORT int ua_addressspace_register ( const char *  url,
const struct ua_addressspace_config config,
enum ua_addressspace_index_type  type 
)

Registers a new namespace.

Parameters
urlURL of namespace.
configAddress space configuration which defines the pool sizes.
typeIndex type to use for indexing nodes. Note: Using UA_INDEX_HASHTABLEQP is not allowed as deleting nodes would corrupt the hashtable.
Returns
Returns the assigned namespace index or negative errorcode in case of an error.

◆ ua_addressspace_register_static()

SERVER_EXPORT int ua_addressspace_register_static ( const char *  url,
int  hashtablesize,
struct mem_objectpool_static nodepool,
struct mem_objectpool_static varpool,
struct mem_objectpool_static vartypepool,
struct mem_objectpool_static methodpool,
struct mem_objectpool_static refpool,
struct mem_objectpool_static stringpool,
const char *const  stringtable[],
struct mem_objectpool_static guidpool,
struct mem_objectpool_static dimpool,
struct ua_staticstore dtdef_store,
uint16_t  nsidx,
unsigned int  num_placeholders,
enum ua_addressspace_index_type  type 
)

Registers a new namespace.

Parameters
urlURL of namespace.
hashtablesizeSize of hashtable for indexing nodes.
nodepoolStatic memory pool of nodes.
varpoolStatic memory pool of variables.
vartypepoolStatic memory pool of variable types.
methodpoolStatic memory pool of methods.
refpoolStatic memory pool of references.
stringpoolStatic memory pool of strings.
stringtableString table with const strings.
guidpoolStatic memory pool of guids.
dimpoolStatic memory pool of guids.
dtdef_storeThe static store for the data type definitions.
nsidxRequested namespace index. Set to -1 if you don't care.
num_placeholdersNumber of placeholde references that get allocated in RAM.
typeIndex type to use for indexing nodes.
Returns
Returns the assigned namespace index or -1 in case of an error.

◆ ua_addressspace_set_default_accessrestrictions()

SERVER_EXPORT int ua_addressspace_set_default_accessrestrictions ( struct ua_addressspace addr,
uint16_t  accessrestrictions 
)

Set the namespace default accessrestrictions for the given addressspace object.

Returns
Zero on success or negative errorcode on failure.

◆ ua_addressspace_set_default_default_rolepermissions()

SERVER_EXPORT int ua_addressspace_set_default_default_rolepermissions ( struct ua_addressspace addr)

Sets the namespace default rolepermissions for the given addressspace object to the SDK defaults.

This function is called automatically by the SDK when loading an addressspace without default rolepermissions.

The SDK defaults are arbitrarily chosen and may change with any version of the SDK, so it is recommended to either load namespaces which already have a default set or use ua_addressspace_set_default_rolepermissions to set explicit defaults.

Returns
Zero on success or negative errorcode on failure.

◆ ua_addressspace_set_default_rolepermissions()

SERVER_EXPORT int ua_addressspace_set_default_rolepermissions ( struct ua_addressspace addr,
const struct ua_nodepermission perms,
uint16_t  num_perms 
)

Set the namespace default rolepermissions for the given addressspace object.

Parameters
addrAddressspace to set the rolepermissions for.
permsThe permissions array to set, copied by this function, so it can be deleted by the caller after calling.
num_permsNumber of entries in the permissions array.
Returns
Zero on success or negative errorcode on failure.

◆ ua_addressspace_set_digest()

SERVER_EXPORT void ua_addressspace_set_digest ( const unsigned char *  digest,
size_t  len 
)

Set the digest which was used to generate NS0.

◆ ua_addressspace_unregister()

SERVER_EXPORT void ua_addressspace_unregister ( uint16_t  nsidx)

Unregister a namespace from the addressspace.

Remove all nodes from the given namespace.

Parameters
nsidxindex of the namespace to unregister.

◆ ua_addressspace_verify_digest()

SERVER_EXPORT bool ua_addressspace_verify_digest ( const unsigned char *  digest,
size_t  len 
)

Returns true if the digest is ok, false otherwise.