open62541 1.3.12
Open source implementation of OPC UA
Loading...
Searching...
No Matches
util.h File Reference

Go to the source code of this file.

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
 

Typedefs

typedef struct UA_Server UA_Server
 
typedef struct UA_ServerConfig UA_ServerConfig
 
typedef void(* UA_ServerCallback) (UA_Server *server, void *data)
 
typedef struct UA_Client UA_Client
 

Enumerations

enum  UA_TimerPolicy
 

Functions

UA_EXPORT UA_StatusCode UA_KeyValueMap_setQualified (UA_KeyValuePair **map, size_t *mapSize, const UA_QualifiedName *key, const UA_Variant *value)
 
UA_EXPORT UA_StatusCode UA_KeyValueMap_set (UA_KeyValuePair **map, size_t *mapSize, const char *key, const UA_Variant *value)
 
UA_EXPORT const UA_VariantUA_KeyValueMap_getQualified (UA_KeyValuePair *map, size_t mapSize, const UA_QualifiedName *key)
 
UA_EXPORT const UA_VariantUA_KeyValueMap_get (UA_KeyValuePair *map, size_t mapSize, const char *key)
 
UA_EXPORT const UA_VariantUA_KeyValueMap_getScalar (UA_KeyValuePair *map, size_t mapSize, const char *key, const UA_DataType *type)
 
UA_EXPORT const UA_VariantUA_KeyValueMap_getArray (UA_KeyValuePair *map, size_t mapSize, const char *key, const UA_DataType *type)
 
UA_EXPORT void UA_KeyValueMap_deleteQualified (UA_KeyValuePair **map, size_t *mapSize, const UA_QualifiedName *key)
 
UA_EXPORT void UA_KeyValueMap_delete (UA_KeyValuePair **map, size_t *mapSize, const char *key)
 
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)
 

Macro Definition Documentation

◆ UA_MIN

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

Definition at line 130 of file util.h.

◆ UA_MAX

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

Definition at line 134 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 144 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 146 of file util.h.

◆ UA_PRINTF_STRING_FORMAT

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

Definition at line 150 of file util.h.

◆ UA_PRINTF_STRING_DATA

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

Definition at line 151 of file util.h.

Typedef Documentation

◆ UA_Server

typedef struct UA_Server UA_Server

Definition at line 20 of file util.h.

◆ UA_ServerConfig

typedef struct UA_ServerConfig UA_ServerConfig

Definition at line 23 of file util.h.

◆ UA_ServerCallback

typedef void(* UA_ServerCallback) (UA_Server *server, void *data)

Definition at line 25 of file util.h.

◆ UA_Client

typedef struct UA_Client UA_Client

Definition at line 28 of file util.h.

Enumeration Type Documentation

◆ UA_TimerPolicy

Timer policy to handle cycle misses.

Enumerator
UA_TIMER_HANDLE_CYCLEMISS_WITH_CURRENTTIME 
UA_TIMER_HANDLE_CYCLEMISS_WITH_BASETIME 

Definition at line 31 of file util.h.

Function Documentation

◆ UA_KeyValueMap_setQualified()

UA_EXPORT UA_StatusCode UA_KeyValueMap_setQualified ( UA_KeyValuePair ** map,
size_t * mapSize,
const UA_QualifiedName * key,
const UA_Variant * value )

Makes 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.

◆ UA_KeyValueMap_set()

UA_EXPORT UA_StatusCode UA_KeyValueMap_set ( UA_KeyValuePair ** map,
size_t * mapSize,
const char * key,
const UA_Variant * value )

Simplified version that assumes the key is in namespace 0.

◆ UA_KeyValueMap_getQualified()

UA_EXPORT const UA_Variant * UA_KeyValueMap_getQualified ( UA_KeyValuePair * map,
size_t mapSize,
const UA_QualifiedName * key )

Returns a pointer into underlying array or NULL if the key is not found.

◆ UA_KeyValueMap_get()

UA_EXPORT const UA_Variant * UA_KeyValueMap_get ( UA_KeyValuePair * map,
size_t mapSize,
const char * key )

Simplified version that assumes the key is in namespace 0.

◆ UA_KeyValueMap_getScalar()

UA_EXPORT const UA_Variant * UA_KeyValueMap_getScalar ( UA_KeyValuePair * map,
size_t mapSize,
const char * key,
const UA_DataType * type )

Returns NULL if the value for the key is not defined or not of the right datatype and scalar/array.

◆ UA_KeyValueMap_getArray()

UA_EXPORT const UA_Variant * UA_KeyValueMap_getArray ( UA_KeyValuePair * map,
size_t mapSize,
const char * key,
const UA_DataType * type )

◆ UA_KeyValueMap_deleteQualified()

UA_EXPORT void UA_KeyValueMap_deleteQualified ( UA_KeyValuePair ** map,
size_t * mapSize,
const UA_QualifiedName * key )

Remove a single entry.

To delete the entire map, use UA_Array_delete.

◆ UA_KeyValueMap_delete()

UA_EXPORT void UA_KeyValueMap_delete ( UA_KeyValuePair ** map,
size_t * mapSize,
const char * key )

Simplified version that assumes the key is in namespace 0.

◆ 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. 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_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.