High Performance OPC UA Server SDK  1.1.0.158
ua_nodeid

Identifier for UA nodes. More...

Data Structures

struct  ua_nodeid
 Structure for an UA Nodeid, see also ua_nodeid. More...
 

Macros

#define UA_NODEID_INITIALIZER   { { 0 }, UA_IDENTIFIER_NUMERIC, 0 }
 Initializes a nodeid struct as numeric null nodeid.
 
#define UA_NODEID_NUMERIC_INITIALIZER(id, ns)   { { id }, UA_IDENTIFIER_NUMERIC, ns }
 Initializes a nodeid struct as numeric nodeid with identifier and namespace index. More...
 

Enumerations

enum  ua_identifiertype { UA_IDENTIFIER_NUMERIC = 0, UA_IDENTIFIER_STRING, UA_IDENTIFIER_GUID, UA_IDENTIFIER_OPAQUE }
 The set of known node identifier types. More...
 

Functions

void ua_nodeid_init (struct ua_nodeid *id)
 Initializes id with a null nodeid.
 
void ua_nodeid_clear (struct ua_nodeid *id)
 Cleans all resources in id and makes it a null nodeid.
 
void ua_nodeid_set_numeric (struct ua_nodeid *id, uint16_t nsindex, uint32_t value)
 Set a numeric value and namespace index for a nodeid. More...
 
int ua_nodeid_set_string (struct ua_nodeid *id, uint16_t nsindex, const char *value)
 Set a string value and namespace index for a nodeid. More...
 
int ua_nodeid_set_guid (struct ua_nodeid *id, uint16_t nsindex, const struct ua_guid *value)
 Set a guid value and namespace index for a nodeid. More...
 
int ua_nodeid_set_bytestring (struct ua_nodeid *id, uint16_t nsindex, const char *value, int32_t len)
 Set a bytestring value and namespace index for a nodeid. More...
 
int ua_nodeid_attach_string (struct ua_nodeid *id, uint16_t nsindex, char *value)
 Attach a string value and set a namespace index for a nodeid. More...
 
int ua_nodeid_attach_string_const (struct ua_nodeid *id, uint16_t nsindex, const char *value)
 Attach a constant string value and set a namespace index for a nodeid. More...
 
void ua_nodeid_attach_guid (struct ua_nodeid *id, uint16_t nsindex, struct ua_guid *value)
 Attach a guid value and set a namespace index for a nodeid. More...
 
int ua_nodeid_attach_bytestring (struct ua_nodeid *id, uint16_t nsindex, char *value, int32_t len)
 Attach a bytestring value and set a namespace index for a nodeid. More...
 
int ua_nodeid_compare (const struct ua_nodeid *a, const struct ua_nodeid *b) UA_PURE_FUNCTION
 Compare two ua_nodeids. More...
 
int ua_nodeid_copy (struct ua_nodeid *dst, const struct ua_nodeid *src)
 Copy the ua_nodeid src to dst. More...
 
bool ua_nodeid_is_null (const struct ua_nodeid *id)
 Test if the nodeid id is a null nodeid according to Part 3, 8.2.4.
 
int ua_nodeid_to_string (const struct ua_nodeid *id, struct ua_string *dst)
 
int ua_nodeid_snprintf (char *dst, size_t size, const struct ua_nodeid *id)
 
int ua_nodeid_from_string (struct ua_nodeid *id, const struct ua_string *src)
 

Detailed Description

Identifier for UA nodes.

Identifier for a unique node in the addressspace of an OPC UA Server. The nodeid consists of the index for the namespace it belongs to and the actual identifier. The identifier can be one of the four types defined by the ua_identifiertype.

A Server shall persist the NodeId of a Node, that is, it is not allowed to generate new NodeIds when rebooting. The server is not allowed to change the namespace index for a namespace URI as long as the server is not restarted, but new namespaces can be added. The namespace index for a namespace URI may change after a server restart.

Clients must be prepared for changes of the namespace index in a NodeId and must persist their own namespace table together with the stored NodeIds for a server.

The following three elements identify a Node within a Server:

Name Type Description
namespaceIndex UInt16 The index for a namespace URI used in an OPC UA server
identifierType enum The format and data type of the identifier
identifier * The identifier for a node in the address space of an OPC UA server

Namespace Index

The namespace is a URI that identifies the naming authority responsible for assigning the identifier element of the NodeId. Naming authorities include the local server, the underlying system, standards bodies and consortia. It is expected that most nodes will use the URI of the server or of the underlying system.

Using a namespace URI allows multiple OPC UA servers attached to the same underlying system to use the same identifier to identify the same object. This enables clients that connect to those Servers to recognise Objects that they have in common.

Namespace URIs are identified by numeric values in OPC UA services to permit more efficient transfer and processing (e.g. table lookups). The numeric values used to identify namespaces correspond to the index into the NamespaceArray. The NamespaceArray is a variable that is part of the Server object in the address space.

The URI for the OPC UA namespace is “http://opcfoundation.org/UA/”. Its corresponding index in the namespace table is 0.

The Namespace URI is case sensitive.

Identifier Type

The IdentifierType element identifies the type of the NodeId, its format and its scope. The following IdentifierTypes are available:

Value Description
UA_IDENTIFIER_NUMERIC Numeric value
UA_IDENTIFIER_STRING String value
UA_IDENTIFIER_GUID Globally Unique Identifier
UA_IDENTIFIER_OPAQUE Namespace specific format in a ByteString

Identifier value

The identifier value element is used within the context of the first two elements to identify a node. Its data type and format is defined by the identifierType.

Numeric identifiers are typically used for static namespaces or for NodeIds in generated code. Such identifiers in generated code have typically defines generated which makes them easy to use and read in code.

