ua_server.h 45 KB

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