server_config.h 9.0 KB

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