open62541 1.4.15
Open source implementation of OPC UA
Loading...
Searching...
No Matches
client.h
Go to the documentation of this file.
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 2015-2020 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
6 * Copyright 2015-2016 (c) Sten GrĂ¼ner
7 * Copyright 2015-2016 (c) Chris Iatrou
8 * Copyright 2015-2017 (c) Florian Palm
9 * Copyright 2015 (c) Holger Jeromin
10 * Copyright 2015 (c) Oleksiy Vasylyev
11 * Copyright 2017 (c) Stefan Profanter, fortiss GmbH
12 * Copyright 2017 (c) Mark Giraud, Fraunhofer IOSB
13 * Copyright 2018 (c) Thomas Stalder, Blue Time Concept SA
14 * Copyright 2018 (c) Kalycito Infotech Private Limited
15 * Copyright 2020 (c) Christian von Arnim, ISW University of Stuttgart
16 * Copyright 2022 (c) Linutronix GmbH (Author: Muddasir Shakil)
17 */
18
19#ifndef UA_CLIENT_H_
20#define UA_CLIENT_H_
21
22#include <open62541/types.h>
23#include <open62541/common.h>
24#include <open62541/util.h>
25
29
30/** Forward declarations */
31struct UA_ClientConfig;
33
35
36
37
39 void *clientContext; /* User-defined pointer attached to the client */
40 UA_Logger *logging; /* Plugin for log output */
41
42 /* Response timeout in ms (0 -> no timeout). If the server does not answer a
43 * request within this time a StatusCode UA_STATUSCODE_BADTIMEOUT is
44 * returned. This timeout can be overridden for individual requests by
45 * setting a non-null "timeoutHint" in the request header. */
47
48 /* The description must be internally consistent.
49 * - The ApplicationUri set in the ApplicationDescription must match the
50 * URI set in the certificate */
52
53 /* The endpoint for the client to connect to.
54 * Such as "opc.tcp://host:port". */
56
57
58 UA_ExtensionObject userIdentityToken; /* Configured User-Identity Token */
59 UA_MessageSecurityMode securityMode; /* None, Sign, SignAndEncrypt. The
60 * default is "invalid". This
61 * indicates the client to select any
62 * matching endpoint. */
63 UA_String securityPolicyUri; /* SecurityPolicy for the SecureChannel. An
64 * empty string indicates the client to select
65 * any matching SecurityPolicy. */
66
67 UA_Boolean noSession; /* Only open a SecureChannel, but no Session */
68 UA_Boolean noReconnect; /* Don't reconnect SecureChannel when the connection
69 * is lost without explicitly closing. */
70 UA_Boolean noNewSession; /* Don't automatically create a new Session when
71 * the intial one is lost. Instead abort the
72 * connection when the Session is lost. */
73
74
77
78
80
81
83
84
85
86 UA_UInt32 secureChannelLifeTime; /* Lifetime in ms (then the channel needs
87 to be renewed) */
88 UA_UInt32 requestedSessionTimeout; /* Session timeout in ms */
90 UA_UInt32 connectivityCheckInterval; /* Connectivity check interval in ms.
91 * 0 = background task disabled */
92
93 /* EventLoop */
95 UA_Boolean externalEventLoop; /* The EventLoop is not deleted with the config */
96
97 /* Available SecurityPolicies */
100
101 /* Certificate Verification Plugin */
103
104 /* Available SecurityPolicies for Authentication. The policy defined by the
105 * AccessControl is selected. If no policy is defined, the policy of the
106 * secure channel is selected.*/
109
110 /* SecurityPolicyUri for the Authentication. */
112
113 /* Callback for state changes. The client state is differentated into the
114 * SecureChannel state and the Session state. The connectStatus is set if
115 * the client connection (including reconnects) has failed and the client
116 * has to "give up". If the connectStatus is not set, the client still has
117 * hope to connect or recover. */
118 void (*stateCallback)(UA_Client *client,
119 UA_SecureChannelState channelState,
120 UA_SessionState sessionState,
121 UA_StatusCode connectStatus);
122
123 /* When connectivityCheckInterval is greater than 0, every
124 * connectivityCheckInterval (in ms), an async read request is performed on
125 * the server. inactivityCallback is called when the client receive no
126 * response for this read request The connection can be closed, this in an
127 * attempt to recreate a healthy connection. */
129
130 /* Number of PublishResponse queued up in the server */
132
133 /* If the client does not receive a PublishResponse after the defined delay
134 * of ``(sub->publishingInterval * sub->maxKeepAliveCount) +
135 * client->config.timeout)``, then subscriptionInactivityCallback is called
136 * for the subscription.. */
138 UA_UInt32 subscriptionId,
139 void *subContext);
140
141 /* Session config */
145
146#ifdef UA_ENABLE_ENCRYPTION
147 /* If the private key is in PEM format and password protected, this callback
148 * is called during initialization to get the password to decrypt the
149 * private key. The memory containing the password is freed by the client
150 * after use. The callback should be set early, other parts of the client
151 * config setup may depend on it. */
153 UA_ByteString *password);
154#endif
155};
156
157
158UA_EXPORT UA_StatusCode
160
161
162UA_EXPORT void
164
165
166UA_EXPORT void
168
169/** Configure Username/Password for the Session authentication. Also see
170 * UA_ClientConfig_setAuthenticationCert for x509-based authentication, which is
171 * implemented as a plugin (as it can be based on different crypto
172 * libraries). */
173static UA_StatusCode
174UA_ClientConfig_setAuthenticationUsername(UA_ClientConfig *config,
175 const char *username,
176 const char *password) {
177 UA_UserNameIdentityToken* identityToken = UA_UserNameIdentityToken_new();
178 if(!identityToken)
180 identityToken->userName = UA_STRING_ALLOC(username);
181 identityToken->password = UA_STRING_ALLOC(password);
182
183 UA_ExtensionObject_clear(&config->userIdentityToken);
184 UA_ExtensionObject_setValue(&config->userIdentityToken, identityToken,
186 return UA_STATUSCODE_GOOD;
187}
188
189
190
191/** Create a new client with a default configuration that adds plugins for
192 * networking, security, logging and so on. See `client_config_default.h` for
193 * more detailed options.
194 *
195 * The default configuration can be used as the starting point to adjust the
196 * client configuration to individual needs. UA_Client_new is implemented in the
197 * /plugins folder under the CC0 license. Furthermore the client confiugration
198 * only uses the public server API.
199 *
200 * @return Returns the configured client or NULL if an error occurs. */
201UA_EXPORT UA_Client * UA_Client_new(void);
202
203/** Creates a new client. Moves the config into the client with a shallow copy.
204 * The config content is cleared together with the client. */
205UA_Client *
207
208/** Returns the current state. All arguments except ``client`` can be NULL. */
209void UA_THREADSAFE
211 UA_SecureChannelState *channelState,
212 UA_SessionState *sessionState,
213 UA_StatusCode *connectStatus);
214
215/** Get the client configuration */
216UA_EXPORT UA_ClientConfig *
218
219/** Get the client context */
220static void *
221UA_Client_getContext(UA_Client *client) {
222 return UA_Client_getConfig(client)->clientContext; /* Cannot fail */
223}
224
225/** (Disconnect and) delete the client */
226void
228
229
230
231/** Returns a shallow copy of the attribute. Don't _clear or _delete the value
232 * variant. Don't use the value after returning the control flow to the client.
233 * Also don't use this in a multi-threaded application. */
234UA_EXPORT UA_StatusCode
236 UA_Variant *outValue);
237
238/** Return a deep copy of the attribute */
241 UA_Variant *outValue);
242
243/** Returns NULL if the attribute is not defined or not a scalar or not of the
244 * right datatype. Otherwise a shallow copy of the scalar value is created at
245 * the target location of the void pointer. Hence don't use this in a
246 * multi-threaded application. */
247UA_EXPORT UA_StatusCode
249 const UA_QualifiedName key,
250 const UA_DataType *type,
251 void *outValue);
252
253
254
255/** Connect with the client configuration. For the async connection, finish
256 * connecting via UA_Client_run_iterate (or manually running a configured
257 * external EventLoop). */
260
261/** Connect to the server. First a SecureChannel is opened, then a Session. The
262 * client configuration restricts the SecureChannel selection and contains the
263 * UserIdentityToken for the Session.
264 *
265 * @param client to use
266 * @param endpointURL to connect (for example "opc.tcp://localhost:4840")
267 * @return Indicates whether the operation succeeded or returns an error code */
268static UA_StatusCode
269UA_Client_connect(UA_Client *client, const char *endpointUrl) {
270 /* Update the configuration */
272 cc->noSession = false; /* Open a Session */
273 UA_String_clear(&cc->endpointUrl);
274 cc->endpointUrl = UA_STRING_ALLOC(endpointUrl);
275
276 /* Connect */
277 return __UA_Client_connect(client, false);
278}
279
280/** Connect async (non-blocking) to the server. After initiating the connection,
281 * call UA_Client_run_iterate repeatedly until the connection is fully
282 * established. You can set a callback to client->config.stateCallback to be
283 * notified when the connection status changes. Or use UA_Client_getState to get
284 * the state manually. */
285static UA_StatusCode
286UA_Client_connectAsync(UA_Client *client, const char *endpointUrl) {
287 /* Update the configuration */
289 cc->noSession = false; /* Open a Session */
290 UA_String_clear(&cc->endpointUrl);
291 cc->endpointUrl = UA_STRING_ALLOC(endpointUrl);
292
293 /* Connect */
294 return __UA_Client_connect(client, true);
295}
296
297/** Connect to the server without creating a session
298 *
299 * @param client to use
300 * @param endpointURL to connect (for example "opc.tcp://localhost:4840")
301 * @return Indicates whether the operation succeeded or returns an error code */
302static UA_StatusCode
303UA_Client_connectSecureChannel(UA_Client *client, const char *endpointUrl) {
304 /* Update the configuration */
306 cc->noSession = true; /* Don't open a Session */
307 UA_String_clear(&cc->endpointUrl);
308 cc->endpointUrl = UA_STRING_ALLOC(endpointUrl);
309
310 /* Connect */
311 return __UA_Client_connect(client, false);
312}
313
314/** Connect async (non-blocking) only the SecureChannel */
315static UA_StatusCode
316UA_Client_connectSecureChannelAsync(UA_Client *client, const char *endpointUrl) {
317 /* Update the configuration */
319 cc->noSession = true; /* Don't open a Session */
320 UA_String_clear(&cc->endpointUrl);
321 cc->endpointUrl = UA_STRING_ALLOC(endpointUrl);
322
323 /* Connect */
324 return __UA_Client_connect(client, true);
325}
326
327/** Connect to the server and create+activate a Session with the given username
328 * and password. This first set the UserIdentityToken in the client config and
329 * then calls the regular connect method. */
330static UA_StatusCode
331UA_Client_connectUsername(UA_Client *client, const char *endpointUrl,
332 const char *username, const char *password) {
333 /* Set the user identity token */
335 UA_StatusCode res =
336 UA_ClientConfig_setAuthenticationUsername(cc, username, password);
337 if(res != UA_STATUSCODE_GOOD)
338 return res;
339
340 /* Connect */
341 return UA_Client_connect(client, endpointUrl);
342}
343
344/** Sets up a listening socket for incoming reverse connect requests by OPC UA
345 * servers. After the first server has connected, the listening socket is
346 * removed. The client state callback is also used for reverse connect. An
347 * implementation could for example issue a new call to
348 * UA_Client_startListeningForReverseConnect after the server has closed the
349 * connection. If the client is connected to any server while
350 * UA_Client_startListeningForReverseConnect is called, the connection will be
351 * closed.
352 *
353 * The reverse connect is closed by calling the standard disconnect functions
354 * like for a "normal" connection that was initiated by the client. Calling one
355 * of the connect methods will also close the listening socket and the
356 * connection to the remote server. */
359 UA_Client *client, const UA_String *listenHostnames,
360 size_t listenHostnamesLength, UA_UInt16 port);
361
362/** Disconnect and close a connection to the selected server. Disconnection is
363 * always performed async (without blocking). */
366
367/** Disconnect async. Run UA_Client_run_iterate until the callback notifies that
368 * all connections are closed. */
371
372/** Disconnect the SecureChannel but keep the Session intact (if it exists). */
375
376/** Disconnect the SecureChannel but keep the Session intact (if it exists). This
377 * is an async operation. Iterate the client until the SecureChannel was fully
378 * cleaned up. */
381
382/** Get the AuthenticationToken and ServerNonce required to activate the current
383 * Session on a different SecureChannel. */
386 UA_Client *client, UA_NodeId *authenticationToken, UA_ByteString *serverNonce);
387
388/** Re-activate the current session. A change of prefered locales can be done by
389 * updating the client configuration. */
392
393/** Async version of UA_Client_activateCurrentSession */
396
397/** Activate an already created Session. This allows a Session to be transferred
398 * from a different client instance. The AuthenticationToken and ServerNonce
399 * must be provided for this. Both can be retrieved for an activated Session
400 * with UA_Client_getSessionAuthenticationToken.
401 *
402 * The UserIdentityToken used for authentication must be identical to the
403 * original activation of the Session. The UserIdentityToken is set in the
404 * client configuration.
405 *
406 * Note the noNewSession option if there should not be a new Session
407 * automatically created when this one closes. */
410 const UA_NodeId authenticationToken,
411 const UA_ByteString serverNonce);
412
413/** Async version of UA_Client_activateSession */
416 const UA_NodeId authenticationToken,
417 const UA_ByteString serverNonce);
418
419
420
421/** Gets a list of endpoints of a server
422 *
423 * @param client to use. Must be connected to the same endpoint given in
424 * serverUrl or otherwise in disconnected state.
425 * @param serverUrl url to connect (for example "opc.tcp://localhost:4840")
426 * @param endpointDescriptionsSize size of the array of endpoint descriptions
427 * @param endpointDescriptions array of endpoint descriptions that is allocated
428 * by the function (you need to free manually)
429 * @return Indicates whether the operation succeeded or returns an error code */
431UA_Client_getEndpoints(UA_Client *client, const char *serverUrl,
432 size_t* endpointDescriptionsSize,
433 UA_EndpointDescription** endpointDescriptions);
434
435/** Gets a list of all registered servers at the given server.
436 *
437 * You can pass an optional filter for serverUris. If the given server is not
438 * registered, an empty array will be returned. If the server is registered,
439 * only that application description will be returned.
440 *
441 * Additionally you can optionally indicate which locale you want for the server
442 * name in the returned application description. The array indicates the order
443 * of preference. A server may have localized names.
444 *
445 * @param client to use. Must be connected to the same endpoint given in
446 * serverUrl or otherwise in disconnected state.
447 * @param serverUrl url to connect (for example "opc.tcp://localhost:4840")
448 * @param serverUrisSize Optional filter for specific server uris
449 * @param serverUris Optional filter for specific server uris
450 * @param localeIdsSize Optional indication which locale you prefer
451 * @param localeIds Optional indication which locale you prefer
452 * @param registeredServersSize size of returned array, i.e., number of
453 * found/registered servers
454 * @param registeredServers array containing found/registered servers
455 * @return Indicates whether the operation succeeded or returns an error code */
457UA_Client_findServers(UA_Client *client, const char *serverUrl,
458 size_t serverUrisSize, UA_String *serverUris,
459 size_t localeIdsSize, UA_String *localeIds,
460 size_t *registeredServersSize,
461 UA_ApplicationDescription **registeredServers);
462
463/** Get a list of all known server in the network. Only supported by LDS servers.
464 *
465 * @param client to use. Must be connected to the same endpoint given in
466 * serverUrl or otherwise in disconnected state.
467 * @param serverUrl url to connect (for example "opc.tcp://localhost:4840")
468 * @param startingRecordId optional. Only return the records with an ID higher
469 * or equal the given. Can be used for pagination to only get a subset of
470 * the full list
471 * @param maxRecordsToReturn optional. Only return this number of records
472
473 * @param serverCapabilityFilterSize optional. Filter the returned list to only
474 * get servers with given capabilities, e.g. "LDS"
475 * @param serverCapabilityFilter optional. Filter the returned list to only get
476 * servers with given capabilities, e.g. "LDS"
477 * @param serverOnNetworkSize size of returned array, i.e., number of
478 * known/registered servers
479 * @param serverOnNetwork array containing known/registered servers
480 * @return Indicates whether the operation succeeded or returns an error code */
482UA_Client_findServersOnNetwork(UA_Client *client, const char *serverUrl,
483 UA_UInt32 startingRecordId,
484 UA_UInt32 maxRecordsToReturn,
485 size_t serverCapabilityFilterSize,
486 UA_String *serverCapabilityFilter,
487 size_t *serverOnNetworkSize,
488 UA_ServerOnNetwork **serverOnNetwork);
489
490
491/** Don't use this function. Use the type versions below instead. */
492void UA_THREADSAFE
493__UA_Client_Service(UA_Client *client, const void *request,
494 const UA_DataType *requestType, void *response,
495 const UA_DataType *responseType);
496
497/*
498 * Attribute Service Set
499 * ^^^^^^^^^^^^^^^^^^^^^ */
501UA_Client_Service_read(UA_Client *client, const UA_ReadRequest request) {
502 UA_ReadResponse response;
504 &response, &UA_TYPES[UA_TYPES_READRESPONSE]);
505 return response;
506}
507
509UA_Client_Service_write(UA_Client *client, const UA_WriteRequest request) {
510 UA_WriteResponse response;
512 &response, &UA_TYPES[UA_TYPES_WRITERESPONSE]);
513 return response;
514}
515
516/*
517 * Historical Access Service Set
518 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */
519#ifdef UA_ENABLE_HISTORIZING
520
522UA_Client_Service_historyRead(UA_Client *client,
523 const UA_HistoryReadRequest request) {
524 UA_HistoryReadResponse response;
526 client, &request, &UA_TYPES[UA_TYPES_HISTORYREADREQUEST],
528 return response;
529}
530
532UA_Client_Service_historyUpdate(UA_Client *client,
533 const UA_HistoryUpdateRequest request) {
536 client, &request, &UA_TYPES[UA_TYPES_HISTORYUPDATEREQUEST],
538 return response;
539}
540
541#endif
542
543/*
544 * Method Service Set
545 * ^^^^^^^^^^^^^^^^^^ */
547UA_Client_Service_call(UA_Client *client,
548 const UA_CallRequest request) {
549 UA_CallResponse response;
551 client, &request, &UA_TYPES[UA_TYPES_CALLREQUEST],
552 &response, &UA_TYPES[UA_TYPES_CALLRESPONSE]);
553 return response;
554}
555
556/*
557 * NodeManagement Service Set
558 * ^^^^^^^^^^^^^^^^^^^^^^^^^^ */
560UA_Client_Service_addNodes(UA_Client *client,
561 const UA_AddNodesRequest request) {
562 UA_AddNodesResponse response;
564 client, &request, &UA_TYPES[UA_TYPES_ADDNODESREQUEST],
566 return response;
567}
568
570UA_Client_Service_addReferences(UA_Client *client,
571 const UA_AddReferencesRequest request) {
574 client, &request, &UA_TYPES[UA_TYPES_ADDREFERENCESREQUEST],
576 return response;
577}
578
580UA_Client_Service_deleteNodes(UA_Client *client,
581 const UA_DeleteNodesRequest request) {
582 UA_DeleteNodesResponse response;
584 client, &request, &UA_TYPES[UA_TYPES_DELETENODESREQUEST],
586 return response;
587}
588
590UA_Client_Service_deleteReferences(
591 UA_Client *client, const UA_DeleteReferencesRequest request) {
594 client, &request, &UA_TYPES[UA_TYPES_DELETEREFERENCESREQUEST],
596 return response;
597}
598
599/*
600 * View Service Set
601 * ^^^^^^^^^^^^^^^^ */
603UA_Client_Service_browse(UA_Client *client,
604 const UA_BrowseRequest request) {
605 UA_BrowseResponse response;
607 client, &request, &UA_TYPES[UA_TYPES_BROWSEREQUEST],
608 &response, &UA_TYPES[UA_TYPES_BROWSERESPONSE]);
609 return response;
610}
611
613UA_Client_Service_browseNext(UA_Client *client,
614 const UA_BrowseNextRequest request) {
615 UA_BrowseNextResponse response;
617 client, &request, &UA_TYPES[UA_TYPES_BROWSENEXTREQUEST],
619 return response;
620}
621
623UA_Client_Service_translateBrowsePathsToNodeIds(
624 UA_Client *client,
628 client, &request,
630 &response,
632 return response;
633}
634
636UA_Client_Service_registerNodes(UA_Client *client,
637 const UA_RegisterNodesRequest request) {
640 client, &request, &UA_TYPES[UA_TYPES_REGISTERNODESREQUEST],
642 return response;
643}
644
646UA_Client_Service_unregisterNodes(
647 UA_Client *client, const UA_UnregisterNodesRequest request) {
650 client, &request, &UA_TYPES[UA_TYPES_UNREGISTERNODESREQUEST],
652 return response;
653}
654
655/*
656 * Query Service Set
657 * ^^^^^^^^^^^^^^^^^ */
658#ifdef UA_ENABLE_QUERY
659
661UA_Client_Service_queryFirst(UA_Client *client,
662 const UA_QueryFirstRequest request) {
663 UA_QueryFirstResponse response;
665 client, &request, &UA_TYPES[UA_TYPES_QUERYFIRSTREQUEST],
667 return response;
668}
669
671UA_Client_Service_queryNext(UA_Client *client,
672 const UA_QueryNextRequest request) {
673 UA_QueryNextResponse response;
675 client, &request, &UA_TYPES[UA_TYPES_QUERYFIRSTREQUEST],
677 return response;
678}
679
680#endif
681
682
683
684typedef void
685(*UA_ClientAsyncServiceCallback)(UA_Client *client, void *userdata,
686 UA_UInt32 requestId, void *response);
687
689__UA_Client_AsyncService(UA_Client *client, const void *request,
690 const UA_DataType *requestType,
692 const UA_DataType *responseType,
693 void *userdata, UA_UInt32 *requestId);
694
695/** Cancel all dispatched requests with the given requestHandle.
696 * The number if cancelled requests is returned by the server.
697 * The output argument cancelCount is not set if NULL. */
700 UA_UInt32 *cancelCount);
701
702/** Map the requestId to the requestHandle used for that request and call the
703 * Cancel service for that requestHandle. */
706 UA_UInt32 *cancelCount);
707
708/** Set new userdata and callback for an existing request.
709 *
710 * @param client Pointer to the UA_Client
711 * @param requestId RequestId of the request, which was returned by
712 * __UA_Client_AsyncService before
713 * @param userdata The new userdata
714 * @param callback The new callback
715 * @return UA_StatusCode UA_STATUSCODE_GOOD on success
716 * UA_STATUSCODE_BADNOTFOUND when no request with requestId is found. */
719 void *userdata, UA_ClientAsyncServiceCallback callback);
720
721/** Listen on the network and process arriving asynchronous responses in the
722 * background. Internal housekeeping, renewal of SecureChannels and subscription
723 * management is done as well. */
726
727/** Force the manual renewal of the SecureChannel. This is useful to renew the
728 * SecureChannel during a downtime when no time-critical operations are
729 * performed. This method is asynchronous. The renewal is triggered (the OPN
730 * message is sent) but not completed. The OPN response is handled with
731 * ``UA_Client_run_iterate`` or a synchronous service-call operation.
732 *
733 * @return The return value is UA_STATUSCODE_GOODCALLAGAIN if the SecureChannel
734 * has not elapsed at least 75% of its lifetime. Otherwise the
735 * ``connectStatus`` is returned. */
738
739
740
741typedef void (*UA_ClientCallback)(UA_Client *client, void *data);
742
743/** Add a callback for execution at a specified time. If the indicated time lies
744 * in the past, then the callback is executed at the next iteration of the
745 * server's main loop.
746 *
747 * @param client The client object.
748 * @param callback The callback that shall be added.
749 * @param data Data that is forwarded to the callback.
750 * @param date The timestamp for the execution time.
751 * @param callbackId Set to the identifier of the repeated callback. This can
752 * be used to cancel the callback later on. If the pointer is null, the
753 * identifier is not set.
754 * @return Upon success, UA_STATUSCODE_GOOD is returned. An error code
755 * otherwise. */
758 void *data, UA_DateTime date, UA_UInt64 *callbackId);
759
760/** Add a callback for cyclic repetition to the client.
761 *
762 * @param client The client object.
763 * @param callback The callback that shall be added.
764 * @param data Data that is forwarded to the callback.
765 * @param interval_ms The callback shall be repeatedly executed with the given
766 * interval (in ms). The interval must be positive. The first execution
767 * occurs at now() + interval at the latest.
768 * @param callbackId Set to the identifier of the repeated callback. This can
769 * be used to cancel the callback later on. If the pointer is null, the
770 * identifier is not set.
771 * @return Upon success, UA_STATUSCODE_GOOD is returned. An error code
772 * otherwise. */
775 void *data, UA_Double interval_ms,
776 UA_UInt64 *callbackId);
777
780 UA_UInt64 callbackId,
781 UA_Double interval_ms);
782
783void UA_THREADSAFE
785
786#define UA_Client_removeRepeatedCallback(server, callbackId) \
787 UA_Client_removeCallback(server, callbackId);
788
789
790
791/** Lookup a datatype by its NodeId. Takes the custom types in the client
792 * configuration into account. Return NULL if none found. */
793UA_EXPORT const UA_DataType *
795
796
797
799
800#endif /* UA_CLIENT_H_ */
UA_StatusCode UA_THREADSAFE UA_Client_addTimedCallback(UA_Client *client, UA_ClientCallback callback, void *data, UA_DateTime date, UA_UInt64 *callbackId)
Add a callback for execution at a specified time.
UA_StatusCode UA_THREADSAFE UA_Client_disconnectSecureChannelAsync(UA_Client *client)
Disconnect the SecureChannel but keep the Session intact (if it exists).
void(* UA_ClientAsyncServiceCallback)(UA_Client *client, void *userdata, UA_UInt32 requestId, void *response)
Definition client.h:685
UA_StatusCode UA_THREADSAFE __UA_Client_AsyncService(UA_Client *client, const void *request, const UA_DataType *requestType, UA_ClientAsyncServiceCallback callback, const UA_DataType *responseType, void *userdata, UA_UInt32 *requestId)
UA_StatusCode UA_THREADSAFE UA_Client_getSessionAuthenticationToken(UA_Client *client, UA_NodeId *authenticationToken, UA_ByteString *serverNonce)
Get the AuthenticationToken and ServerNonce required to activate the current Session on a different S...
UA_StatusCode UA_THREADSAFE UA_Client_activateCurrentSessionAsync(UA_Client *client)
Async version of UA_Client_activateCurrentSession.
UA_EXPORT UA_ClientConfig * UA_Client_getConfig(UA_Client *client)
Get the client configuration.
void UA_THREADSAFE UA_Client_removeCallback(UA_Client *client, UA_UInt64 callbackId)
UA_StatusCode UA_THREADSAFE UA_Client_findServers(UA_Client *client, const char *serverUrl, size_t serverUrisSize, UA_String *serverUris, size_t localeIdsSize, UA_String *localeIds, size_t *registeredServersSize, UA_ApplicationDescription **registeredServers)
Gets a list of all registered servers at the given server.
UA_EXPORT UA_StatusCode UA_Client_getConnectionAttribute_scalar(UA_Client *client, const UA_QualifiedName key, const UA_DataType *type, void *outValue)
Returns NULL if the attribute is not defined or not a scalar or not of the right datatype.
UA_EXPORT void UA_ClientConfig_delete(UA_ClientConfig *config)
UA_StatusCode UA_THREADSAFE UA_Client_activateSession(UA_Client *client, const UA_NodeId authenticationToken, const UA_ByteString serverNonce)
Activate an already created Session.
void UA_THREADSAFE UA_Client_getState(UA_Client *client, UA_SecureChannelState *channelState, UA_SessionState *sessionState, UA_StatusCode *connectStatus)
Returns the current state.
void(* UA_ClientCallback)(UA_Client *client, void *data)
Definition client.h:741
UA_StatusCode UA_Client_startListeningForReverseConnect(UA_Client *client, const UA_String *listenHostnames, size_t listenHostnamesLength, UA_UInt16 port)
Sets up a listening socket for incoming reverse connect requests by OPC UA servers.
void UA_THREADSAFE __UA_Client_Service(UA_Client *client, const void *request, const UA_DataType *requestType, void *response, const UA_DataType *responseType)
Don't use this function.
UA_StatusCode UA_THREADSAFE UA_Client_activateSessionAsync(UA_Client *client, const UA_NodeId authenticationToken, const UA_ByteString serverNonce)
Async version of UA_Client_activateSession.
UA_StatusCode UA_THREADSAFE UA_Client_findServersOnNetwork(UA_Client *client, const char *serverUrl, UA_UInt32 startingRecordId, UA_UInt32 maxRecordsToReturn, size_t serverCapabilityFilterSize, UA_String *serverCapabilityFilter, size_t *serverOnNetworkSize, UA_ServerOnNetwork **serverOnNetwork)
Get a list of all known server in the network.
UA_EXPORT void UA_ClientConfig_clear(UA_ClientConfig *config)
UA_StatusCode UA_THREADSAFE UA_Client_disconnectSecureChannel(UA_Client *client)
Disconnect the SecureChannel but keep the Session intact (if it exists).
UA_EXPORT const UA_DataType * UA_Client_findDataType(UA_Client *client, const UA_NodeId *typeId)
Lookup a datatype by its NodeId.
UA_EXPORT UA_StatusCode UA_Client_getConnectionAttribute(UA_Client *client, const UA_QualifiedName key, UA_Variant *outValue)
Returns a shallow copy of the attribute.
UA_Client * UA_Client_newWithConfig(const UA_ClientConfig *config)
Creates a new client.
UA_StatusCode UA_THREADSAFE UA_Client_getEndpoints(UA_Client *client, const char *serverUrl, size_t *endpointDescriptionsSize, UA_EndpointDescription **endpointDescriptions)
Gets a list of endpoints of a server.
UA_StatusCode UA_THREADSAFE UA_Client_renewSecureChannel(UA_Client *client)
Force the manual renewal of the SecureChannel.
UA_EXPORT UA_Client * UA_Client_new(void)
Create a new client with a default configuration that adds plugins for networking,...
void UA_Client_delete(UA_Client *client)
(Disconnect and) delete the client
UA_StatusCode UA_THREADSAFE UA_Client_activateCurrentSession(UA_Client *client)
Re-activate the current session.
UA_EXPORT UA_StatusCode UA_THREADSAFE UA_Client_getConnectionAttributeCopy(UA_Client *client, const UA_QualifiedName key, UA_Variant *outValue)
Return a deep copy of the attribute.
UA_StatusCode UA_THREADSAFE __UA_Client_connect(UA_Client *client, UA_Boolean async)
Connect with the client configuration.
UA_StatusCode UA_THREADSAFE UA_Client_run_iterate(UA_Client *client, UA_UInt32 timeout)
Listen on the network and process arriving asynchronous responses in the background.
UA_StatusCode UA_THREADSAFE UA_Client_disconnectAsync(UA_Client *client)
Disconnect async.
UA_EXPORT UA_THREADSAFE UA_StatusCode UA_Client_cancelByRequestHandle(UA_Client *client, UA_UInt32 requestHandle, UA_UInt32 *cancelCount)
Cancel all dispatched requests with the given requestHandle.
UA_EXPORT UA_StatusCode UA_ClientConfig_copy(UA_ClientConfig const *src, UA_ClientConfig *dst)
UA_StatusCode UA_THREADSAFE UA_Client_disconnect(UA_Client *client)
Disconnect and close a connection to the selected server.
UA_StatusCode UA_THREADSAFE UA_Client_addRepeatedCallback(UA_Client *client, UA_ClientCallback callback, void *data, UA_Double interval_ms, UA_UInt64 *callbackId)
Add a callback for cyclic repetition to the client.
UA_StatusCode UA_THREADSAFE UA_Client_modifyAsyncCallback(UA_Client *client, UA_UInt32 requestId, void *userdata, UA_ClientAsyncServiceCallback callback)
Set new userdata and callback for an existing request.
UA_StatusCode UA_THREADSAFE UA_Client_changeRepeatedCallbackInterval(UA_Client *client, UA_UInt64 callbackId, UA_Double interval_ms)
UA_EXPORT UA_THREADSAFE UA_StatusCode UA_Client_cancelByRequestId(UA_Client *client, UA_UInt32 requestId, UA_UInt32 *cancelCount)
Map the requestId to the requestHandle used for that request and call the Cancel service for that req...
struct UA_Client UA_Client
Definition common.h:206
UA_SessionState
Definition common.h:149
UA_SecureChannelState
Definition common.h:133
#define _UA_BEGIN_DECLS
#undef UA_DEBUG_DUMP_PKGS
Definition config.h:100
#define UA_THREADSAFE
Definition config.h:413
#define _UA_END_DECLS
Definition config.h:107
#define UA_STATUSCODE_BADOUTOFMEMORY
Not enough memory to complete the operation.
Definition statuscodes.h:23
#define UA_STATUSCODE_GOOD
The operation succeeded.
Definition statuscodes.h:8
AddNodesRequest.
AddNodesResponse.
AddReferencesRequest.
AddReferencesResponse.
ApplicationDescription.
BrowseNextRequest.
BrowseNextResponse.
BrowseResponse.
UA_EventLoop * eventLoop
Definition client.h:94
UA_String sessionName
Definition client.h:142
UA_UInt32 timeout
Definition client.h:46
size_t authSecurityPoliciesSize
Definition client.h:107
UA_Boolean externalEventLoop
Definition client.h:95
size_t securityPoliciesSize
Definition client.h:98
UA_EndpointDescription endpoint
Definition client.h:75
const UA_DataTypeArray * customDataTypes
Definition client.h:82
UA_UInt16 outStandingPublishRequests
Definition client.h:131
UA_Boolean noReconnect
Definition client.h:68
UA_Boolean noSession
Definition client.h:67
size_t sessionLocaleIdsSize
Definition client.h:144
UA_String applicationUri
Definition client.h:79
UA_Boolean noNewSession
Definition client.h:70
UA_UInt32 requestedSessionTimeout
Definition client.h:88
UA_CertificateVerification certificateVerification
Definition client.h:102
void(* stateCallback)(UA_Client *client, UA_SecureChannelState channelState, UA_SessionState sessionState, UA_StatusCode connectStatus)
Definition client.h:118
UA_SecurityPolicy * securityPolicies
Definition client.h:99
UA_StatusCode(* privateKeyPasswordCallback)(UA_ClientConfig *cc, UA_ByteString *password)
Definition client.h:152
UA_ApplicationDescription clientDescription
Definition client.h:51
UA_String authSecurityPolicyUri
Definition client.h:111
UA_ConnectionConfig localConnectionConfig
Definition client.h:89
UA_Logger * logging
Definition client.h:40
UA_String securityPolicyUri
Definition client.h:63
UA_ExtensionObject userIdentityToken
Definition client.h:58
UA_MessageSecurityMode securityMode
Definition client.h:59
UA_UserTokenPolicy userTokenPolicy
Definition client.h:76
void(* inactivityCallback)(UA_Client *client)
Definition client.h:128
UA_String endpointUrl
Definition client.h:55
UA_UInt32 connectivityCheckInterval
Definition client.h:90
void(* subscriptionInactivityCallback)(UA_Client *client, UA_UInt32 subscriptionId, void *subContext)
Definition client.h:137
void * clientContext
Definition client.h:39
UA_SecurityPolicy * authSecurityPolicies
Definition client.h:108
UA_LocaleId * sessionLocaleIds
Definition client.h:143
UA_UInt32 secureChannelLifeTime
Definition client.h:86
Datatype arrays with custom type definitions can be added in a linked list to the client or server co...
Definition types.h:878
DeleteNodesRequest.
DeleteNodesResponse.
DeleteReferencesRequest.
DeleteReferencesResponse.
EndpointDescription.
HistoryReadRequest.
HistoryReadResponse.
HistoryUpdateRequest.
HistoryUpdateResponse.
QueryFirstRequest.
QueryFirstResponse.
QueryNextRequest.
QueryNextResponse.
RegisterNodesRequest.
RegisterNodesResponse.
ServerOnNetwork.
TranslateBrowsePathsToNodeIdsRequest.
TranslateBrowsePathsToNodeIdsResponse.
UnregisterNodesRequest.
UnregisterNodesResponse.
UserNameIdentityToken.
UserTokenPolicy.
void UA_ExtensionObject_setValue(UA_ExtensionObject *eo, void *p, const UA_DataType *type)
Initialize the ExtensionObject and set the "decoded" value to the given pointer.
_UA_BEGIN_DECLS typedef bool UA_Boolean
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition types.h:27
uint16_t UA_UInt16
Definition types.h:47
uint32_t UA_UInt32
Definition types.h:57
void * dst
Definition types.h:948
uint32_t UA_StatusCode
Definition types.h:82
double UA_Double
Definition types.h:77
#define UA_STRING_ALLOC(CHARS)
uint64_t UA_UInt64
Definition types.h:67
const UA_DataType * type
Definition types.h:626
#define UA_TYPES_WRITERESPONSE
#define UA_TYPES_HISTORYUPDATEREQUEST
#define UA_TYPES_UNREGISTERNODESRESPONSE
#define UA_TYPES_CALLREQUEST
#define UA_TYPES_HISTORYUPDATERESPONSE
#define UA_TYPES_BROWSENEXTREQUEST
#define UA_TYPES_ADDNODESREQUEST
#define UA_TYPES_TRANSLATEBROWSEPATHSTONODEIDSRESPONSE
#define UA_TYPES_ADDREFERENCESREQUEST
#define UA_TYPES_HISTORYREADREQUEST
#define UA_TYPES_BROWSENEXTRESPONSE
UA_MessageSecurityMode
MessageSecurityMode.
#define UA_TYPES_DELETEREFERENCESREQUEST
#define UA_TYPES_BROWSEREQUEST
#define UA_TYPES_REGISTERNODESREQUEST
#define UA_TYPES_CALLRESPONSE
#define UA_TYPES_ADDNODESRESPONSE
#define UA_TYPES_ADDREFERENCESRESPONSE
#define UA_TYPES_DELETEREFERENCESRESPONSE
#define UA_TYPES_DELETENODESRESPONSE
#define UA_TYPES_QUERYFIRSTRESPONSE
#define UA_TYPES_READREQUEST
#define UA_TYPES_WRITEREQUEST
#define UA_TYPES_HISTORYREADRESPONSE
#define UA_TYPES_TRANSLATEBROWSEPATHSTONODEIDSREQUEST
#define UA_TYPES_USERNAMEIDENTITYTOKEN
#define UA_TYPES_DELETENODESREQUEST
#define UA_TYPES_BROWSERESPONSE
#define UA_TYPES_READRESPONSE
#define UA_TYPES_QUERYFIRSTREQUEST
#define UA_TYPES_UNREGISTERNODESREQUEST
#define UA_TYPES_REGISTERNODESRESPONSE
UA_DataType UA_TYPES[388]