ANSI C UA Server SDK  1.5.1.313
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
UaBaseSettings

Get configuration from a settings backend. More...

Data Structures

struct  UaBase_Settings
 Settings structure to get configuration from a settings backend. More...
 

Functions

OpcUa_StatusCode UaBase_Settings_Initialize (UaBase_Settings *pSettings, const char *szPath)
 Initializes a settings structure using the passed file path. More...
 
OpcUa_StatusCode UaBase_Settings_Flush (UaBase_Settings *pSettings)
 Writes all changes in the passed settings structure to disk. More...
 
OpcUa_StatusCode UaBase_Settings_Clear (UaBase_Settings *pSettings)
 Closes the passed settings structure. More...
 
OpcUa_StatusCode UaBase_Settings_BeginGroup (UaBase_Settings *pSettings, const char *szGroup)
 Set the current group of the settings. More...
 
OpcUa_StatusCode UaBase_Settings_EndGroup (UaBase_Settings *pSettings)
 Clear the current group of the settings. More...
 
OpcUa_StatusCode UaBase_Settings_ReadString (UaBase_Settings *pSettings, const char *szKey, char *szValue, int len, const char *szDefaultValue)
 Reads a setting as string. More...
 
OpcUa_StatusCode UaBase_Settings_WriteString (UaBase_Settings *pSettings, const char *szKey, const char *szValue)
 Writes a setting as string. More...
 
OpcUa_StatusCode UaBase_Settings_ReadUaString (UaBase_Settings *pSettings, const char *szKey, OpcUa_String *pValue, const char *szDefaultValue)
 Reads a setting as string. More...
 
OpcUa_StatusCode UaBase_Settings_WriteUaString (UaBase_Settings *pSettings, const char *szKey, const OpcUa_String *pValue)
 Writes a setting as string. More...
 
OpcUa_StatusCode UaBase_Settings_ReadBool (UaBase_Settings *pSettings, const char *szKey, OpcUa_Boolean *pbVal, OpcUa_Boolean bDefVal)
 Returns the boolean value of setting szKey. More...
 
OpcUa_StatusCode UaBase_Settings_WriteBool (UaBase_Settings *pSettings, const char *szKey, OpcUa_Boolean bVal)
 Write a boolean value to setting szKey. More...
 
OpcUa_StatusCode UaBase_Settings_ReadInt (UaBase_Settings *pSettings, const char *szKey, OpcUa_Int *piVal, OpcUa_Int iDefVal)
 Returns the integer value of setting szKey. More...
 
OpcUa_StatusCode UaBase_Settings_WriteInt (UaBase_Settings *pSettings, const char *szKey, OpcUa_Int iVal)
 Write an integer value to setting szKey. More...
 
OpcUa_StatusCode UaBase_Settings_ReadUInt (UaBase_Settings *pSettings, const char *szKey, OpcUa_UInt *piVal, OpcUa_UInt iDefVal)
 Returns the unsigned integer value of setting szKey. More...
 
OpcUa_StatusCode UaBase_Settings_WriteUInt (UaBase_Settings *pSettings, const char *szKey, OpcUa_UInt iVal)
 Write an unsigned integer value to setting szKey. More...
 
OpcUa_StatusCode UaBase_Settings_ReadFloat (UaBase_Settings *pSettings, const char *szKey, OpcUa_Float *pfltVal, OpcUa_Float fltDefVal)
 Returns the float value of setting szKey. More...
 
OpcUa_StatusCode UaBase_Settings_WriteFloat (UaBase_Settings *pSettings, const char *szKey, OpcUa_Float fltVal)
 Write a float value to setting szKey. More...
 
OpcUa_StatusCode UaBase_Settings_ReadDouble (UaBase_Settings *pSettings, const char *szKey, OpcUa_Double *pdblVal, OpcUa_Double dblDefVal)
 Returns the double value of setting szKey. More...
 
OpcUa_StatusCode UaBase_Settings_WriteDouble (UaBase_Settings *pSettings, const char *szKey, OpcUa_Double dblVal)
 Write a double value to setting szKey. More...
 

Detailed Description

Get configuration from a settings backend.

