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