UA ANSI C Server Professional  1.4.0.285
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
UaServerSettings

Get configuration from a settings backend. More...

Data Structures

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

Typedefs

typedef struct _UaServer_Settings UaServer_Settings
 Settings structure to get configuration from a settings backend. More...
 

Functions

OpcUa_StatusCode UaServer_Settings_Initialize (UaServer_Settings *pSettings, const char *szPath)
 Initializes a settings structure using the passed file path. More...
 
OpcUa_StatusCode UaServer_Settings_Flush (UaServer_Settings *pSettings)
 Writes all changes in the passed settings structure to disk. More...
 
OpcUa_StatusCode UaServer_Settings_Clear (UaServer_Settings *pSettings)
 Closes the passed settings structure. More...
 
OpcUa_StatusCode UaServer_Settings_BeginGroup (UaServer_Settings *pSettings, const char *szGroup)
 Set the current group of the settings. More...
 
OpcUa_StatusCode UaServer_Settings_EndGroup (UaServer_Settings *pSettings)
 Clear the current group of the settings. More...
 
OpcUa_StatusCode UaServer_Settings_ReadString (UaServer_Settings *pSettings, const char *szKey, char *szValue, int len, const char *szDefaultValue)
 Reads a setting as string. More...
 
OpcUa_StatusCode UaServer_Settings_WriteString (UaServer_Settings *pSettings, const char *szKey, const char *szValue)
 Writes a setting as string. More...
 
OpcUa_StatusCode UaServer_Settings_ReadUaString (UaServer_Settings *pSettings, const char *szKey, OpcUa_String *pValue, const char *szDefaultValue)
 Reads a setting as string. More...
 
OpcUa_StatusCode UaServer_Settings_WriteUaString (UaServer_Settings *pSettings, const char *szKey, const OpcUa_String *pValue)
 Writes a setting as string. More...
 
OpcUa_StatusCode UaServer_Settings_ReadBool (UaServer_Settings *pSettings, const char *szKey, OpcUa_Boolean *pbVal, OpcUa_Boolean bDefVal)
 Returns the boolean value of setting szKey. More...
 
OpcUa_StatusCode UaServer_Settings_WriteBool (UaServer_Settings *pSettings, const char *szKey, OpcUa_Boolean bVal)
 Write a boolean value to setting szKey. More...
 
OpcUa_StatusCode UaServer_Settings_ReadInt (UaServer_Settings *pSettings, const char *szKey, OpcUa_Int *piVal, OpcUa_Int iDefVal)
 Returns the integer value of setting szKey. More...
 
OpcUa_StatusCode UaServer_Settings_WriteInt (UaServer_Settings *pSettings, const char *szKey, OpcUa_Int iVal)
 Write an integer value to setting szKey. More...
 
OpcUa_StatusCode UaServer_Settings_ReadUInt (UaServer_Settings *pSettings, const char *szKey, OpcUa_UInt *piVal, OpcUa_UInt iDefVal)
 Returns the unsigned integer value of setting szKey. More...
 
OpcUa_StatusCode UaServer_Settings_WriteUInt (UaServer_Settings *pSettings, const char *szKey, OpcUa_UInt iVal)
 Write an unsigned integer value to setting szKey. More...
 
OpcUa_StatusCode UaServer_Settings_ReadFloat (UaServer_Settings *pSettings, const char *szKey, OpcUa_Float *pfltVal, OpcUa_Float fltDefVal)
 Returns the float value of setting szKey. More...
 
OpcUa_StatusCode UaServer_Settings_WriteFloat (UaServer_Settings *pSettings, const char *szKey, OpcUa_Float fltVal)
 Write a float value to setting szKey. More...
 
OpcUa_StatusCode UaServer_Settings_ReadDouble (UaServer_Settings *pSettings, const char *szKey, OpcUa_Double *pdblVal, OpcUa_Double dblDefVal)
 Returns the double value of setting szKey. More...
 
OpcUa_StatusCode UaServer_Settings_WriteDouble (UaServer_Settings *pSettings, const char *szKey, OpcUa_Double dblVal)
 Write a double value to setting szKey. More...
 
OpcUa_StatusCode UaServer_Settings_GetConfigurationFromSettings (UaServer_Settings *pSettings, UaServer_Configuration *pServerConfiguration, const char *szHostname)
 Fill the server configuration object using the provided settings structure. 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 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 = 30000
