server_config.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. *
  5. * Copyright 2017 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
  6. * Copyright 2017 (c) Stefan Profanter, fortiss GmbH
  7. * Copyright 2017 (c) Henrik Norrman
  8. * Copyright 2018 (c) Fabian Arndt, Root-Core
  9. */
  10. #ifndef UA_SERVER_CONFIG_H_
  11. #define UA_SERVER_CONFIG_H_
  12. #include <open62541/plugin/accesscontrol.h>
  13. #include <open62541/plugin/log.h>
  14. #include <open62541/plugin/network.h>
  15. #include <open62541/plugin/pki.h>
  16. #include <open62541/plugin/securitypolicy.h>
  17. #include <open62541/server.h>
  18. #ifdef UA_ENABLE_PUBSUB
  19. #include <open62541/plugin/pubsub.h>
  20. #endif
  21. #ifdef UA_ENABLE_HISTORIZING
  22. #include <open62541/plugin/historydatabase.h>
  23. #endif
  24. _UA_BEGIN_DECLS
  25. /**
  26. * .. _server-configuration:
  27. *
  28. * Server Configuration
  29. * --------------------
  30. * The configuration structure is passed to the server during initialization.
  31. * The server expects that the configuration is not modified during runtime.
  32. * Currently, only one server can use a configuration at a time. During
  33. * shutdown, the server will clean up the parts of the configuration that are
  34. * modified at runtime through the provided API.
  35. *
  36. * Examples for configurations are provided in the ``/plugins`` folder.
  37. * The usual usage is as follows:
  38. *
  39. * 1. Create a server configuration with default settings as a starting point
  40. * 2. Modifiy the configuration, e.g. by adding a server certificate
  41. * 3. Instantiate a server with it
  42. * 4. After shutdown of the server, clean up the configuration (free memory)
  43. *
  44. * The :ref:`tutorials` provide a good starting point for this. */
  45. typedef struct {
  46. UA_UInt32 min;
  47. UA_UInt32 max;
  48. } UA_UInt32Range;
  49. typedef struct {
  50. UA_Duration min;
  51. UA_Duration max;
  52. } UA_DurationRange;
  53. struct UA_ServerConfig {
  54. UA_UInt16 nThreads; /* only if multithreading is enabled */
  55. UA_Logger logger;
  56. /* Server Description */
  57. UA_BuildInfo buildInfo;
  58. UA_ApplicationDescription applicationDescription;
  59. UA_ByteString serverCertificate;
  60. /* Rule Handling */
  61. UA_RuleHandling verifyRequestTimestamp; /* Verify that the server sends a
  62. * timestamp in the request header */
  63. /* MDNS Discovery */
  64. #ifdef UA_ENABLE_DISCOVERY
  65. UA_String mdnsServerName;
  66. size_t serverCapabilitiesSize;
  67. UA_String *serverCapabilities;
  68. #endif
  69. /* Custom DataTypes. Attention! Custom datatypes are not cleaned up together
  70. * with the configuration. So it is possible to allocate them on ROM. */
  71. const UA_DataTypeArray *customDataTypes;
  72. /**
  73. * .. note:: See the section on :ref:`generic-types`. Examples for working
  74. * with custom data types are provided in
  75. * ``/examples/custom_datatype/``. */
  76. /* Networking */
  77. size_t networkLayersSize;
  78. UA_ServerNetworkLayer *networkLayers;
  79. UA_String customHostname;
  80. #ifdef UA_ENABLE_PUBSUB
  81. /*PubSub network layer */
  82. size_t pubsubTransportLayersSize;
  83. UA_PubSubTransportLayer *pubsubTransportLayers;
  84. #endif
  85. /* Available security policies */
  86. size_t securityPoliciesSize;
  87. UA_SecurityPolicy* securityPolicies;
  88. /* Available endpoints */
  89. size_t endpointsSize;
  90. UA_EndpointDescription *endpoints;
  91. /* Node Lifecycle callbacks */
  92. UA_GlobalNodeLifecycle nodeLifecycle;
  93. /**
  94. * .. note:: See the section for :ref:`node lifecycle
  95. * handling<node-lifecycle>`. */
  96. /* Access Control */
  97. UA_AccessControl accessControl;
  98. /**
  99. * .. note:: See the section for :ref:`access-control
  100. * handling<access-control>`. */
  101. /* Certificate Verification */
  102. UA_CertificateVerification certificateVerification;
  103. /* Relax constraints for the InformationModel */
  104. UA_Boolean relaxEmptyValueConstraint; /* Nominally, only variables with data
  105. * type BaseDataType can have an empty
  106. * value. */
  107. /* Limits for SecureChannels */
  108. UA_UInt16 maxSecureChannels;
  109. UA_UInt32 maxSecurityTokenLifetime; /* in ms */
  110. /* Limits for Sessions */
  111. UA_UInt16 maxSessions;
  112. UA_Double maxSessionTimeout; /* in ms */
  113. /* Operation limits */
  114. UA_UInt32 maxNodesPerRead;
  115. UA_UInt32 maxNodesPerWrite;
  116. UA_UInt32 maxNodesPerMethodCall;
  117. UA_UInt32 maxNodesPerBrowse;
  118. UA_UInt32 maxNodesPerRegisterNodes;
  119. UA_UInt32 maxNodesPerTranslateBrowsePathsToNodeIds;
  120. UA_UInt32 maxNodesPerNodeManagement;
  121. UA_UInt32 maxMonitoredItemsPerCall;
  122. /* Limits for Requests */
  123. UA_UInt32 maxReferencesPerNode;
  124. /* Limits for Subscriptions */
  125. UA_UInt32 maxSubscriptions;
  126. UA_UInt32 maxSubscriptionsPerSession;
  127. UA_DurationRange publishingIntervalLimits; /* in ms (must not be less than 5) */
  128. UA_UInt32Range lifeTimeCountLimits;
  129. UA_UInt32Range keepAliveCountLimits;
  130. UA_UInt32 maxNotificationsPerPublish;
  131. UA_Boolean enableRetransmissionQueue;
  132. UA_UInt32 maxRetransmissionQueueSize; /* 0 -> unlimited size */
  133. #ifdef UA_ENABLE_SUBSCRIPTIONS_EVENTS
  134. UA_UInt32 maxEventsPerNode; /* 0 -> unlimited size */
  135. #endif
  136. /* Limits for MonitoredItems */
  137. UA_UInt32 maxMonitoredItems;
  138. UA_UInt32 maxMonitoredItemsPerSubscription;
  139. UA_DurationRange samplingIntervalLimits; /* in ms (must not be less than 5) */
  140. UA_UInt32Range queueSizeLimits; /* Negotiated with the client */
  141. /* Limits for PublishRequests */
  142. UA_UInt32 maxPublishReqPerSession;
  143. /* Discovery */
  144. #ifdef UA_ENABLE_DISCOVERY
  145. /* Timeout in seconds when to automatically remove a registered server from
  146. * the list, if it doesn't re-register within the given time frame. A value
  147. * of 0 disables automatic removal. Default is 60 Minutes (60*60). Must be
  148. * bigger than 10 seconds, because cleanup is only triggered approximately
  149. * every 10 seconds. The server will still be removed depending on the
  150. * state of the semaphore file. */
  151. UA_UInt32 discoveryCleanupTimeout;
  152. #endif
  153. #ifdef UA_ENABLE_SUBSCRIPTIONS
  154. /* Register MonitoredItem in Userland
  155. *
  156. * @param server Allows the access to the server object
  157. * @param sessionId The session id, represented as an node id
  158. * @param sessionContext An optional pointer to user-defined data for the specific data source
  159. * @param nodeid Id of the node in question
  160. * @param nodeidContext An optional pointer to user-defined data, associated
  161. * with the node in the nodestore. Note that, if the node has already been removed,
  162. * this value contains a NULL pointer.
  163. * @param attributeId Identifies which attribute (value, data type etc.) is monitored
  164. * @param removed Determines if the MonitoredItem was removed or created. */
  165. void (*monitoredItemRegisterCallback)(UA_Server *server,
  166. const UA_NodeId *sessionId, void *sessionContext,
  167. const UA_NodeId *nodeId, void *nodeContext,
  168. UA_UInt32 attibuteId, UA_Boolean removed);
  169. #endif
  170. /* Historical Access */
  171. #ifdef UA_ENABLE_HISTORIZING
  172. UA_HistoryDatabase historyDatabase;
  173. UA_Boolean accessHistoryDataCapability;
  174. UA_UInt32 maxReturnDataValues; /* 0 -> unlimited size */
  175. UA_Boolean accessHistoryEventsCapability;
  176. UA_UInt32 maxReturnEventValues; /* 0 -> unlimited size */
  177. UA_Boolean insertDataCapability;
  178. UA_Boolean insertEventCapability;
  179. UA_Boolean insertAnnotationsCapability;
  180. UA_Boolean replaceDataCapability;
  181. UA_Boolean replaceEventCapability;
  182. UA_Boolean updateDataCapability;
  183. UA_Boolean updateEventCapability;
  184. UA_Boolean deleteRawCapability;
  185. UA_Boolean deleteEventCapability;
  186. UA_Boolean deleteAtTimeDataCapability;
  187. #endif
  188. };
  189. void UA_EXPORT
  190. UA_ServerConfig_clean(UA_ServerConfig *config);
  191. /* Set a custom hostname in server configuration */
  192. UA_EXPORT void
  193. UA_ServerConfig_setCustomHostname(UA_ServerConfig *config,
  194. const UA_String customHostname);
  195. _UA_END_DECLS
  196. #endif /* UA_SERVER_CONFIG_H_ */