ua_server.h 46 KB

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