ua_server.h 45 KB

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