The following paragraphs give an overview of the configuration settings. Details about the entries and their valid values can be found in the comments of the configuration file and in the documentation of the UaServer_Configuration structure.

The 'General' section contains settings of the SDK regarding limits in providers, sessions and subscriptions.

[General]
# Maximum number of nodes per provider supported by the server.
MaxProviderNodes = 3000
# Maximum number of references to return in a Browse/BrowseNext response.
MaxReferencesToReturn = 10000
# Maximum number of SecureChannels (0 -> unlimited).
MaxSecureChannels = 100
# Maximum number of sessions (0 -> unlimited).
MaxSessions = 50
# Maximum number of subscriptions per session.
MaxSubscriptionsPerSession = 20
# Maximum number of publish requests per session.
MaxPublishPerSession = 10
# Maximum number of continuation points per session.
MaxContinuationPointsPerSession = 5
# Maximum number of continuation points per session for Query services.
MaxQueryContinuationPointsPerSession = 5
# Maximum number of continuation points per session for ReadHistory services.
MaxHistoryContinuationPointsPerSession = 5
# The minimum supported publishing interval.
MinPublishingInterval = 50
# The maximum supported publishing interval.
MaxPublishingInterval = 3600000
# The minimum supported KeepAliveInterval for subscriptions.
MinKeepAliveInterval = 500
# The maximum supported KeepAliveInterval for subscriptions.
MaxKeepAliveInterval = 1200000
# The minimum supported Lifetime for subscriptions.
MinLifetimeInterval = 1500
# The maximum supported Lifetime for subscriptions.
MaxLifetimeInterval = 3600000
# Maximum number of monitored items per subscription.
MaxMonitoredItemsPerSubscription = 1000
# Maximum queue size for data monitored items.
MaxMonitoredItemsQueueSize = 10000
# Maximum queue size for event monitored items.
MaxEventMonitoredItemsQueueSize = 10000
# Maximum number of monitored items for the subscription containing the data logger nodes.
MaxDataLoggerSubscriptionItems = 1000
# Publishing interval of the subscription containing the data logger nodes.
DataLoggerSubscriptionPublishingInterval = 500

In the 'Endpoints' section the endpoints of the server are configured. 'Endpoints/size' is the number of endpoints to be created. The settings of the endpoints follow as 'Endpoints/n/...', where n is the number of the endpoint.

For 'EndpointURL' and 'BindURL' the placeholder [gethostname] can be used. It will be replaced with the content of szHostname passed to the function.

The endpoint settings 'SecurityPolicies' and 'UserTokenPolicies' contain a comma separated list of sections containing suitable settings as described below. The setting 'PKIStore' contains the name of a section containing suitable settings as described below.

For running the server without security, set the PKIStore to a configuration with a PkiType of 'None' ('PKIStore_None' in the example delivered with the SDK), set 'SecurityPolicies' to 'SecurityPolicy_None' only and 'UserTokenPolicies' to 'Anonymous' only.

[Endpoints]
Endpoints/size = 1
# URL of the Endpoint; this URL is used for Discovery and to open the Endpoints
# in the UA stack if no BindURL is configured.
# [gethostname] can be used as placeholder for the computer name.
Endpoints/0/EndpointURL = opc.tcp://[gethostname]:48020
# Optional URL that allows to define a specific address the stack should use to bind to.
# Can be used to bind the endpoint to a specific network card or to localhost only.
# [gethostname] can be used as placeholder for the computer name
Endpoints/0/BindURL = opc.tcp://[gethostname]:48020
# SecurityPolicies the endpoint shall offer (comma separated list of sections)
# The SecurityPolicy 'SecurityPolicy_Basic128Rsa15' is no longer recommended.
# It is up to an administrator to configure the actual exposed SecurityPolicies.
Endpoints/0/SecurityPolicies = SecurityPolicy_None, SecurityPolicy_Basic256, SecurityPolicy_Basic256Sha256
# UserTokenPolicies the endpoint shall offer (comma separated list of sections)
Endpoints/0/UserTokenPolicies = Anonymous, UserName_256, UserName_256Sha256, Certificate_256, Certificate_256Sha256
# The PKI store section this endpoint shall use
# This example settings file provides two stores, PKIStore_OpenSSL and PKIStore_None
Endpoints/0/PKIStore = PKIStore_OpenSSL
# This option can be activated if certificates are used only for message security but not for application authentication.
# If set to true, all client certificates will be accepted automatically and they are not stored.
# It is strongly recommended to use this option only together with user authentication.
Endpoints/0/TrustAllClientCertificates = false

