server_config.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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/nodestore.h>
  14. #include <open62541/plugin/log.h>
  15. #include <open62541/plugin/network.h>
  16. #include <open62541/plugin/pki.h>
  17. #include <open62541/plugin/securitypolicy.h>
  18. #include <open62541/server.h>
  19. #ifdef UA_ENABLE_PUBSUB
  20. #include <open62541/plugin/pubsub.h>
  21. #endif
  22. #ifdef UA_ENABLE_HISTORIZING
  23. #include <open62541/plugin/historydatabase.h>
  24. #endif
  25. _UA_BEGIN_DECLS
  26. /**
  27. * .. _server-configuration:
  28. *
  29. * Server Configuration
  30. * --------------------
  31. * The configuration structure is passed to the server during initialization.
  32. * The server expects that the configuration is not modified during runtime.
  33. * Currently, only one server can use a configuration at a time. During
  34. * shutdown, the server will clean up the parts of the configuration that are
  35. * modified at runtime through the provided API.
  36. *
  37. * Examples for configurations are provided in the ``/plugins`` folder.
  38. * The usual usage is as follows:
  39. *
  40. * 1. Create a server configuration with default settings as a starting point
  41. * 2. Modifiy the configuration, e.g. by adding a server certificate
  42. * 3. Instantiate a server with it
  43. * 4. After shutdown of the server, clean up the configuration (free memory)
  44. *
  45. * The :ref:`tutorials` provide a good starting point for this. */
  46. typedef struct {
  47. UA_UInt32 min;
  48. UA_UInt32 max;
  49. } UA_UInt32Range;
  50. typedef struct {
  51. UA_Duration min;
  52. UA_Duration max;
  53. } UA_DurationRange;
  54. #ifdef UA_ENABLE_DISCOVERY
  55. typedef struct {
  56. /* Timeout in seconds when to automatically remove a registered server from
  57. * the list, if it doesn't re-register within the given time frame. A value
  58. * of 0 disables automatic removal. Default is 60 Minutes (60*60). Must be
  59. * bigger than 10 seconds, because cleanup is only triggered approximately
  60. * every 10 seconds. The server will still be removed depending on the
  61. * state of the semaphore file. */
  62. UA_UInt32 cleanupTimeout;
  63. /* Enable mDNS announce and response to queries */
  64. bool mdnsEnable;
  65. #ifdef UA_ENABLE_DISCOVERY_MULTICAST
  66. UA_MdnsDiscoveryConfiguration mdns;
  67. UA_String mdnsInterfaceIP;
  68. # if !defined(UA_HAS_GETIFADDR)
  69. uint32_t *ipAddressList;
  70. size_t ipAddressListSize;
  71. # endif
  72. #endif
  73. } UA_ServerConfig_Discovery;
  74. #endif
  75. typedef void
  76. (*UA_Server_AsyncOperationNotifyCallback)(UA_Server *server);
  77. struct UA_ServerConfig {
  78. UA_UInt16 nThreads; /* only if multithreading is enabled */
  79. UA_Logger logger;
  80. /* Server Description:
  81. * The description must be internally consistent.
  82. * - The ApplicationUri set in the ApplicationDescription must match the
  83. * URI set in the server certificate */
  84. UA_BuildInfo buildInfo;
  85. UA_ApplicationDescription applicationDescription;
  86. UA_ByteString serverCertificate;
  87. UA_Double shutdownDelay; /* Delay in ms from the shutdown signal (ctrl-c)
  88. until the actual shutdown. Clients need to be
  89. able to get a notification ahead of time. */
  90. /* Rule Handling */
  91. UA_RuleHandling verifyRequestTimestamp; /* Verify that the server sends a
  92. * timestamp in the request header */
  93. /* Custom DataTypes. Attention! Custom datatypes are not cleaned up together
  94. * with the configuration. So it is possible to allocate them on ROM. */
  95. const UA_DataTypeArray *customDataTypes;
  96. /**
  97. * .. note:: See the section on :ref:`generic-types`. Examples for working
  98. * with custom data types are provided in
  99. * ``/examples/custom_datatype/``. */
  100. /* Networking */
  101. size_t networkLayersSize;
  102. UA_ServerNetworkLayer *networkLayers;
  103. UA_String customHostname;
  104. #ifdef UA_ENABLE_PUBSUB
  105. /*PubSub network layer */
  106. size_t pubsubTransportLayersSize;
  107. UA_PubSubTransportLayer *pubsubTransportLayers;
  108. #endif
  109. /* Available security policies */
  110. size_t securityPoliciesSize;
  111. UA_SecurityPolicy* securityPolicies;
  112. /* Available endpoints */
  113. size_t endpointsSize;
  114. UA_EndpointDescription *endpoints;
  115. /* Node Lifecycle callbacks */
  116. UA_GlobalNodeLifecycle nodeLifecycle;
  117. /**
  118. * .. note:: See the section for :ref:`node lifecycle
  119. * handling<node-lifecycle>`. */
  120. /* Access Control */
  121. UA_AccessControl accessControl;
  122. /**
  123. * .. note:: See the section for :ref:`access-control
  124. * handling<access-control>`. */
  125. /* Async Operations */
  126. #if UA_MULTITHREADING >= 100
  127. UA_Double asyncOperationTimeout; /* in ms, 0 => unlimited */
  128. size_t maxAsyncOperationQueueSize; /* 0 => unlimited */
  129. UA_Double asyncCallRequestTimeout UA_DEPRECATED; /* in ms, 0 => unlimited */
  130. /* Notify workers when an async operation was enqueued */
  131. UA_Server_AsyncOperationNotifyCallback asyncOperationNotifyCallback;
  132. #endif
  133. /**
  134. * .. note:: See the section for :ref:`async
  135. * operations<async-operations>`. */
  136. /* Nodestore */
  137. UA_Nodestore nodestore;
  138. /* Certificate Verification */
  139. UA_CertificateVerification certificateVerification;
  140. /* Relax constraints for the InformationModel */
  141. UA_Boolean relaxEmptyValueConstraint; /* Nominally, only variables with data
  142. * type BaseDataType can have an empty
  143. * value. */
  144. /* Limits for SecureChannels */
  145. UA_UInt16 maxSecureChannels;
  146. UA_UInt32 maxSecurityTokenLifetime; /* in ms */
  147. /* Limits for Sessions */
  148. UA_UInt16 maxSessions;
  149. UA_Double maxSessionTimeout; /* in ms */
  150. /* Operation limits */
  151. UA_UInt32 maxNodesPerRead;
  152. UA_UInt32 maxNodesPerWrite;
  153. UA_UInt32 maxNodesPerMethodCall;
  154. UA_UInt32 maxNodesPerBrowse;
  155. UA_UInt32 maxNodesPerRegisterNodes;
  156. UA_UInt32 maxNodesPerTranslateBrowsePathsToNodeIds;
  157. UA_UInt32 maxNodesPerNodeManagement;
  158. UA_UInt32 maxMonitoredItemsPerCall;
  159. /* Limits for Requests */
  160. UA_UInt32 maxReferencesPerNode;
  161. /* Limits for Subscriptions */
  162. UA_UInt32 maxSubscriptions;
  163. UA_UInt32 maxSubscriptionsPerSession;
  164. UA_DurationRange publishingIntervalLimits; /* in ms (must not be less than 5) */
  165. UA_UInt32Range lifeTimeCountLimits;
  166. UA_UInt32Range keepAliveCountLimits;
  167. UA_UInt32 maxNotificationsPerPublish;
  168. UA_Boolean enableRetransmissionQueue;
  169. UA_UInt32 maxRetransmissionQueueSize; /* 0 -> unlimited size */
  170. #ifdef UA_ENABLE_SUBSCRIPTIONS_EVENTS
  171. UA_UInt32 maxEventsPerNode; /* 0 -> unlimited size */
  172. #endif
  173. /* Limits for MonitoredItems */
  174. UA_UInt32 maxMonitoredItems;
  175. UA_UInt32 maxMonitoredItemsPerSubscription;
  176. UA_DurationRange samplingIntervalLimits; /* in ms (must not be less than 5) */
  177. UA_UInt32Range queueSizeLimits; /* Negotiated with the client */
  178. /* Limits for PublishRequests */
  179. UA_UInt32 maxPublishReqPerSession;
  180. /* Discovery */
  181. #ifdef UA_ENABLE_DISCOVERY
  182. UA_ServerConfig_Discovery discovery;
  183. #endif
  184. #ifdef UA_ENABLE_SUBSCRIPTIONS
  185. /* Register MonitoredItem in Userland
  186. *
  187. * @param server Allows the access to the server object
  188. * @param sessionId The session id, represented as an node id
  189. * @param sessionContext An optional pointer to user-defined data for the specific data source
  190. * @param nodeid Id of the node in question
  191. * @param nodeidContext An optional pointer to user-defined data, associated
  192. * with the node in the nodestore. Note that, if the node has already been removed,
  193. * this value contains a NULL pointer.
  194. * @param attributeId Identifies which attribute (value, data type etc.) is monitored
  195. * @param removed Determines if the MonitoredItem was removed or created. */
  196. void (*monitoredItemRegisterCallback)(UA_Server *server,
  197. const UA_NodeId *sessionId, void *sessionContext,
  198. const UA_NodeId *nodeId, void *nodeContext,
  199. UA_UInt32 attibuteId, UA_Boolean removed);
  200. #endif
  201. /* Historical Access */
  202. #ifdef UA_ENABLE_HISTORIZING
  203. UA_HistoryDatabase historyDatabase;
  204. UA_Boolean accessHistoryDataCapability;
  205. UA_UInt32 maxReturnDataValues; /* 0 -> unlimited size */
  206. UA_Boolean accessHistoryEventsCapability;
  207. UA_UInt32 maxReturnEventValues; /* 0 -> unlimited size */
  208. UA_Boolean insertDataCapability;
  209. UA_Boolean insertEventCapability;
  210. UA_Boolean insertAnnotationsCapability;
  211. UA_Boolean replaceDataCapability;
  212. UA_Boolean replaceEventCapability;
  213. UA_Boolean updateDataCapability;
  214. UA_Boolean updateEventCapability;
  215. UA_Boolean deleteRawCapability;
  216. UA_Boolean deleteEventCapability;
  217. UA_Boolean deleteAtTimeDataCapability;
  218. #endif
  219. };
  220. void UA_EXPORT
  221. UA_ServerConfig_clean(UA_ServerConfig *config);
  222. /* Set a custom hostname in server configuration */
  223. UA_EXPORT void
  224. UA_ServerConfig_setCustomHostname(UA_ServerConfig *config,
  225. const UA_String customHostname);
  226. _UA_END_DECLS
  227. #endif /* UA_SERVER_CONFIG_H_ */