String identifiers are typically used for nodes that are dynamically generated during system configuration. The string is either a path of nodes with a server specific delimiters or a server specific addressing schema contained in the string.

String identifiers are case sensitive. That is, clients shall consider them case sensitive. Servers are allowed to provide alternative NodeIds and using this mechanism severs can handle NodeIds as case insensitive.

Normally the scope of NodeIds is the server in which they are defined. For certain types of NodeIds, NodeIds can uniquely identify a Node within a system, or across systems (e.g. GUIDs). System-wide and globally-unique identifiers allow clients to track Nodes, such as work orders, as they move between OPC UA servers as they progress through the system.

Opaque identifiers are identifiers that are free-format byte strings that might or might not be human interpretable.

Identifier values of IdentifierType STRING are restricted to 4096 characters. Identifier values of IdentifierType OPAQUE are restricted to 4096 bytes.

A null NodeId has special meaning. For example, many services define special behaviour if a null NodeId is passed as a parameter. A null NodeId always has a NamespaceIndex equal to 0. A node in the address space cannot have a null NodeId. Each identifier type has a set of identifier values that represent a null NodeId:

Identifier Type Identifier
NUMERIC 0
STRING A null or Empty String (“”)
GUID A Guid initialised with zeros (e.g. 00000000-0000-0000-0000-000000)
OPAQUE A ByteString with Length=0

Macro Definition Documentation

#define UA_NODEID_NUMERIC_INITIALIZER (   id,
  ns 
)    { { id }, UA_IDENTIFIER_NUMERIC, ns }

Initializes a nodeid struct as numeric nodeid with identifier and namespace index.

Parameters
idThe numeric identifier.
nsThe namespace index.

Enumeration Type Documentation

The set of known node identifier types.

Enumerator
UA_IDENTIFIER_NUMERIC 

The identifier is a 32bit unsigned integer.

UA_IDENTIFIER_STRING 

The identifier is a ua_string.

UA_IDENTIFIER_GUID 

The identifier is a ua_guid.

UA_IDENTIFIER_OPAQUE 

The identifier is a ua_bytestring.

Function Documentation

int ua_nodeid_attach_bytestring ( struct ua_nodeid id,
uint16_t  nsindex,
char *  value,
int32_t  len 
)

Attach a bytestring value and set a namespace index for a nodeid.

This function takes ownership of value and frees it, when ua_nodeid_clear is called on that nodeid. Thus value must not be freed after attaching to the nodeid.

Parameters
idNodeid to attach the value.
nsindexNamespace index to set.
valueBytestring to attach.
lenLength of the bytestring to attach.
void ua_nodeid_attach_guid ( struct ua_nodeid id,
uint16_t  nsindex,
struct ua_guid value 
)

Attach a guid value and set a namespace index for a nodeid.

This function takes ownership of value and frees it, when ua_nodeid_clear is called on that nodeid. Thus value must not be freed after attaching to the nodeid.

Parameters
idNodeid to attach the value.
nsindexNamespace index to set.
valueua_guid to attach.
int ua_nodeid_attach_string ( struct ua_nodeid id,
uint16_t  nsindex,
char *  value 
)

Attach a string value and set a namespace index for a nodeid.

This function takes ownership of value and frees it, when ua_nodeid_clear is called on that nodeid. Thus value must not be freed after attaching to the nodeid.

Parameters
idNodeid to attach the value.
nsindexNamespace index to set.
valueZero terminated string to attach.
int ua_nodeid_attach_string_const ( struct ua_nodeid id,
uint16_t  nsindex,
const char *  value 
)

Attach a constant string value and set a namespace index for a nodeid.

This function takes ownership of value but does not free it, when ua_nodeid_clear is called on that nodeid. Thus only string literals should be passed as value. It is still necessary to call ua_nodeid_clear on the nodeid when it is no longer needed.

Parameters
idNodeid to attach the value.
nsindexNamespace index to set.
valueZero terminated string literal to attach.
int ua_nodeid_compare ( const struct ua_nodeid a,
const struct ua_nodeid b 
)

Compare two ua_nodeids.

Returns
Zero if the ua_nodeids are the same.
int ua_nodeid_copy ( struct ua_nodeid dst,
const struct ua_nodeid src 
)

Copy the ua_nodeid src to dst.

Returns
Zero on success or errorcode on failure.
int ua_nodeid_set_bytestring ( struct ua_nodeid id,
uint16_t  nsindex,
const char *  value,
int32_t  len 
)

Set a bytestring value and namespace index for a nodeid.

This function creates a copy of value, that is attached to the nodeid and freed when ua_nodeid_clear is called on that nodeid.

Parameters
idNodeid to set the value.
nsindexNamespace index to set.
valueBytestring to set.
lenLength of the bytestring to set.
int ua_nodeid_set_guid ( struct ua_nodeid id,
uint16_t  nsindex,
const struct ua_guid value 
)

Set a guid value and namespace index for a nodeid.

This function creates a copy of value, that is attached to the nodeid and freed when ua_nodeid_clear is called on that nodeid.

Parameters
idNodeid to set the value.
nsindexNamespace index to set.
valueua_guid to set.
void ua_nodeid_set_numeric ( struct ua_nodeid id,
uint16_t  nsindex,
uint32_t  value 
)

Set a numeric value and namespace index for a nodeid.

Parameters
idNodeid to set the value.
nsindexNamespace index to set.
valueNumeric value to set.
int ua_nodeid_set_string ( struct ua_nodeid id,
uint16_t  nsindex,
const char *  value 
)

Set a string value and namespace index for a nodeid.

This function creates a copy of value, that is attached to the nodeid and freed when ua_nodeid_clear is called on that nodeid.

Parameters
idNodeid to set the value.
nsindexNamespace index to set.
valueZero terminated string to set.