As an example, there is a commented out HTTPS endpoint declared, by uncommenting it and setting the 'Endpoints/size' setting to 2, the endpoint is created when starting the server.

# Uncomment the next settings (Endpoints/1/...) and set Endpoints/size to 2 to enable the HTTPS based profiles.
# This profile works but is not officially supported in this version of the SDK.
# This is the HTTP based protocol that will be supported by embedded devices.
# The HTTPS profile is not completely tested, so you can use it on your own risk.
# Additionally, you have to recompile the SDK with the following options set to 'ON' after setting
# ENABLE_EXPERIMENTAL_OPTIONS to 'ON':
# TLS : UASTACK_WITH_TLS
# HTTPS : UASTACK_WITH_HTTPS
#Endpoints/1/EndpointURL = https://[gethostname]:48021
#Endpoints/1/BindURL = https://[gethostname]:48021
#Endpoints/1/SecurityPolicies = SecurityPolicy_None
#Endpoints/1/UserTokenPolicies = Anonymous
#Endpoints/1/PKIStore = PKIStore_OpenSSL
#Endpoints/1/TrustAllClientCertificates = false

Sections containing settings for a security policy to be used in the endpoint setting 'SecurityPolicies' are expected to contain two settings, 'Url' and 'MessageSecurity'.

The setting 'MessageSecurity' is one of 'None', 'Sign' or 'SignAndEncrypt', or a combination of the last two.

[SecurityPolicy_None]
Url = http://opcfoundation.org/UA/SecurityPolicy#None
MessageSecurity = None
# The SecurityPolicy 'SecurityPolicy_Basic128Rsa15' is no longer recommended.
# It is up to an administrator to configure the actual exposed SecurityPolicies.
#[SecurityPolicy_Basic128Rsa15]
#Url = http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15
#MessageSecurity = Sign, SignAndEncrypt
[SecurityPolicy_Basic256]
Url = http://opcfoundation.org/UA/SecurityPolicy#Basic256
MessageSecurity = Sign, SignAndEncrypt

Sections containing settings for a user token policy to be used in the endpoint setting 'UserTokenPolicies' are expected to contain at least two settings, 'PolicyId' and 'TokenType'.

The 'TokenType' may be one of 'Anonymous', 'UserName' or 'Certificate'. If declaring a user name or a certificate token, a SecurityPolicyUri should be provided for defining how the secret of the token should be encrypted by a client.

Sections containing settings for a PKI store to be used in the endpoint setting 'PKIStore' are expected to contain at least the setting 'PkiType'.

The 'PkiType' may be one of 'None', 'OpenSSL' or, on Windows, 'WIN32'. If declaring an OpenSSL or WIN32 store, additional settings are required as described below:

If a self signed certificate should be created when starting the server, the setting 'GenerateCertificate' has to be set to true and additional settings are required as described below:

The 'PKI' section contains settings for rejected certificates and a list of all existing sections containing settings of a PKI store. The list of stores is needed for creating the certificates before starting up the server.

The 'Discovery' section contains all settings for the registration at a discovery server.

The 'Authentication' section contains settings required by the internal authentication and the authorization module.

Function Documentation

OpcUa_StatusCode UaBase_Settings_BeginGroup ( UaBase_Settings pSettings,
const char *  szGroup 
)

Set the current group of the settings.

If the group does not exist, it is created. Groups cannot be nested.

Parameters
pSettingsPointer to settings object
szGroupName of the group
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_Clear ( UaBase_Settings pSettings)

Closes the passed settings structure.

The settings are not flushed automatically, call UaBase_Settings_Flush before if changes should be written to disk.

Parameters
pSettingsPointer to settings object.
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_EndGroup ( UaBase_Settings pSettings)

Clear the current group of the settings.

Parameters
pSettingsPointer to settings object
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_Flush ( UaBase_Settings pSettings)

