ua_server.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. /*
  2. * Copyright (C) 2014 the contributors as stated in the AUTHORS file
  3. *
  4. * This file is part of open62541. open62541 is free software: you can
  5. * redistribute it and/or modify it under the terms of the GNU Lesser General
  6. * Public License, version 3 (as published by the Free Software Foundation) with
  7. * a static linking exception as stated in the LICENSE file provided with
  8. * open62541.
  9. *
  10. * open62541 is distributed in the hope that it will be useful, but WITHOUT ANY
  11. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  13. * details.
  14. */
  15. #ifndef UA_SERVER_H_
  16. #define UA_SERVER_H_
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #include "ua_config.h"
  21. #include "ua_types.h"
  22. #include "ua_types_generated.h"
  23. #include "ua_nodeids.h"
  24. #include "ua_log.h"
  25. #include "ua_job.h"
  26. #include "ua_connection.h"
  27. /*****************/
  28. /* Server Config */
  29. /*****************/
  30. struct UA_ServerNetworkLayer; // forwards declaration
  31. typedef struct UA_ServerNetworkLayer UA_ServerNetworkLayer;
  32. typedef struct {
  33. UA_String username;
  34. UA_String password;
  35. } UA_UsernamePasswordLogin;
  36. typedef struct {
  37. UA_UInt16 nThreads; // only if multithreading is enabled
  38. UA_Logger logger;
  39. UA_BuildInfo buildInfo;
  40. UA_ApplicationDescription applicationDescription;
  41. UA_ByteString serverCertificate;
  42. size_t networkLayersSize;
  43. UA_ServerNetworkLayer *networkLayers;
  44. UA_Boolean enableAnonymousLogin;
  45. UA_Boolean enableUsernamePasswordLogin;
  46. size_t usernamePasswordLoginsSize;
  47. UA_UsernamePasswordLogin usernamePasswordLogins[];
  48. } UA_ServerConfig;
  49. extern UA_EXPORT const UA_ServerConfig UA_ServerConfig_standard;
  50. /*********************************/
  51. /* Initialize and run the server */
  52. /*********************************/
  53. UA_Server UA_EXPORT * UA_Server_new(const UA_ServerConfig config);
  54. void UA_EXPORT UA_Server_delete(UA_Server *server);
  55. /**
  56. * Runs the main loop of the server. In each iteration, this calls into the networklayers to see if
  57. * jobs have arrived and checks if repeated jobs need to be triggered.
  58. */
  59. UA_StatusCode UA_EXPORT UA_Server_run(UA_Server *server, volatile UA_Boolean *running);
  60. /** The prologue part of UA_Server_run (no need to use if you call UA_Server_run) */
  61. UA_StatusCode UA_EXPORT UA_Server_run_startup(UA_Server *server);
  62. /** One iteration of UA_Server_run (no need to use if you call UA_Server_run) */
  63. UA_StatusCode UA_EXPORT UA_Server_run_iterate(UA_Server *server);
  64. /** The epilogue part of UA_Server_run (no need to use if you call UA_Server_run) */
  65. UA_StatusCode UA_EXPORT UA_Server_run_shutdown(UA_Server *server);
  66. /**
  67. * @param server The server object.
  68. * @param job The job that shall be added.
  69. * @param interval The job shall be repeatedly executed with the given interval (in ms). The
  70. * interval must be larger than 5ms. The first execution occurs at now() + interval at the
  71. * latest.
  72. * @param jobId Set to the guid of the repeated job. This can be used to cancel the job later on. If
  73. * the pointer is null, the guid is not set.
  74. * @return Upon success, UA_STATUSCODE_GOOD is returned. An error code otherwise.
  75. */
  76. UA_StatusCode UA_EXPORT UA_Server_addRepeatedJob(UA_Server *server, UA_Job job,
  77. UA_UInt32 interval, UA_Guid *jobId);
  78. /**
  79. * Remove repeated job. The entry will be removed asynchronously during the next iteration of the
  80. * server main loop.
  81. *
  82. * @param server The server object.
  83. * @param jobId The id of the job that shall be removed.
  84. * @return Upon sucess, UA_STATUSCODE_GOOD is returned. An error code otherwise.
  85. */
  86. UA_StatusCode UA_EXPORT UA_Server_removeRepeatedJob(UA_Server *server, UA_Guid jobId);
  87. /** @brief Add a new namespace to the server. Returns the index of the new namespace */
  88. UA_UInt16 UA_EXPORT UA_Server_addNamespace(UA_Server *server, const char* name);
  89. /**
  90. * Interface to the binary network layers. This structure is returned from the
  91. * function that initializes the network layer. The layer is already bound to a
  92. * specific port and listening. The functions in the structure are never called
  93. * in parallel but only sequentially from the server's main loop. So the network
  94. * layer does not need to be thread-safe.
  95. */
  96. struct UA_ServerNetworkLayer {
  97. void *handle; // pointer to internal data
  98. UA_String discoveryUrl;
  99. /**
  100. * Starts listening on the the networklayer.
  101. *
  102. * @param nl The network layer
  103. * @param logger The logger
  104. * @return Returns UA_STATUSCODE_GOOD or an error code.
  105. */
  106. UA_StatusCode (*start)(UA_ServerNetworkLayer *nl, UA_Logger logger);
  107. /**
  108. * Gets called from the main server loop and returns the jobs (accumulated messages and close
  109. * events) for dispatch.
  110. *
  111. * @param nl The network layer
  112. * @param jobs When the returned integer is >0, *jobs points to an array of UA_Job of the
  113. * returned size.
  114. * @param timeout The timeout during which an event must arrive in microseconds
  115. * @return The size of the jobs array. If the result is negative, an error has occurred.
  116. */
  117. size_t (*getJobs)(UA_ServerNetworkLayer *nl, UA_Job **jobs, UA_UInt16 timeout);
  118. /**
  119. * Closes the network connection and returns all the jobs that need to be finished before the
  120. * network layer can be safely deleted.
  121. *
  122. * @param nl The network layer
  123. * @param jobs When the returned integer is >0, jobs points to an array of UA_Job of the
  124. * returned size.
  125. * @return The size of the jobs array. If the result is negative, an error has occurred.
  126. */
  127. size_t (*stop)(UA_ServerNetworkLayer *nl, UA_Job **jobs);
  128. /** Deletes the network content. Call only after stopping. */
  129. void (*deleteMembers)(UA_ServerNetworkLayer *nl);
  130. };
  131. /**********************/
  132. /* Set Node Callbacks */
  133. /**********************/
  134. /**
  135. * Datasources are the interface to local data providers. It is expected that
  136. * the read and release callbacks are implemented. The write callback can be set
  137. * to null. The read callback is set to null will result in a BADINTERNALERROR.
  138. */
  139. typedef struct {
  140. void *handle; ///> A custom pointer to reuse the same datasource functions for multiple sources
  141. /**
  142. * Copies the data from the source into the provided value.
  143. *
  144. * @param handle An optional pointer to user-defined data for the specific data source
  145. * @param nodeid Id of the read node
  146. * @param includeSourceTimeStamp If true, then the datasource is expected to set the source
  147. * timestamp in the returned value
  148. * @param range If not null, then the datasource shall return only a selection of the (nonscalar)
  149. * data. Set UA_STATUSCODE_BADINDEXRANGEINVALID in the value if this does not apply.
  150. * @param value The (non-null) DataValue that is returned to the client. The data source sets the
  151. * read data, the result status and optionally a sourcetimestamp.
  152. * @return Returns a status code for logging. Error codes intended for the original caller are set
  153. * in the value. If an error is returned, then no releasing of the value is done.
  154. */
  155. UA_StatusCode (*read)(void *handle, const UA_NodeId nodeid, UA_Boolean includeSourceTimeStamp,
  156. const UA_NumericRange *range, UA_DataValue *value);
  157. /**
  158. * Write into a data source. The write member of UA_DataSource can be empty if the operation
  159. * is unsupported.
  160. *
  161. * @param handle An optional pointer to user-defined data for the specific data source
  162. * @param nodeid Id of the node being written to
  163. * @param data The data to be written into the data source
  164. * @param range An optional data range. If the data source is scalar or does not support writing
  165. * of ranges, then an error code is returned.
  166. * @return Returns a status code that is returned to the user
  167. */
  168. UA_StatusCode (*write)(void *handle, const UA_NodeId nodeid,
  169. const UA_Variant *data, const UA_NumericRange *range);
  170. } UA_DataSource;
  171. UA_StatusCode UA_EXPORT
  172. UA_Server_setVariableNode_dataSource(UA_Server *server, const UA_NodeId nodeId,
  173. const UA_DataSource dataSource);
  174. /* Value Callbacks can be attach to variable and variable type nodes. If
  175. not-null, they are called before reading and after writing respectively */
  176. typedef struct {
  177. void *handle;
  178. void (*onRead)(void *handle, const UA_NodeId nodeid,
  179. const UA_Variant *data, const UA_NumericRange *range);
  180. void (*onWrite)(void *handle, const UA_NodeId nodeid,
  181. const UA_Variant *data, const UA_NumericRange *range);
  182. } UA_ValueCallback;
  183. UA_StatusCode UA_EXPORT
  184. UA_Server_setVariableNode_valueCallback(UA_Server *server, const UA_NodeId nodeId,
  185. const UA_ValueCallback callback);
  186. /* The lifecycle management allows to track the instantiation and deletion of
  187. object nodes derived from object types. */
  188. typedef struct {
  189. void * (*constructor)(const UA_NodeId instance); ///< Returns the instance handle attached to the node
  190. void (*destructor)(const UA_NodeId instance, void *instanceHandle);
  191. } UA_ObjectLifecycleManagement;
  192. UA_StatusCode UA_EXPORT
  193. UA_Server_setObjectTypeNode_lifecycleManagement(UA_Server *server, UA_NodeId nodeId,
  194. UA_ObjectLifecycleManagement olm);
  195. /* Iterate over all nodes referenced by parentNodeId by calling the callback
  196. function for each child node */
  197. typedef UA_StatusCode (*UA_NodeIteratorCallback)(UA_NodeId childId, UA_Boolean isInverse,
  198. UA_NodeId referenceTypeId, void *handle);
  199. UA_StatusCode UA_EXPORT
  200. UA_Server_forEachChildNodeCall(UA_Server *server, UA_NodeId parentNodeId,
  201. UA_NodeIteratorCallback callback, void *handle);
  202. /*******************/
  203. /* Node Management */
  204. /*******************/
  205. typedef struct UA_InstantiationCallback_s {
  206. UA_StatusCode (*method)(UA_NodeId objectId, UA_NodeId definitionId, void *handle);
  207. void *handle;
  208. } UA_InstantiationCallback;
  209. UA_StatusCode UA_EXPORT
  210. UA_Server_addReference(UA_Server *server, const UA_NodeId sourceId, const UA_NodeId refTypeId,
  211. const UA_ExpandedNodeId targetId, UA_Boolean isForward);
  212. UA_StatusCode UA_EXPORT
  213. UA_Server_deleteNode(UA_Server *server, const UA_NodeId nodeId, UA_Boolean deleteReferences);
  214. UA_StatusCode UA_EXPORT
  215. UA_Server_deleteReference(UA_Server *server, const UA_NodeId sourceNodeId, const UA_NodeId referenceTypeId,
  216. UA_Boolean isForward, const UA_ExpandedNodeId targetNodeId,
  217. UA_Boolean deleteBidirectional);
  218. /* Don't use this function. There are typed versions as inline functions. */
  219. UA_StatusCode UA_EXPORT
  220. __UA_Server_addNode(UA_Server *server, const UA_NodeClass nodeClass, const UA_NodeId requestedNewNodeId,
  221. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  222. const UA_QualifiedName browseName, const UA_NodeId typeDefinition,
  223. const UA_NodeAttributes *attr, const UA_DataType *attributeType,
  224. UA_InstantiationCallback *instantiationCallback, UA_NodeId *outNewNodeId);
  225. static UA_INLINE UA_StatusCode
  226. UA_Server_addVariableNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  227. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  228. const UA_QualifiedName browseName, const UA_NodeId typeDefinition,
  229. const UA_VariableAttributes attr, UA_InstantiationCallback *instantiationCallback, UA_NodeId *outNewNodeId) {
  230. return __UA_Server_addNode(server, UA_NODECLASS_VARIABLE, requestedNewNodeId, parentNodeId,
  231. referenceTypeId, browseName, typeDefinition, (const UA_NodeAttributes*)&attr,
  232. &UA_TYPES[UA_TYPES_VARIABLEATTRIBUTES], instantiationCallback, outNewNodeId); }
  233. static UA_INLINE UA_StatusCode
  234. UA_Server_addVariableTypeNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  235. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  236. const UA_QualifiedName browseName, const UA_VariableTypeAttributes attr,
  237. UA_InstantiationCallback *instantiationCallback, UA_NodeId *outNewNodeId) {
  238. return __UA_Server_addNode(server, UA_NODECLASS_VARIABLETYPE, requestedNewNodeId, parentNodeId,
  239. referenceTypeId, browseName, UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  240. &UA_TYPES[UA_TYPES_VARIABLETYPEATTRIBUTES], instantiationCallback, outNewNodeId); }
  241. static UA_INLINE UA_StatusCode
  242. UA_Server_addObjectNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  243. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  244. const UA_QualifiedName browseName, const UA_NodeId typeDefinition,
  245. const UA_ObjectAttributes attr, UA_InstantiationCallback *instantiationCallback, UA_NodeId *outNewNodeId) {
  246. return __UA_Server_addNode(server, UA_NODECLASS_OBJECT, requestedNewNodeId, parentNodeId,
  247. referenceTypeId, browseName, typeDefinition, (const UA_NodeAttributes*)&attr,
  248. &UA_TYPES[UA_TYPES_OBJECTATTRIBUTES], instantiationCallback, outNewNodeId); }
  249. static UA_INLINE UA_StatusCode
  250. UA_Server_addObjectTypeNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  251. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  252. const UA_QualifiedName browseName, const UA_ObjectTypeAttributes attr,
  253. UA_InstantiationCallback *instantiationCallback, UA_NodeId *outNewNodeId) {
  254. return __UA_Server_addNode(server, UA_NODECLASS_OBJECTTYPE, requestedNewNodeId, parentNodeId,
  255. referenceTypeId, browseName, UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  256. &UA_TYPES[UA_TYPES_OBJECTTYPEATTRIBUTES], instantiationCallback, outNewNodeId); }
  257. static UA_INLINE UA_StatusCode
  258. UA_Server_addViewNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  259. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  260. const UA_QualifiedName browseName, const UA_ViewAttributes attr,
  261. UA_InstantiationCallback *instantiationCallback, UA_NodeId *outNewNodeId) {
  262. return __UA_Server_addNode(server, UA_NODECLASS_VIEW, requestedNewNodeId, parentNodeId,
  263. referenceTypeId, browseName, UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  264. &UA_TYPES[UA_TYPES_VIEWATTRIBUTES], instantiationCallback, outNewNodeId); }
  265. static UA_INLINE UA_StatusCode
  266. UA_Server_addReferenceTypeNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  267. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  268. const UA_QualifiedName browseName, const UA_ReferenceTypeAttributes attr,
  269. UA_InstantiationCallback *instantiationCallback, UA_NodeId *outNewNodeId) {
  270. return __UA_Server_addNode(server, UA_NODECLASS_REFERENCETYPE, requestedNewNodeId, parentNodeId,
  271. referenceTypeId, browseName, UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  272. &UA_TYPES[UA_TYPES_REFERENCETYPEATTRIBUTES], instantiationCallback, outNewNodeId); }
  273. static UA_INLINE UA_StatusCode
  274. UA_Server_addDataTypeNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  275. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  276. const UA_QualifiedName browseName, const UA_DataTypeAttributes attr,
  277. UA_InstantiationCallback *instantiationCallback, UA_NodeId *outNewNodeId) {
  278. return __UA_Server_addNode(server, UA_NODECLASS_DATATYPE, requestedNewNodeId, parentNodeId,
  279. referenceTypeId, browseName, UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  280. &UA_TYPES[UA_TYPES_DATATYPEATTRIBUTES], instantiationCallback, outNewNodeId); }
  281. UA_StatusCode UA_EXPORT
  282. UA_Server_addDataSourceVariableNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  283. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  284. const UA_QualifiedName browseName, const UA_NodeId typeDefinition,
  285. const UA_VariableAttributes attr, const UA_DataSource dataSource,
  286. UA_NodeId *outNewNodeId);
  287. typedef UA_StatusCode (*UA_MethodCallback)(void *methodHandle, const UA_NodeId objectId,
  288. size_t inputSize, const UA_Variant *input,
  289. size_t outputSize, UA_Variant *output);
  290. #ifdef UA_ENABLE_METHODCALLS
  291. UA_StatusCode UA_EXPORT
  292. UA_Server_addMethodNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  293. const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId,
  294. const UA_QualifiedName browseName, const UA_MethodAttributes attr,
  295. UA_MethodCallback method, void *handle,
  296. size_t inputArgumentsSize, const UA_Argument* inputArguments,
  297. size_t outputArgumentsSize, const UA_Argument* outputArguments,
  298. UA_NodeId *outNewNodeId);
  299. #endif
  300. /*************************/
  301. /* Write Node Attributes */
  302. /*************************/
  303. /* The following node attributes cannot be written
  304. - NodeClass
  305. - NodeId
  306. - Symmetric
  307. - ContainsNoLoop
  308. The following attributes cannot be written from the server, as there is no "user" in the server
  309. - UserWriteMask
  310. - UserAccessLevel
  311. - UserExecutable
  312. The following attributes are currently taken from the value variant:
  313. TODO: Handle them independent from the variable, ensure that the implicit constraints hold
  314. - DataType
  315. - ValueRank
  316. - ArrayDimensions
  317. - Historizing is currently unsupported
  318. */
  319. /* Don't use this function. There are typed versions with no additional overhead. */
  320. UA_StatusCode UA_EXPORT
  321. __UA_Server_write(UA_Server *server, const UA_NodeId *nodeId, const UA_AttributeId attributeId,
  322. const UA_DataType *type, const void *value);
  323. static UA_INLINE UA_StatusCode
  324. UA_Server_writeBrowseName(UA_Server *server, const UA_NodeId nodeId, const UA_QualifiedName browseName) {
  325. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_BROWSENAME, &UA_TYPES[UA_TYPES_QUALIFIEDNAME], &browseName); }
  326. static UA_INLINE UA_StatusCode
  327. UA_Server_writeDisplayName(UA_Server *server, const UA_NodeId nodeId, const UA_LocalizedText displayName) {
  328. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_DISPLAYNAME, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT], &displayName); }
  329. static UA_INLINE UA_StatusCode
  330. UA_Server_writeDescription(UA_Server *server, const UA_NodeId nodeId, const UA_LocalizedText description) {
  331. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_DESCRIPTION, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT], &description); }
  332. static UA_INLINE UA_StatusCode
  333. UA_Server_writeWriteMask(UA_Server *server, const UA_NodeId nodeId, const UA_UInt32 writeMask) {
  334. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_WRITEMASK, &UA_TYPES[UA_TYPES_UINT32], &writeMask); }
  335. static UA_INLINE UA_StatusCode
  336. UA_Server_writeIsAbstract(UA_Server *server, const UA_NodeId nodeId, const UA_Boolean isAbstract) {
  337. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_ISABSTRACT, &UA_TYPES[UA_TYPES_BOOLEAN], &isAbstract); }
  338. static UA_INLINE UA_StatusCode
  339. UA_Server_writeInverseName(UA_Server *server, const UA_NodeId nodeId, const UA_LocalizedText inverseName) {
  340. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_INVERSENAME, &UA_TYPES[UA_TYPES_LOCALIZEDTEXT], &inverseName); }
  341. static UA_INLINE UA_StatusCode
  342. UA_Server_writeEventNotifier(UA_Server *server, const UA_NodeId nodeId, const UA_Byte eventNotifier) {
  343. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_EVENTNOTIFIER, &UA_TYPES[UA_TYPES_BYTE], &eventNotifier); }
  344. static UA_INLINE UA_StatusCode
  345. UA_Server_writeValue(UA_Server *server, const UA_NodeId nodeId, const UA_Variant value) {
  346. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_VALUE, &UA_TYPES[UA_TYPES_VARIANT], &value); }
  347. static UA_INLINE UA_StatusCode
  348. UA_Server_writeAccessLevel(UA_Server *server, const UA_NodeId nodeId, const UA_UInt32 accessLevel) {
  349. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_ACCESSLEVEL, &UA_TYPES[UA_TYPES_UINT32], &accessLevel); }
  350. static UA_INLINE UA_StatusCode
  351. UA_Server_writeMinimumSamplingInterval(UA_Server *server, const UA_NodeId nodeId, const UA_Double miniumSamplingInterval) {
  352. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL, &UA_TYPES[UA_TYPES_DOUBLE], &miniumSamplingInterval); }
  353. static UA_INLINE UA_StatusCode
  354. UA_Server_writeExecutable(UA_Server *server, const UA_NodeId nodeId, const UA_Boolean executable) {
  355. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_EXECUTABLE, &UA_TYPES[UA_TYPES_BOOLEAN], &executable); }
  356. /************************/
  357. /* Read Node Attributes */
  358. /************************/
  359. /* The following attributes cannot be read, since the "admin" user always has all rights.
  360. - UserWriteMask
  361. - UserAccessLevel
  362. - UserExecutable
  363. */
  364. /* Don't use this function. There are typed versions for every supported attribute. */
  365. UA_StatusCode UA_EXPORT
  366. __UA_Server_read(UA_Server *server, const UA_NodeId *nodeId, UA_AttributeId attributeId, void *v);
  367. static UA_INLINE UA_StatusCode
  368. UA_Server_readNodeId(UA_Server *server, const UA_NodeId nodeId, UA_NodeId *outNodeId) {
  369. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_NODEID, outNodeId); }
  370. static UA_INLINE UA_StatusCode
  371. UA_Server_readNodeClass(UA_Server *server, const UA_NodeId nodeId, UA_NodeClass *outNodeClass) {
  372. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_NODECLASS, outNodeClass); }
  373. static UA_INLINE UA_StatusCode
  374. UA_Server_readBrowseName(UA_Server *server, const UA_NodeId nodeId, UA_QualifiedName *outBrowseName) {
  375. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_BROWSENAME, outBrowseName); }
  376. static UA_INLINE UA_StatusCode
  377. UA_Server_readDisplayName(UA_Server *server, const UA_NodeId nodeId, UA_LocalizedText *outDisplayName) {
  378. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_DISPLAYNAME, outDisplayName); }
  379. static UA_INLINE UA_StatusCode
  380. UA_Server_readDescription(UA_Server *server, const UA_NodeId nodeId, UA_LocalizedText *outDescription) {
  381. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_DESCRIPTION, outDescription); }
  382. static UA_INLINE UA_StatusCode
  383. UA_Server_readWriteMask(UA_Server *server, const UA_NodeId nodeId, UA_UInt32 *outWriteMask) {
  384. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_WRITEMASK, outWriteMask); }
  385. static UA_INLINE UA_StatusCode
  386. UA_Server_readIsAbstract(UA_Server *server, const UA_NodeId nodeId, UA_Boolean *outIsAbstract) {
  387. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_ISABSTRACT, outIsAbstract); }
  388. static UA_INLINE UA_StatusCode
  389. UA_Server_readSymmetric(UA_Server *server, const UA_NodeId nodeId, UA_Boolean *outSymmetric) {
  390. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_SYMMETRIC, outSymmetric); }
  391. static UA_INLINE UA_StatusCode
  392. UA_Server_readInverseName(UA_Server *server, const UA_NodeId nodeId, UA_LocalizedText *outInverseName) {
  393. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_INVERSENAME, outInverseName); }
  394. static UA_INLINE UA_StatusCode
  395. UA_Server_readContainsNoLoop(UA_Server *server, const UA_NodeId nodeId, UA_Boolean *outContainsNoLoops) {
  396. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_CONTAINSNOLOOPS, outContainsNoLoops); }
  397. static UA_INLINE UA_StatusCode
  398. UA_Server_readEventNotifier(UA_Server *server, const UA_NodeId nodeId, UA_Byte *outEventNotifier) {
  399. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_EVENTNOTIFIER, outEventNotifier); }
  400. static UA_INLINE UA_StatusCode
  401. UA_Server_readValue(UA_Server *server, const UA_NodeId nodeId, UA_Variant *outValue) {
  402. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_VALUE, outValue); }
  403. static UA_INLINE UA_StatusCode
  404. UA_Server_readDataType(UA_Server *server, const UA_NodeId nodeId, UA_NodeId *outDataType) {
  405. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_DATATYPE, outDataType); }
  406. static UA_INLINE UA_StatusCode
  407. UA_Server_readValueRank(UA_Server *server, const UA_NodeId nodeId, UA_Int32 *outValueRank) {
  408. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_VALUERANK, outValueRank); }
  409. /* Returns a variant with an int32 array */
  410. static UA_INLINE UA_StatusCode
  411. UA_Server_readArrayDimensions(UA_Server *server, const UA_NodeId nodeId, UA_Variant *outArrayDimensions) {
  412. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_ARRAYDIMENSIONS, outArrayDimensions); }
  413. static UA_INLINE UA_StatusCode
  414. UA_Server_readAccessLevel(UA_Server *server, const UA_NodeId nodeId, UA_UInt32 *outAccessLevel) {
  415. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_ACCESSLEVEL, outAccessLevel); }
  416. static UA_INLINE UA_StatusCode
  417. UA_Server_readMinimumSamplingInterval(UA_Server *server, const UA_NodeId nodeId, UA_Double *outMinimumSamplingInterval) {
  418. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL, outMinimumSamplingInterval); }
  419. static UA_INLINE UA_StatusCode
  420. UA_Server_readHistorizing(UA_Server *server, const UA_NodeId nodeId, UA_Boolean *outHistorizing) {
  421. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_HISTORIZING, outHistorizing); }
  422. static UA_INLINE UA_StatusCode
  423. UA_Server_readExecutable(UA_Server *server, const UA_NodeId nodeId, UA_Boolean *outExecutable) {
  424. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_EXECUTABLE, outExecutable); }
  425. /****************/
  426. /* Browse Nodes */
  427. /****************/
  428. UA_BrowseResult UA_EXPORT UA_Server_browse(UA_Server *server, UA_UInt32 maxrefs, const UA_BrowseDescription *descr);
  429. UA_BrowseResult UA_Server_browseNext(UA_Server *server, UA_Boolean releaseContinuationPoint, const UA_ByteString *continuationPoint);
  430. /***************/
  431. /* Call Method */
  432. /***************/
  433. #ifdef UA_ENABLE_METHODCALLS
  434. UA_CallMethodResult UA_EXPORT UA_Server_call(UA_Server *server, const UA_CallMethodRequest *request);
  435. #endif
  436. #ifdef __cplusplus
  437. }
  438. #endif
  439. #endif /* UA_SERVER_H_ */