open62541 1.4.15
Open source implementation of OPC UA
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
util.h File Reference
#include <open62541/types.h>
#include <open62541/types_generated.h>
#include <open62541/types_generated_handling.h>

Go to the source code of this file.

Data Structures

struct  UA_UInt32Range
 
struct  UA_DurationRange
 
struct  UA_KeyValueMap
 
struct  UA_ConnectionConfig
 

Macros

#define UA_MIN(A, B)   ((A) > (B) ? (B) : (A))
 
#define UA_MAX(A, B)   ((A) > (B) ? (A) : (B))
 
#define UA_PRINTF_GUID_FORMAT
 
#define UA_PRINTF_GUID_DATA(GUID)
 
#define UA_PRINTF_STRING_FORMAT   "\"%.*s\""
 
#define UA_PRINTF_STRING_DATA(STRING)   (int)(STRING).length, (STRING).data
 

Functions

void UA_random_seed (UA_UInt64 seed)
 
UA_UInt32 UA_UInt32_random (void)
 
UA_Guid UA_Guid_random (void)
 
UA_EXPORT UA_KeyValueMapUA_KeyValueMap_new (void)
 
UA_EXPORT void UA_KeyValueMap_clear (UA_KeyValueMap *map)
 
UA_EXPORT void UA_KeyValueMap_delete (UA_KeyValueMap *map)
 
UA_EXPORT UA_Boolean UA_KeyValueMap_isEmpty (const UA_KeyValueMap *map)
 
UA_EXPORT UA_Boolean UA_KeyValueMap_contains (const UA_KeyValueMap *map, const UA_QualifiedName key)
 
UA_EXPORT UA_StatusCode UA_KeyValueMap_set (UA_KeyValueMap *map, const UA_QualifiedName key, const UA_Variant *value)
 
UA_EXPORT UA_StatusCode UA_KeyValueMap_setScalar (UA_KeyValueMap *map, const UA_QualifiedName key, void *p, const UA_DataType *type)
 
UA_EXPORT const UA_VariantUA_KeyValueMap_get (const UA_KeyValueMap *map, const UA_QualifiedName key)
 
UA_EXPORT const void * UA_KeyValueMap_getScalar (const UA_KeyValueMap *map, const UA_QualifiedName key, const UA_DataType *type)
 
UA_EXPORT UA_StatusCode UA_KeyValueMap_remove (UA_KeyValueMap *map, const UA_QualifiedName key)
 
UA_EXPORT UA_StatusCode UA_KeyValueMap_copy (const UA_KeyValueMap *src, UA_KeyValueMap *dst)
 
UA_EXPORT UA_StatusCode UA_KeyValueMap_merge (UA_KeyValueMap *lhs, const UA_KeyValueMap *rhs)
 
UA_StatusCode UA_parseEndpointUrl (const UA_String *endpointUrl, UA_String *outHostname, UA_UInt16 *outPort, UA_String *outPath)
 
UA_StatusCode UA_parseEndpointUrlEthernet (const UA_String *endpointUrl, UA_String *target, UA_UInt16 *vid, UA_Byte *pcp)
 
size_t UA_readNumber (const UA_Byte *buf, size_t buflen, UA_UInt32 *number)
 
size_t UA_readNumberWithBase (const UA_Byte *buf, size_t buflen, UA_UInt32 *number, UA_Byte base)
 
UA_EXPORT UA_Boolean UA_constantTimeEqual (const void *ptr1, const void *ptr2, size_t length)
 
UA_EXPORT void UA_ByteString_memZero (UA_ByteString *bs)
 

Variables

UA_EXPORT const UA_KeyValueMap UA_KEYVALUEMAP_NULL
 
UA_EXPORT const UA_VariableAttributes UA_VariableAttributes_default
 
UA_EXPORT const UA_VariableTypeAttributes UA_VariableTypeAttributes_default
 
UA_EXPORT const UA_MethodAttributes UA_MethodAttributes_default
 
UA_EXPORT const UA_ObjectAttributes UA_ObjectAttributes_default
 
UA_EXPORT const UA_ObjectTypeAttributes UA_ObjectTypeAttributes_default
 
UA_EXPORT const UA_ReferenceTypeAttributes UA_ReferenceTypeAttributes_default
 
UA_EXPORT const UA_DataTypeAttributes UA_DataTypeAttributes_default
 
UA_EXPORT const UA_ViewAttributes UA_ViewAttributes_default
 

Macro Definition Documentation

◆ UA_MAX

#define UA_MAX (   A,
 
)    ((A) > (B) ? (A) : (B))