Writes all changes in the passed settings structure to disk.

Parameters
pSettingsPointer to settings object
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_Initialize ( UaBase_Settings pSettings,
const char *  szPath 
)

Initializes a settings structure using the passed file path.

The default implementation uses a file based backend.

Parameters
pSettingsPointer to settings object
szPathPath to the settings file
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_ReadBool ( UaBase_Settings pSettings,
const char *  szKey,
OpcUa_Boolean *  pbVal,
OpcUa_Boolean  bDefVal 
)

Returns the boolean value of setting szKey.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be read
pbValPointer to an OpcUa_Boolean where the value is stored
bDefValThe default value to return if the setting does not exist
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_ReadDouble ( UaBase_Settings pSettings,
const char *  szKey,
OpcUa_Double *  pdblVal,
OpcUa_Double  dblDefVal 
)

Returns the double value of setting szKey.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be read
pdblValPointer to an OpcUa_Double where the value is stored
dblDefValThe default value to return if the setting does not exist
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_ReadFloat ( UaBase_Settings pSettings,
const char *  szKey,
OpcUa_Float *  pfltVal,
OpcUa_Float  fltDefVal 
)

Returns the float value of setting szKey.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be read
pfltValPointer to an OpcUa_Float where the value is stored
fltDefValThe default value to return if the setting does not exist
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_ReadInt ( UaBase_Settings pSettings,
const char *  szKey,
OpcUa_Int *  piVal,
OpcUa_Int  iDefVal 
)

Returns the integer value of setting szKey.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be read
piValPointer to an OpcUa_Int where the value is stored
iDefValThe default value to return if the setting does not exist
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_ReadString ( UaBase_Settings pSettings,
const char *  szKey,
char *  szValue,
int  len,
const char *  szDefaultValue 
)

Reads a setting as string.

Placeholders of the format $ENV{NAME} are automatically replaced with the content of the environment variable NAME.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be read
szValuePointer to string which receives the read result
lenLength of szValue in bytes
szDefaultValueDefault value which should be returned if the key does not exist yet
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_ReadUaString ( UaBase_Settings pSettings,
const char *  szKey,
OpcUa_String *  pValue,
const char *  szDefaultValue 
)

Reads a setting as string.

Placeholders of the format $ENV{NAME} are automatically replaced with the content of the environment variable NAME.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be read
pValuePointer to string which receives the read result
szDefaultValueDefault value which should be returned if the key does not exist yet
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_ReadUInt ( UaBase_Settings pSettings,
const char *  szKey,
OpcUa_UInt *  piVal,
OpcUa_UInt  iDefVal 
)

Returns the unsigned integer value of setting szKey.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be read
piValPointer to an OpcUa_UInt where the value is stored
iDefValThe default value to return if the setting does not exist
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_WriteBool ( UaBase_Settings pSettings,
const char *  szKey,
OpcUa_Boolean  bVal 
)

Write a boolean value to setting szKey.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be written
bValThe value to write
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_WriteDouble ( UaBase_Settings pSettings,
const char *  szKey,
OpcUa_Double  dblVal 
)

Write a double value to setting szKey.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be written
dblValThe value to write
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_WriteFloat ( UaBase_Settings pSettings,
const char *  szKey,
OpcUa_Float  fltVal 
)

Write a float value to setting szKey.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be written
fltValThe value to write
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_WriteInt ( UaBase_Settings pSettings,
const char *  szKey,
OpcUa_Int  iVal 
)

Write an integer value to setting szKey.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be written
iValThe value to write
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_WriteString ( UaBase_Settings pSettings,
const char *  szKey,
const char *  szValue 
)

Writes a setting as string.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be written
szValuePointer to string to write
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_WriteUaString ( UaBase_Settings pSettings,
const char *  szKey,
const OpcUa_String *  pValue 
)

Writes a setting as string.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be written
pValuePointer to string to write
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaBase_Settings_WriteUInt ( UaBase_Settings pSettings,
const char *  szKey,
OpcUa_UInt  iVal 
)

Write an unsigned integer value to setting szKey.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be written
iValThe value to write
Returns
OpcUa_StatusCode