ua_server.h 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053
  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. #ifndef UA_SERVER_H_
  5. #define UA_SERVER_H_
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #include "ua_types.h"
  10. #include "ua_types_generated.h"
  11. #include "ua_types_generated_handling.h"
  12. #include "ua_plugin_log.h"
  13. #include "ua_plugin_network.h"
  14. #include "ua_plugin_access_control.h"
  15. #include "ua_plugin_securitypolicy.h"
  16. /**
  17. * .. _server:
  18. *
  19. * Server
  20. * ======
  21. *
  22. * Server Configuration
  23. * --------------------
  24. * The configuration structure is passed to the server during initialization. */
  25. typedef struct {
  26. UA_UInt32 min;
  27. UA_UInt32 max;
  28. } UA_UInt32Range;
  29. typedef struct {
  30. UA_Double min;
  31. UA_Double max;
  32. } UA_DoubleRange;
  33. typedef struct {
  34. UA_UInt16 nThreads; /* only if multithreading is enabled */
  35. UA_Logger logger;
  36. /* Server Description */
  37. UA_BuildInfo buildInfo;
  38. UA_ApplicationDescription applicationDescription;
  39. #ifdef UA_ENABLE_DISCOVERY
  40. UA_String mdnsServerName;
  41. size_t serverCapabilitiesSize;
  42. UA_String *serverCapabilities;
  43. #endif
  44. /* Custom DataTypes */
  45. size_t customDataTypesSize;
  46. UA_DataType *customDataTypes;
  47. /* Networking */
  48. size_t networkLayersSize;
  49. UA_ServerNetworkLayer *networkLayers;
  50. /* Available endpoints */
  51. UA_Endpoints endpoints;
  52. /* Access Control */
  53. UA_AccessControl accessControl;
  54. /* Limits for SecureChannels */
  55. UA_UInt16 maxSecureChannels;
  56. UA_UInt32 maxSecurityTokenLifetime; /* in ms */
  57. /* Limits for Sessions */
  58. UA_UInt16 maxSessions;
  59. UA_Double maxSessionTimeout; /* in ms */
  60. /* Limits for Subscriptions */
  61. UA_DoubleRange publishingIntervalLimits;
  62. UA_UInt32Range lifeTimeCountLimits;
  63. UA_UInt32Range keepAliveCountLimits;
  64. UA_UInt32 maxNotificationsPerPublish;
  65. UA_UInt32 maxRetransmissionQueueSize; /* 0 -> unlimited size */
  66. /* Limits for MonitoredItems */
  67. UA_DoubleRange samplingIntervalLimits;
  68. UA_UInt32Range queueSizeLimits; /* Negotiated with the client */
  69. /* Discovery */
  70. #ifdef UA_ENABLE_DISCOVERY
  71. /* Timeout in seconds when to automatically remove a registered server from
  72. * the list, if it doesn't re-register within the given time frame. A value
  73. * of 0 disables automatic removal. Default is 60 Minutes (60*60). Must be
  74. * bigger than 10 seconds, because cleanup is only triggered approximately
  75. * ervery 10 seconds. The server will still be removed depending on the
  76. * state of the semaphore file. */
  77. UA_UInt32 discoveryCleanupTimeout;
  78. #endif
  79. } UA_ServerConfig;
  80. /**
  81. * .. _server-lifecycle:
  82. *
  83. * Server Lifecycle
  84. * ---------------- */
  85. UA_Server UA_EXPORT * UA_Server_new(const UA_ServerConfig *config);
  86. void UA_EXPORT UA_Server_delete(UA_Server *server);
  87. /* Runs the main loop of the server. In each iteration, this calls into the
  88. * networklayers to see if messages have arrived.
  89. *
  90. * @param server The server object.
  91. * @param running The loop is run as long as *running is true.
  92. * Otherwise, the server shuts down.
  93. * @return Returns the statuscode of the UA_Server_run_shutdown method */
  94. UA_StatusCode UA_EXPORT
  95. UA_Server_run(UA_Server *server, volatile UA_Boolean *running);
  96. /* The prologue part of UA_Server_run (no need to use if you call
  97. * UA_Server_run) */
  98. UA_StatusCode UA_EXPORT UA_Server_run_startup(UA_Server *server);
  99. /* Executes a single iteration of the server's main loop.
  100. *
  101. * @param server The server object.
  102. * @param waitInternal Should we wait for messages in the networklayer?
  103. * Otherwise, the timouts for the networklayers are set to zero.
  104. * The default max wait time is 50millisec.
  105. * @return Returns how long we can wait until the next scheduled
  106. * callback (in ms) */
  107. UA_UInt16 UA_EXPORT
  108. UA_Server_run_iterate(UA_Server *server, UA_Boolean waitInternal);
  109. /* The epilogue part of UA_Server_run (no need to use if you call
  110. * UA_Server_run) */
  111. UA_StatusCode UA_EXPORT UA_Server_run_shutdown(UA_Server *server);
  112. /**
  113. * Repeated Callbacks
  114. * ------------------ */
  115. typedef void (*UA_ServerCallback)(UA_Server *server, void *data);
  116. /* Add a callback for cyclic repetition to the server.
  117. *
  118. * @param server The server object.
  119. * @param callback The callback that shall be added.
  120. * @param interval The callback shall be repeatedly executed with the given interval
  121. * (in ms). The interval must be larger than 5ms. The first execution
  122. * occurs at now() + interval at the latest.
  123. * @param callbackId Set to the identifier of the repeated callback . This can be used to cancel
  124. * the callback later on. If the pointer is null, the identifier is not set.
  125. * @return Upon success, UA_STATUSCODE_GOOD is returned.
  126. * An error code otherwise. */
  127. UA_StatusCode UA_EXPORT
  128. UA_Server_addRepeatedCallback(UA_Server *server, UA_ServerCallback callback,
  129. void *data, UA_UInt32 interval, UA_UInt64 *callbackId);
  130. UA_StatusCode UA_EXPORT
  131. UA_Server_changeRepeatedCallbackInterval(UA_Server *server, UA_UInt64 callbackId,
  132. UA_UInt32 interval);
  133. /* Remove a repeated callback.
  134. *
  135. * @param server The server object.
  136. * @param callbackId The id of the callback that shall be removed.
  137. * @return Upon sucess, UA_STATUSCODE_GOOD is returned.
  138. * An error code otherwise. */
  139. UA_StatusCode UA_EXPORT
  140. UA_Server_removeRepeatedCallback(UA_Server *server, UA_UInt64 callbackId);
  141. /**
  142. * Reading and Writing Node Attributes
  143. * -----------------------------------
  144. * The functions for reading and writing node attributes call the regular read
  145. * and write service in the background that are also used over the network.
  146. *
  147. * The following attributes cannot be read, since the local "admin" user always
  148. * has full rights.
  149. *
  150. * - UserWriteMask
  151. * - UserAccessLevel
  152. * - UserExecutable */
  153. /* Read an attribute of a node. The specialized functions below provide a more
  154. * concise syntax.
  155. *
  156. * @param server The server object.
  157. * @param item ReadValueIds contain the NodeId of the target node, the id of the
  158. * attribute to read and (optionally) an index range to read parts
  159. * of an array only. See the section on NumericRange for the format
  160. * used for array ranges.
  161. * @param timestamps Which timestamps to return for the attribute.
  162. * @return Returns a DataValue that contains either an error code, or a variant
  163. * with the attribute value and the timestamps. */
  164. UA_DataValue UA_EXPORT
  165. UA_Server_read(UA_Server *server, const UA_ReadValueId *item,
  166. UA_TimestampsToReturn timestamps);
  167. /* Don't use this function. There are typed versions for every supported
  168. * attribute. */
  169. UA_StatusCode UA_EXPORT
  170. __UA_Server_read(UA_Server *server, const UA_NodeId *nodeId,
  171. UA_AttributeId attributeId, void *v);
  172. static UA_INLINE UA_StatusCode
  173. UA_Server_readNodeId(UA_Server *server, const UA_NodeId nodeId,
  174. UA_NodeId *outNodeId) {
  175. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_NODEID, outNodeId);
  176. }
  177. static UA_INLINE UA_StatusCode
  178. UA_Server_readNodeClass(UA_Server *server, const UA_NodeId nodeId,
  179. UA_NodeClass *outNodeClass) {
  180. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_NODECLASS,
  181. outNodeClass);
  182. }
  183. static UA_INLINE UA_StatusCode
  184. UA_Server_readBrowseName(UA_Server *server, const UA_NodeId nodeId,
  185. UA_QualifiedName *outBrowseName) {
  186. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_BROWSENAME,
  187. outBrowseName);
  188. }
  189. static UA_INLINE UA_StatusCode
  190. UA_Server_readDisplayName(UA_Server *server, const UA_NodeId nodeId,
  191. UA_LocalizedText *outDisplayName) {
  192. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_DISPLAYNAME,
  193. outDisplayName);
  194. }
  195. static UA_INLINE UA_StatusCode
  196. UA_Server_readDescription(UA_Server *server, const UA_NodeId nodeId,
  197. UA_LocalizedText *outDescription) {
  198. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_DESCRIPTION,
  199. outDescription);
  200. }
  201. static UA_INLINE UA_StatusCode
  202. UA_Server_readWriteMask(UA_Server *server, const UA_NodeId nodeId,
  203. UA_UInt32 *outWriteMask) {
  204. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_WRITEMASK,
  205. outWriteMask);
  206. }
  207. static UA_INLINE UA_StatusCode
  208. UA_Server_readIsAbstract(UA_Server *server, const UA_NodeId nodeId,
  209. UA_Boolean *outIsAbstract) {
  210. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_ISABSTRACT,
  211. outIsAbstract);
  212. }
  213. static UA_INLINE UA_StatusCode
  214. UA_Server_readSymmetric(UA_Server *server, const UA_NodeId nodeId,
  215. UA_Boolean *outSymmetric) {
  216. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_SYMMETRIC,
  217. outSymmetric);
  218. }
  219. static UA_INLINE UA_StatusCode
  220. UA_Server_readInverseName(UA_Server *server, const UA_NodeId nodeId,
  221. UA_LocalizedText *outInverseName) {
  222. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_INVERSENAME,
  223. outInverseName);
  224. }
  225. static UA_INLINE UA_StatusCode
  226. UA_Server_readContainsNoLoop(UA_Server *server, const UA_NodeId nodeId,
  227. UA_Boolean *outContainsNoLoops) {
  228. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_CONTAINSNOLOOPS,
  229. outContainsNoLoops);
  230. }
  231. static UA_INLINE UA_StatusCode
  232. UA_Server_readEventNotifier(UA_Server *server, const UA_NodeId nodeId,
  233. UA_Byte *outEventNotifier) {
  234. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_EVENTNOTIFIER,
  235. outEventNotifier);
  236. }
  237. static UA_INLINE UA_StatusCode
  238. UA_Server_readValue(UA_Server *server, const UA_NodeId nodeId,
  239. UA_Variant *outValue) {
  240. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_VALUE, outValue);
  241. }
  242. static UA_INLINE UA_StatusCode
  243. UA_Server_readDataType(UA_Server *server, const UA_NodeId nodeId,
  244. UA_NodeId *outDataType) {
  245. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_DATATYPE,
  246. outDataType);
  247. }
  248. static UA_INLINE UA_StatusCode
  249. UA_Server_readValueRank(UA_Server *server, const UA_NodeId nodeId,
  250. UA_Int32 *outValueRank) {
  251. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_VALUERANK,
  252. outValueRank);
  253. }
  254. /* Returns a variant with an int32 array */
  255. static UA_INLINE UA_StatusCode
  256. UA_Server_readArrayDimensions(UA_Server *server, const UA_NodeId nodeId,
  257. UA_Variant *outArrayDimensions) {
  258. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_ARRAYDIMENSIONS,
  259. outArrayDimensions);
  260. }
  261. static UA_INLINE UA_StatusCode
  262. UA_Server_readAccessLevel(UA_Server *server, const UA_NodeId nodeId,
  263. UA_Byte *outAccessLevel) {
  264. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_ACCESSLEVEL,
  265. outAccessLevel);
  266. }
  267. static UA_INLINE UA_StatusCode
  268. UA_Server_readMinimumSamplingInterval(UA_Server *server, const UA_NodeId nodeId,
  269. UA_Double *outMinimumSamplingInterval) {
  270. return __UA_Server_read(server, &nodeId,
  271. UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL,
  272. outMinimumSamplingInterval);
  273. }
  274. static UA_INLINE UA_StatusCode
  275. UA_Server_readHistorizing(UA_Server *server, const UA_NodeId nodeId,
  276. UA_Boolean *outHistorizing) {
  277. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_HISTORIZING,
  278. outHistorizing);
  279. }
  280. static UA_INLINE UA_StatusCode
  281. UA_Server_readExecutable(UA_Server *server, const UA_NodeId nodeId,
  282. UA_Boolean *outExecutable) {
  283. return __UA_Server_read(server, &nodeId, UA_ATTRIBUTEID_EXECUTABLE,
  284. outExecutable);
  285. }
  286. /**
  287. * The following node attributes cannot be changed once a node has been created:
  288. *
  289. * - NodeClass
  290. * - NodeId
  291. * - Symmetric
  292. * - ContainsNoLoop
  293. *
  294. * The following attributes cannot be written from the server, as they are
  295. * specific to the different users and set by the access control callback:
  296. *
  297. * - UserWriteMask
  298. * - UserAccessLevel
  299. * - UserExecutable
  300. *
  301. * Historizing is currently unsupported */
  302. /* Overwrite an attribute of a node. The specialized functions below provide a
  303. * more concise syntax.
  304. *
  305. * @param server The server object.
  306. * @param value WriteValues contain the NodeId of the target node, the id of the
  307. * attribute to overwritten, the actual value and (optionally) an
  308. * index range to replace parts of an array only. of an array only.
  309. * See the section on NumericRange for the format used for array
  310. * ranges.
  311. * @return Returns a status code. */
  312. UA_StatusCode UA_EXPORT
  313. UA_Server_write(UA_Server *server, const UA_WriteValue *value);
  314. /* Don't use this function. There are typed versions with no additional
  315. * overhead. */
  316. UA_StatusCode UA_EXPORT
  317. __UA_Server_write(UA_Server *server, const UA_NodeId *nodeId,
  318. const UA_AttributeId attributeId,
  319. const UA_DataType *attr_type, const void *attr);
  320. static UA_INLINE UA_StatusCode
  321. UA_Server_writeBrowseName(UA_Server *server, const UA_NodeId nodeId,
  322. const UA_QualifiedName browseName) {
  323. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_BROWSENAME,
  324. &UA_TYPES[UA_TYPES_QUALIFIEDNAME], &browseName);
  325. }
  326. static UA_INLINE UA_StatusCode
  327. UA_Server_writeDisplayName(UA_Server *server, const UA_NodeId nodeId,
  328. const UA_LocalizedText displayName) {
  329. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_DISPLAYNAME,
  330. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT], &displayName);
  331. }
  332. static UA_INLINE UA_StatusCode
  333. UA_Server_writeDescription(UA_Server *server, const UA_NodeId nodeId,
  334. const UA_LocalizedText description) {
  335. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_DESCRIPTION,
  336. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT], &description);
  337. }
  338. static UA_INLINE UA_StatusCode
  339. UA_Server_writeWriteMask(UA_Server *server, const UA_NodeId nodeId,
  340. const UA_UInt32 writeMask) {
  341. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_WRITEMASK,
  342. &UA_TYPES[UA_TYPES_UINT32], &writeMask);
  343. }
  344. static UA_INLINE UA_StatusCode
  345. UA_Server_writeIsAbstract(UA_Server *server, const UA_NodeId nodeId,
  346. const UA_Boolean isAbstract) {
  347. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_ISABSTRACT,
  348. &UA_TYPES[UA_TYPES_BOOLEAN], &isAbstract);
  349. }
  350. static UA_INLINE UA_StatusCode
  351. UA_Server_writeInverseName(UA_Server *server, const UA_NodeId nodeId,
  352. const UA_LocalizedText inverseName) {
  353. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_INVERSENAME,
  354. &UA_TYPES[UA_TYPES_LOCALIZEDTEXT], &inverseName);
  355. }
  356. static UA_INLINE UA_StatusCode
  357. UA_Server_writeEventNotifier(UA_Server *server, const UA_NodeId nodeId,
  358. const UA_Byte eventNotifier) {
  359. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_EVENTNOTIFIER,
  360. &UA_TYPES[UA_TYPES_BYTE], &eventNotifier);
  361. }
  362. static UA_INLINE UA_StatusCode
  363. UA_Server_writeValue(UA_Server *server, const UA_NodeId nodeId,
  364. const UA_Variant value) {
  365. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_VALUE,
  366. &UA_TYPES[UA_TYPES_VARIANT], &value);
  367. }
  368. static UA_INLINE UA_StatusCode
  369. UA_Server_writeDataType(UA_Server *server, const UA_NodeId nodeId,
  370. const UA_NodeId dataType) {
  371. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_DATATYPE,
  372. &UA_TYPES[UA_TYPES_NODEID], &dataType);
  373. }
  374. static UA_INLINE UA_StatusCode
  375. UA_Server_writeValueRank(UA_Server *server, const UA_NodeId nodeId,
  376. const UA_Int32 valueRank) {
  377. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_VALUERANK,
  378. &UA_TYPES[UA_TYPES_INT32], &valueRank);
  379. }
  380. static UA_INLINE UA_StatusCode
  381. UA_Server_writeArrayDimensions(UA_Server *server, const UA_NodeId nodeId,
  382. const UA_Variant arrayDimensions) {
  383. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_VALUE,
  384. &UA_TYPES[UA_TYPES_VARIANT], &arrayDimensions);
  385. }
  386. static UA_INLINE UA_StatusCode
  387. UA_Server_writeAccessLevel(UA_Server *server, const UA_NodeId nodeId,
  388. const UA_Byte accessLevel) {
  389. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_ACCESSLEVEL,
  390. &UA_TYPES[UA_TYPES_BYTE], &accessLevel);
  391. }
  392. static UA_INLINE UA_StatusCode
  393. UA_Server_writeMinimumSamplingInterval(UA_Server *server, const UA_NodeId nodeId,
  394. const UA_Double miniumSamplingInterval) {
  395. return __UA_Server_write(server, &nodeId,
  396. UA_ATTRIBUTEID_MINIMUMSAMPLINGINTERVAL,
  397. &UA_TYPES[UA_TYPES_DOUBLE],
  398. &miniumSamplingInterval);
  399. }
  400. static UA_INLINE UA_StatusCode
  401. UA_Server_writeExecutable(UA_Server *server, const UA_NodeId nodeId,
  402. const UA_Boolean executable) {
  403. return __UA_Server_write(server, &nodeId, UA_ATTRIBUTEID_EXECUTABLE,
  404. &UA_TYPES[UA_TYPES_BOOLEAN], &executable); }
  405. /**
  406. * Browsing
  407. * -------- */
  408. UA_BrowseResult UA_EXPORT
  409. UA_Server_browse(UA_Server *server, UA_UInt32 maxrefs,
  410. const UA_BrowseDescription *descr);
  411. UA_BrowseResult UA_EXPORT
  412. UA_Server_browseNext(UA_Server *server, UA_Boolean releaseContinuationPoint,
  413. const UA_ByteString *continuationPoint);
  414. UA_BrowsePathResult UA_EXPORT
  415. UA_Server_translateBrowsePathToNodeIds(UA_Server *server,
  416. const UA_BrowsePath *browsePath);
  417. #ifndef HAVE_NODEITER_CALLBACK
  418. #define HAVE_NODEITER_CALLBACK
  419. /* Iterate over all nodes referenced by parentNodeId by calling the callback
  420. * function for each child node (in ifdef because GCC/CLANG handle include order
  421. * differently) */
  422. typedef UA_StatusCode
  423. (*UA_NodeIteratorCallback)(UA_NodeId childId, UA_Boolean isInverse,
  424. UA_NodeId referenceTypeId, void *handle);
  425. #endif
  426. UA_StatusCode UA_EXPORT
  427. UA_Server_forEachChildNodeCall(UA_Server *server, UA_NodeId parentNodeId,
  428. UA_NodeIteratorCallback callback, void *handle);
  429. #ifdef UA_ENABLE_DISCOVERY
  430. /**
  431. * Discovery
  432. * --------- */
  433. /* Register the given server instance at the discovery server.
  434. * This should be called periodically.
  435. * The semaphoreFilePath is optional. If the given file is deleted,
  436. * the server will automatically be unregistered. This could be
  437. * for example a pid file which is deleted if the server crashes.
  438. *
  439. * When the server shuts down you need to call unregister.
  440. *
  441. * @param server
  442. * @param discoveryServerUrl if set to NULL, the default value
  443. * 'opc.tcp://localhost:4840' will be used
  444. * @param semaphoreFilePath optional parameter pointing to semaphore file. */
  445. UA_StatusCode UA_EXPORT
  446. UA_Server_register_discovery(UA_Server *server, const char* discoveryServerUrl,
  447. const char* semaphoreFilePath);
  448. /* Unregister the given server instance from the discovery server.
  449. * This should only be called when the server is shutting down.
  450. * @param server
  451. * @param discoveryServerUrl if set to NULL, the default value
  452. * 'opc.tcp://localhost:4840' will be used */
  453. UA_StatusCode UA_EXPORT
  454. UA_Server_unregister_discovery(UA_Server *server, const char* discoveryServerUrl);
  455. /* Adds a periodic callback to register the server with the LDS (local discovery server)
  456. * periodically. The interval between each register call is given as second parameter.
  457. * It should be 10 minutes by default (= 10*60*1000).
  458. *
  459. * The delayFirstRegisterMs parameter indicates the delay for the first register call.
  460. * If it is 0, the first register call will be after intervalMs milliseconds,
  461. * otherwise the server's first register will be after delayFirstRegisterMs.
  462. *
  463. * When you manually unregister the server, you also need to cancel the
  464. * periodic callback, otherwise it will be automatically be registered again.
  465. *
  466. * If you call this method multiple times for the same discoveryServerUrl, the older
  467. * periodic callback will be removed.
  468. *
  469. * @param server
  470. * @param discoveryServerUrl if set to NULL, the default value
  471. * 'opc.tcp://localhost:4840' will be used
  472. * @param intervalMs
  473. * @param delayFirstRegisterMs
  474. * @param periodicCallbackId */
  475. UA_StatusCode UA_EXPORT
  476. UA_Server_addPeriodicServerRegisterCallback(UA_Server *server, const char* discoveryServerUrl,
  477. UA_UInt32 intervalMs,
  478. UA_UInt32 delayFirstRegisterMs,
  479. UA_UInt64 *periodicCallbackId);
  480. /* Callback for RegisterServer. Data is passed from the register call */
  481. typedef void (*UA_Server_registerServerCallback)(const UA_RegisteredServer *registeredServer,
  482. void* data);
  483. /* Set the callback which is called if another server registeres or unregisters
  484. * with this instance. If called multiple times, previous data will be
  485. * overwritten.
  486. *
  487. * @param server
  488. * @param cb the callback
  489. * @param data data passed to the callback
  490. * @return UA_STATUSCODE_SUCCESS on success */
  491. void UA_EXPORT
  492. UA_Server_setRegisterServerCallback(UA_Server *server, UA_Server_registerServerCallback cb,
  493. void* data);
  494. #ifdef UA_ENABLE_DISCOVERY_MULTICAST
  495. /* Callback for server detected through mDNS. Data is passed from the register
  496. * call
  497. *
  498. * @param isServerAnnounce indicates if the server has just been detected. If
  499. * set to false, this means the server is shutting down.
  500. * @param isTxtReceived indicates if we already received the corresponding TXT
  501. * record with the path and caps data */
  502. typedef void (*UA_Server_serverOnNetworkCallback)(const UA_ServerOnNetwork *serverOnNetwork,
  503. UA_Boolean isServerAnnounce,
  504. UA_Boolean isTxtReceived, void* data);
  505. /* Set the callback which is called if another server is found through mDNS or
  506. * deleted. It will be called for any mDNS message from the remote server, thus
  507. * it may be called multiple times for the same instance. Also the SRV and TXT
  508. * records may arrive later, therefore for the first call the server
  509. * capabilities may not be set yet. If called multiple times, previous data will
  510. * be overwritten.
  511. *
  512. * @param server
  513. * @param cb the callback
  514. * @param data data passed to the callback
  515. * @return UA_STATUSCODE_SUCCESS on success */
  516. void UA_EXPORT
  517. UA_Server_setServerOnNetworkCallback(UA_Server *server,
  518. UA_Server_serverOnNetworkCallback cb,
  519. void* data);
  520. #endif /* UA_ENABLE_DISCOVERY_MULTICAST */
  521. #endif /* UA_ENABLE_DISCOVERY */
  522. /**
  523. * Method Call
  524. * ----------- */
  525. #ifdef UA_ENABLE_METHODCALLS
  526. UA_CallMethodResult UA_EXPORT
  527. UA_Server_call(UA_Server *server, const UA_CallMethodRequest *request);
  528. #endif
  529. /**
  530. * Node Lifecycle
  531. * --------------
  532. *
  533. * Every node has a context pointer with user-defined data (or NULL). The
  534. * user-defined data is assigned before the first constructor is called. The
  535. * constructors and destructors can can change (reallocate or free) the context
  536. * pointer.
  537. *
  538. * There are two layers of lifecycle management: global and for the specific
  539. * node-type (for VariableTypes and ObjectTypes only). The lifecycle is as
  540. * follows:
  541. *
  542. * 1. Global Constructor
  543. * 2. Node-Type Constructor (for Variables and Objects)
  544. * 3. (Usage-period of the Node)
  545. * 4. Node-Type Destructor
  546. * 5. Global Destructor
  547. *
  548. * The constructor callbacks can be set to NULL and are not used in that case.
  549. * When the AddNodes service is used over the network, the context pointer is
  550. * initially set to NULL.
  551. *
  552. * If the node-type constructor fails, the global destructor is called before
  553. * the node is removed.
  554. *
  555. * Global Node Lifecycle
  556. * ^^^^^^^^^^^^^^^^^^^^^ */
  557. typedef struct {
  558. /* Can be NULL. */
  559. UA_StatusCode (*constructor)(const UA_NodeId *nodeId, void **nodeContext);
  560. /* Can be NULL. The global destructor cannot set a new context pointer. The
  561. * node memory is freed directly afterwards anyway. */
  562. void (*destructor)(const UA_NodeId *nodeId, void *nodeContext);
  563. } UA_NodeLifecycle;
  564. void UA_EXPORT
  565. UA_Server_setNodeLifecycle(UA_Server *server, UA_NodeLifecycle lifecycle);
  566. /**
  567. * Node Type Lifecycle
  568. * ^^^^^^^^^^^^^^^^^^^ */
  569. typedef struct {
  570. /* Can be NULL. */
  571. UA_StatusCode (*constructor)(const UA_NodeId *typeId, void *typeContext,
  572. const UA_NodeId *instanceId, void **instanceContext);
  573. /* Can be NULL. */
  574. void (*destructor)(const UA_NodeId *typeId, void *typeContext,
  575. const UA_NodeId *instanceId, void **instanceContext);
  576. } UA_NodeTypeLifecycle;
  577. UA_StatusCode UA_EXPORT
  578. UA_Server_setNodeTypeLifecycle(UA_Server *server, UA_NodeId nodeId,
  579. UA_NodeTypeLifecycle lifecycle);
  580. /**
  581. * Interacting with the Node Context
  582. * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */
  583. UA_StatusCode UA_EXPORT
  584. UA_Server_getNodeContext(UA_Server *server, UA_NodeId nodeId, void **context);
  585. UA_StatusCode UA_EXPORT
  586. UA_Server_setNodeContext(UA_Server *server, UA_NodeId nodeId, void *context);
  587. /**
  588. * Variable Value Storage
  589. * ^^^^^^^^^^^^^^^^^^^^^^
  590. * - Datasources for variable nodes, where the variable content is managed
  591. * externally
  592. * - Value-callbacks for variable nodes, where userspace is notified when a
  593. * read/write occurs
  594. *
  595. * .. _datasource:
  596. *
  597. * Data Source Callback
  598. * ~~~~~~~~~~~~~~~~~~~~
  599. *
  600. * The server has a unique way of dealing with the content of variables. Instead
  601. * of storing a variant attached to the variable node, the node can point to a
  602. * function with a local data provider. Whenever the value attribute is read,
  603. * the function will be called and asked to provide a UA_DataValue return value
  604. * that contains the value content and additional timestamps.
  605. *
  606. * It is expected that the read callback is implemented. The write callback can
  607. * be set to a null-pointer. */
  608. typedef struct {
  609. /* Copies the data from the source into the provided value.
  610. *
  611. * @param handle An optional pointer to user-defined data for the
  612. * specific data source
  613. * @param nodeid Id of the read node
  614. * @param includeSourceTimeStamp If true, then the datasource is expected to
  615. * set the source timestamp in the returned value
  616. * @param range If not null, then the datasource shall return only a
  617. * selection of the (nonscalar) data. Set
  618. * UA_STATUSCODE_BADINDEXRANGEINVALID in the value if this does not
  619. * apply.
  620. * @param value The (non-null) DataValue that is returned to the client. The
  621. * data source sets the read data, the result status and optionally a
  622. * sourcetimestamp.
  623. * @return Returns a status code for logging. Error codes intended for the
  624. * original caller are set in the value. If an error is returned,
  625. * then no releasing of the value is done. */
  626. UA_StatusCode (*read)(const UA_NodeId *nodeId, void *nodeContext,
  627. UA_Boolean includeSourceTimeStamp,
  628. const UA_NumericRange *range, UA_DataValue *value);
  629. /* Write into a data source. The write member of UA_DataSource can be empty
  630. * if the operation is unsupported.
  631. *
  632. * @param handle An optional pointer to user-defined data for the
  633. * specific data source
  634. * @param nodeid Id of the node being written to
  635. * @param data The data to be written into the data source
  636. * @param range An optional data range. If the data source is scalar or does
  637. * not support writing of ranges, then an error code is returned.
  638. * @return Returns a status code that is returned to the user */
  639. UA_StatusCode (*write)(const UA_NodeId *nodeId, void *nodeContext,
  640. const UA_Variant *data, const UA_NumericRange *range);
  641. } UA_DataSource;
  642. UA_StatusCode UA_EXPORT
  643. UA_Server_setVariableNode_dataSource(UA_Server *server, const UA_NodeId nodeId,
  644. const UA_DataSource dataSource);
  645. /**
  646. * .. _value-callback:
  647. *
  648. * Value Callback
  649. * ~~~~~~~~~~~~~~
  650. * Value Callbacks can be attached to variable and variable type nodes. If
  651. * not-null, they are called before reading and after writing respectively. */
  652. typedef struct {
  653. /* Called before the value attribute is read. It is possible to write into the
  654. * value attribute during onRead (using the write service). The node is
  655. * re-opened afterwards so that changes are considered in the following read
  656. * operation.
  657. *
  658. * @param handle Points to user-provided data for the callback.
  659. * @param nodeid The identifier of the node.
  660. * @param data Points to the current node value.
  661. * @param range Points to the numeric range the client wants to read from
  662. * (or NULL). */
  663. void (*onRead)(const UA_NodeId *nodeid, void *nodeContext,
  664. const UA_Variant *data, const UA_NumericRange *range);
  665. /* Called after writing the value attribute. The node is re-opened after
  666. * writing so that the new value is visible in the callback.
  667. *
  668. * @param handle Points to user-provided data for the callback.
  669. * @param nodeid The identifier of the node.
  670. * @param data Points to the current node value (after writing).
  671. * @param range Points to the numeric range the client wants to write to (or
  672. * NULL). */
  673. void (*onWrite)(const UA_NodeId *nodeId, void *nodeContext,
  674. const UA_Variant *data, const UA_NumericRange *range);
  675. } UA_ValueCallback;
  676. UA_StatusCode UA_EXPORT
  677. UA_Server_setVariableNode_valueCallback(UA_Server *server,
  678. const UA_NodeId nodeId,
  679. const UA_ValueCallback callback);
  680. /**
  681. * Method Callbacks
  682. * ~~~~~~~~~~~~~~~~ */
  683. typedef UA_StatusCode
  684. (*UA_MethodCallback)(const UA_NodeId *methodId, void *methodContext,
  685. const UA_NodeId *objectId, void *objectContext,
  686. const UA_NodeId *sessionId, void *sessionContext,
  687. size_t inputSize, const UA_Variant *input,
  688. size_t outputSize, UA_Variant *output);
  689. UA_StatusCode UA_EXPORT
  690. UA_Server_setMethodNode_callback(UA_Server *server,
  691. const UA_NodeId methodNodeId,
  692. UA_MethodCallback methodCallback);
  693. /**
  694. * .. _addnodes:
  695. *
  696. * Node Addition and Deletion
  697. * ^^^^^^^^^^^^^^^^^^^^^^^^^^
  698. * When creating dynamic node instances at runtime, chances are that you will
  699. * not care about the specific NodeId of the new node, as long as you can
  700. * reference it later. When passing numeric NodeIds with a numeric identifier 0,
  701. * the stack evaluates this as "select a random unassigned numeric NodeId in
  702. * that namespace". To find out which NodeId was actually assigned to the new
  703. * node, you may pass a pointer `outNewNodeId`, which will (after a successfull
  704. * node insertion) contain the nodeId of the new node. You may also pass NULL
  705. * pointer if this result is not relevant. The namespace index for nodes you
  706. * create should never be 0, as that index is reserved for OPC UA's
  707. * self-description (namespace * 0).
  708. *
  709. * The methods for node addition and deletion take mostly const arguments that
  710. * are not modified. When creating a node, a deep copy of the node identifier,
  711. * node attributes, etc. is created. Therefore, it is possible to call for
  712. * example `UA_Server_addVariablenode` with a value attribute (a :ref:`variant`)
  713. * pointing to a memory location on the stack. If you need changes to a variable
  714. * value to manifest at a specific memory location, please use a
  715. * :ref:`datasource` or a :ref:`value-callback`. */
  716. /* Protect against redundant definitions for server/client */
  717. #ifndef UA_DEFAULT_ATTRIBUTES_DEFINED
  718. #define UA_DEFAULT_ATTRIBUTES_DEFINED
  719. /* The default for variables is "BaseDataType" for the datatype, -2 for the
  720. * valuerank and a read-accesslevel. */
  721. UA_EXPORT extern const UA_VariableAttributes UA_VariableAttributes_default;
  722. UA_EXPORT extern const UA_VariableTypeAttributes UA_VariableTypeAttributes_default;
  723. /* Methods are executable by default */
  724. UA_EXPORT extern const UA_MethodAttributes UA_MethodAttributes_default;
  725. /* The remaining attribute definitions are currently all zeroed out */
  726. UA_EXPORT extern const UA_ObjectAttributes UA_ObjectAttributes_default;
  727. UA_EXPORT extern const UA_ObjectTypeAttributes UA_ObjectTypeAttributes_default;
  728. UA_EXPORT extern const UA_ReferenceTypeAttributes UA_ReferenceTypeAttributes_default;
  729. UA_EXPORT extern const UA_DataTypeAttributes UA_DataTypeAttributes_default;
  730. UA_EXPORT extern const UA_ViewAttributes UA_ViewAttributes_default;
  731. #endif
  732. /* The instantiation callback is used to track the addition of new nodes. It is
  733. * also called for all sub-nodes contained in an object or variable type node
  734. * that is instantiated. */
  735. typedef struct {
  736. UA_StatusCode (*method)(const UA_NodeId objectId,
  737. const UA_NodeId typeDefinitionId, void *handle);
  738. void *handle;
  739. } UA_InstantiationCallback;
  740. /* Don't use this function. There are typed versions as inline functions. */
  741. UA_StatusCode UA_EXPORT
  742. __UA_Server_addNode(UA_Server *server, const UA_NodeClass nodeClass,
  743. const UA_NodeId *requestedNewNodeId,
  744. const UA_NodeId *parentNodeId,
  745. const UA_NodeId *referenceTypeId,
  746. const UA_QualifiedName browseName,
  747. const UA_NodeId *typeDefinition,
  748. const UA_NodeAttributes *attr,
  749. const UA_DataType *attributeType,
  750. void *nodeContext, UA_NodeId *outNewNodeId);
  751. static UA_INLINE UA_StatusCode
  752. UA_Server_addVariableNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  753. const UA_NodeId parentNodeId,
  754. const UA_NodeId referenceTypeId,
  755. const UA_QualifiedName browseName,
  756. const UA_NodeId typeDefinition,
  757. const UA_VariableAttributes attr,
  758. void *nodeContext, UA_NodeId *outNewNodeId) {
  759. return __UA_Server_addNode(server, UA_NODECLASS_VARIABLE, &requestedNewNodeId,
  760. &parentNodeId, &referenceTypeId, browseName,
  761. &typeDefinition, (const UA_NodeAttributes*)&attr,
  762. &UA_TYPES[UA_TYPES_VARIABLEATTRIBUTES],
  763. nodeContext, outNewNodeId);
  764. }
  765. static UA_INLINE UA_StatusCode
  766. UA_Server_addVariableTypeNode(UA_Server *server,
  767. const UA_NodeId requestedNewNodeId,
  768. const UA_NodeId parentNodeId,
  769. const UA_NodeId referenceTypeId,
  770. const UA_QualifiedName browseName,
  771. const UA_NodeId typeDefinition,
  772. const UA_VariableTypeAttributes attr,
  773. void *nodeContext, UA_NodeId *outNewNodeId) {
  774. return __UA_Server_addNode(server, UA_NODECLASS_VARIABLETYPE,
  775. &requestedNewNodeId, &parentNodeId, &referenceTypeId,
  776. browseName, &typeDefinition,
  777. (const UA_NodeAttributes*)&attr,
  778. &UA_TYPES[UA_TYPES_VARIABLETYPEATTRIBUTES],
  779. nodeContext, outNewNodeId);
  780. }
  781. static UA_INLINE UA_StatusCode
  782. UA_Server_addObjectNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  783. const UA_NodeId parentNodeId,
  784. const UA_NodeId referenceTypeId,
  785. const UA_QualifiedName browseName,
  786. const UA_NodeId typeDefinition,
  787. const UA_ObjectAttributes attr,
  788. void *nodeContext, UA_NodeId *outNewNodeId) {
  789. return __UA_Server_addNode(server, UA_NODECLASS_OBJECT, &requestedNewNodeId,
  790. &parentNodeId, &referenceTypeId, browseName,
  791. &typeDefinition, (const UA_NodeAttributes*)&attr,
  792. &UA_TYPES[UA_TYPES_OBJECTATTRIBUTES],
  793. nodeContext, outNewNodeId);
  794. }
  795. static UA_INLINE UA_StatusCode
  796. UA_Server_addObjectTypeNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  797. const UA_NodeId parentNodeId,
  798. const UA_NodeId referenceTypeId,
  799. const UA_QualifiedName browseName,
  800. const UA_ObjectTypeAttributes attr,
  801. void *nodeContext, UA_NodeId *outNewNodeId) {
  802. return __UA_Server_addNode(server, UA_NODECLASS_OBJECTTYPE, &requestedNewNodeId,
  803. &parentNodeId, &referenceTypeId, browseName,
  804. &UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  805. &UA_TYPES[UA_TYPES_OBJECTTYPEATTRIBUTES],
  806. nodeContext, outNewNodeId);
  807. }
  808. static UA_INLINE UA_StatusCode
  809. UA_Server_addViewNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  810. const UA_NodeId parentNodeId,
  811. const UA_NodeId referenceTypeId,
  812. const UA_QualifiedName browseName,
  813. const UA_ViewAttributes attr,
  814. void *nodeContext, UA_NodeId *outNewNodeId) {
  815. return __UA_Server_addNode(server, UA_NODECLASS_VIEW, &requestedNewNodeId,
  816. &parentNodeId, &referenceTypeId, browseName,
  817. &UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  818. &UA_TYPES[UA_TYPES_VIEWATTRIBUTES],
  819. nodeContext, outNewNodeId);
  820. }
  821. static UA_INLINE UA_StatusCode
  822. UA_Server_addReferenceTypeNode(UA_Server *server,
  823. const UA_NodeId requestedNewNodeId,
  824. const UA_NodeId parentNodeId,
  825. const UA_NodeId referenceTypeId,
  826. const UA_QualifiedName browseName,
  827. const UA_ReferenceTypeAttributes attr,
  828. void *nodeContext, UA_NodeId *outNewNodeId) {
  829. return __UA_Server_addNode(server, UA_NODECLASS_REFERENCETYPE,
  830. &requestedNewNodeId, &parentNodeId, &referenceTypeId,
  831. browseName, &UA_NODEID_NULL,
  832. (const UA_NodeAttributes*)&attr,
  833. &UA_TYPES[UA_TYPES_REFERENCETYPEATTRIBUTES],
  834. nodeContext, outNewNodeId);
  835. }
  836. static UA_INLINE UA_StatusCode
  837. UA_Server_addDataTypeNode(UA_Server *server,
  838. const UA_NodeId requestedNewNodeId,
  839. const UA_NodeId parentNodeId,
  840. const UA_NodeId referenceTypeId,
  841. const UA_QualifiedName browseName,
  842. const UA_DataTypeAttributes attr,
  843. void *nodeContext, UA_NodeId *outNewNodeId) {
  844. return __UA_Server_addNode(server, UA_NODECLASS_DATATYPE, &requestedNewNodeId,
  845. &parentNodeId, &referenceTypeId, browseName,
  846. &UA_NODEID_NULL, (const UA_NodeAttributes*)&attr,
  847. &UA_TYPES[UA_TYPES_DATATYPEATTRIBUTES],
  848. nodeContext, outNewNodeId);
  849. }
  850. UA_StatusCode UA_EXPORT
  851. UA_Server_addDataSourceVariableNode(UA_Server *server,
  852. const UA_NodeId requestedNewNodeId,
  853. const UA_NodeId parentNodeId,
  854. const UA_NodeId referenceTypeId,
  855. const UA_QualifiedName browseName,
  856. const UA_NodeId typeDefinition,
  857. const UA_VariableAttributes attr,
  858. const UA_DataSource dataSource,
  859. void *nodeContext, UA_NodeId *outNewNodeId);
  860. UA_StatusCode UA_EXPORT
  861. UA_Server_addMethodNode(UA_Server *server, const UA_NodeId requestedNewNodeId,
  862. const UA_NodeId parentNodeId,
  863. const UA_NodeId referenceTypeId,
  864. const UA_QualifiedName browseName,
  865. const UA_MethodAttributes attr, UA_MethodCallback method,
  866. size_t inputArgumentsSize, const UA_Argument* inputArguments,
  867. size_t outputArgumentsSize, const UA_Argument* outputArguments,
  868. void *nodeContext, UA_NodeId *outNewNodeId);
  869. UA_StatusCode UA_EXPORT
  870. UA_Server_deleteNode(UA_Server *server, const UA_NodeId nodeId,
  871. UA_Boolean deleteReferences);
  872. /**
  873. * Reference Management
  874. * -------------------- */
  875. UA_StatusCode UA_EXPORT
  876. UA_Server_addReference(UA_Server *server, const UA_NodeId sourceId,
  877. const UA_NodeId refTypeId,
  878. const UA_ExpandedNodeId targetId, UA_Boolean isForward);
  879. UA_StatusCode UA_EXPORT
  880. UA_Server_deleteReference(UA_Server *server, const UA_NodeId sourceNodeId,
  881. const UA_NodeId referenceTypeId, UA_Boolean isForward,
  882. const UA_ExpandedNodeId targetNodeId,
  883. UA_Boolean deleteBidirectional);
  884. /**
  885. * Utility Functions
  886. * ----------------- */
  887. /* Add a new namespace to the server. Returns the index of the new namespace */
  888. UA_UInt16 UA_EXPORT UA_Server_addNamespace(UA_Server *server, const char* name);
  889. /**
  890. * Deprecated Server API
  891. * ---------------------
  892. * This file contains outdated API definitions that are kept for backwards
  893. * compatibility. Please switch to the new API, as the following definitions
  894. * will be removed eventually.
  895. *
  896. * UA_Job API
  897. * ^^^^^^^^^^
  898. * UA_Job was replaced since it unneccessarily exposed server internals to the
  899. * end-user. Please use plain UA_ServerCallbacks instead. The following UA_Job
  900. * definition contains just the fraction of the original struct that was useful
  901. * to end-users. */
  902. typedef enum {
  903. UA_JOBTYPE_METHODCALL
  904. } UA_JobType;
  905. typedef struct {
  906. UA_JobType type;
  907. union {
  908. struct {
  909. void *data;
  910. UA_ServerCallback method;
  911. } methodCall;
  912. } job;
  913. } UA_Job;
  914. UA_DEPRECATED static UA_INLINE UA_StatusCode
  915. UA_Server_addRepeatedJob(UA_Server *server, UA_Job job,
  916. UA_UInt32 interval, UA_Guid *jobId) {
  917. return UA_Server_addRepeatedCallback(server, job.job.methodCall.method,
  918. job.job.methodCall.data, interval,
  919. (UA_UInt64*)(uintptr_t)jobId);
  920. }
  921. UA_DEPRECATED static UA_INLINE UA_StatusCode
  922. UA_Server_removeRepeatedJob(UA_Server *server, UA_Guid jobId) {
  923. return UA_Server_removeRepeatedCallback(server,
  924. *(UA_UInt64*)(uintptr_t)&jobId);
  925. }
  926. #ifdef __cplusplus
  927. }
  928. #endif
  929. #endif /* UA_SERVER_H_ */