/src/open62541/include/open62541/server.h
Line | Count | Source |
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 | | * |
5 | | * Copyright 2014-2025 (c) Fraunhofer IOSB (Author: Julius Pfrommer) |
6 | | * Copyright 2015-2016 (c) Sten GrĂ¼ner |
7 | | * Copyright 2014-2015, 2017 (c) Florian Palm |
8 | | * Copyright 2015-2016 (c) Chris Iatrou |
9 | | * Copyright 2015-2016 (c) Oleksiy Vasylyev |
10 | | * Copyright 2016-2017 (c) Stefan Profanter, fortiss GmbH |
11 | | * Copyright 2017 (c) Henrik Norrman |
12 | | * Copyright 2018 (c) Fabian Arndt, Root-Core |
13 | | * Copyright 2017-2020 (c) HMS Industrial Networks AB (Author: Jonas Green) |
14 | | * Copyright 2020-2022 (c) Christian von Arnim, ISW University of Stuttgart (for VDW and umati) |
15 | | */ |
16 | | |
17 | | #ifndef UA_SERVER_H_ |
18 | | #define UA_SERVER_H_ |
19 | | |
20 | | #include <open62541/common.h> |
21 | | #include <open62541/util.h> |
22 | | #include <open62541/types.h> |
23 | | #include <open62541/client.h> |
24 | | |
25 | | #include <open62541/plugin/log.h> |
26 | | #include <open62541/plugin/certificategroup.h> |
27 | | #include <open62541/plugin/eventloop.h> |
28 | | #include <open62541/plugin/accesscontrol.h> |
29 | | #include <open62541/plugin/securitypolicy.h> |
30 | | |
31 | | #ifdef UA_ENABLE_HISTORIZING |
32 | | #include <open62541/plugin/historydatabase.h> |
33 | | #endif |
34 | | |
35 | | #ifdef UA_ENABLE_PUBSUB |
36 | | #include <open62541/server_pubsub.h> |
37 | | #endif |
38 | | |
39 | | /* Forward Declarations */ |
40 | | struct UA_Nodestore; |
41 | | typedef struct UA_Nodestore UA_Nodestore; |
42 | | |
43 | | struct UA_ServerConfig; |
44 | | typedef struct UA_ServerConfig UA_ServerConfig; |
45 | | |
46 | | _UA_BEGIN_DECLS |
47 | | |
48 | | /** |
49 | | * .. _server: |
50 | | * |
51 | | * Server |
52 | | * ====== |
53 | | * An OPC UA server contains an object-oriented information model and makes it |
54 | | * accessible to clients over the network via the OPC UA :ref:`services`. The |
55 | | * information model can be used either used to store "passive data" or as an |
56 | | * "active database" that integrates with data-sources and devices. For the |
57 | | * latter, user-defined callbacks can be attached to VariableNodes and |
58 | | * MethodNodes. |
59 | | * |
60 | | * .. _server-lifecycle: |
61 | | * |
62 | | * Server Lifecycle |
63 | | * ---------------- |
64 | | * This section describes the API for creating, running and deleting a server. |
65 | | * At runtime, the server continuously listens on the network, acceppts incoming |
66 | | * connections and processes received messages. Furthermore, timed (cyclic) |
67 | | * callbacks are executed. */ |
68 | | |
69 | | /* Create a new server with a default configuration that adds plugins for |
70 | | * networking, security, logging and so on. See the "server_config_default.h" |
71 | | * for more detailed options. |
72 | | * |
73 | | * The default configuration can be used as the starting point to adjust the |
74 | | * server configuration to individual needs. UA_Server_new is implemented in the |
75 | | * /plugins folder under the CC0 license. Furthermore the server confiugration |
76 | | * only uses the public server API. |
77 | | * |
78 | | * Returns the configured server or NULL if an error occurs. */ |
79 | | UA_EXPORT UA_Server * |
80 | | UA_Server_new(void); |
81 | | |
82 | | /* Creates a new server. Moves the config into the server with a shallow copy. |
83 | | * The config content is cleared together with the server. */ |
84 | | UA_EXPORT UA_Server * |
85 | | UA_Server_newWithConfig(UA_ServerConfig *config); |
86 | | |
87 | | /* Delete the server and its configuration */ |
88 | | UA_EXPORT UA_StatusCode |
89 | | UA_Server_delete(UA_Server *server); |
90 | | |
91 | | /* Get the configuration. Always succeeds as this simplfy resolves a pointer. |
92 | | * Attention! Do not adjust the configuration while the server is running! */ |
93 | | UA_EXPORT UA_ServerConfig * |
94 | | UA_Server_getConfig(UA_Server *server); |
95 | | |
96 | | /* Get the current server lifecycle state */ |
97 | | UA_EXPORT UA_LifecycleState |
98 | | UA_Server_getLifecycleState(UA_Server *server); |
99 | | |
100 | | /* Runs the server until until "running" is set to false. The logical sequence |
101 | | * is as follows: |
102 | | * |
103 | | * - UA_Server_run_startup |
104 | | * - Loop UA_Server_run_iterate while "running" is true |
105 | | * - UA_Server_run_shutdown */ |
106 | | UA_EXPORT UA_StatusCode |
107 | | UA_Server_run(UA_Server *server, const volatile UA_Boolean *running); |
108 | | |
109 | | /* Runs the server until interrupted. On Unix/Windows this registers an |
110 | | * interrupt for SIGINT (ctrl-c). The method only returns after having received |
111 | | * the interrupt or upon an error condition. The logical sequence is as follows: |
112 | | * |
113 | | * - Register the interrupt |
114 | | * - UA_Server_run_startup |
115 | | * - Loop until interrupt: UA_Server_run_iterate |
116 | | * - UA_Server_run_shutdown |
117 | | * - Deregister the interrupt |
118 | | * |
119 | | * Attention! This method is implemented individually for the different |
120 | | * platforms (POSIX/Win32/etc.). The default implementation is in |
121 | | * /plugins/ua_config_default.c under the CC0 license. Adjust as needed. */ |
122 | | UA_EXPORT UA_StatusCode |
123 | | UA_Server_runUntilInterrupt(UA_Server *server); |
124 | | |
125 | | /* The prologue part of UA_Server_run (no need to use if you call |
126 | | * UA_Server_run or UA_Server_runUntilInterrupt) */ |
127 | | UA_EXPORT UA_StatusCode |
128 | | UA_Server_run_startup(UA_Server *server); |
129 | | |
130 | | /* Executes a single iteration of the server's main loop. |
131 | | * |
132 | | * @param server The server object. |
133 | | * @param waitInternal Should we wait for messages in the networklayer? |
134 | | * Otherwise, the timeouts for the networklayers are set to zero. |
135 | | * The default max wait time is 200ms. |
136 | | * @return Returns how long we can wait until the next scheduled |
137 | | * callback (in ms) */ |
138 | | UA_EXPORT UA_UInt16 |
139 | | UA_Server_run_iterate(UA_Server *server, UA_Boolean waitInternal); |
140 | | |
141 | | /* The epilogue part of UA_Server_run (no need to use if you call |
142 | | * UA_Server_run or UA_Server_runUntilInterrupt) */ |
143 | | UA_EXPORT UA_StatusCode |
144 | | UA_Server_run_shutdown(UA_Server *server); |
145 | | |
146 | | /** |
147 | | * Timed Callbacks |
148 | | * --------------- |
149 | | * Timed callback are executed at their defined timestamp. The callback can also |
150 | | * be registered with a cyclic repetition interval. */ |
151 | | |
152 | | typedef void (*UA_ServerCallback)(UA_Server *server, void *data); |
153 | | |
154 | | /* Add a callback for execution at a specified time. If the indicated time lies |
155 | | * in the past, then the callback is executed at the next iteration of the |
156 | | * server's main loop. |
157 | | * |
158 | | * @param server The server object. |
159 | | * @param callback The callback that shall be added. |
160 | | * @param data Data that is forwarded to the callback. |
161 | | * @param date The timestamp for the execution time. |
162 | | * @param callbackId Set to the identifier of the repeated callback . This can |
163 | | * be used to cancel the callback later on. If the pointer is null, the |
164 | | * identifier is not set. |
165 | | * @return Upon success, ``UA_STATUSCODE_GOOD`` is returned. An error code |
166 | | * otherwise. */ |
167 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
168 | | UA_Server_addTimedCallback(UA_Server *server, UA_ServerCallback callback, |
169 | | void *data, UA_DateTime date, UA_UInt64 *callbackId); |
170 | | |
171 | | /* Add a callback for cyclic repetition to the server. |
172 | | * |
173 | | * @param server The server object. |
174 | | * @param callback The callback that shall be added. |
175 | | * @param data Data that is forwarded to the callback. |
176 | | * @param interval_ms The callback shall be repeatedly executed with the given |
177 | | * interval (in ms). The interval must be positive. The first execution |
178 | | * occurs at now() + interval at the latest. |
179 | | * @param callbackId Set to the identifier of the repeated callback . This can |
180 | | * be used to cancel the callback later on. If the pointer is null, the |
181 | | * identifier is not set. |
182 | | * @return Upon success, ``UA_STATUSCODE_GOOD`` is returned. An error code |
183 | | * otherwise. */ |
184 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
185 | | UA_Server_addRepeatedCallback(UA_Server *server, UA_ServerCallback callback, |
186 | | void *data, UA_Double interval_ms, |
187 | | UA_UInt64 *callbackId); |
188 | | |
189 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
190 | | UA_Server_changeRepeatedCallbackInterval(UA_Server *server, UA_UInt64 callbackId, |
191 | | UA_Double interval_ms); |
192 | | |
193 | | /* Remove a repeated callback. Does nothing if the callback is not found. */ |
194 | | void UA_EXPORT UA_THREADSAFE |
195 | | UA_Server_removeCallback(UA_Server *server, UA_UInt64 callbackId); |
196 | | |
197 | | #define UA_Server_removeRepeatedCallback(server, callbackId) \ |
198 | | UA_Server_removeCallback(server, callbackId) |
199 | | |
200 | | /** |
201 | | * Application Notification |
202 | | * ------------------------ |
203 | | * The server defines callbacks to notify the application on defined triggering |
204 | | * points. These callbacks are executed with the (re-entrant) server-mutex held. |
205 | | * |
206 | | * The different types of callback are disambiguated by their type enum. Besides |
207 | | * the global notification callback (which is always triggered), the server |
208 | | * configuration contains specialized callbacks that trigger only for specific |
209 | | * notifications. This can reduce the burden of high-frequency notifications. |
210 | | * |
211 | | * If a specialized notification callback is set, it always gets called before |
212 | | * the global notification callback for the same triggering point. |
213 | | * |
214 | | * See the section on the :ref:`Application Notification` enum for more |
215 | | * documentation on the notifications and their defined payload. */ |
216 | | |
217 | | typedef void (*UA_ServerNotificationCallback)(UA_Server *server, |
218 | | UA_ApplicationNotificationType type, |
219 | | const UA_KeyValueMap payload); |
220 | | |
221 | | /** |
222 | | * .. _server-session-handling: |
223 | | * |
224 | | * Session Handling |
225 | | * ---------------- |
226 | | * Sessions are managed via the OPC UA Session Service Set (CreateSession, |
227 | | * ActivateSession, CloseSession). The identifier of sessions is generated |
228 | | * internally in the server and is always a Guid-NodeId. |
229 | | * |
230 | | * The creation of sessions is passed to the :ref:`access-control`. There, the |
231 | | * authentication information is evaluated and a context-pointer is attached to |
232 | | * the new session. The context pointer (and the session identifier) are then |
233 | | * forwarded to all user-defined callbacks that can be triggere by a session. |
234 | | * |
235 | | * When the operations from the OPC UA Services are invoked locally via the |
236 | | * C-API, this implies that the operations are executed with the access rights |
237 | | * of the "admin-session" that is always present in a server. Any AccessControl |
238 | | * checks are omitted for the admin-session. |
239 | | * |
240 | | * The admin-session has the identifier |
241 | | * ``g=00000001-0000-0000-0000-000000000000``. Its session context pointer needs |
242 | | * to be manually set (NULL by default). */ |
243 | | |
244 | | void UA_EXPORT |
245 | | UA_Server_setAdminSessionContext(UA_Server *server, void *context); |
246 | | |
247 | | /* Manually close a session */ |
248 | | UA_EXPORT UA_StatusCode UA_THREADSAFE |
249 | | UA_Server_closeSession(UA_Server *server, const UA_NodeId *sessionId); |
250 | | |
251 | | /** |
252 | | * Besides the session context pointer from the AccessControl plugin, a session |
253 | | * carries attributes in a key-value map. Always defined (and read-only) session |
254 | | * attributes are: |
255 | | * |
256 | | * - ``0:localeIds`` (``UA_String``): List of preferred languages |
257 | | * - ``0:clientDescription`` (``UA_ApplicationDescription``): Client description |
258 | | * - ``0:sessionName`` (``String``): Client-defined name of the session |
259 | | * - ``0:clientUserId`` (``String``): User identifier used to activate the session |
260 | | * |
261 | | * Additional attributes can be set manually with the API below. */ |
262 | | |
263 | | /* Returns a shallow copy of the attribute (don't _clear or _delete manually). |
264 | | * While the method is thread-safe, the returned value is not protected. Only |
265 | | * use it in a (callback) context where the server is locked for the current |
266 | | * thread. */ |
267 | | UA_EXPORT UA_StatusCode UA_THREADSAFE |
268 | | UA_Server_getSessionAttribute(UA_Server *server, const UA_NodeId *sessionId, |
269 | | const UA_QualifiedName key, UA_Variant *outValue); |
270 | | |
271 | | /* Return a deep copy of the attribute */ |
272 | | UA_EXPORT UA_StatusCode UA_THREADSAFE |
273 | | UA_Server_getSessionAttributeCopy(UA_Server *server, const UA_NodeId *sessionId, |
274 | | const UA_QualifiedName key, UA_Variant *outValue); |
275 | | |
276 | | /* Returns NULL if the attribute is not defined or not a scalar or not of the |
277 | | * right datatype. Otherwise a shallow copy of the scalar value is created at |
278 | | * the target location of the void pointer (don't _clear or _delete manually). |
279 | | * While the method is thread-safe, the returned value is not protected. Only |
280 | | * use it in a (callback) context where the server is locked for the current |
281 | | * thread. */ |
282 | | UA_EXPORT UA_StatusCode UA_THREADSAFE |
283 | | UA_Server_getSessionAttribute_scalar(UA_Server *server, |
284 | | const UA_NodeId *sessionId, |
285 | | const UA_QualifiedName key, |
286 | | const UA_DataType *type, |
287 | | void *outValue); |
288 | | |
289 | | UA_EXPORT UA_StatusCode UA_THREADSAFE |
290 | | UA_Server_setSessionAttribute(UA_Server *server, const UA_NodeId *sessionId, |
291 | | const UA_QualifiedName key, |
292 | | const UA_Variant *value); |
293 | | |
294 | | UA_EXPORT UA_StatusCode UA_THREADSAFE |
295 | | UA_Server_deleteSessionAttribute(UA_Server *server, const UA_NodeId *sessionId, |
296 | | const UA_QualifiedName key); |
297 | | |
298 | | /** |
299 | | * Attribute Service Set |
300 | | * --------------------- |
301 | | * The functions for reading and writing node attributes call the regular read |
302 | | * and write service in the background that are also used over the network. |
303 | | * |
304 | | * The following attributes cannot be read, since the local "admin" user always |
305 | | * has full rights. |
306 | | * |
307 | | * - UserWriteMask |
308 | | * - UserAccessLevel |
309 | | * - UserExecutable */ |
310 | | |
311 | | /* Read an attribute of a node. Returns a deep copy. */ |
312 | | UA_DataValue UA_EXPORT UA_THREADSAFE |
313 | | UA_Server_read(UA_Server *server, const UA_ReadValueId *item, |
314 | | UA_TimestampsToReturn timestamps); |
315 | | |
316 | | /** |
317 | | * The following specialized read methods are a shorthand for the regular read |
318 | | * and set a deep copy of the attribute to the ``out`` pointer (when |
319 | | * successful). */ |
320 | | |
321 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
322 | | UA_Server_readNodeId(UA_Server *server, const UA_NodeId nodeId, |
323 | | UA_NodeId *out); |
324 | | |
325 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
326 | | UA_Server_readNodeClass(UA_Server *server, const UA_NodeId nodeId, |
327 | | UA_NodeClass *out); |
328 | | |
329 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
330 | | UA_Server_readBrowseName(UA_Server *server, const UA_NodeId nodeId, |
331 | | UA_QualifiedName *out); |
332 | | |
333 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
334 | | UA_Server_readDisplayName(UA_Server *server, const UA_NodeId nodeId, |
335 | | UA_LocalizedText *out); |
336 | | |
337 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
338 | | UA_Server_readDescription(UA_Server *server, const UA_NodeId nodeId, |
339 | | UA_LocalizedText *out); |
340 | | |
341 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
342 | | UA_Server_readWriteMask(UA_Server *server, const UA_NodeId nodeId, |
343 | | UA_UInt32 *out); |
344 | | |
345 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
346 | | UA_Server_readIsAbstract(UA_Server *server, const UA_NodeId nodeId, |
347 | | UA_Boolean *out); |
348 | | |
349 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
350 | | UA_Server_readSymmetric(UA_Server *server, const UA_NodeId nodeId, |
351 | | UA_Boolean *out); |
352 | | |
353 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
354 | | UA_Server_readInverseName(UA_Server *server, const UA_NodeId nodeId, |
355 | | UA_LocalizedText *out); |
356 | | |
357 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
358 | | UA_Server_readContainsNoLoops(UA_Server *server, const UA_NodeId nodeId, |
359 | | UA_Boolean *out); |
360 | | |
361 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
362 | | UA_Server_readEventNotifier(UA_Server *server, const UA_NodeId nodeId, |
363 | | UA_Byte *out); |
364 | | |
365 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
366 | | UA_Server_readValue(UA_Server *server, const UA_NodeId nodeId, |
367 | | UA_Variant *out); |
368 | | |
369 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
370 | | UA_Server_readDataType(UA_Server *server, const UA_NodeId nodeId, |
371 | | UA_NodeId *out); |
372 | | |
373 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
374 | | UA_Server_readValueRank(UA_Server *server, const UA_NodeId nodeId, |
375 | | UA_Int32 *out); |
376 | | |
377 | | /* Returns a variant with an uint32 array */ |
378 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
379 | | UA_Server_readArrayDimensions(UA_Server *server, const UA_NodeId nodeId, |
380 | | UA_Variant *out); |
381 | | |
382 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
383 | | UA_Server_readAccessLevel(UA_Server *server, const UA_NodeId nodeId, |
384 | | UA_Byte *out); |
385 | | |
386 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
387 | | UA_Server_readAccessLevelEx(UA_Server *server, const UA_NodeId nodeId, |
388 | | UA_UInt32 *out); |
389 | | |
390 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
391 | | UA_Server_readMinimumSamplingInterval(UA_Server *server, const UA_NodeId nodeId, |
392 | | UA_Double *out); |
393 | | |
394 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
395 | | UA_Server_readHistorizing(UA_Server *server, const UA_NodeId nodeId, |
396 | | UA_Boolean *out); |
397 | | |
398 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
399 | | UA_Server_readExecutable(UA_Server *server, const UA_NodeId nodeId, |
400 | | UA_Boolean *out); |
401 | | |
402 | | /** |
403 | | * The following node attributes cannot be written once a node has been created: |
404 | | * |
405 | | * - NodeClass |
406 | | * - NodeId |
407 | | * - Symmetric |
408 | | * - ContainsNoLoops |
409 | | * |
410 | | * The following attributes cannot be written from C-API, as they are specific |
411 | | * to the session (context set by the access control callback): |
412 | | * |
413 | | * - UserWriteMask |
414 | | * - UserAccessLevel |
415 | | * - UserExecutable |
416 | | */ |
417 | | |
418 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
419 | | UA_Server_write(UA_Server *server, const UA_WriteValue *value); |
420 | | |
421 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
422 | | UA_Server_writeBrowseName(UA_Server *server, const UA_NodeId nodeId, |
423 | | const UA_QualifiedName browseName); |
424 | | |
425 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
426 | | UA_Server_writeDisplayName(UA_Server *server, const UA_NodeId nodeId, |
427 | | const UA_LocalizedText displayName); |
428 | | |
429 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
430 | | UA_Server_writeDescription(UA_Server *server, const UA_NodeId nodeId, |
431 | | const UA_LocalizedText description); |
432 | | |
433 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
434 | | UA_Server_writeWriteMask(UA_Server *server, const UA_NodeId nodeId, |
435 | | const UA_UInt32 writeMask); |
436 | | |
437 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
438 | | UA_Server_writeIsAbstract(UA_Server *server, const UA_NodeId nodeId, |
439 | | const UA_Boolean isAbstract); |
440 | | |
441 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
442 | | UA_Server_writeInverseName(UA_Server *server, const UA_NodeId nodeId, |
443 | | const UA_LocalizedText inverseName); |
444 | | |
445 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
446 | | UA_Server_writeEventNotifier(UA_Server *server, const UA_NodeId nodeId, |
447 | | const UA_Byte eventNotifier); |
448 | | |
449 | | /* The value attribute is a DataValue. Here only a variant is provided. The |
450 | | * StatusCode is set to UA_STATUSCODE_GOOD, sourceTimestamp and serverTimestamp |
451 | | * are set to UA_DateTime_now(). See below for setting the full DataValue. */ |
452 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
453 | | UA_Server_writeValue(UA_Server *server, const UA_NodeId nodeId, |
454 | | const UA_Variant value); |
455 | | |
456 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
457 | | UA_Server_writeDataValue(UA_Server *server, const UA_NodeId nodeId, |
458 | | const UA_DataValue value); |
459 | | |
460 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
461 | | UA_Server_writeDataType(UA_Server *server, const UA_NodeId nodeId, |
462 | | const UA_NodeId dataType); |
463 | | |
464 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
465 | | UA_Server_writeValueRank(UA_Server *server, const UA_NodeId nodeId, |
466 | | const UA_Int32 valueRank); |
467 | | |
468 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
469 | | UA_Server_writeArrayDimensions(UA_Server *server, const UA_NodeId nodeId, |
470 | | const UA_Variant arrayDimensions); |
471 | | |
472 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
473 | | UA_Server_writeAccessLevel(UA_Server *server, const UA_NodeId nodeId, |
474 | | const UA_Byte accessLevel); |
475 | | |
476 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
477 | | UA_Server_writeAccessLevelEx(UA_Server *server, const UA_NodeId nodeId, |
478 | | const UA_UInt32 accessLevelEx); |
479 | | |
480 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
481 | | UA_Server_writeMinimumSamplingInterval(UA_Server *server, const UA_NodeId nodeId, |
482 | | const UA_Double miniumSamplingInterval); |
483 | | |
484 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
485 | | UA_Server_writeHistorizing(UA_Server *server, const UA_NodeId nodeId, |
486 | | const UA_Boolean historizing); |
487 | | |
488 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
489 | | UA_Server_writeExecutable(UA_Server *server, const UA_NodeId nodeId, |
490 | | const UA_Boolean executable); |
491 | | |
492 | | /** |
493 | | * .. _server-method-call: |
494 | | * |
495 | | * Method Service Set |
496 | | * ------------------ |
497 | | * |
498 | | * The Method Service Set defines the means to invoke methods. A MethodNode is a |
499 | | * component of an ObjectNode or of an ObjectTypeNode. The input and output |
500 | | * arguments of a method are a list of ``UA_Variant``. The type- and |
501 | | * size-requirements of the arguments can be retrieved from the |
502 | | * **InputArguments** and **OutputArguments** variable below the MethodNode. |
503 | | * |
504 | | * For calling a method, both ``methodId`` and ``objectId`` need to be defined |
505 | | * by their NodeId. This is required because the same MethodNode can be |
506 | | * referenced from multiple objects. |
507 | | * |
508 | | * In this server implementation, when an object is instantiated from a an |
509 | | * ObjectType, all (mandatory) methods are automatically added to the new object |
510 | | * instance. This is done by adding an additional reference to the original |
511 | | * MethodNode. It is however possible to add a custom MethodNode directly to the |
512 | | * object instance. It is also possible to remove a (optional) MethodNode that |
513 | | * exists in the ObjectType from an instance. |
514 | | * |
515 | | * The ``methodId`` can point to a MethodNode that exists in the ObjectType but |
516 | | * not in the object instance. It is resolved to the actual MethodNode of the |
517 | | * object instance by taking the *BrowseName* attribute of the |
518 | | * ``methodId``-MethodNode and looking up the member of the ``objectId`` object |
519 | | * with the same BrowseName. |
520 | | * |
521 | | * The resolved MethodNode then is used to |
522 | | * |
523 | | * - Check permissions for the current Session to call the method |
524 | | * - Obtain the ``UA_MethodCallback`` to execute |
525 | | * - Forwarded as ``methodId`` to said callback |
526 | | * |
527 | | * To showcase the resolution of the MethodNode with an example, consider this |
528 | | * information model:: |
529 | | * |
530 | | * ObjectType ObjectType Object |
531 | | * Creature (i=10) <-isSubTypeOf- Insect (i=20) <-hasTypeDef- Ant (i=30) |
532 | | * | | | |
533 | | * hasComponent hasComponent hasComponent |
534 | | * | | | |
535 | | * v v v |
536 | | * Methods Methods Methods |
537 | | * - Walk (i=11) - Walk (i=21) - Walk (i=31) |
538 | | * - Fly (i=12) - Fly (i=22) - Amount (i=33) |
539 | | * - Amount (i=13) - Amount (i=23) |
540 | | * |
541 | | * The following table shows what ``methodId`` - ``objectId`` combinations are |
542 | | * allowed to be used as parameters for the Call service and the resolved |
543 | | * ``methodId``. |
544 | | * |
545 | | * ======== ======== ==================================== ================= |
546 | | * objectId methodId Corresponds to in OO-languages Resolved methodId |
547 | | * ======== ======== ==================================== ================= |
548 | | * i=30 i=31 ``Ant a; a.Walk();`` i=31 |
549 | | * i=30 i=21 ``Ant a; Insect i = a; i.Walk();`` i=31 |
550 | | * i=30 i=11 ``Ant a; Creature c = a; c.Walk();`` i=31 |
551 | | * i=20 i=23 ``Insect::Amount();`` i=23 |
552 | | * i=10 i=13 ``Creature::Amount();`` i=13 |
553 | | * ======== ======== ==================================== ================= |
554 | | * |
555 | | * The next table shows ``methodId`` - ``objectId`` combinations that are not |
556 | | * allowed. Note that an ObjecType cannot execute a methodId from a subtype or |
557 | | * instance. |
558 | | * |
559 | | * ======== ======== ===================================================== |
560 | | * objectId methodId Reason |
561 | | * ======== ======== ===================================================== |
562 | | * i=30 i=22 Object "Ant" does not own a method "Fly" |
563 | | * i=30 i=12 Object "Ant" does not own a method "Fly" |
564 | | * i=10 i=23 The method is not owned by the object type "Creature" |
565 | | * i=20 i=13 The method is not owned by the object type "Insect" |
566 | | * ======== ======== ===================================================== */ |
567 | | |
568 | | #ifdef UA_ENABLE_METHODCALLS |
569 | | UA_CallMethodResult UA_EXPORT UA_THREADSAFE |
570 | | UA_Server_call(UA_Server *server, const UA_CallMethodRequest *request); |
571 | | #endif |
572 | | |
573 | | /** |
574 | | * View Service Set |
575 | | * ---------------- |
576 | | * The View Service Set allows Clients to discover Nodes by browsing the |
577 | | * information model. */ |
578 | | |
579 | | /* Browse the references of a particular node. See the definition of |
580 | | * BrowseDescription structure for details. */ |
581 | | UA_BrowseResult UA_EXPORT UA_THREADSAFE |
582 | | UA_Server_browse(UA_Server *server, UA_UInt32 maxReferences, |
583 | | const UA_BrowseDescription *bd); |
584 | | |
585 | | UA_BrowseResult UA_EXPORT UA_THREADSAFE |
586 | | UA_Server_browseNext(UA_Server *server, UA_Boolean releaseContinuationPoint, |
587 | | const UA_ByteString *continuationPoint); |
588 | | |
589 | | /* Non-standard version of the Browse service that recurses into child nodes. |
590 | | * |
591 | | * Possible loops (that can occur for non-hierarchical references) are handled |
592 | | * internally. Every node is added at most once to the results array. |
593 | | * |
594 | | * Nodes are only added if they match the NodeClassMask in the |
595 | | * BrowseDescription. However, child nodes are still recursed into if the |
596 | | * NodeClass does not match. So it is possible, for example, to get all |
597 | | * VariableNodes below a certain ObjectNode, with additional objects in the |
598 | | * hierarchy below. */ |
599 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
600 | | UA_Server_browseRecursive(UA_Server *server, const UA_BrowseDescription *bd, |
601 | | size_t *resultsSize, UA_ExpandedNodeId **results); |
602 | | |
603 | | /* Translate abrowse path to (potentially several) NodeIds. Each browse path is |
604 | | * constructed of a starting Node and a RelativePath. The specified starting |
605 | | * Node identifies the Node from which the RelativePath is based. The |
606 | | * RelativePath contains a sequence of ReferenceTypes and BrowseNames. */ |
607 | | UA_BrowsePathResult UA_EXPORT UA_THREADSAFE |
608 | | UA_Server_translateBrowsePathToNodeIds(UA_Server *server, |
609 | | const UA_BrowsePath *browsePath); |
610 | | |
611 | | /* A simplified TranslateBrowsePathsToNodeIds based on the |
612 | | * SimpleAttributeOperand type (Part 4, 7.4.4.5). |
613 | | * |
614 | | * This specifies a relative path using a list of BrowseNames instead of the |
615 | | * RelativePath structure. The list of BrowseNames is equivalent to a |
616 | | * RelativePath that specifies forward references which are subtypes of the |
617 | | * HierarchicalReferences ReferenceType. All Nodes followed by the browsePath |
618 | | * shall be of the NodeClass Object or Variable. */ |
619 | | UA_BrowsePathResult UA_EXPORT UA_THREADSAFE |
620 | | UA_Server_browseSimplifiedBrowsePath(UA_Server *server, const UA_NodeId origin, |
621 | | size_t browsePathSize, |
622 | | const UA_QualifiedName *browsePath); |
623 | | |
624 | | #ifndef HAVE_NODEITER_CALLBACK |
625 | | #define HAVE_NODEITER_CALLBACK |
626 | | /* Iterate over all nodes referenced by parentNodeId by calling the callback |
627 | | * function for each child node (in ifdef because GCC/CLANG handle include order |
628 | | * differently) */ |
629 | | typedef UA_StatusCode |
630 | | (*UA_NodeIteratorCallback)(UA_NodeId childId, UA_Boolean isInverse, |
631 | | UA_NodeId referenceTypeId, void *handle); |
632 | | #endif |
633 | | |
634 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
635 | | UA_Server_forEachChildNodeCall(UA_Server *server, UA_NodeId parentNodeId, |
636 | | UA_NodeIteratorCallback callback, void *handle); |
637 | | |
638 | | /** |
639 | | * .. _local-monitoreditems: |
640 | | * |
641 | | * MonitoredItem Service Set |
642 | | * ------------------------- |
643 | | * MonitoredItems are used with the Subscription mechanism of OPC UA to |
644 | | * transported notifications for data changes and events. MonitoredItems can |
645 | | * also be registered locally. Notifications are then forwarded to a |
646 | | * user-defined callback instead of a remote client. |
647 | | * |
648 | | * Local MonitoredItems are delivered asynchronously. That is, the notification |
649 | | * is inserted as a *Delayed Callback* for the EventLoop. The callback is then |
650 | | * triggered when the control flow next returns to the EventLoop. */ |
651 | | |
652 | | #ifdef UA_ENABLE_SUBSCRIPTIONS |
653 | | |
654 | | /* Delete a local MonitoredItem. Used for both DataChange- and |
655 | | * Event-MonitoredItems. */ |
656 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
657 | | UA_Server_deleteMonitoredItem(UA_Server *server, UA_UInt32 monitoredItemId); |
658 | | |
659 | | typedef void (*UA_Server_DataChangeNotificationCallback) |
660 | | (UA_Server *server, UA_UInt32 monitoredItemId, void *monitoredItemContext, |
661 | | const UA_NodeId *nodeId, void *nodeContext, UA_UInt32 attributeId, |
662 | | const UA_DataValue *value); |
663 | | |
664 | | /** |
665 | | * DataChange MonitoredItem use a sampling interval and filter criteria to |
666 | | * notify the userland about value changes. Note that the sampling interval can |
667 | | * also be zero to be notified about changes "right away". For this we hook the |
668 | | * MonitoredItem into the observed Node and check the filter after every call of |
669 | | * the Write-Service. */ |
670 | | |
671 | | /* Create a local MonitoredItem to detect data changes. |
672 | | * |
673 | | * @param server The server executing the MonitoredItem |
674 | | * @param timestampsToReturn Shall timestamps be added to the value for the |
675 | | * callback? |
676 | | * @param item The parameters of the new MonitoredItem. Note that the attribute |
677 | | * of the ReadValueId (the node that is monitored) can not be |
678 | | * ``UA_ATTRIBUTEID_EVENTNOTIFIER``. See below for event notifications. |
679 | | * @param monitoredItemContext A pointer that is forwarded with the callback |
680 | | * @param callback The callback that is executed on detected data changes |
681 | | * @return Returns a description of the created MonitoredItem. The structure |
682 | | * also contains a StatusCode (in case of an error) and the identifier |
683 | | * of the new MonitoredItem. */ |
684 | | UA_MonitoredItemCreateResult UA_EXPORT UA_THREADSAFE |
685 | | UA_Server_createDataChangeMonitoredItem(UA_Server *server, |
686 | | UA_TimestampsToReturn timestampsToReturn, |
687 | | const UA_MonitoredItemCreateRequest item, |
688 | | void *monitoredItemContext, |
689 | | UA_Server_DataChangeNotificationCallback callback); |
690 | | |
691 | | /** |
692 | | * See the section on :ref`events` for how to emit events in the server. |
693 | | * |
694 | | * Event-MonitoredItems emit notifications with a list of "fields" (variants). |
695 | | * The fields are specified as *SimpleAttributeOperands* in the select-clause of |
696 | | * the MonitoredItem's event filter. For the local event callback, instead of |
697 | | * using a list of variants, we use a key-value map for the event fields. They |
698 | | * key names are generated with ``UA_SimpleAttributeOperand_print`` to get a |
699 | | * human-readable representation. |
700 | | * |
701 | | * The received event-fields map could look like this:: |
702 | | * |
703 | | * /Severity => UInt16(1000) |
704 | | * /Message => LocalizedText("en-US", "My Event Message") |
705 | | * /EventType => NodeId(i=50831) |
706 | | * /SourceNode => NodeId(i=2253) |
707 | | * |
708 | | * The order of the keys is identical to the order of SimpleAttributeOperands in |
709 | | * the select-clause. This feature requires the build flag ``UA_ENABLE_PARSING`` |
710 | | * enabled. Otherwise the key-value map uses empty keys (the order of fields is |
711 | | * still the same as the specified select-clauses). */ |
712 | | |
713 | | #ifdef UA_ENABLE_SUBSCRIPTIONS_EVENTS |
714 | | |
715 | | typedef void (*UA_Server_EventNotificationCallback) |
716 | | (UA_Server *server, UA_UInt32 monitoredItemId, void *monitoredItemContext, |
717 | | const UA_KeyValueMap eventFields); |
718 | | |
719 | | /* Create a local MonitoredItem for Events. The API is simplifed compared to a |
720 | | * UA_MonitoredItemCreateRequest. The unavailable options are not relevant for |
721 | | * local MonitoredItems (e.g. the queue size) or not relevant for Event |
722 | | * MonitoredItems (e.g. the sampling interval). |
723 | | * |
724 | | * @param server The server executing the MonitoredItem |
725 | | * @param nodeId The node where events are collected. Note that events "bubble |
726 | | * up" to their parents (via hierarchical references). |
727 | | * @param filter The filter defined which event fields are selected (select |
728 | | * clauses) and which events are considered for this particular |
729 | | * MonitoredItem (where clause). |
730 | | * @param monitoredItemContext A pointer that is forwarded with the callback |
731 | | * @param callback The callback that is executed for each event |
732 | | * @return Returns a description of the created MonitoredItem. The structure |
733 | | * also contains a StatusCode (in case of an error) and the identifier |
734 | | * of the new MonitoredItem. */ |
735 | | UA_MonitoredItemCreateResult UA_EXPORT UA_THREADSAFE |
736 | | UA_Server_createEventMonitoredItem(UA_Server *server, const UA_NodeId nodeId, |
737 | | const UA_EventFilter filter, |
738 | | void *monitoredItemContext, |
739 | | UA_Server_EventNotificationCallback callback); |
740 | | |
741 | | /* Extended version UA_Server_createEventMonitoredItem that allows setting of |
742 | | * uncommon parameters (for local MonitoredItems) like the MonitoringMode and |
743 | | * queue sizes. |
744 | | * |
745 | | * @param server The server executing the MonitoredItem |
746 | | * @param item The description of the MonitoredItem. Must use |
747 | | * UA_ATTRIBUTEID_EVENTNOTIFIER and an EventFilter. |
748 | | * @param monitoredItemContext A pointer that is forwarded with the callback |
749 | | * @param callback The callback that is executed for each event |
750 | | * @return Returns a description of the created MonitoredItem. The structure |
751 | | * also contains a StatusCode (in case of an error) and the identifier |
752 | | * of the new MonitoredItem. */ |
753 | | UA_MonitoredItemCreateResult UA_EXPORT UA_THREADSAFE |
754 | | UA_Server_createEventMonitoredItemEx(UA_Server *server, |
755 | | const UA_MonitoredItemCreateRequest item, |
756 | | void *monitoredItemContext, |
757 | | UA_Server_EventNotificationCallback callback); |
758 | | |
759 | | #endif /* UA_ENABLE_SUBSCRIPTIONS_EVENTS */ |
760 | | |
761 | | #endif /* UA_ENABLE_SUBSCRIPTIONS */ |
762 | | |
763 | | /** |
764 | | * .. _server-node-management: |
765 | | * |
766 | | * Node Management Service Set |
767 | | * --------------------------- |
768 | | * When creating dynamic node instances at runtime, chances are that you will |
769 | | * not care about the specific NodeId of the new node, as long as you can |
770 | | * reference it later. When passing numeric NodeIds with a numeric identifier 0, |
771 | | * the stack evaluates this as "select a random unassigned numeric NodeId in |
772 | | * that namespace". To find out which NodeId was actually assigned to the new |
773 | | * node, you may pass a pointer `outNewNodeId`, which will (after a successful |
774 | | * node insertion) contain the nodeId of the new node. You may also pass a |
775 | | * ``NULL`` pointer if this result is not needed. |
776 | | * |
777 | | * See the Section :ref:`node-lifecycle` on constructors and on attaching |
778 | | * user-defined data to nodes. |
779 | | * |
780 | | * The Section :ref:`default-node-attributes` contains useful starting points |
781 | | * for defining node attributes. Forgetting to set the ValueRank or the |
782 | | * AccessLevel leads to errors that can be hard to track down for new users. The |
783 | | * default attributes have a high likelihood to "do the right thing". |
784 | | * |
785 | | * The methods for node addition and deletion take mostly const arguments that |
786 | | * are not modified. When creating a node, a deep copy of the node identifier, |
787 | | * node attributes, etc. is created. Therefore, it is possible to call for |
788 | | * example ``UA_Server_addVariablenode`` with a value attribute (a |
789 | | * :ref:`variant`) pointing to a memory location on the stack. |
790 | | * |
791 | | * .. _variable-node: |
792 | | * |
793 | | * VariableNode |
794 | | * ~~~~~~~~~~~~ |
795 | | * Variables store values as well as contraints for possible values. There are |
796 | | * three options for storing the value: Internal in the VariableNode data |
797 | | * structure itself, external with a double-pointer (to switch to an updated |
798 | | * value with an atomic pointer-replacing operation) or with a callback |
799 | | * registered by the application. */ |
800 | | |
801 | | typedef enum { |
802 | | UA_VALUESOURCETYPE_INTERNAL = 0, |
803 | | UA_VALUESOURCETYPE_EXTERNAL = 1, |
804 | | UA_VALUESOURCETYPE_CALLBACK = 2 |
805 | | } UA_ValueSourceType; |
806 | | |
807 | | typedef struct { |
808 | | /* Notify the application before the value attribute is read. Ignored if |
809 | | * NULL. It is possible to write into the value attribute during onRead |
810 | | * (using the write service). The node is re-retrieved from the Nodestore |
811 | | * afterwards so that changes are considered in the following read |
812 | | * operation. |
813 | | * |
814 | | * @param handle Points to user-provided data for the callback. |
815 | | * @param nodeid The identifier of the node. |
816 | | * @param data Points to the current node value. |
817 | | * @param range Points to the numeric range the client wants to read from |
818 | | * (or NULL). */ |
819 | | void (*onRead)(UA_Server *server, const UA_NodeId *sessionId, |
820 | | void *sessionContext, const UA_NodeId *nodeid, |
821 | | void *nodeContext, const UA_NumericRange *range, |
822 | | const UA_DataValue *value); |
823 | | |
824 | | /* Notify the application after writing the value attribute. Ignored if |
825 | | * NULL. The node is re-retrieved after writing, so that the new value is |
826 | | * visible in the callback. |
827 | | * |
828 | | * @param server The server executing the callback |
829 | | * @sessionId The identifier of the session |
830 | | * @sessionContext Additional data attached to the session |
831 | | * in the access control layer |
832 | | * @param nodeid The identifier of the node. |
833 | | * @param nodeUserContext Additional data attached to the node by |
834 | | * the user. |
835 | | * @param nodeConstructorContext Additional data attached to the node |
836 | | * by the type constructor(s). |
837 | | * @param range Points to the numeric range the client wants to write to (or |
838 | | * NULL). */ |
839 | | void (*onWrite)(UA_Server *server, const UA_NodeId *sessionId, |
840 | | void *sessionContext, const UA_NodeId *nodeId, |
841 | | void *nodeContext, const UA_NumericRange *range, |
842 | | const UA_DataValue *data); |
843 | | } UA_ValueSourceNotifications; |
844 | | |
845 | | typedef struct { |
846 | | /* Copies the data from the source into the provided value. |
847 | | * |
848 | | * !! ZERO-COPY OPERATIONS POSSIBLE !! |
849 | | * It is not required to return a copy of the actual content data. You can |
850 | | * return a pointer to memory owned by the user. Memory can be reused |
851 | | * between read callbacks of a DataSource, as the result is already encoded |
852 | | * on the network buffer between each read operation. |
853 | | * |
854 | | * To use zero-copy reads, set the value of the `value->value` Variant |
855 | | * without copying, e.g. with `UA_Variant_setScalar`. Then, also set |
856 | | * `value->value.storageType` to `UA_VARIANT_DATA_NODELETE` to prevent the |
857 | | * memory being cleaned up. Don't forget to also set `value->hasValue` to |
858 | | * true to indicate the presence of a value. |
859 | | * |
860 | | * To make an async read, return UA_STATUSCODE_GOODCOMPLETESASYNCHRONOUSLY. |
861 | | * The result can then be set at a later time using |
862 | | * UA_Server_setAsyncReadResult. Note that the server might cancel the async |
863 | | * read by calling serverConfig->asyncOperationCancelCallback. |
864 | | * |
865 | | * @param server The server executing the callback |
866 | | * @param sessionId The identifier of the session |
867 | | * @param sessionContext Additional data attached to the session in the |
868 | | * access control layer |
869 | | * @param nodeId The identifier of the node being read from |
870 | | * @param nodeContext Additional data attached to the node by the user |
871 | | * @param includeSourceTimeStamp If true, then the datasource is expected to |
872 | | * set the source timestamp in the returned value |
873 | | * @param range If not null, then the datasource shall return only a |
874 | | * selection of the (nonscalar) data. Set |
875 | | * UA_STATUSCODE_BADINDEXRANGEINVALID in the value if this does not |
876 | | * apply |
877 | | * @param value The (non-null) DataValue that is returned to the client. The |
878 | | * data source sets the read data, the result status and optionally a |
879 | | * sourcetimestamp. |
880 | | * @return Returns a status code for logging. Error codes intended for the |
881 | | * original caller are set in the value. If an error is returned, |
882 | | * then no releasing of the value is done. */ |
883 | | UA_StatusCode (*read)(UA_Server *server, const UA_NodeId *sessionId, |
884 | | void *sessionContext, const UA_NodeId *nodeId, |
885 | | void *nodeContext, UA_Boolean includeSourceTimeStamp, |
886 | | const UA_NumericRange *range, UA_DataValue *value); |
887 | | |
888 | | /* Write into a data source. This method pointer can be NULL if the |
889 | | * operation is unsupported. |
890 | | * |
891 | | * To make an async write, return UA_STATUSCODE_GOODCOMPLETESASYNCHRONOUSLY. |
892 | | * The result can then be set at a later time using |
893 | | * UA_Server_setAsyncWriteResult. Note that the server might cancel the |
894 | | * async read by calling serverConfig->asyncOperationCancelCallback. |
895 | | * |
896 | | * @param server The server executing the callback |
897 | | * @param sessionId The identifier of the session |
898 | | * @param sessionContext Additional data attached to the session in the |
899 | | * access control layer |
900 | | * @param nodeId The identifier of the node being written to |
901 | | * @param nodeContext Additional data attached to the node by the user |
902 | | * @param range If not NULL, then the datasource shall return only a |
903 | | * selection of the (nonscalar) data. Set |
904 | | * UA_STATUSCODE_BADINDEXRANGEINVALID in the value if this does not |
905 | | * apply |
906 | | * @param value The (non-NULL) DataValue that has been written by the client. |
907 | | * The data source contains the written data, the result status and |
908 | | * optionally a sourcetimestamp |
909 | | * @return Returns a status code for logging. Error codes intended for the |
910 | | * original caller are set in the value. If an error is returned, |
911 | | * then no releasing of the value is done. */ |
912 | | UA_StatusCode (*write)(UA_Server *server, const UA_NodeId *sessionId, |
913 | | void *sessionContext, const UA_NodeId *nodeId, |
914 | | void *nodeContext, const UA_NumericRange *range, |
915 | | const UA_DataValue *value); |
916 | | } UA_CallbackValueSource; |
917 | | |
918 | | /** |
919 | | * By default, when adding a VariableNode, the value from the |
920 | | * ``UA_VariableAttributes`` is used. The methods following afterwards can be |
921 | | * used to override the value source. */ |
922 | | |
923 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
924 | | UA_Server_addVariableNode(UA_Server *server, const UA_NodeId requestedNewNodeId, |
925 | | const UA_NodeId parentNodeId, |
926 | | const UA_NodeId referenceTypeId, |
927 | | const UA_QualifiedName browseName, |
928 | | const UA_NodeId typeDefinition, |
929 | | const UA_VariableAttributes attr, |
930 | | void *nodeContext, UA_NodeId *outNewNodeId); |
931 | | |
932 | | /* Add a VariableNode with a callback value-source */ |
933 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
934 | | UA_Server_addCallbackValueSourceVariableNode(UA_Server *server, |
935 | | const UA_NodeId requestedNewNodeId, |
936 | | const UA_NodeId parentNodeId, |
937 | | const UA_NodeId referenceTypeId, |
938 | | const UA_QualifiedName browseName, |
939 | | const UA_NodeId typeDefinition, |
940 | | const UA_VariableAttributes attr, |
941 | | const UA_CallbackValueSource evs, |
942 | | void *nodeContext, UA_NodeId *outNewNodeId); |
943 | | |
944 | | /* Legacy API */ |
945 | | #define UA_Server_addDataSourceVariableNode(server, requestedNewNodeId, parentNodeId, \ |
946 | | referenceTypeId, browseName, typeDefinition, \ |
947 | | attr, dataSource, nodeContext, outNewNodeId) \ |
948 | | UA_Server_addCallbackValueSourceVariableNode(server, requestedNewNodeId, \ |
949 | | parentNodeId, referenceTypeId, \ |
950 | | browseName, typeDefinition, \ |
951 | | attr, dataSource, nodeContext, \ |
952 | | outNewNodeId) |
953 | | |
954 | | /* Set an internal value source. Both the value argument and the notifications |
955 | | * argument can be NULL. If value is NULL, the Read service is used to get the |
956 | | * latest value before switching from a callback to an internal value source. If |
957 | | * notifications is NULL, then all onRead/onWrite notifications are disabled. */ |
958 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
959 | | UA_Server_setVariableNode_internalValueSource(UA_Server *server, |
960 | | const UA_NodeId nodeId, const UA_DataValue *value, |
961 | | const UA_ValueSourceNotifications *notifications); |
962 | | |
963 | | /* For the external value, no initial copy is made. The node "just" points to |
964 | | * the provided double-pointer. Otherwise identical to the internal data |
965 | | * source. */ |
966 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
967 | | UA_Server_setVariableNode_externalValueSource(UA_Server *server, |
968 | | const UA_NodeId nodeId, UA_DataValue **value, |
969 | | const UA_ValueSourceNotifications *notifications); |
970 | | |
971 | | /* It is expected that the read callback is implemented. Whenever the value |
972 | | * attribute is read, the function will be called and asked to fill a |
973 | | * UA_DataValue structure that contains the value content and additional |
974 | | * metadata like timestamps. |
975 | | * |
976 | | * The write callback can be set to a null-pointer. Then writing into the value |
977 | | * is disabled. */ |
978 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
979 | | UA_Server_setVariableNode_callbackValueSource(UA_Server *server, |
980 | | const UA_NodeId nodeId, const UA_CallbackValueSource evs); |
981 | | |
982 | | /* Deprecated API */ |
983 | | typedef UA_CallbackValueSource UA_DataSource; |
984 | | #define UA_Server_setVariableNode_dataSource(server, nodeId, dataSource) \ |
985 | 0 | UA_Server_setVariableNode_callbackValueSource(server, nodeId, dataSource) |
986 | | |
987 | | /* Deprecated API */ |
988 | | typedef UA_ValueSourceNotifications UA_ValueCallback; |
989 | | #define UA_Server_setVariableNode_valueCallback(server, nodeId, callback) \ |
990 | | UA_Server_setVariableNode_internalValueSource(server, nodeId, NULL, &callback) |
991 | | |
992 | | /* VariableNodes that are "dynamic" (default for user-created variables) receive |
993 | | * and store a SourceTimestamp. For non-dynamic VariableNodes the current time |
994 | | * is used for the SourceTimestamp. */ |
995 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
996 | | UA_Server_setVariableNodeDynamic(UA_Server *server, const UA_NodeId nodeId, |
997 | | UA_Boolean isDynamic); |
998 | | |
999 | | /** |
1000 | | * VariableTypeNode |
1001 | | * ~~~~~~~~~~~~~~~~ */ |
1002 | | |
1003 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
1004 | | UA_Server_addVariableTypeNode(UA_Server *server, |
1005 | | const UA_NodeId requestedNewNodeId, |
1006 | | const UA_NodeId parentNodeId, |
1007 | | const UA_NodeId referenceTypeId, |
1008 | | const UA_QualifiedName browseName, |
1009 | | const UA_NodeId typeDefinition, |
1010 | | const UA_VariableTypeAttributes attr, |
1011 | | void *nodeContext, UA_NodeId *outNewNodeId); |
1012 | | |
1013 | | /** |
1014 | | * MethodNode |
1015 | | * ~~~~~~~~~~ |
1016 | | * Please refer to the :ref:`Method Service Set <server-method-call>` to get |
1017 | | * information about which MethodNodes may get executed and would thus require |
1018 | | * callbacks to be registered. */ |
1019 | | |
1020 | | typedef UA_StatusCode |
1021 | | (*UA_MethodCallback)(UA_Server *server, |
1022 | | const UA_NodeId *sessionId, void *sessionContext, |
1023 | | const UA_NodeId *methodId, void *methodContext, |
1024 | | const UA_NodeId *objectId, void *objectContext, |
1025 | | size_t inputSize, const UA_Variant *input, |
1026 | | size_t outputSize, UA_Variant *output); |
1027 | | |
1028 | | #ifdef UA_ENABLE_METHODCALLS |
1029 | | |
1030 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
1031 | | UA_Server_addMethodNode(UA_Server *server, const UA_NodeId requestedNewNodeId, |
1032 | | const UA_NodeId parentNodeId, const UA_NodeId referenceTypeId, |
1033 | | const UA_QualifiedName browseName, const UA_MethodAttributes attr, |
1034 | | UA_MethodCallback method, |
1035 | | size_t inputArgumentsSize, const UA_Argument *inputArguments, |
1036 | | size_t outputArgumentsSize, const UA_Argument *outputArguments, |
1037 | | void *nodeContext, UA_NodeId *outNewNodeId); |
1038 | | |
1039 | | /* Extended version, allows the additional definition of fixed NodeIds for the |
1040 | | * InputArgument/OutputArgument child variables */ |
1041 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1042 | | UA_Server_addMethodNodeEx(UA_Server *server, const UA_NodeId requestedNewNodeId, |
1043 | | const UA_NodeId parentNodeId, |
1044 | | const UA_NodeId referenceTypeId, |
1045 | | const UA_QualifiedName browseName, |
1046 | | const UA_MethodAttributes attr, UA_MethodCallback method, |
1047 | | size_t inputArgumentsSize, const UA_Argument *inputArguments, |
1048 | | const UA_NodeId inputArgumentsRequestedNewNodeId, |
1049 | | UA_NodeId *inputArgumentsOutNewNodeId, |
1050 | | size_t outputArgumentsSize, const UA_Argument *outputArguments, |
1051 | | const UA_NodeId outputArgumentsRequestedNewNodeId, |
1052 | | UA_NodeId *outputArgumentsOutNewNodeId, |
1053 | | void *nodeContext, UA_NodeId *outNewNodeId); |
1054 | | |
1055 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1056 | | UA_Server_setMethodNodeCallback(UA_Server *server, |
1057 | | const UA_NodeId methodNodeId, |
1058 | | UA_MethodCallback methodCallback); |
1059 | | |
1060 | | /* Backwards compatibility definition */ |
1061 | | #define UA_Server_setMethodNode_callback(server, methodNodeId, methodCallback) \ |
1062 | | UA_Server_setMethodNodeCallback(server, methodNodeId, methodCallback) |
1063 | | |
1064 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1065 | | UA_Server_getMethodNodeCallback(UA_Server *server, |
1066 | | const UA_NodeId methodNodeId, |
1067 | | UA_MethodCallback *outMethodCallback); |
1068 | | |
1069 | | #endif |
1070 | | |
1071 | | /** |
1072 | | * ObjectNode |
1073 | | * ~~~~~~~~~~ */ |
1074 | | |
1075 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
1076 | | UA_Server_addObjectNode(UA_Server *server, const UA_NodeId requestedNewNodeId, |
1077 | | const UA_NodeId parentNodeId, |
1078 | | const UA_NodeId referenceTypeId, |
1079 | | const UA_QualifiedName browseName, |
1080 | | const UA_NodeId typeDefinition, |
1081 | | const UA_ObjectAttributes attr, |
1082 | | void *nodeContext, UA_NodeId *outNewNodeId); |
1083 | | |
1084 | | /** |
1085 | | * ObjectTypeNode |
1086 | | * ~~~~~~~~~~~~~~ */ |
1087 | | |
1088 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
1089 | | UA_Server_addObjectTypeNode(UA_Server *server, const UA_NodeId requestedNewNodeId, |
1090 | | const UA_NodeId parentNodeId, |
1091 | | const UA_NodeId referenceTypeId, |
1092 | | const UA_QualifiedName browseName, |
1093 | | const UA_ObjectTypeAttributes attr, |
1094 | | void *nodeContext, UA_NodeId *outNewNodeId); |
1095 | | |
1096 | | /** |
1097 | | * ReferenceTypeNode |
1098 | | * ~~~~~~~~~~~~~~~~~ */ |
1099 | | |
1100 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
1101 | | UA_Server_addReferenceTypeNode(UA_Server *server, |
1102 | | const UA_NodeId requestedNewNodeId, |
1103 | | const UA_NodeId parentNodeId, |
1104 | | const UA_NodeId referenceTypeId, |
1105 | | const UA_QualifiedName browseName, |
1106 | | const UA_ReferenceTypeAttributes attr, |
1107 | | void *nodeContext, UA_NodeId *outNewNodeId); |
1108 | | |
1109 | | /** |
1110 | | * DataTypeNode |
1111 | | * ~~~~~~~~~~~~ */ |
1112 | | |
1113 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
1114 | | UA_Server_addDataTypeNode(UA_Server *server, |
1115 | | const UA_NodeId requestedNewNodeId, |
1116 | | const UA_NodeId parentNodeId, |
1117 | | const UA_NodeId referenceTypeId, |
1118 | | const UA_QualifiedName browseName, |
1119 | | const UA_DataTypeAttributes attr, |
1120 | | void *nodeContext, UA_NodeId *outNewNodeId); |
1121 | | |
1122 | | /** |
1123 | | * ViewNode |
1124 | | * ~~~~~~~~ */ |
1125 | | |
1126 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
1127 | | UA_Server_addViewNode(UA_Server *server, const UA_NodeId requestedNewNodeId, |
1128 | | const UA_NodeId parentNodeId, |
1129 | | const UA_NodeId referenceTypeId, |
1130 | | const UA_QualifiedName browseName, |
1131 | | const UA_ViewAttributes attr, |
1132 | | void *nodeContext, UA_NodeId *outNewNodeId); |
1133 | | |
1134 | | /** |
1135 | | * .. _node-lifecycle: |
1136 | | * |
1137 | | * Node Lifecycle: Constructors, Destructors and Node Contexts |
1138 | | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1139 | | * To finalize the instantiation of a node, a (user-defined) constructor |
1140 | | * callback is executed. There can be both a global constructor for all nodes |
1141 | | * and node-type constructor specific to the TypeDefinition of the new node |
1142 | | * (attached to an ObjectTypeNode or VariableTypeNode). |
1143 | | * |
1144 | | * In the hierarchy of ObjectTypes and VariableTypes, only the constructor of |
1145 | | * the (lowest) type defined for the new node is executed. Note that every |
1146 | | * Object and Variable can have only one ``isTypeOf`` reference. But type-nodes |
1147 | | * can technically have several ``hasSubType`` references to implement multiple |
1148 | | * inheritance. Issues of (multiple) inheritance in the constructor need to be |
1149 | | * solved by the user. |
1150 | | * |
1151 | | * When a node is destroyed, the node-type destructor is called before the |
1152 | | * global destructor. So the overall node lifecycle is as follows: |
1153 | | * |
1154 | | * 1. Global Constructor (set in the server config) |
1155 | | * 2. Node-Type Constructor (for VariableType or ObjectTypes) |
1156 | | * 3. (Usage-period of the Node) |
1157 | | * 4. Node-Type Destructor |
1158 | | * 5. Global Destructor |
1159 | | * |
1160 | | * The constructor and destructor callbacks can be set to ``NULL`` and are not |
1161 | | * used in that case. If the node-type constructor fails, the global destructor |
1162 | | * will be called before removing the node. The destructors are assumed to never |
1163 | | * fail. |
1164 | | * |
1165 | | * Every node carries a user-context and a constructor-context pointer. The |
1166 | | * user-context is used to attach custom data to a node. But the (user-defined) |
1167 | | * constructors and destructors may replace the user-context pointer if they |
1168 | | * wish to do so. The initial value for the constructor-context is ``NULL``. |
1169 | | * When the ``AddNodes`` service is used over the network, the user-context |
1170 | | * pointer of the new node is also initially set to ``NULL``. */ |
1171 | | |
1172 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1173 | | UA_Server_getNodeContext(UA_Server *server, UA_NodeId nodeId, void **nodeContext); |
1174 | | |
1175 | | /* Careful! The user has to ensure that the destructor callbacks still work. */ |
1176 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1177 | | UA_Server_setNodeContext(UA_Server *server, UA_NodeId nodeId, void *nodeContext); |
1178 | | |
1179 | | /** |
1180 | | * Global constructor and destructor callbacks used for every node type. |
1181 | | * It gets set in the server config. */ |
1182 | | |
1183 | | typedef struct { |
1184 | | /* Can be NULL. May replace the nodeContext */ |
1185 | | UA_StatusCode (*constructor)(UA_Server *server, |
1186 | | const UA_NodeId *sessionId, void *sessionContext, |
1187 | | const UA_NodeId *nodeId, void **nodeContext); |
1188 | | |
1189 | | /* Can be NULL. The context cannot be replaced since the node is destroyed |
1190 | | * immediately afterwards anyway. */ |
1191 | | void (*destructor)(UA_Server *server, |
1192 | | const UA_NodeId *sessionId, void *sessionContext, |
1193 | | const UA_NodeId *nodeId, void *nodeContext); |
1194 | | |
1195 | | /* Can be NULL. Called during recursive node instantiation. While mandatory |
1196 | | * child nodes are automatically created if not already present, optional child |
1197 | | * nodes are not. This callback can be used to define whether an optional child |
1198 | | * node should be created. |
1199 | | * |
1200 | | * @param server The server executing the callback |
1201 | | * @param sessionId The identifier of the session |
1202 | | * @param sessionContext Additional data attached to the session in the |
1203 | | * access control layer |
1204 | | * @param sourceNodeId Source node from the type definition. If the new node |
1205 | | * shall be created, it will be a copy of this node. |
1206 | | * @param targetParentNodeId Parent of the potential new child node |
1207 | | * @param referenceTypeId Identifies the reference type which that the parent |
1208 | | * node has to the new node. |
1209 | | * @return Return UA_TRUE if the child node shall be instantiated, |
1210 | | * UA_FALSE otherwise. */ |
1211 | | UA_Boolean (*createOptionalChild)(UA_Server *server, |
1212 | | const UA_NodeId *sessionId, |
1213 | | void *sessionContext, |
1214 | | const UA_NodeId *sourceNodeId, |
1215 | | const UA_NodeId *targetParentNodeId, |
1216 | | const UA_NodeId *referenceTypeId); |
1217 | | |
1218 | | /* Can be NULL. Called when a node is to be copied during recursive |
1219 | | * node instantiation. Allows definition of the NodeId for the new node. |
1220 | | * If the callback is set to NULL or the resulting NodeId is UA_NODEID_NUMERIC(X,0) |
1221 | | * an unused nodeid in namespace X will be used. E.g. passing UA_NODEID_NULL will |
1222 | | * result in a NodeId in namespace 0. |
1223 | | * |
1224 | | * @param server The server executing the callback |
1225 | | * @param sessionId The identifier of the session |
1226 | | * @param sessionContext Additional data attached to the session in the |
1227 | | * access control layer |
1228 | | * @param sourceNodeId Source node of the copy operation |
1229 | | * @param targetParentNodeId Parent node of the new node |
1230 | | * @param referenceTypeId Identifies the reference type which that the parent |
1231 | | * node has to the new node. */ |
1232 | | UA_StatusCode (*generateChildNodeId)(UA_Server *server, |
1233 | | const UA_NodeId *sessionId, void *sessionContext, |
1234 | | const UA_NodeId *sourceNodeId, |
1235 | | const UA_NodeId *targetParentNodeId, |
1236 | | const UA_NodeId *referenceTypeId, |
1237 | | UA_NodeId *targetNodeId); |
1238 | | } UA_GlobalNodeLifecycle; |
1239 | | |
1240 | | /** |
1241 | | * The following node-type lifecycle can be set for VariableTypeNodes and |
1242 | | * ObjectTypeNodes. It gets called for instances of this node-type. */ |
1243 | | |
1244 | | typedef struct { |
1245 | | /* Can be NULL. May replace the nodeContext */ |
1246 | | UA_StatusCode (*constructor)(UA_Server *server, |
1247 | | const UA_NodeId *sessionId, void *sessionContext, |
1248 | | const UA_NodeId *typeNodeId, void *typeNodeContext, |
1249 | | const UA_NodeId *nodeId, void **nodeContext); |
1250 | | |
1251 | | /* Can be NULL. May replace the nodeContext. */ |
1252 | | void (*destructor)(UA_Server *server, |
1253 | | const UA_NodeId *sessionId, void *sessionContext, |
1254 | | const UA_NodeId *typeNodeId, void *typeNodeContext, |
1255 | | const UA_NodeId *nodeId, void **nodeContext); |
1256 | | } UA_NodeTypeLifecycle; |
1257 | | |
1258 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1259 | | UA_Server_setNodeTypeLifecycle(UA_Server *server, UA_NodeId nodeId, |
1260 | | UA_NodeTypeLifecycle lifecycle); |
1261 | | |
1262 | | /** |
1263 | | * Detailed Node Construction |
1264 | | * ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1265 | | * The method pair UA_Server_addNode_begin and _finish splits the AddNodes |
1266 | | * service in two parts. This is useful if the node shall be modified before |
1267 | | * finish the instantiation. For example to add children with specific NodeIds. |
1268 | | * Otherwise, mandatory children (e.g. of an ObjectType) are added with |
1269 | | * pseudo-random unique NodeIds. Existing children are detected during the |
1270 | | * _finish part via their matching BrowseName. |
1271 | | * |
1272 | | * The _begin method: |
1273 | | * - prepares the node and adds it to the nodestore |
1274 | | * - copies some unassigned attributes from the TypeDefinition node internally |
1275 | | * - adds the references to the parent (and the TypeDefinition if applicable) |
1276 | | * - performs type-checking of variables. |
1277 | | * |
1278 | | * You can add an object node without a parent if you set the parentNodeId and |
1279 | | * referenceTypeId to UA_NODE_ID_NULL. Then you need to add the parent reference |
1280 | | * and hasTypeDef reference yourself before calling the _finish method. |
1281 | | * Not that this is only allowed for object nodes. |
1282 | | * |
1283 | | * The _finish method: |
1284 | | * - copies mandatory children |
1285 | | * - calls the node constructor(s) at the end |
1286 | | * - may remove the node if it encounters an error. |
1287 | | * |
1288 | | * The special UA_Server_addMethodNode_finish method needs to be used for method |
1289 | | * nodes, since there you need to explicitly specifiy the input and output |
1290 | | * arguments which are added in the finish step (if not yet already there) */ |
1291 | | |
1292 | | /* The ``attr`` argument must have a type according to the NodeClass. |
1293 | | * ``VariableAttributes`` for variables, ``ObjectAttributes`` for objects, and |
1294 | | * so on. Missing attributes are taken from the TypeDefinition node if |
1295 | | * applicable. */ |
1296 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1297 | | UA_Server_addNode_begin(UA_Server *server, const UA_NodeClass nodeClass, |
1298 | | const UA_NodeId requestedNewNodeId, |
1299 | | const UA_NodeId parentNodeId, |
1300 | | const UA_NodeId referenceTypeId, |
1301 | | const UA_QualifiedName browseName, |
1302 | | const UA_NodeId typeDefinition, |
1303 | | const void *attr, const UA_DataType *attributeType, |
1304 | | void *nodeContext, UA_NodeId *outNewNodeId); |
1305 | | |
1306 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1307 | | UA_Server_addNode_finish(UA_Server *server, const UA_NodeId nodeId); |
1308 | | |
1309 | | #ifdef UA_ENABLE_METHODCALLS |
1310 | | |
1311 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1312 | | UA_Server_addMethodNode_finish(UA_Server *server, const UA_NodeId nodeId, |
1313 | | UA_MethodCallback method, |
1314 | | size_t inputArgumentsSize, const UA_Argument *inputArguments, |
1315 | | size_t outputArgumentsSize, const UA_Argument *outputArguments); |
1316 | | |
1317 | | #endif |
1318 | | |
1319 | | /* Deletes a node and optionally all references leading to the node. */ |
1320 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1321 | | UA_Server_deleteNode(UA_Server *server, const UA_NodeId nodeId, |
1322 | | UA_Boolean deleteReferences); |
1323 | | |
1324 | | /** |
1325 | | * Reference Management |
1326 | | * ~~~~~~~~~~~~~~~~~~~~ */ |
1327 | | |
1328 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1329 | | UA_Server_addReference(UA_Server *server, const UA_NodeId sourceId, |
1330 | | const UA_NodeId refTypeId, |
1331 | | const UA_ExpandedNodeId targetId, UA_Boolean isForward); |
1332 | | |
1333 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1334 | | UA_Server_deleteReference(UA_Server *server, const UA_NodeId sourceNodeId, |
1335 | | const UA_NodeId referenceTypeId, UA_Boolean isForward, |
1336 | | const UA_ExpandedNodeId targetNodeId, |
1337 | | UA_Boolean deleteBidirectional); |
1338 | | |
1339 | | /** |
1340 | | * .. _async-operations: |
1341 | | * |
1342 | | * Async Operations |
1343 | | * ---------------- |
1344 | | * Some operations can take time, such as reading a sensor that needs to warm up |
1345 | | * first. In order not to block the server, a long-running operation can be |
1346 | | * handled asynchronously and the result returned at a later time. The core idea |
1347 | | * is that a userland callback can return |
1348 | | * UA_STATUSCODE_GOODCOMPLETESASYNCHRONOUSLY as the statuscode to signal that it |
1349 | | * wishes to complete the operation later. |
1350 | | * |
1351 | | * Currently, async operations are supported for the services |
1352 | | * |
1353 | | * - Read |
1354 | | * - Write |
1355 | | * - Call |
1356 | | * |
1357 | | * with the caveat that read/write need a CallbackValueSource registered for the |
1358 | | * variable. Values that are stored directly in a VariableNode are written and |
1359 | | * read immediately. |
1360 | | * |
1361 | | * Note that an async operation can be cancelled (e.g. after a timeout period or |
1362 | | * if the caller cannot wait for the result). This is signaled in the configured |
1363 | | * ``asyncOperationCancelCallback``. The provided memory locations to store the |
1364 | | * operation output are then no longer valid. */ |
1365 | | |
1366 | | /* When the UA_MethodCallback returns UA_STATUSCODE_GOODCOMPLETESASYNCHRONOUSLY, |
1367 | | * then an async operation is created in the server for later completion. The |
1368 | | * output pointer from the method callback is used to identify the async |
1369 | | * operation. Do not access the output pointer after the operation has been |
1370 | | * cancelled or after setting the result. */ |
1371 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
1372 | | UA_Server_setAsyncCallMethodResult(UA_Server *server, UA_Variant *output, |
1373 | | UA_StatusCode result); |
1374 | | |
1375 | | /* See the UA_CallbackValueSource documentation */ |
1376 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
1377 | | UA_Server_setAsyncReadResult(UA_Server *server, UA_DataValue *result); |
1378 | | |
1379 | | /* See the UA_CallbackValueSource documentation. The value needs to be the |
1380 | | * pointer used in the write callback. The statuscode is the result signal to be |
1381 | | * returned asynchronously. */ |
1382 | | UA_EXPORT UA_THREADSAFE UA_StatusCode |
1383 | | UA_Server_setAsyncWriteResult(UA_Server *server, const UA_DataValue *value, |
1384 | | UA_StatusCode result); |
1385 | | |
1386 | | /** |
1387 | | * The server supports asynchronous "local" read/write/call operations. The user |
1388 | | * supplies a result-callback that gets called either synchronously (if the |
1389 | | * operation terminates right away) or asynchronously at a later time. The |
1390 | | * result-callback is called exactly one time for each operation, also if the |
1391 | | * operation is cancelled. In this case a StatusCode like |
1392 | | * ``UA_STATUSCODE_BADTIMEOUT`` or ``UA_STATUSCODE_BADSHUTDOWN`` is set. |
1393 | | * |
1394 | | * If an operation returns asynchronously, then the result-callback is executed |
1395 | | * only in the next iteration of the Eventloop. An exception to this is |
1396 | | * UA_Server_cancelAsync, which can optionally call the result-callback right |
1397 | | * away (e.g. as part of a cleanup where the context of the result-callback gets |
1398 | | * removed). |
1399 | | * |
1400 | | * Async operations incur a small overhead since memory is allocated to persist |
1401 | | * the operation over time. |
1402 | | * |
1403 | | * The operation timeout is defined in milliseconds. A timeout of zero means |
1404 | | * infinite. */ |
1405 | | |
1406 | | typedef void(*UA_ServerAsyncReadResultCallback) |
1407 | | (UA_Server *server, void *asyncOpContext, const UA_DataValue *result); |
1408 | | typedef void(*UA_ServerAsyncWriteResultCallback) |
1409 | | (UA_Server *server, void *asyncOpContext, UA_StatusCode result); |
1410 | | typedef void(*UA_ServerAsyncMethodResultCallback) |
1411 | | (UA_Server *server, void *asyncOpContext, const UA_CallMethodResult *result); |
1412 | | |
1413 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1414 | | UA_Server_read_async(UA_Server *server, const UA_ReadValueId *operation, |
1415 | | UA_TimestampsToReturn timestamps, |
1416 | | UA_ServerAsyncReadResultCallback callback, |
1417 | | void *asyncOpContext, UA_UInt32 timeout); |
1418 | | |
1419 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1420 | | UA_Server_write_async(UA_Server *server, const UA_WriteValue *operation, |
1421 | | UA_ServerAsyncWriteResultCallback callback, |
1422 | | void *asyncOpContext, UA_UInt32 timeout); |
1423 | | |
1424 | | #ifdef UA_ENABLE_METHODCALLS |
1425 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1426 | | UA_Server_call_async(UA_Server *server, const UA_CallMethodRequest *operation, |
1427 | | UA_ServerAsyncMethodResultCallback callback, |
1428 | | void *asyncOpContext, UA_UInt32 timeout); |
1429 | | #endif |
1430 | | |
1431 | | /** |
1432 | | * Local async operations can be manually cancelled (besides an internal cancel |
1433 | | * due to a timeout or server shutdown). The local async operations to be |
1434 | | * cancelled are selected by matching their asyncOpContext pointer. This can |
1435 | | * cancel multiple operations that use the same context pointer. |
1436 | | * |
1437 | | * For operations where the async result was not yet set, the |
1438 | | * asyncOperationCancelCallback from the server-config gets called and the |
1439 | | * cancel-status is set in the operation result. |
1440 | | * |
1441 | | * For async operations where the result has already been set, but not yet |
1442 | | * notified with the result-callback (to be done in the next EventLoop |
1443 | | * iteration), the asyncOperationCancelCallback is not called and no cancel |
1444 | | * status is set in the result. |
1445 | | * |
1446 | | * Each operation's result-callback gets called exactly once. When the operation |
1447 | | * is cancelled, the result-callback can be called synchronously using the |
1448 | | * synchronousResultCallback flag. Otherwise the result gets returned "normally" |
1449 | | * in the next EventLoop iteration. The synchronous option ensures that all |
1450 | | * (matching) async operations are fully cancelled right away. This can be |
1451 | | * important in a cleanup situation where the asyncOpContext is no longer valid |
1452 | | * in the future. */ |
1453 | | |
1454 | | void UA_EXPORT UA_THREADSAFE |
1455 | | UA_Server_cancelAsync(UA_Server *server, void *asyncOpContext, |
1456 | | UA_StatusCode status, |
1457 | | UA_Boolean synchronousResultCallback); |
1458 | | |
1459 | | /** |
1460 | | * .. _events: |
1461 | | * |
1462 | | * Events |
1463 | | * ------ |
1464 | | * Events are emitted by objects in the OPC UA information model. Starting at |
1465 | | * the source-node, the events "bubble up" in the hierarchy of objects and are |
1466 | | * caught by MonitoredItems listening for them. |
1467 | | * |
1468 | | * EventTypes are special ObjectTypeNodes that describe the (data) fields of an |
1469 | | * event instance. An EventType can simply contain a flat list of VariableNodes. |
1470 | | * But (deep) nesting of objects and variables is also allowed. The individual |
1471 | | * MonitoredItems then contain an EventFilter (with a select-clause) that |
1472 | | * defines the event fields to be transmitted to a particular client. |
1473 | | * |
1474 | | * In open62541, there are three possible sources for the event fields. When the |
1475 | | * select-clause of an EventFilter is resolved, the sources are evaluated in the |
1476 | | * following order: |
1477 | | * |
1478 | | * 1. An key-value map that defines event fields. The key of its entries is a |
1479 | | * "path-string", a :ref:``human-readable encoding of a |
1480 | | * SimpleAttributeOperand<parse-sao>`. For example ``/SourceNode`` or |
1481 | | * ``/EventType``. |
1482 | | * 2. An NodeId pointing to an ObjectNode that instantiates an EventType. The |
1483 | | * ``SimpleAttributeOperands`` from the EventFilter are resolved in its |
1484 | | * context. |
1485 | | * 3. The event fields defined as mandatory for the *BaseEventType* have a |
1486 | | * default that gets used if they are not defined otherwise: |
1487 | | * |
1488 | | * /EventId |
1489 | | * ByteString to uniquely identify the event instance |
1490 | | * (default: random 16-byte ByteString) |
1491 | | * |
1492 | | * /EventType |
1493 | | * NodeId of the EventType (default: argument of ``_createEvent``) |
1494 | | * |
1495 | | * /SourceNode |
1496 | | * NodeId of the emitting node (default: argument of ``_createEvent``) |
1497 | | * |
1498 | | * /SourceName |
1499 | | * LocalizedText with the DisplayName of the source node |
1500 | | * (default: read from the information model) |
1501 | | * |
1502 | | * /Time |
1503 | | * DateTime with the timestamp when the event occurred |
1504 | | * (default: current time) |
1505 | | * |
1506 | | * /ReceiveTime |
1507 | | * DateTime when the server received the information about the event from an |
1508 | | * underlying device (default: current time) |
1509 | | * |
1510 | | * /Message |
1511 | | * LocalizedText with a human-readable description of the event (default: |
1512 | | * argument of ``_createEvent``) |
1513 | | * |
1514 | | * /Severity |
1515 | | * UInt16 for the urgency of the event defined to be between 1 (lowest) and |
1516 | | * 1000 (catastrophic) (default: argument of ``_createEvent``) |
1517 | | * |
1518 | | * An event field that is missing from all sources resolves to an empty variant. |
1519 | | * |
1520 | | * It is typically faster to define event-fields in the key-value map than to |
1521 | | * look them up from an event instance in the information model. This is |
1522 | | * particularly important for events emitted at a high frequency. */ |
1523 | | |
1524 | | #ifdef UA_ENABLE_SUBSCRIPTIONS_EVENTS |
1525 | | |
1526 | | /* Create an event in the server. The eventFields and eventInstance pointer can |
1527 | | * be NULL and are then not considered as a source of event fields. The |
1528 | | * outEventId pointer can be NULL. If set, the EventId of a successfully created |
1529 | | * Event gets copied into the argument. */ |
1530 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1531 | | UA_Server_createEvent(UA_Server *server, const UA_NodeId sourceNode, |
1532 | | const UA_NodeId eventType, UA_UInt16 severity, |
1533 | | const UA_LocalizedText message, |
1534 | | const UA_KeyValueMap *eventFields, |
1535 | | const UA_NodeId *eventInstance, |
1536 | | UA_ByteString *outEventId); |
1537 | | |
1538 | | /* Extended version of the _createEvent API. The members of the |
1539 | | * UA_EventDescription structure have the same meaning as above. |
1540 | | * |
1541 | | * In addition, the extended version allows the filtering of Events to be only |
1542 | | * transmitted to a particular Session/Subscription/MonitoredItem. The filtering |
1543 | | * criteria can be NULL. But the subscriptionId requires a sessionId and the |
1544 | | * monitoredItemId requires a subscriptionId as context. */ |
1545 | | |
1546 | | typedef struct { |
1547 | | /* Event fields */ |
1548 | | UA_NodeId sourceNode; |
1549 | | UA_NodeId eventType; |
1550 | | UA_UInt16 severity; |
1551 | | UA_LocalizedText message; |
1552 | | const UA_KeyValueMap *eventFields; |
1553 | | const UA_NodeId *eventInstance; |
1554 | | |
1555 | | /* Restrict who can receive the event */ |
1556 | | const UA_NodeId *sessionId; |
1557 | | const UA_UInt32 *subscriptionId; |
1558 | | const UA_UInt32 *monitoredItemId; |
1559 | | } UA_EventDescription; |
1560 | | |
1561 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1562 | | UA_Server_createEventEx(UA_Server *server, |
1563 | | const UA_EventDescription *ed, |
1564 | | UA_ByteString *outEventId); |
1565 | | |
1566 | | #endif /* UA_ENABLE_SUBSCRIPTIONS_EVENTS */ |
1567 | | |
1568 | | #ifdef UA_ENABLE_DISCOVERY |
1569 | | |
1570 | | /** |
1571 | | * Discovery |
1572 | | * --------- |
1573 | | * |
1574 | | * Registering at a Discovery Server |
1575 | | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
1576 | | |
1577 | | /* Register the given server instance at the discovery server. This should be |
1578 | | * called periodically, for example every 10 minutes, depending on the |
1579 | | * configuration of the discovery server. You should also call |
1580 | | * _unregisterDiscovery when the server shuts down. |
1581 | | * |
1582 | | * The supplied client configuration is used to create a new client to connect |
1583 | | * to the discovery server. The client configuration is moved over to the server |
1584 | | * and eventually cleaned up internally. The structure pointed at by `cc` is |
1585 | | * zeroed to avoid accessing outdated information. |
1586 | | * |
1587 | | * The eventloop and logging plugins in the client configuration are replaced by |
1588 | | * those configured in the server. */ |
1589 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1590 | | UA_Server_registerDiscovery(UA_Server *server, UA_ClientConfig *cc, |
1591 | | const UA_String discoveryServerUrl, |
1592 | | const UA_String semaphoreFilePath); |
1593 | | |
1594 | | /* Deregister the given server instance from the discovery server. |
1595 | | * This should be called when the server is shutting down. */ |
1596 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1597 | | UA_Server_deregisterDiscovery(UA_Server *server, UA_ClientConfig *cc, |
1598 | | const UA_String discoveryServerUrl); |
1599 | | |
1600 | | /** |
1601 | | * Operating a Discovery Server |
1602 | | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
1603 | | |
1604 | | /* Callback for RegisterServer. Data is passed from the register call */ |
1605 | | typedef void |
1606 | | (*UA_Server_registerServerCallback)(const UA_RegisteredServer *registeredServer, |
1607 | | void* data); |
1608 | | |
1609 | | /* Set the callback which is called if another server registeres or unregisters |
1610 | | * with this instance. This callback is called every time the server gets a |
1611 | | * register call. This especially means that for every periodic server register |
1612 | | * the callback will be called. |
1613 | | * |
1614 | | * @param server |
1615 | | * @param cb the callback |
1616 | | * @param data data passed to the callback |
1617 | | * @return ``UA_STATUSCODE_SUCCESS`` on success */ |
1618 | | void UA_EXPORT UA_THREADSAFE |
1619 | | UA_Server_setRegisterServerCallback(UA_Server *server, |
1620 | | UA_Server_registerServerCallback cb, void* data); |
1621 | | |
1622 | | #ifdef UA_ENABLE_DISCOVERY_MULTICAST |
1623 | | |
1624 | | /* Callback for server detected through mDNS. Data is passed from the register |
1625 | | * call |
1626 | | * |
1627 | | * @param isServerAnnounce indicates if the server has just been detected. If |
1628 | | * set to false, this means the server is shutting down. |
1629 | | * @param isTxtReceived indicates if we already received the corresponding TXT |
1630 | | * record with the path and caps data */ |
1631 | | typedef void |
1632 | | (*UA_Server_serverOnNetworkCallback)(const UA_ServerOnNetwork *serverOnNetwork, |
1633 | | UA_Boolean isServerAnnounce, |
1634 | | UA_Boolean isTxtReceived, void* data); |
1635 | | |
1636 | | /* Set the callback which is called if another server is found through mDNS or |
1637 | | * deleted. It will be called for any mDNS message from the remote server, thus |
1638 | | * it may be called multiple times for the same instance. Also the SRV and TXT |
1639 | | * records may arrive later, therefore for the first call the server |
1640 | | * capabilities may not be set yet. If called multiple times, previous data will |
1641 | | * be overwritten. |
1642 | | * |
1643 | | * @param server |
1644 | | * @param cb the callback |
1645 | | * @param data data passed to the callback |
1646 | | * @return ``UA_STATUSCODE_SUCCESS`` on success */ |
1647 | | void UA_EXPORT UA_THREADSAFE |
1648 | | UA_Server_setServerOnNetworkCallback(UA_Server *server, |
1649 | | UA_Server_serverOnNetworkCallback cb, |
1650 | | void* data); |
1651 | | |
1652 | | #endif /* UA_ENABLE_DISCOVERY_MULTICAST */ |
1653 | | |
1654 | | #endif /* UA_ENABLE_DISCOVERY */ |
1655 | | |
1656 | | /** |
1657 | | * Alarms & Conditions (Experimental) |
1658 | | * ---------------------------------- */ |
1659 | | |
1660 | | #ifdef UA_ENABLE_SUBSCRIPTIONS_ALARMS_CONDITIONS |
1661 | | typedef enum UA_TwoStateVariableCallbackType { |
1662 | | UA_ENTERING_ENABLEDSTATE, |
1663 | | UA_ENTERING_ACKEDSTATE, |
1664 | | UA_ENTERING_CONFIRMEDSTATE, |
1665 | | UA_ENTERING_ACTIVESTATE |
1666 | | } UA_TwoStateVariableCallbackType; |
1667 | | |
1668 | | /* Callback prototype to set user specific callbacks */ |
1669 | | typedef UA_StatusCode |
1670 | | (*UA_TwoStateVariableChangeCallback)(UA_Server *server, const UA_NodeId *condition); |
1671 | | |
1672 | | /* Create condition instance. The function checks first whether the passed |
1673 | | * conditionType is a subType of ConditionType. Then checks whether the |
1674 | | * condition source has HasEventSource reference to its parent. If not, a |
1675 | | * HasEventSource reference will be created between condition source and server |
1676 | | * object. To expose the condition in address space, a hierarchical |
1677 | | * ReferenceType should be passed to create the reference to condition source. |
1678 | | * Otherwise, UA_NODEID_NULL should be passed to make the condition not exposed. |
1679 | | * |
1680 | | * @param server The server object |
1681 | | * @param conditionId The NodeId of the requested Condition Object. When passing |
1682 | | * UA_NODEID_NUMERIC(X,0) an unused nodeid in namespace X will be used. |
1683 | | * E.g. passing UA_NODEID_NULL will result in a NodeId in namespace 0. |
1684 | | * @param conditionType The NodeId of the node representation of the ConditionType |
1685 | | * @param conditionName The name of the condition to be created |
1686 | | * @param conditionSource The NodeId of the Condition Source (Parent of the Condition) |
1687 | | * @param hierarchialReferenceType The NodeId of Hierarchical ReferenceType |
1688 | | * between Condition and its source |
1689 | | * @param outConditionId The NodeId of the created Condition |
1690 | | * @return The StatusCode of the UA_Server_createCondition method */ |
1691 | | UA_StatusCode UA_EXPORT |
1692 | | UA_Server_createCondition(UA_Server *server, |
1693 | | const UA_NodeId conditionId, |
1694 | | const UA_NodeId conditionType, |
1695 | | const UA_QualifiedName conditionName, |
1696 | | const UA_NodeId conditionSource, |
1697 | | const UA_NodeId hierarchialReferenceType, |
1698 | | UA_NodeId *outConditionId); |
1699 | | |
1700 | | /* The method pair UA_Server_addCondition_begin and _finish splits the |
1701 | | * UA_Server_createCondtion in two parts similiar to the |
1702 | | * UA_Server_addNode_begin / _finish pair. This is useful if the node shall be |
1703 | | * modified before finish the instantiation. For example to add children with |
1704 | | * specific NodeIds. |
1705 | | * For details refer to the UA_Server_addNode_begin / _finish methods. |
1706 | | * |
1707 | | * Additionally to UA_Server_addNode_begin UA_Server_addCondition_begin checks |
1708 | | * if the passed condition type is a subtype of the OPC UA ConditionType. |
1709 | | * |
1710 | | * @param server The server object |
1711 | | * @param conditionId The NodeId of the requested Condition Object. When passing |
1712 | | * UA_NODEID_NUMERIC(X,0) an unused nodeid in namespace X will be used. |
1713 | | * E.g. passing UA_NODEID_NULL will result in a NodeId in namespace 0. |
1714 | | * @param conditionType The NodeId of the node representation of the ConditionType |
1715 | | * @param conditionName The name of the condition to be added |
1716 | | * @param outConditionId The NodeId of the added Condition |
1717 | | * @return The StatusCode of the UA_Server_addCondition_begin method */ |
1718 | | UA_StatusCode UA_EXPORT |
1719 | | UA_Server_addCondition_begin(UA_Server *server, |
1720 | | const UA_NodeId conditionId, |
1721 | | const UA_NodeId conditionType, |
1722 | | const UA_QualifiedName conditionName, |
1723 | | UA_NodeId *outConditionId); |
1724 | | |
1725 | | /* Second call of the UA_Server_addCondition_begin and _finish pair. |
1726 | | * Additionally to UA_Server_addNode_finish UA_Server_addCondition_finish: |
1727 | | * - checks whether the condition source has HasEventSource reference to its |
1728 | | * parent. If not, a HasEventSource reference will be created between |
1729 | | * condition source and server object |
1730 | | * - exposes the condition in the address space if hierarchialReferenceType is |
1731 | | * not UA_NODEID_NULL by adding a reference of this type from the condition |
1732 | | * source to the condition instance |
1733 | | * - initializes the standard condition fields and callbacks |
1734 | | * |
1735 | | * @param server The server object |
1736 | | * @param conditionId The NodeId of the unfinished Condition Object |
1737 | | * @param conditionSource The NodeId of the Condition Source (Parent of the Condition) |
1738 | | * @param hierarchialReferenceType The NodeId of Hierarchical ReferenceType |
1739 | | * between Condition and its source |
1740 | | * @return The StatusCode of the UA_Server_addCondition_finish method */ |
1741 | | |
1742 | | UA_StatusCode UA_EXPORT |
1743 | | UA_Server_addCondition_finish(UA_Server *server, |
1744 | | const UA_NodeId conditionId, |
1745 | | const UA_NodeId conditionSource, |
1746 | | const UA_NodeId hierarchialReferenceType); |
1747 | | |
1748 | | /* Set the value of condition field. |
1749 | | * |
1750 | | * @param server The server object |
1751 | | * @param condition The NodeId of the node representation of the Condition Instance |
1752 | | * @param value Variant Value to be written to the Field |
1753 | | * @param fieldName Name of the Field in which the value should be written |
1754 | | * @return The StatusCode of the UA_Server_setConditionField method*/ |
1755 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1756 | | UA_Server_setConditionField(UA_Server *server, |
1757 | | const UA_NodeId condition, |
1758 | | const UA_Variant *value, |
1759 | | const UA_QualifiedName fieldName); |
1760 | | |
1761 | | /* Set the value of property of condition field. |
1762 | | * |
1763 | | * @param server The server object |
1764 | | * @param condition The NodeId of the node representation of the Condition |
1765 | | * Instance |
1766 | | * @param value Variant Value to be written to the Field |
1767 | | * @param variableFieldName Name of the Field which has a property |
1768 | | * @param variablePropertyName Name of the Field Property in which the value |
1769 | | * should be written |
1770 | | * @return The StatusCode of the UA_Server_setConditionVariableFieldProperty*/ |
1771 | | UA_StatusCode UA_EXPORT |
1772 | | UA_Server_setConditionVariableFieldProperty(UA_Server *server, |
1773 | | const UA_NodeId condition, |
1774 | | const UA_Variant *value, |
1775 | | const UA_QualifiedName variableFieldName, |
1776 | | const UA_QualifiedName variablePropertyName); |
1777 | | |
1778 | | /* Triggers an event only for an enabled condition. The condition list is |
1779 | | * updated then with the last generated EventId. |
1780 | | * |
1781 | | * @param server The server object |
1782 | | * @param condition The NodeId of the node representation of the Condition Instance |
1783 | | * @param conditionSource The NodeId of the node representation of the Condition Source |
1784 | | * @param outEventId last generated EventId |
1785 | | * @return The StatusCode of the UA_Server_triggerConditionEvent method */ |
1786 | | UA_StatusCode UA_EXPORT |
1787 | | UA_Server_triggerConditionEvent(UA_Server *server, |
1788 | | const UA_NodeId condition, |
1789 | | const UA_NodeId conditionSource, |
1790 | | UA_ByteString *outEventId); |
1791 | | |
1792 | | /* Add an optional condition field using its name. (TODO Adding optional methods |
1793 | | * is not implemented yet) |
1794 | | * |
1795 | | * @param server The server object |
1796 | | * @param condition The NodeId of the node representation of the Condition Instance |
1797 | | * @param conditionType The NodeId of the node representation of the Condition Type |
1798 | | * from which the optional field comes |
1799 | | * @param fieldName Name of the optional field |
1800 | | * @param outOptionalVariable The NodeId of the created field (Variable Node) |
1801 | | * @return The StatusCode of the UA_Server_addConditionOptionalField method */ |
1802 | | UA_StatusCode UA_EXPORT |
1803 | | UA_Server_addConditionOptionalField(UA_Server *server, |
1804 | | const UA_NodeId condition, |
1805 | | const UA_NodeId conditionType, |
1806 | | const UA_QualifiedName fieldName, |
1807 | | UA_NodeId *outOptionalVariable); |
1808 | | |
1809 | | /* Function used to set a user specific callback to TwoStateVariable Fields of a |
1810 | | * condition. The callbacks will be called before triggering the events when |
1811 | | * transition to true State of EnabledState/Id, AckedState/Id, ConfirmedState/Id |
1812 | | * and ActiveState/Id occurs. |
1813 | | * |
1814 | | * @param server The server object |
1815 | | * @param condition The NodeId of the node representation of the Condition Instance |
1816 | | * @param conditionSource The NodeId of the node representation of the Condition Source |
1817 | | * @param removeBranch (Not Implemented yet) |
1818 | | * @param callback User specific callback function |
1819 | | * @param callbackType Callback function type, indicates where it should be called |
1820 | | * @return The StatusCode of the UA_Server_setConditionTwoStateVariableCallback method */ |
1821 | | UA_StatusCode UA_EXPORT |
1822 | | UA_Server_setConditionTwoStateVariableCallback(UA_Server *server, |
1823 | | const UA_NodeId condition, |
1824 | | const UA_NodeId conditionSource, |
1825 | | UA_Boolean removeBranch, |
1826 | | UA_TwoStateVariableChangeCallback callback, |
1827 | | UA_TwoStateVariableCallbackType callbackType); |
1828 | | |
1829 | | /* Delete a condition from the address space and the internal lists. |
1830 | | * |
1831 | | * @param server The server object |
1832 | | * @param condition The NodeId of the node representation of the Condition Instance |
1833 | | * @param conditionSource The NodeId of the node representation of the Condition Source |
1834 | | * @return ``UA_STATUSCODE_GOOD`` on success */ |
1835 | | UA_StatusCode UA_EXPORT |
1836 | | UA_Server_deleteCondition(UA_Server *server, |
1837 | | const UA_NodeId condition, |
1838 | | const UA_NodeId conditionSource); |
1839 | | |
1840 | | /* Set the LimitState of the LimitAlarmType |
1841 | | * |
1842 | | * @param server The server object |
1843 | | * @param conditionId NodeId of the node representation of the Condition Instance |
1844 | | * @param limitValue The value from the trigger node */ |
1845 | | UA_StatusCode UA_EXPORT |
1846 | | UA_Server_setLimitState(UA_Server *server, const UA_NodeId conditionId, |
1847 | | UA_Double limitValue); |
1848 | | |
1849 | | /* Parse the certifcate and set Expiration date |
1850 | | * |
1851 | | * @param server The server object |
1852 | | * @param conditionId NodeId of the node representation of the Condition Instance |
1853 | | * @param cert The certificate for parsing */ |
1854 | | UA_StatusCode UA_EXPORT |
1855 | | UA_Server_setExpirationDate(UA_Server *server, const UA_NodeId conditionId, |
1856 | | UA_ByteString cert); |
1857 | | |
1858 | | #endif /* UA_ENABLE_SUBSCRIPTIONS_ALARMS_CONDITIONS */ |
1859 | | |
1860 | | /** |
1861 | | * Statistics |
1862 | | * ---------- |
1863 | | * Statistic counters keeping track of the current state of the stack. Counters |
1864 | | * are structured per OPC UA communication layer. */ |
1865 | | |
1866 | | typedef struct { |
1867 | | UA_SecureChannelStatistics scs; |
1868 | | UA_SessionStatistics ss; |
1869 | | } UA_ServerStatistics; |
1870 | | |
1871 | | UA_ServerStatistics UA_EXPORT UA_THREADSAFE |
1872 | | UA_Server_getStatistics(UA_Server *server); |
1873 | | |
1874 | | /** |
1875 | | * Reverse Connect |
1876 | | * --------------- |
1877 | | * The reverse connect feature of OPC UA permits the server instead of the |
1878 | | * client to establish the connection. The client must expose the listening port |
1879 | | * so the server is able to reach it. */ |
1880 | | |
1881 | | /* The reverse connect state change callback is called whenever the state of a |
1882 | | * reverse connect is changed by a connection attempt, a successful connection |
1883 | | * or a connection loss. |
1884 | | * |
1885 | | * The reverse connect states reflect the state of the secure channel currently |
1886 | | * associated with a reverse connect. The state will remain |
1887 | | * UA_SECURECHANNELSTATE_CONNECTING while the server attempts repeatedly to |
1888 | | * establish a connection. */ |
1889 | | typedef void (*UA_Server_ReverseConnectStateCallback)(UA_Server *server, |
1890 | | UA_UInt64 handle, |
1891 | | UA_SecureChannelState state, |
1892 | | void *context); |
1893 | | |
1894 | | /* Registers a reverse connect in the server. The server periodically attempts |
1895 | | * to establish a connection if the initial connect fails or if the connection |
1896 | | * breaks. |
1897 | | * |
1898 | | * @param server The server object |
1899 | | * @param url The URL of the remote client |
1900 | | * @param stateCallback The callback which will be called on state changes |
1901 | | * @param callbackContext The context for the state callback |
1902 | | * @param handle Is set to the handle of the reverse connect if not NULL |
1903 | | * @return Returns UA_STATUSCODE_GOOD if the reverse connect has been registered */ |
1904 | | UA_StatusCode UA_EXPORT |
1905 | | UA_Server_addReverseConnect(UA_Server *server, UA_String url, |
1906 | | UA_Server_ReverseConnectStateCallback stateCallback, |
1907 | | void *callbackContext, UA_UInt64 *handle); |
1908 | | |
1909 | | /* Removes a reverse connect from the server and closes the connection if it is |
1910 | | * currently open. |
1911 | | * |
1912 | | * @param server The server object |
1913 | | * @param handle The handle of the reverse connect to remove |
1914 | | * @return Returns UA_STATUSCODE_GOOD if the reverse connect has been |
1915 | | * successfully removed */ |
1916 | | UA_StatusCode UA_EXPORT |
1917 | | UA_Server_removeReverseConnect(UA_Server *server, UA_UInt64 handle); |
1918 | | |
1919 | | /** |
1920 | | * Utility Functions |
1921 | | * ----------------- */ |
1922 | | |
1923 | | /* Lookup a datatype by its NodeId. Takes the custom types in the server |
1924 | | * configuration into account. Return NULL if none found. */ |
1925 | | UA_EXPORT const UA_DataType * |
1926 | | UA_Server_findDataType(UA_Server *server, const UA_NodeId *typeId); |
1927 | | |
1928 | | /* Add a new namespace to the server. Returns the index of the new namespace */ |
1929 | | UA_UInt16 UA_EXPORT UA_THREADSAFE |
1930 | | UA_Server_addNamespace(UA_Server *server, const char* name); |
1931 | | |
1932 | | /* Get namespace by name from the server. */ |
1933 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1934 | | UA_Server_getNamespaceByName(UA_Server *server, const UA_String namespaceUri, |
1935 | | size_t* foundIndex); |
1936 | | |
1937 | | /* Get namespace by id from the server. */ |
1938 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1939 | | UA_Server_getNamespaceByIndex(UA_Server *server, const size_t namespaceIndex, |
1940 | | UA_String *foundUri); |
1941 | | |
1942 | | /** |
1943 | | * Some convenience functions are provided to simplify the interaction with |
1944 | | * objects. */ |
1945 | | |
1946 | | /* Write an object property. The property is represented as a VariableNode with |
1947 | | * a ``HasProperty`` reference from the ObjectNode. The VariableNode is |
1948 | | * identified by its BrowseName. Writing the property sets the value attribute |
1949 | | * of the VariableNode. |
1950 | | * |
1951 | | * @param server The server object |
1952 | | * @param objectId The identifier of the object (node) |
1953 | | * @param propertyName The name of the property |
1954 | | * @param value The value to be set for the event attribute |
1955 | | * @return The StatusCode for setting the event attribute */ |
1956 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1957 | | UA_Server_writeObjectProperty(UA_Server *server, const UA_NodeId objectId, |
1958 | | const UA_QualifiedName propertyName, |
1959 | | const UA_Variant value); |
1960 | | |
1961 | | /* Directly point to the scalar value instead of a variant */ |
1962 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1963 | | UA_Server_writeObjectProperty_scalar(UA_Server *server, const UA_NodeId objectId, |
1964 | | const UA_QualifiedName propertyName, |
1965 | | const void *value, const UA_DataType *type); |
1966 | | |
1967 | | /* Read an object property. |
1968 | | * |
1969 | | * @param server The server object |
1970 | | * @param objectId The identifier of the object (node) |
1971 | | * @param propertyName The name of the property |
1972 | | * @param value Contains the property value after reading. Must not be NULL. |
1973 | | * @return The StatusCode for setting the event attribute */ |
1974 | | UA_StatusCode UA_EXPORT UA_THREADSAFE |
1975 | | UA_Server_readObjectProperty(UA_Server *server, const UA_NodeId objectId, |
1976 | | const UA_QualifiedName propertyName, |
1977 | | UA_Variant *value); |
1978 | | |
1979 | | /** |
1980 | | * .. _server-configuration: |
1981 | | * |
1982 | | * Server Configuration |
1983 | | * -------------------- |
1984 | | * The configuration structure is passed to the server during initialization. |
1985 | | * The server expects that the configuration is not modified during runtime. |
1986 | | * Currently, only one server can use a configuration at a time. During |
1987 | | * shutdown, the server will clean up the parts of the configuration that are |
1988 | | * modified at runtime through the provided API. |
1989 | | * |
1990 | | * Examples for configurations are provided in the ``/plugins`` folder. |
1991 | | * The usual usage is as follows: |
1992 | | * |
1993 | | * 1. Create a server configuration with default settings as a starting point |
1994 | | * 2. Modifiy the configuration, e.g. by adding a server certificate |
1995 | | * 3. Instantiate a server with it |
1996 | | * 4. After shutdown of the server, clean up the configuration (free memory) |
1997 | | * |
1998 | | * The :ref:`tutorials` provide a good starting point for this. */ |
1999 | | |
2000 | | struct UA_ServerConfig { |
2001 | | void *context; /* Used to attach custom data to a server config. This can |
2002 | | * then be retrieved e.g. in a callback that forwards a |
2003 | | * pointer to the server. */ |
2004 | | UA_Logger *logging; /* Plugin for log output */ |
2005 | | |
2006 | | /* Server Description |
2007 | | * ~~~~~~~~~~~~~~~~~~ |
2008 | | * The description must be internally consistent. The ApplicationUri set in |
2009 | | * the ApplicationDescription must match the URI set in the server |
2010 | | * certificate. |
2011 | | * The applicationType is not just descriptive, it changes the actual |
2012 | | * functionality of the server. The RegisterServer service is available only |
2013 | | * if the server is a DiscoveryServer and the applicationType is set to the |
2014 | | * appropriate value.*/ |
2015 | | UA_BuildInfo buildInfo; |
2016 | | UA_ApplicationDescription applicationDescription; |
2017 | | |
2018 | | /* Server Lifecycle |
2019 | | * ~~~~~~~~~~~~~~~~ |
2020 | | * Delay in ms from the shutdown signal (ctrl-c) until the actual shutdown. |
2021 | | * Clients need to be able to get a notification ahead of time. */ |
2022 | | UA_Double shutdownDelay; |
2023 | | |
2024 | | /* If an asynchronous server shutdown is used, this callback notifies about |
2025 | | * the current lifecycle state (notably the STOPPING -> STOPPED |
2026 | | * transition). */ |
2027 | | void (*notifyLifecycleState)(UA_Server *server, UA_LifecycleState state); |
2028 | | |
2029 | | /* Rule Handling |
2030 | | * ~~~~~~~~~~~~~ |
2031 | | * Override the handling of standard-defined behavior. These settings are |
2032 | | * used to balance the following contradicting requirements: |
2033 | | * |
2034 | | * - Strict conformance with the standard (for certification). |
2035 | | * - Ensure interoperability with old/non-conforming implementations |
2036 | | * encountered in the wild. |
2037 | | * |
2038 | | * The defaults are set for compatibility with the largest number of OPC UA |
2039 | | * vendors (with log warnings activated). Cf. Postel's Law "be conservative |
2040 | | * in what you send, be liberal in what you accept". |
2041 | | * |
2042 | | * See the section :ref:`rule-handling` for the possible settings. */ |
2043 | | |
2044 | | /* Verify that the server sends a timestamp in the request header */ |
2045 | | UA_RuleHandling verifyRequestTimestamp; |
2046 | | |
2047 | | /* Variables (that don't have a DataType of BaseDataType) must not have an |
2048 | | * empty variant value. The default behaviour is to auto-create a matching |
2049 | | * zeroed-out value for empty VariableNodes when they are added. */ |
2050 | | UA_RuleHandling allowEmptyVariables; |
2051 | | |
2052 | | UA_RuleHandling allowAllCertificateUris; |
2053 | | |
2054 | | /* Custom Data Types |
2055 | | * ~~~~~~~~~~~~~~~~~ |
2056 | | * The following is a linked list of arrays with custom data types. All data |
2057 | | * types that are accessible from here are automatically considered for the |
2058 | | * decoding of received messages. Custom data types are not cleaned up |
2059 | | * together with the configuration. So it is possible to allocate them on |
2060 | | * ROM. |
2061 | | * |
2062 | | * See the section on :ref:`generic-types`. Examples for working with custom |
2063 | | * data types are provided in ``/examples/custom_datatype/``. */ |
2064 | | UA_DataTypeArray *customDataTypes; |
2065 | | |
2066 | | /* EventLoop |
2067 | | * ~~~~~~~~~ |
2068 | | * The sever can be plugged into an external EventLoop. Otherwise the |
2069 | | * EventLoop is considered to be attached to the server's lifecycle and will |
2070 | | * be destroyed when the config is cleaned up. */ |
2071 | | UA_EventLoop *eventLoop; |
2072 | | UA_Boolean externalEventLoop; /* The EventLoop is not deleted with the config */ |
2073 | | |
2074 | | /* Application Notification |
2075 | | * ~~~~~~~~~~~~~~~~~~~~~~~~ |
2076 | | * The notification callbacks can be NULL. The global callback receives all |
2077 | | * notifications. The specialized callbacks receive only the subset |
2078 | | * indicated by their name. */ |
2079 | | UA_ServerNotificationCallback globalNotificationCallback; |
2080 | | UA_ServerNotificationCallback lifecycleNotificationCallback; |
2081 | | UA_ServerNotificationCallback secureChannelNotificationCallback; |
2082 | | UA_ServerNotificationCallback sessionNotificationCallback; |
2083 | | UA_ServerNotificationCallback serviceNotificationCallback; |
2084 | | UA_ServerNotificationCallback subscriptionNotificationCallback; |
2085 | | |
2086 | | /* Networking |
2087 | | * ~~~~~~~~~~ |
2088 | | * The `severUrls` array contains the server URLs like |
2089 | | * `opc.tcp://my-server:4840` or `opc.wss://localhost:443`. The URLs are |
2090 | | * used both for discovery and to set up the server sockets based on the |
2091 | | * defined hostnames (and ports). |
2092 | | * |
2093 | | * - If the list is empty: Listen on all network interfaces with TCP port 4840. |
2094 | | * - If the hostname of a URL is empty: Use the define protocol and port and |
2095 | | * listen on all interfaces. */ |
2096 | | UA_String *serverUrls; |
2097 | | size_t serverUrlsSize; |
2098 | | |
2099 | | /* The following settings are specific to OPC UA with TCP transport. */ |
2100 | | UA_Boolean tcpEnabled; |
2101 | | UA_UInt32 tcpBufSize; /* Max length of sent and received chunks (packets) |
2102 | | * (default: 64kB) */ |
2103 | | UA_UInt32 tcpMaxMsgSize; /* Max length of messages |
2104 | | * (default: 0 -> unbounded) */ |
2105 | | UA_UInt32 tcpMaxChunks; /* Max number of chunks per message |
2106 | | * (default: 0 -> unbounded) */ |
2107 | | UA_Boolean tcpReuseAddr; |
2108 | | |
2109 | | /* Security and Encryption |
2110 | | * ~~~~~~~~~~~~~~~~~~~~~~~ */ |
2111 | | size_t securityPoliciesSize; |
2112 | | UA_SecurityPolicy* securityPolicies; |
2113 | | |
2114 | | /* Endpoints with combinations of SecurityPolicy and SecurityMode. If the |
2115 | | * UserIdentityToken array of the Endpoint is not set, then it will be |
2116 | | * filled by the server for all UserTokenPolicies that are configured in the |
2117 | | * AccessControl plugin. */ |
2118 | | size_t endpointsSize; |
2119 | | UA_EndpointDescription *endpoints; |
2120 | | |
2121 | | /* Only allow the following discovery services to be executed on a |
2122 | | * SecureChannel with SecurityPolicyNone: GetEndpointsRequest, |
2123 | | * FindServersRequest and FindServersOnNetworkRequest. |
2124 | | * |
2125 | | * Only enable this option if there is no endpoint with SecurityPolicy#None |
2126 | | * in the endpoints list. The SecurityPolicy#None must be present in the |
2127 | | * securityPolicies list. */ |
2128 | | UA_Boolean securityPolicyNoneDiscoveryOnly; |
2129 | | |
2130 | | /* Allow clients without encryption support to connect with username and password. |
2131 | | * This requires to transmit the password in plain text over the network which is |
2132 | | * why this option is disabled by default. |
2133 | | * Make sure you really need this before enabling plain text passwords. */ |
2134 | | UA_Boolean allowNonePolicyPassword; |
2135 | | |
2136 | | /* Different sets of certificates are trusted for SecureChannel / Session */ |
2137 | | UA_CertificateGroup secureChannelPKI; |
2138 | | UA_CertificateGroup sessionPKI; |
2139 | | |
2140 | | /* See the AccessControl Plugin API */ |
2141 | | UA_AccessControl accessControl; |
2142 | | |
2143 | | /* Nodes and Node Lifecycle |
2144 | | * ~~~~~~~~~~~~~~~~~~~~~~~~ |
2145 | | * See the section for :ref:`node lifecycle handling<node-lifecycle>`. */ |
2146 | | UA_Nodestore *nodestore; |
2147 | | UA_GlobalNodeLifecycle *nodeLifecycle; |
2148 | | |
2149 | | /* Copy the HasModellingRule reference in instances from the type |
2150 | | * definition in UA_Server_addObjectNode and UA_Server_addVariableNode. |
2151 | | * |
2152 | | * Part 3 - 6.4.4: [...] it is not required that newly created or referenced |
2153 | | * instances based on InstanceDeclarations have a ModellingRule, however, it |
2154 | | * is allowed that they have any ModellingRule independent of the |
2155 | | * ModellingRule of their InstanceDeclaration */ |
2156 | | UA_Boolean modellingRulesOnInstances; |
2157 | | |
2158 | | /* Limits |
2159 | | * ~~~~~~ */ |
2160 | | /* Limits for SecureChannels */ |
2161 | | UA_UInt16 maxSecureChannels; |
2162 | | UA_UInt32 maxSecurityTokenLifetime; /* in ms */ |
2163 | | |
2164 | | /* Limits for Sessions */ |
2165 | | UA_UInt16 maxSessions; |
2166 | | UA_Double maxSessionTimeout; /* in ms */ |
2167 | | |
2168 | | /* Operation limits */ |
2169 | | UA_UInt32 maxNodesPerRead; |
2170 | | UA_UInt32 maxNodesPerWrite; |
2171 | | UA_UInt32 maxNodesPerMethodCall; |
2172 | | UA_UInt32 maxNodesPerBrowse; |
2173 | | UA_UInt32 maxNodesPerRegisterNodes; |
2174 | | UA_UInt32 maxNodesPerTranslateBrowsePathsToNodeIds; |
2175 | | UA_UInt32 maxNodesPerNodeManagement; |
2176 | | UA_UInt32 maxMonitoredItemsPerCall; |
2177 | | |
2178 | | /* Limits for Requests */ |
2179 | | UA_UInt32 maxReferencesPerNode; |
2180 | | |
2181 | | #ifdef UA_ENABLE_ENCRYPTION |
2182 | | /* Limits for TrustList */ |
2183 | | UA_UInt32 maxTrustListSize; /* in bytes, 0 => unlimited */ |
2184 | | UA_UInt32 maxRejectedListSize; /* 0 => unlimited */ |
2185 | | #endif |
2186 | | |
2187 | | /* Async Operations |
2188 | | * ~~~~~~~~~~~~~~~~ |
2189 | | * See the section for :ref:`async operations<async-operations>`. */ |
2190 | | UA_Double asyncOperationTimeout; /* in ms, 0 => unlimited */ |
2191 | | size_t maxAsyncOperationQueueSize; /* 0 => unlimited */ |
2192 | | |
2193 | | /* Notifies the userland that an async operation has been canceled. The |
2194 | | * memory for setting the output value is then freed internally and should |
2195 | | * not be touched afterwards. */ |
2196 | | void (*asyncOperationCancelCallback)(UA_Server *server, const void *out); |
2197 | | |
2198 | | /* Discovery |
2199 | | * ~~~~~~~~~ */ |
2200 | | #ifdef UA_ENABLE_DISCOVERY |
2201 | | /* Timeout in seconds when to automatically remove a registered server from |
2202 | | * the list, if it doesn't re-register within the given time frame. A value |
2203 | | * of 0 disables automatic removal. Default is 60 Minutes (60*60). Must be |
2204 | | * bigger than 10 seconds, because cleanup is only triggered approximately |
2205 | | * every 10 seconds. The server will still be removed depending on the |
2206 | | * state of the semaphore file. */ |
2207 | | UA_UInt32 discoveryCleanupTimeout; |
2208 | | |
2209 | | # ifdef UA_ENABLE_DISCOVERY_MULTICAST |
2210 | | UA_Boolean mdnsEnabled; |
2211 | | UA_MdnsDiscoveryConfiguration mdnsConfig; |
2212 | | # ifdef UA_ENABLE_DISCOVERY_MULTICAST_MDNSD |
2213 | | UA_String mdnsInterfaceIP; |
2214 | | # if !defined(UA_HAS_GETIFADDR) |
2215 | | size_t mdnsIpAddressListSize; |
2216 | | UA_UInt32 *mdnsIpAddressList; |
2217 | | # endif |
2218 | | # endif |
2219 | | # endif |
2220 | | #endif |
2221 | | |
2222 | | /* Subscriptions |
2223 | | * ~~~~~~~~~~~~~ */ |
2224 | | UA_Boolean subscriptionsEnabled; |
2225 | | #ifdef UA_ENABLE_SUBSCRIPTIONS |
2226 | | /* Limits for Subscriptions */ |
2227 | | UA_UInt32 maxSubscriptions; |
2228 | | UA_UInt32 maxSubscriptionsPerSession; |
2229 | | UA_DurationRange publishingIntervalLimits; /* in ms (must not be less than 5) */ |
2230 | | UA_UInt32Range lifeTimeCountLimits; |
2231 | | UA_UInt32Range keepAliveCountLimits; |
2232 | | UA_UInt32 maxNotificationsPerPublish; |
2233 | | UA_Boolean enableRetransmissionQueue; |
2234 | | UA_UInt32 maxRetransmissionQueueSize; /* 0 -> unlimited size */ |
2235 | | # ifdef UA_ENABLE_SUBSCRIPTIONS_EVENTS |
2236 | | UA_UInt32 maxEventsPerNode; /* 0 -> unlimited size */ |
2237 | | # endif |
2238 | | |
2239 | | /* Limits for MonitoredItems */ |
2240 | | UA_UInt32 maxMonitoredItems; |
2241 | | UA_UInt32 maxMonitoredItemsPerSubscription; |
2242 | | UA_DurationRange samplingIntervalLimits; /* in ms (must not be less than 5) */ |
2243 | | UA_UInt32Range queueSizeLimits; /* Negotiated with the client */ |
2244 | | |
2245 | | /* Limits for PublishRequests */ |
2246 | | UA_UInt32 maxPublishReqPerSession; |
2247 | | |
2248 | | /* Register MonitoredItem in Userland |
2249 | | * |
2250 | | * @param server Allows the access to the server object |
2251 | | * @param sessionId The session id, represented as an node id |
2252 | | * @param sessionContext An optional pointer to user-defined data for the |
2253 | | * specific data source |
2254 | | * @param nodeid Id of the node in question |
2255 | | * @param nodeidContext An optional pointer to user-defined data, associated |
2256 | | * with the node in the nodestore. Note that, if the node has already |
2257 | | * been removed, this value contains a NULL pointer. |
2258 | | * @param attributeId Identifies which attribute (value, data type etc.) is |
2259 | | * monitored |
2260 | | * @param removed Determines if the MonitoredItem was removed or created. */ |
2261 | | void (*monitoredItemRegisterCallback)(UA_Server *server, |
2262 | | const UA_NodeId *sessionId, |
2263 | | void *sessionContext, |
2264 | | const UA_NodeId *nodeId, |
2265 | | void *nodeContext, |
2266 | | UA_UInt32 attibuteId, |
2267 | | UA_Boolean removed); |
2268 | | #endif |
2269 | | |
2270 | | /* PubSub |
2271 | | * ~~~~~~ */ |
2272 | | #ifdef UA_ENABLE_PUBSUB |
2273 | | UA_Boolean pubsubEnabled; |
2274 | | UA_PubSubConfiguration pubSubConfig; |
2275 | | #endif |
2276 | | |
2277 | | /* Historical Access |
2278 | | * ~~~~~~~~~~~~~~~~~ */ |
2279 | | UA_Boolean historizingEnabled; |
2280 | | #ifdef UA_ENABLE_HISTORIZING |
2281 | | UA_HistoryDatabase historyDatabase; |
2282 | | |
2283 | | UA_Boolean accessHistoryDataCapability; |
2284 | | UA_UInt32 maxReturnDataValues; /* 0 -> unlimited size */ |
2285 | | |
2286 | | UA_Boolean accessHistoryEventsCapability; |
2287 | | UA_UInt32 maxReturnEventValues; /* 0 -> unlimited size */ |
2288 | | |
2289 | | UA_Boolean insertDataCapability; |
2290 | | UA_Boolean insertEventCapability; |
2291 | | UA_Boolean insertAnnotationsCapability; |
2292 | | |
2293 | | UA_Boolean replaceDataCapability; |
2294 | | UA_Boolean replaceEventCapability; |
2295 | | |
2296 | | UA_Boolean updateDataCapability; |
2297 | | UA_Boolean updateEventCapability; |
2298 | | |
2299 | | UA_Boolean deleteRawCapability; |
2300 | | UA_Boolean deleteEventCapability; |
2301 | | UA_Boolean deleteAtTimeDataCapability; |
2302 | | #endif |
2303 | | |
2304 | | /* Reverse Connect |
2305 | | * ~~~~~~~~~~~~~~~ */ |
2306 | | UA_UInt32 reverseReconnectInterval; /* Default is 15000 ms */ |
2307 | | |
2308 | | /* Certificate Password Callback |
2309 | | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
2310 | | #ifdef UA_ENABLE_ENCRYPTION |
2311 | | /* If the private key is in PEM format and password protected, this callback |
2312 | | * is called during initialization to get the password to decrypt the |
2313 | | * private key. The memory containing the password is freed by the client |
2314 | | * after use. The callback should be set early, other parts of the client |
2315 | | * config setup may depend on it. */ |
2316 | | UA_StatusCode (*privateKeyPasswordCallback)(UA_ServerConfig *sc, |
2317 | | UA_ByteString *password); |
2318 | | #endif |
2319 | | }; |
2320 | | |
2321 | | void UA_EXPORT |
2322 | | UA_ServerConfig_clear(UA_ServerConfig *config); |
2323 | | |
2324 | | UA_DEPRECATED static UA_INLINE void |
2325 | 0 | UA_ServerConfig_clean(UA_ServerConfig *config) { |
2326 | 0 | UA_ServerConfig_clear(config); |
2327 | 0 | } Unexecuted instantiation: fuzz_tcp_message.cc:UA_ServerConfig_clean(UA_ServerConfig*) Unexecuted instantiation: ua_util.c:UA_ServerConfig_clean Unexecuted instantiation: ua_session.c:UA_ServerConfig_clean Unexecuted instantiation: ua_nodes.c:UA_ServerConfig_clean Unexecuted instantiation: ua_server.c:UA_ServerConfig_clean Unexecuted instantiation: ua_server_ns0.c:UA_ServerConfig_clean Unexecuted instantiation: ua_server_ns0_diagnostics.c:UA_ServerConfig_clean Unexecuted instantiation: ua_server_ns0_gds.c:UA_ServerConfig_clean Unexecuted instantiation: ua_server_config.c:UA_ServerConfig_clean Unexecuted instantiation: ua_server_binary.c:UA_ServerConfig_clean Unexecuted instantiation: ua_server_utils.c:UA_ServerConfig_clean Unexecuted instantiation: ua_server_async.c:UA_ServerConfig_clean Unexecuted instantiation: ua_subscription.c:UA_ServerConfig_clean Unexecuted instantiation: ua_subscription_datachange.c:UA_ServerConfig_clean Unexecuted instantiation: ua_subscription_event.c:UA_ServerConfig_clean Unexecuted instantiation: ua_subscription_alarms_conditions.c:UA_ServerConfig_clean Unexecuted instantiation: ua_services.c:UA_ServerConfig_clean Unexecuted instantiation: ua_services_view.c:UA_ServerConfig_clean Unexecuted instantiation: ua_services_method.c:UA_ServerConfig_clean Unexecuted instantiation: ua_services_session.c:UA_ServerConfig_clean Unexecuted instantiation: ua_services_attribute.c:UA_ServerConfig_clean Unexecuted instantiation: ua_services_discovery.c:UA_ServerConfig_clean Unexecuted instantiation: ua_services_subscription.c:UA_ServerConfig_clean Unexecuted instantiation: ua_services_monitoreditem.c:UA_ServerConfig_clean Unexecuted instantiation: ua_services_securechannel.c:UA_ServerConfig_clean Unexecuted instantiation: ua_services_nodemanagement.c:UA_ServerConfig_clean Unexecuted instantiation: namespace0_generated.c:UA_ServerConfig_clean Unexecuted instantiation: ua_pubsub_connection.c:UA_ServerConfig_clean Unexecuted instantiation: ua_pubsub_dataset.c:UA_ServerConfig_clean Unexecuted instantiation: ua_pubsub_writer.c:UA_ServerConfig_clean Unexecuted instantiation: ua_pubsub_writergroup.c:UA_ServerConfig_clean Unexecuted instantiation: ua_pubsub_reader.c:UA_ServerConfig_clean Unexecuted instantiation: ua_pubsub_readergroup.c:UA_ServerConfig_clean Unexecuted instantiation: ua_pubsub_manager.c:UA_ServerConfig_clean Unexecuted instantiation: ua_pubsub_ns0.c:UA_ServerConfig_clean Unexecuted instantiation: ua_pubsub_ns0_sks.c:UA_ServerConfig_clean Unexecuted instantiation: ua_pubsub_keystorage.c:UA_ServerConfig_clean Unexecuted instantiation: ua_discovery_mdns.c:UA_ServerConfig_clean Unexecuted instantiation: ua_discovery.c:UA_ServerConfig_clean Unexecuted instantiation: ua_accesscontrol_default.c:UA_ServerConfig_clean Unexecuted instantiation: ua_nodestore_ziptree.c:UA_ServerConfig_clean Unexecuted instantiation: ua_config_default.c:UA_ServerConfig_clean Unexecuted instantiation: ua_config_json.c:UA_ServerConfig_clean Unexecuted instantiation: ua_history_data_backend_memory.c:UA_ServerConfig_clean Unexecuted instantiation: ua_history_data_gathering_default.c:UA_ServerConfig_clean Unexecuted instantiation: ua_history_database_default.c:UA_ServerConfig_clean |
2328 | | |
2329 | | /** |
2330 | | * Update the Server Certificate at Runtime |
2331 | | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
2332 | | * If certificateGroupId is null the DefaultApplicationGroup is used. |
2333 | | */ |
2334 | | |
2335 | | UA_StatusCode UA_EXPORT |
2336 | | UA_Server_updateCertificate(UA_Server *server, |
2337 | | const UA_NodeId certificateGroupId, |
2338 | | const UA_NodeId certificateTypeId, |
2339 | | const UA_ByteString certificate, |
2340 | | const UA_ByteString *privateKey); |
2341 | | |
2342 | | /* Creates a PKCS #10 DER encoded certificate request signed with the server's |
2343 | | * private key. |
2344 | | * If certificateGroupId is null the DefaultApplicationGroup is used. |
2345 | | */ |
2346 | | UA_StatusCode UA_EXPORT |
2347 | | UA_Server_createSigningRequest(UA_Server *server, |
2348 | | const UA_NodeId certificateGroupId, |
2349 | | const UA_NodeId certificateTypeId, |
2350 | | const UA_String *subjectName, |
2351 | | const UA_Boolean *regenerateKey, |
2352 | | const UA_ByteString *nonce, |
2353 | | UA_ByteString *csr); |
2354 | | |
2355 | | /* Adds certificates and Certificate Revocation Lists (CRLs) to a specific |
2356 | | * certificate group on the server. |
2357 | | * |
2358 | | * @param server The server object |
2359 | | * @param certificateGroupId The NodeId of the certificate group where |
2360 | | * certificates will be added |
2361 | | * @param certificates The certificates to be added |
2362 | | * @param certificatesSize The number of certificates |
2363 | | * @param crls The associated CRLs for the certificates, required when adding |
2364 | | * issuer certificates |
2365 | | * @param crlsSize The number of CRLs |
2366 | | * @param isTrusted Indicates whether the certificates should be added to the |
2367 | | * trusted list or the issuer list |
2368 | | * @param appendCertificates Indicates whether the certificates should be added |
2369 | | * to the list or replace the existing list |
2370 | | * @return ``UA_STATUSCODE_GOOD`` on success */ |
2371 | | UA_StatusCode UA_EXPORT |
2372 | | UA_Server_addCertificates(UA_Server *server, |
2373 | | const UA_NodeId certificateGroupId, |
2374 | | UA_ByteString *certificates, |
2375 | | size_t certificatesSize, |
2376 | | UA_ByteString *crls, |
2377 | | size_t crlsSize, |
2378 | | const UA_Boolean isTrusted, |
2379 | | const UA_Boolean appendCertificates); |
2380 | | |
2381 | | /* Removes certificates from a specific certificate group on the server. The |
2382 | | * corresponding CRLs are removed automatically. |
2383 | | * |
2384 | | * @param server The server object |
2385 | | * @param certificateGroupId The NodeId of the certificate group from which |
2386 | | * certificates will be removed |
2387 | | * @param certificates The certificates to be removed |
2388 | | * @param certificatesSize The number of certificates |
2389 | | * @param isTrusted Indicates whether the certificates are being removed from |
2390 | | * the trusted list or the issuer list |
2391 | | * @return ``UA_STATUSCODE_GOOD`` on success */ |
2392 | | UA_StatusCode UA_EXPORT |
2393 | | UA_Server_removeCertificates(UA_Server *server, |
2394 | | const UA_NodeId certificateGroupId, |
2395 | | UA_ByteString *certificates, |
2396 | | size_t certificatesSize, |
2397 | | const UA_Boolean isTrusted); |
2398 | | |
2399 | | |
2400 | | _UA_END_DECLS |
2401 | | |
2402 | | #ifdef UA_ENABLE_PUBSUB |
2403 | | #include <open62541/server_pubsub.h> |
2404 | | #endif |
2405 | | |
2406 | | #endif /* UA_SERVER_H_ */ |