Definition at line 192 of file util.h.

◆ UA_MIN

#define UA_MIN (   A,
 
)    ((A) > (B) ? (B) : (A))

Definition at line 188 of file util.h.

◆ UA_PRINTF_GUID_DATA

#define UA_PRINTF_GUID_DATA (   GUID)
Value:
(GUID).data1, (GUID).data2, (GUID).data3, \
(GUID).data4[0], (GUID).data4[1], (GUID).data4[2], (GUID).data4[3], \
(GUID).data4[4], (GUID).data4[5], (GUID).data4[6], (GUID).data4[7]

Definition at line 204 of file util.h.

◆ UA_PRINTF_GUID_FORMAT

#define UA_PRINTF_GUID_FORMAT
Value:
"%08" PRIx32 "-%04" PRIx16 "-%04" PRIx16 \
"-%02" PRIx8 "%02" PRIx8 "-%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8 "%02" PRIx8

Definition at line 202 of file util.h.

◆ UA_PRINTF_STRING_DATA

#define UA_PRINTF_STRING_DATA (   STRING)    (int)(STRING).length, (STRING).data

Definition at line 209 of file util.h.

◆ UA_PRINTF_STRING_FORMAT

#define UA_PRINTF_STRING_FORMAT   "\"%.*s\""

Definition at line 208 of file util.h.

Function Documentation

◆ UA_ByteString_memZero()

UA_EXPORT void UA_ByteString_memZero ( UA_ByteString bs)

Zero-out memory in a way that is not removed by compiler-optimizations.

Use this to ensure cryptographic secrets don't leave traces after the memory was freed.

◆ UA_constantTimeEqual()

UA_EXPORT UA_Boolean UA_constantTimeEqual ( const void *  ptr1,
const void *  ptr2,
size_t  length 
)

Compare memory in constant time to mitigate timing attacks.

Returns true if ptr1 and ptr2 are equal for length bytes.

◆ UA_Guid_random()

UA_Guid UA_Guid_random ( void  )

◆ UA_KeyValueMap_clear()

UA_EXPORT void UA_KeyValueMap_clear ( UA_KeyValueMap map)

◆ UA_KeyValueMap_contains()

UA_EXPORT UA_Boolean UA_KeyValueMap_contains ( const UA_KeyValueMap map,
const UA_QualifiedName  key 
)

Does the map contain an entry for the key?

◆ UA_KeyValueMap_copy()

UA_EXPORT UA_StatusCode UA_KeyValueMap_copy ( const UA_KeyValueMap src,
UA_KeyValueMap dst 
)

Create a deep copy of the given KeyValueMap.

◆ UA_KeyValueMap_delete()

UA_EXPORT void UA_KeyValueMap_delete ( UA_KeyValueMap map)

◆ UA_KeyValueMap_get()

UA_EXPORT const UA_Variant * UA_KeyValueMap_get ( const UA_KeyValueMap map,
const UA_QualifiedName  key 
)

Returns a pointer to the value or NULL if the key is not found.

◆ UA_KeyValueMap_getScalar()

UA_EXPORT const void * UA_KeyValueMap_getScalar ( const UA_KeyValueMap map,
const UA_QualifiedName  key,
const UA_DataType type 
)

Returns NULL if the value for the key is not defined, not of the right datatype or not a scalar.

◆ UA_KeyValueMap_isEmpty()

UA_EXPORT UA_Boolean UA_KeyValueMap_isEmpty ( const UA_KeyValueMap map)

Is the map empty (or NULL)?

◆ UA_KeyValueMap_merge()

UA_EXPORT UA_StatusCode UA_KeyValueMap_merge ( UA_KeyValueMap lhs,
const UA_KeyValueMap rhs 
)

Copy entries from the right-hand-side into the left-hand-size.

Reallocates previous memory in the left-hand-side. If the operation fails, both maps are left untouched.

◆ UA_KeyValueMap_new()

UA_EXPORT UA_KeyValueMap * UA_KeyValueMap_new ( void  )

◆ UA_KeyValueMap_remove()

UA_EXPORT UA_StatusCode UA_KeyValueMap_remove ( UA_KeyValueMap map,
const UA_QualifiedName  key 
)

Remove a single entry.

To delete the entire map, use UA_KeyValueMap_clear.

◆ UA_KeyValueMap_set()

UA_EXPORT UA_StatusCode UA_KeyValueMap_set ( UA_KeyValueMap map,
const UA_QualifiedName  key,
const UA_Variant value 
)

Insert a copy of the value.

