High Performance OPC UA Server SDK  1.7.1.383
call_utility

Utilitys for simplifying the call service implementation. More...

Data Structures

struct  uaserver_call_utility_arg
 Structure to describe a method input or output argument. More...
 

Macros

#define uaserver_call_utility_clear_plain_array(structure)
 Clear a plain array with no further allocated data. More...
 
#define uaserver_call_utility_clear_array(structure, structure_count, clear_fct)
 Clear each member of an array and the array itself. More...
 

Enumerations

enum  uaserver_call_utility_flag { UASERVER_CALL_UTILITY_FLAG_NONE = 0, UASERVER_CALL_UTILITY_FLAG_SKIP_TYPE_CHECK = 1, UASERVER_CALL_UTILITY_FLAG_ABSTRACT_TYPE = 2 }
 Flags to influence the behavior of functions. More...
 

Functions

SERVER_EXPORT ua_statuscode uaserver_call_utility_check_arguments (const struct uaserver_call_utility_arg *types, int32_t num_types, const struct ua_callmethodrequest *req, struct ua_callmethodresult *res)
 Utility function to check the input arguments provided by a client for a method. More...
 
SERVER_EXPORT ua_statuscode uaserver_call_utility_attach_arguments (struct ua_callmethodresult *res, const struct uaserver_call_utility_arg *types, int32_t num_types,...)
 Attach output arguments to the ua_callmethodresult. More...
 
SERVER_EXPORT ua_statuscode uaserver_call_utility_check_permission (const struct uasession_session *session, const struct ua_nodeid *object_nodeid, const struct ua_nodeid *method_nodeid)
 This function evaluates the call permissions. More...
 

Detailed Description

Utilitys for simplifying the call service implementation.

Macro Definition Documentation

◆ uaserver_call_utility_clear_array

#define uaserver_call_utility_clear_array (   structure,
  structure_count,
  clear_fct 
)
Value:
if (structure) { \
size_t structure_count_i; \
for (structure_count_i = 0; structure_count_i < structure_count; structure_count_i++) { \
clear_fct(&structure[structure_count_i]); \
} \
ipc_free(structure); \
}

Clear each member of an array and the array itself.

◆ uaserver_call_utility_clear_plain_array

#define uaserver_call_utility_clear_plain_array (   structure)
Value:
if (structure) { \
ipc_free(structure); \
}

Clear a plain array with no further allocated data.

Enumeration Type Documentation

◆ uaserver_call_utility_flag

Flags to influence the behavior of functions.

Enumerator
UASERVER_CALL_UTILITY_FLAG_NONE 

No flag is given, use the default behaviour.

UASERVER_CALL_UTILITY_FLAG_SKIP_TYPE_CHECK 

Skip the type check for an argument.

UASERVER_CALL_UTILITY_FLAG_ABSTRACT_TYPE 

The extension object is an abstract type, so no exact type check should be performed.

Function Documentation

◆ uaserver_call_utility_attach_arguments()

SERVER_EXPORT ua_statuscode uaserver_call_utility_attach_arguments ( struct ua_callmethodresult res,
const struct uaserver_call_utility_arg types,
int32_t  num_types,
  ... 
)

Attach output arguments to the ua_callmethodresult.

Takes an array of output argument type descriptions and attaches values to the ua_callmethodresult according to the description. The function takes a variable number of arguments, so it works for any number and type of output arguments.

The values are attached to the ua_callmethodresult and detached values are set to NULL, in case of an error a partial number of values might be attached, so all values must be checked for NULL and cleared and the ua_callmethodresult must be cleared.

Example usage for different datatypes:

const struct uaserver_call_utility_arg args[] = {
{&g_uaprovider_server_nsidx, 0, UA_VT_UINT32, UASERVER_CALL_UTILITY_FLAG_NONE},
{&g_uaprovider_server_nsidx, 0, UA_VT_STRING, UASERVER_CALL_UTILITY_FLAG_NONE},
{&g_uaprovider_server_nsidx, 0, UA_VT_BYTESTRING, UASERVER_CALL_UTILITY_FLAG_NONE},
{&g_uaprovider_server_nsidx, 0, UA_VT_LOCALIZEDTEXT, UASERVER_CALL_UTILITY_FLAG_NONE},
{&g_uaprovider_server_nsidx, UA_ID_ANONYMOUSIDENTITYTOKEN, UA_VT_EXTENSIONOBJECT, UASERVER_CALL_UTILITY_FLAG_NONE},
{&g_uaprovider_server_nsidx, 0, UA_VT_IS_ARRAY | UA_VT_UINT32, UASERVER_CALL_UTILITY_FLAG_NONE},
{&g_uaprovider_server_nsidx, 0, UA_VT_IS_ARRAY | UA_VT_STRING, UASERVER_CALL_UTILITY_FLAG_NONE},
{&g_uaprovider_server_nsidx, UA_ID_ANONYMOUSIDENTITYTOKEN, UA_VT_IS_ARRAY | UA_VT_EXTENSIONOBJECT, UASERVER_CALL_UTILITY_FLAG_NONE},
};
uint32_t val0_uint32 = 54323;
struct ua_string *val1_str = NULL;
struct ua_bytestring *val2_bs = NULL;
struct ua_localizedtext *val3_lt = NULL;
struct ua_anonymousidentitytoken *val4_token = NULL;
uint32_t *array0_uint32 = NULL;
struct ua_string *array1_str = NULL;
struct ua_anonymousidentitytoken *array2_token = NULL;
int32_t array_length = 21; // length of all arrays
... // fill values and arrays
&val0_uint32,
&val1_str,
&val2_bs,
&val3_lt,
&val4_token,
&array0_uint32, array_length,
&array1_str, array_length,
&array2_token, array_length
);

◆ uaserver_call_utility_check_arguments()

SERVER_EXPORT ua_statuscode uaserver_call_utility_check_arguments ( const struct uaserver_call_utility_arg types,
int32_t  num_types,
const struct ua_callmethodrequest req,
struct ua_callmethodresult res 
)

Utility function to check the input arguments provided by a client for a method.

Takes an array of input argument type descripitons and checks the values in a ua_callmethodrequest match the description. If it does returns a good statuscode, else the ua_callmethodresult is filled accordingly and a bad statuscode is returned.

◆ uaserver_call_utility_check_permission()

SERVER_EXPORT ua_statuscode uaserver_call_utility_check_permission ( const struct uasession_session session,
const struct ua_nodeid object_nodeid,
const struct ua_nodeid method_nodeid 
)

This function evaluates the call permissions.

The client may do the method call with the method from the object or the method from the typedefinition, but the permission must always be checked on the object's method. Additionally the object (or objecttype) must also have the permission.

Parameters
sessionThe session of the client.
object_nodeidThe object of the method call.
method_nodeidThe method of the method call.
Returns
statuscode to indicate whether the call is allowed