server_config.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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. struct UA_ServerConfig {
  71. UA_UInt16 nThreads; /* only if multithreading is enabled */
  72. UA_Logger logger;
  73. /* Server Description */
  74. UA_BuildInfo buildInfo;
  75. UA_ApplicationDescription applicationDescription;
  76. UA_ByteString serverCertificate;
  77. /* Rule Handling */
  78. UA_RuleHandling verifyRequestTimestamp; /* Verify that the server sends a
  79. * timestamp in the request header */
  80. /* Custom DataTypes. Attention! Custom datatypes are not cleaned up together
  81. * with the configuration. So it is possible to allocate them on ROM. */
  82. const UA_DataTypeArray *customDataTypes;
  83. /**
  84. * .. note:: See the section on :ref:`generic-types`. Examples for working
  85. * with custom data types are provided in
  86. * ``/examples/custom_datatype/``. */
  87. /* Networking */
  88. size_t networkLayersSize;
  89. UA_ServerNetworkLayer *networkLayers;
  90. UA_String customHostname;
  91. #ifdef UA_ENABLE_PUBSUB
  92. /*PubSub network layer */
  93. size_t pubsubTransportLayersSize;
  94. UA_PubSubTransportLayer *pubsubTransportLayers;
  95. #endif
  96. /* Available security policies */
  97. size_t securityPoliciesSize;
  98. UA_SecurityPolicy* securityPolicies;
  99. /* Available endpoints */
  100. size_t endpointsSize;
  101. UA_EndpointDescription *endpoints;
  102. /* Node Lifecycle callbacks */
  103. UA_GlobalNodeLifecycle nodeLifecycle;
  104. /**
  105. * .. note:: See the section for :ref:`node lifecycle
  106. * handling<node-lifecycle>`. */
  107. /* Access Control */
  108. UA_AccessControl accessControl;
  109. /**
  110. * .. note:: See the section for :ref:`access-control
  111. * handling<access-control>`. */
  112. /* Certificate Verification */
  113. UA_CertificateVerification certificateVerification;
  114. /* Relax constraints for the InformationModel */
  115. UA_Boolean relaxEmptyValueConstraint; /* Nominally, only variables with data
  116. * type BaseDataType can have an empty
  117. * value. */
  118. /* Limits for SecureChannels */
  119. UA_UInt16 maxSecureChannels;
  120. UA_UInt32 maxSecurityTokenLifetime; /* in ms */
  121. /* Limits for Sessions */
  122. UA_UInt16 maxSessions;
  123. UA_Double maxSessionTimeout; /* in ms */
  124. /* Operation limits */
  125. UA_UInt32 maxNodesPerRead;
  126. UA_UInt32 maxNodesPerWrite;
  127. UA_UInt32 maxNodesPerMethodCall;
  128. UA_UInt32 maxNodesPerBrowse;
  129. UA_UInt32 maxNodesPerRegisterNodes;
  130. UA_UInt32 maxNodesPerTranslateBrowsePathsToNodeIds;
  131. UA_UInt32 maxNodesPerNodeManagement;
  132. UA_UInt32 maxMonitoredItemsPerCall;
  133. /* Limits for Requests */
  134. UA_UInt32 maxReferencesPerNode;
  135. /* Limits for Subscriptions */
  136. UA_UInt32 maxSubscriptions;
  137. UA_UInt32 maxSubscriptionsPerSession;
  138. UA_DurationRange publishingIntervalLimits; /* in ms (must not be less than 5) */
  139. UA_UInt32Range lifeTimeCountLimits;
  140. UA_UInt32Range keepAliveCountLimits;
  141. UA_UInt32 maxNotificationsPerPublish;
  142. UA_Boolean enableRetransmissionQueue;
  143. UA_UInt32 maxRetransmissionQueueSize; /* 0 -> unlimited size */
  144. #ifdef UA_ENABLE_SUBSCRIPTIONS_EVENTS
  145. UA_UInt32 maxEventsPerNode; /* 0 -> unlimited size */
  146. #endif
  147. /* Limits for MonitoredItems */
  148. UA_UInt32 maxMonitoredItems;
  149. UA_UInt32 maxMonitoredItemsPerSubscription;
  150. UA_DurationRange samplingIntervalLimits; /* in ms (must not be less than 5) */
  151. UA_UInt32Range queueSizeLimits; /* Negotiated with the client */
  152. /* Limits for PublishRequests */
  153. UA_UInt32 maxPublishReqPerSession;
  154. /* Discovery */
  155. #ifdef UA_ENABLE_DISCOVERY
  156. UA_ServerConfig_Discovery discovery;
  157. #endif
  158. #ifdef UA_ENABLE_SUBSCRIPTIONS
  159. /* Register MonitoredItem in Userland
  160. *
  161. * @param server Allows the access to the server object
  162. * @param sessionId The session id, represented as an node id
  163. * @param sessionContext An optional pointer to user-defined data for the specific data source
  164. * @param nodeid Id of the node in question
  165. * @param nodeidContext An optional pointer to user-defined data, associated
  166. * with the node in the nodestore. Note that, if the node has already been removed,
  167. * this value contains a NULL pointer.
  168. * @param attributeId Identifies which attribute (value, data type etc.) is monitored
  169. * @param removed Determines if the MonitoredItem was removed or created. */
  170. void (*monitoredItemRegisterCallback)(UA_Server *server,
  171. const UA_NodeId *sessionId, void *sessionContext,
  172. const UA_NodeId *nodeId, void *nodeContext,
  173. UA_UInt32 attibuteId, UA_Boolean removed);
  174. #endif
  175. /* Historical Access */
  176. #ifdef UA_ENABLE_HISTORIZING
  177. UA_HistoryDatabase historyDatabase;
  178. UA_Boolean accessHistoryDataCapability;
  179. UA_UInt32 maxReturnDataValues; /* 0 -> unlimited size */
  180. UA_Boolean accessHistoryEventsCapability;
  181. UA_UInt32 maxReturnEventValues; /* 0 -> unlimited size */
  182. UA_Boolean insertDataCapability;
  183. UA_Boolean insertEventCapability;
  184. UA_Boolean insertAnnotationsCapability;
  185. UA_Boolean replaceDataCapability;
  186. UA_Boolean replaceEventCapability;
  187. UA_Boolean updateDataCapability;
  188. UA_Boolean updateEventCapability;
  189. UA_Boolean deleteRawCapability;
  190. UA_Boolean deleteEventCapability;
  191. UA_Boolean deleteAtTimeDataCapability;
  192. #endif
  193. };
  194. void UA_EXPORT
  195. UA_ServerConfig_clean(UA_ServerConfig *config);
  196. /* Set a custom hostname in server configuration */
  197. UA_EXPORT void
  198. UA_ServerConfig_setCustomHostname(UA_ServerConfig *config,
  199. const UA_String customHostname);
  200. _UA_END_DECLS
  201. #endif /* UA_SERVER_CONFIG_H_ */