# The minimum supported Lifetime for subscriptions.
MinLifetimeInterval = 1500
# The maximum supported Lifetime for subscriptions.
MaxLifetimeInterval = 90000
# Maximum number of monitored items per subscription.
MaxMonitoredItemsPerSubscription = 1000
# Maximum queue size for monitored items.
MaxMonitoredItemsQueueSize = 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.

[Endpoints]
Endpoints/size = 1
# Endpoint URL to listen on; [gethostname] gets replaced with the local hostname
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] gets replaced with the local hostname
Endpoints/0/BindURL = opc.tcp://[gethostname]:48020
# SecurityPolicies the endpoint shall offer (comma separated list of sections)
Endpoints/0/SecurityPolicies = SecurityPolicy_None, SecurityPolicy_Basic128Rsa15, SecurityPolicy_Basic256
# UserTokenPolicies the endpoint shall offer (comma separated list of sections)
Endpoints/0/UserTokenPolicies = Anonymous, UserName_128, Certificate_128
# The PKI store section this endpoint shall use
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':
# 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
[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.

[Anonymous]
PolicyId = Anonymous_Token
TokenType = Anonymous
[UserName_128]
PolicyId = UserName_128_Token
TokenType = UserName
SecurityPolicyUri = http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15
[Certificate_128]
PolicyId = Certificate_128_Token
TokenType = Certificate
SecurityPolicyUri = http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15

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:

[PKIStore_OpenSSL]
# The PKI provider to use. OpenSSL is available on all platforms
PkiType = OpenSSL
# Server Certificate: Path to a PEM or DER encoded certificate file.
CertificateFile = $ENV{ALLUSERSPROFILE}/UnifiedAutomation/UaSdkAnsiCServerPro/pki/own/uaservercert.der
# Server Private Key: Path to a PEM encoded private key file. This should not be password protected
# so that the server can start unattended. With a password protected file the server will need to prompt the user to
# input the password to unlock the file, which is not possible when running as a service.
CertificateKeyFile = $ENV{ALLUSERSPROFILE}/UnifiedAutomation/UaSdkAnsiCServerPro/pki/own/uaserverkey.nopass.pem
# Path to trusted certificates. This includes trusted CA certificates as well as self-signed certificates.
TrustListPath = $ENV{ALLUSERSPROFILE}/UnifiedAutomation/UaSdkAnsiCServerPro/pki/trusted/certs
# This is the directory where the server stores certificate revocation lists.
# By default this directory contains no CRLs.
CRLPath = $ENV{ALLUSERSPROFILE}/UnifiedAutomation/UaSdkAnsiCServerPro/pki/trusted/crl
# Path to untrusted CA certificates. These certificates are only used to build a complete certificate chain.
IssuerTrustListPath = $ENV{ALLUSERSPROFILE}/UnifiedAutomation/UaSdkAnsiCServerPro/pki/issuers/certs
# Path to untrusted CA certificates. These certificates are only used to build a complete certificate chain.
IssuerCRLPath = $ENV{ALLUSERSPROFILE}/UnifiedAutomation/UaSdkAnsiCServerPro/pki/issuers/crl
# Optional comma separated list of PKI store specific flags, depending on the PkiType following values are possible:
# PkiType = OpenSSL: OPENSSL_CHECK_REVOCATION_STATUS, OPENSSL_SET_DEFAULT_PATHS
#Flags =

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:

# Enable server certificate creation if certificate is not available
GenerateCertificate = true
# Name of the application - [ApplicationName] is the default value to use the configured ApplicationName
CommonName = [ApplicationName]
# Name of the organization using the OPC UA server
Organization = Unified Automation GmbH
# Name of the organization unit using the OPC UA server
OrganizationUnit =
# Name of the location where the OPC UA server is running
Locality = Nuremberg
# State where the OPC UA server is running
State = Bavaria
# Two letter code for country where the OPC UA server is running e.g. DE or US
Country = DE
# The number of years the certificate is valid for. The maximum accepted number is 20
# but it is strongly recommended to use a shorter time.
YearsValidFor = 5
# Key length of the certificate to create. Valid values are 1024 and 2048 bits
KeyLength = 2048

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.

[PKI]
# RejectedPath: Path where rejected certificates will be stored.
RejectedPath = $ENV{ALLUSERSPROFILE}/UnifiedAutomation/UaSdkAnsiCServerPro/pki/rejected
# Maximum number of rejected certificates. This prevents malicious programs from filling up available disk space by
# calling OpenSecureChannel with different certificates.
MaxRejectedCertificates = 50
# All groups containing PKI store settings (comma separated list of groups)
PKIStores = PKIStore_OpenSSL

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

[Discovery]
# Enables registration at the local discovery server: true (=default), false
Register = true
DiscoveryURL = opc.tcp://localhost:4840/UADiscovery/discovery
DiscoveryInterval = 30000

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

[Authentication]
# file path to passwd file
PasswdFilePath = passwd
# file path to group file
GroupFilePath = group
# The folder containing accepted user certificates for X509 authentication tokens.
UserCertsDir = $ENV{ALLUSERSPROFILE}/UnifiedAutomation/UaSdkAnsiCServerPro/auth_pki/certs
# The folder containing certificate revocation lists for X509 authentication tokens.
UserCrlDir = $ENV{ALLUSERSPROFILE}/UnifiedAutomation/UaSdkAnsiCServerPro/auth_pki/crl
# The folder containing issuer certificates for X509 authentication tokens.
UserIssuerCertsDir = $ENV{ALLUSERSPROFILE}/UnifiedAutomation/UaSdkAnsiCServerPro/auth_pki/cacerts
# The folder containing issuer revocation lists for X509 authentication tokens.
UserIssuerCrlDir = $ENV{ALLUSERSPROFILE}/UnifiedAutomation/UaSdkAnsiCServerPro/auth_pki/cacrl

Typedef Documentation

Settings structure to get configuration from a settings backend.

The default implementation reads the settings from file.

Function Documentation

OpcUa_StatusCode UaServer_Settings_BeginGroup ( UaServer_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 UaServer_Settings_Clear ( UaServer_Settings pSettings)

Closes the passed settings structure.

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

Parameters
pSettingsPointer to settings object.
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaServer_Settings_EndGroup ( UaServer_Settings pSettings)

Clear the current group of the settings.

Parameters
pSettingsPointer to settings object
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaServer_Settings_Flush ( UaServer_Settings pSettings)

Writes all changes in the passed settings structure to disk.

Parameters
pSettingsPointer to settings object
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaServer_Settings_GetConfigurationFromSettings ( UaServer_Settings pSettings,
UaServer_Configuration pServerConfiguration,
const char *  szHostname 
)

Fill the server configuration object using the provided settings structure.

The provided settings object is expected to contain settings described above.

Parameters
pSettingsThe settings to use.
pServerConfigurationThe server configuration to set.
szHostnameOptional: the string to replace [gethostname] placeholders with.
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaServer_Settings_Initialize ( UaServer_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 UaServer_Settings_ReadBool ( UaServer_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 UaServer_Settings_ReadDouble ( UaServer_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 UaServer_Settings_ReadFloat ( UaServer_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 UaServer_Settings_ReadInt ( UaServer_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 UaServer_Settings_ReadString ( UaServer_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 UaServer_Settings_ReadUaString ( UaServer_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 UaServer_Settings_ReadUInt ( UaServer_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 UaServer_Settings_WriteBool ( UaServer_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 read
bValThe value to write
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaServer_Settings_WriteDouble ( UaServer_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 read
dblValThe value to write
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaServer_Settings_WriteFloat ( UaServer_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 read
fltValThe value to write
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaServer_Settings_WriteInt ( UaServer_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 read
iValThe value to write
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaServer_Settings_WriteString ( UaServer_Settings pSettings,
const char *  szKey,
const char *  szValue 
)

Writes a setting as string.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be read
szValuePointer to string which receives the read result
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaServer_Settings_WriteUaString ( UaServer_Settings pSettings,
const char *  szKey,
const OpcUa_String *  pValue 
)

Writes a setting as string.

Parameters
pSettingsPointer to settings object
szKeyKey name which should be read
pValuePointer to string which receives the read result
Returns
OpcUa_StatusCode
OpcUa_StatusCode UaServer_Settings_WriteUInt ( UaServer_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 read
iValThe value to write
Returns
OpcUa_StatusCode