Can reallocate the underlying array. This invalidates pointers into the previous array. If the key exists already, the value is overwritten (upsert semantics).

◆ UA_KeyValueMap_setScalar()

UA_EXPORT UA_StatusCode UA_KeyValueMap_setScalar ( UA_KeyValueMap map,
const UA_QualifiedName  key,
void *  p,
const UA_DataType type 
)

Helper function for scalar insertion that internally calls UA_KeyValueMap_set

◆ UA_parseEndpointUrl()

UA_StatusCode UA_parseEndpointUrl ( const UA_String endpointUrl,
UA_String outHostname,
UA_UInt16 outPort,
UA_String outPath 
)

Split the given endpoint url into hostname, port and path.

All arguments must be non-NULL. EndpointUrls have the form "opc.tcp://hostname:port/path", port and path may be omitted (together with the prefix colon and slash).

Parameters
endpointUrlThe endpoint URL.
outHostnameSet to the parsed hostname. The string points into the original endpointUrl, so no memory is allocated. If an IPv6 address is given, hostname contains e.g. '[2001:0db8:85a3::8a2e:0370:7334]'
outPortSet to the port of the url or left unchanged.
outPathSet to the path if one is present in the endpointUrl. Can be NULL. Then not path is returned. Starting or trailing '/' are NOT included in the path. The string points into the original endpointUrl, so no memory is allocated.
Returns
Returns UA_STATUSCODE_BADTCPENDPOINTURLINVALID if parsing failed.

◆ UA_parseEndpointUrlEthernet()

UA_StatusCode UA_parseEndpointUrlEthernet ( const UA_String endpointUrl,
UA_String target,
UA_UInt16 vid,
UA_Byte pcp 
)

Split the given endpoint url into hostname, vid and pcp.

All arguments must be non-NULL. EndpointUrls have the form "opc.eth://<host>[:<VID>[.PCP]]". The host is a MAC address, an IP address or a registered name like a hostname. The format of a MAC address is six groups of hexadecimal digits, separated by hyphens (e.g. 01-23-45-67-89-ab). A system may also accept hostnames and/or IP addresses if it provides means to resolve it to a MAC address (e.g. DNS and Reverse-ARP).

Note: currently only parsing MAC address is supported.

Parameters
endpointUrlThe endpoint URL.
vidSet to VLAN ID.
pcpSet to Priority Code Point.
Returns
Returns UA_STATUSCODE_BADINTERNALERROR if parsing failed.

◆ UA_random_seed()

void UA_random_seed ( UA_UInt64  seed)

◆ UA_readNumber()

size_t UA_readNumber ( const UA_Byte buf,
size_t  buflen,
UA_UInt32 number 
)

Convert given byte string to a positive number.

Returns the number of valid digits. Stops if a non-digit char is found and returns the number of digits up to that point.

◆ UA_readNumberWithBase()

size_t UA_readNumberWithBase ( const UA_Byte buf,
size_t  buflen,
UA_UInt32 number,
UA_Byte  base 
)

Same as UA_ReadNumber but with a base parameter.

◆ UA_UInt32_random()

UA_UInt32 UA_UInt32_random ( void  )

Variable Documentation

◆ UA_DataTypeAttributes_default

UA_EXPORT const UA_DataTypeAttributes UA_DataTypeAttributes_default
extern

◆ UA_KEYVALUEMAP_NULL

UA_EXPORT const UA_KeyValueMap UA_KEYVALUEMAP_NULL
extern

◆ UA_MethodAttributes_default

UA_EXPORT const UA_MethodAttributes UA_MethodAttributes_default
extern

Methods are executable by default.

◆ UA_ObjectAttributes_default

UA_EXPORT const UA_ObjectAttributes UA_ObjectAttributes_default
extern

The remaining attribute definitions are currently all zeroed out.

◆ UA_ObjectTypeAttributes_default

UA_EXPORT const UA_ObjectTypeAttributes UA_ObjectTypeAttributes_default
extern

◆ UA_ReferenceTypeAttributes_default

UA_EXPORT const UA_ReferenceTypeAttributes UA_ReferenceTypeAttributes_default
extern

◆ UA_VariableAttributes_default

UA_EXPORT const UA_VariableAttributes UA_VariableAttributes_default
extern

The default for variables is "BaseDataType" for the datatype, -2 for the valuerank and a read-accesslevel.

◆ UA_VariableTypeAttributes_default

UA_EXPORT const UA_VariableTypeAttributes UA_VariableTypeAttributes_default
extern

◆ UA_ViewAttributes_default

UA_EXPORT const UA_ViewAttributes UA_ViewAttributes_default
extern