open62541 1.4.15
Open source implementation of OPC UA
Loading...
Searching...
No Matches
ua_pubsub.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 (c) 2017-2019 Fraunhofer IOSB (Author: Andreas Ebner)
6 * Copyright (c) 2019 Kalycito Infotech Private Limited
7 * Copyright (c) 2020 Yannick Wallerer, Siemens AG
8 * Copyright (c) 2020, 2022 Thomas Fischer, Siemens AG
9 * Copyright (c) 2021 Fraunhofer IOSB (Author: Jan Hermes)
10 * Copyright (c) 2022 Siemens AG (Author: Thomas Fischer)
11 * Copyright (c) 2022 Fraunhofer IOSB (Author: Noel Graf)
12 * Copyright (c) 2022 Linutronix GmbH (Author: Muddasir Shakil)
13 */
14
15#ifndef UA_PUBSUB_H_
16#define UA_PUBSUB_H_
17
18#define UA_INTERNAL
19#include <open62541/server.h>
21
22#include "open62541_queue.h"
23#include "ziptree.h"
25
26#ifdef UA_ENABLE_PUBSUB_SKS
28#endif
29
31
32#ifdef UA_ENABLE_PUBSUB
33
34/** Max number of underlying for sending and receiving */
35#define UA_PUBSUB_MAXCHANNELS 8
36
37struct UA_WriterGroup;
39
40struct UA_ReaderGroup;
42
43struct UA_SecurityGroup;
45
46
47/** PublishedDataSet */
48
49
60
64
67
70
73 const UA_PublishedDataSetConfig *publishedDataSetConfig,
74 UA_NodeId *pdsIdentifier);
75
76void
78 UA_PublishedDataSet *publishedDataSet);
79
82
86
93
101void
103 UA_StandaloneSubscribedDataSet *subscribedDataSet);
104
105#define UA_LOG_PDS_INTERNAL(LOGGER, LEVEL, PDS, MSG, ...) \
106 if(UA_LOGLEVEL <= UA_LOGLEVEL_##LEVEL) { \
107 UA_String idStr = UA_STRING_NULL; \
108 if(PDS) \
109 UA_NodeId_print(&(PDS)->identifier, &idStr); \
110 UA_LOG_##LEVEL(LOGGER, UA_LOGCATEGORY_PUBSUB, \
111 "DataSet %.*s\t| " MSG "%.0s", (int)idStr.length, \
112 (char*)idStr.data, __VA_ARGS__); \
113 UA_String_clear(&idStr); \
114 }
115
116#define UA_LOG_TRACE_DATASET(LOGGER, PDS, ...) \
117 UA_MACRO_EXPAND(UA_LOG_PDS_INTERNAL(LOGGER, TRACE, PDS, __VA_ARGS__, ""))
118#define UA_LOG_DEBUG_DATASET(LOGGER, PDS, ...) \
119 UA_MACRO_EXPAND(UA_LOG_PDS_INTERNAL(LOGGER, DEBUG, PDS, __VA_ARGS__, ""))
120#define UA_LOG_INFO_DATASET(LOGGER, PDS, ...) \
121 UA_MACRO_EXPAND(UA_LOG_PDS_INTERNAL(LOGGER, INFO, PDS, __VA_ARGS__, ""))
122#define UA_LOG_WARNING_DATASET(LOGGER, PDS, ...) \
123 UA_MACRO_EXPAND(UA_LOG_PDS_INTERNAL(LOGGER, WARNING, PDS, __VA_ARGS__, ""))
124#define UA_LOG_ERROR_DATASET(LOGGER, PDS, ...) \
125 UA_MACRO_EXPAND(UA_LOG_PDS_INTERNAL(LOGGER, ERROR, PDS, __VA_ARGS__, ""))
126#define UA_LOG_FATAL_DATASET(LOGGER, PDS, ...) \
127 UA_MACRO_EXPAND(UA_LOG_PDS_INTERNAL(LOGGER, FATAL, PDS, __VA_ARGS__, ""))
128
129
130/** Connection */
131
132
133typedef struct UA_PubSubConnection {
135
138
139 /* The send/recv connections are only opened if the state is operational */
142 UA_Boolean json; /* Extracted from the TransportProfileUrl */
143
144 /* Channels belonging to the PubSubConnection. Send channels belong to
145 * WriterGroups, recv channels belong to ReaderGroups. We only open channels
146 * if there is at least one WriterGroup/ReaderGroup respectively.
147 *
148 * Some channels belong exclusively to just one WriterGroup/ReaderGroup that
149 * defines additional connection properties. For example an MQTT topic name
150 * or QoS parameters. In that case a dedicated NetworkCallback is used that
151 * takes this ReaderGroup/WriterGroup directly as context. */
155 uintptr_t sendChannel;
156
158 LIST_HEAD(, UA_WriterGroup) writerGroups;
159
161 LIST_HEAD(, UA_ReaderGroup) readerGroups;
162
164
165 UA_DateTime silenceErrorUntil; /* Avoid generating too many logs */
166
167 UA_Boolean deleteFlag; /* To be deleted - in addition to the PubSubState */
168 UA_DelayedCallback dc; /* For delayed freeing */
170
174
177 UA_NodeId connectionIdentifier);
178
181 const UA_PubSubConnectionConfig *connectionConfig,
182 UA_NodeId *connectionIdentifier);
183
184void
186
187void
189
192 UA_Boolean validate);
193
194void
196
197/** Returns either the eventloop configured in the connection or, in its absence,
198 * for the server */
201
204 UA_PubSubConnection *connection,
205 UA_PubSubState state,
206 UA_StatusCode cause);
207
208#define UA_LOG_CONNECTION_INTERNAL(LOGGER, LEVEL, CONNECTION, MSG, ...) \
209 if(UA_LOGLEVEL <= UA_LOGLEVEL_##LEVEL) { \
210 UA_String idStr = UA_STRING_NULL; \
211 if(CONNECTION) \
212 UA_NodeId_print(&(CONNECTION)->identifier, &idStr); \
213 UA_LOG_##LEVEL(LOGGER, UA_LOGCATEGORY_PUBSUB, \
214 "Connection %.*s\t| " MSG "%.0s", (int)idStr.length, \
215 (char*)idStr.data, __VA_ARGS__); \
216 UA_String_clear(&idStr); \
217 }
218
219#define UA_LOG_TRACE_CONNECTION(LOGGER, CONNECTION, ...) \
220 UA_MACRO_EXPAND(UA_LOG_CONNECTION_INTERNAL(LOGGER, TRACE, CONNECTION, __VA_ARGS__, ""))
221#define UA_LOG_DEBUG_CONNECTION(LOGGER, CONNECTION, ...) \
222 UA_MACRO_EXPAND(UA_LOG_CONNECTION_INTERNAL(LOGGER, DEBUG, CONNECTION, __VA_ARGS__, ""))
223#define UA_LOG_INFO_CONNECTION(LOGGER, CONNECTION, ...) \
224 UA_MACRO_EXPAND(UA_LOG_CONNECTION_INTERNAL(LOGGER, INFO, CONNECTION, __VA_ARGS__, ""))
225#define UA_LOG_WARNING_CONNECTION(LOGGER, CONNECTION, ...) \
226 UA_MACRO_EXPAND(UA_LOG_CONNECTION_INTERNAL(LOGGER, WARNING, CONNECTION, __VA_ARGS__, ""))
227#define UA_LOG_ERROR_CONNECTION(LOGGER, CONNECTION, ...) \
228 UA_MACRO_EXPAND(UA_LOG_CONNECTION_INTERNAL(LOGGER, ERROR, CONNECTION, __VA_ARGS__, ""))
229#define UA_LOG_FATAL_CONNECTION(LOGGER, CONNECTION, ...) \
230 UA_MACRO_EXPAND(UA_LOG_CONNECTION_INTERNAL(LOGGER, FATAL, CONNECTION, __VA_ARGS__, ""))
231
232
233/** DataSetWriter */
234
235
240
259
263
266
269 UA_DataSetWriter *dataSetWriter,
270 UA_PubSubState state,
271 UA_StatusCode cause);
272
275 UA_DataSetMessage *dataSetMessage,
276 UA_DataSetWriter *dataSetWriter);
277
280 UA_DataSetMessage *dsm);
281
282void
284
285void
287
290 const UA_NodeId writerGroup, const UA_NodeId dataSet,
291 const UA_DataSetWriterConfig *dataSetWriterConfig,
292 UA_NodeId *writerIdentifier);
293
294
297
298#define UA_LOG_WRITER_INTERNAL(LOGGER, LEVEL, WRITER, MSG, ...) \
299 if(UA_LOGLEVEL <= UA_LOGLEVEL_##LEVEL) { \
300 UA_String idStr = UA_STRING_NULL; \
301 UA_String groupIdStr = UA_STRING_NULL; \
302 if(WRITER) { \
303 UA_NodeId_print(&(WRITER)->identifier, &idStr); \
304 UA_NodeId_print(&(WRITER)->linkedWriterGroup, &groupIdStr); \
305 } \
306 UA_LOG_##LEVEL(LOGGER, UA_LOGCATEGORY_PUBSUB, \
307 "WriterGroup %.*s\t| Writer %.*s\t| " MSG "%.0s", \
308 (int)groupIdStr.length, (char*)groupIdStr.data, \
309 (int)idStr.length, (char*)idStr.data, \
310 __VA_ARGS__); \
311 UA_String_clear(&idStr); \
312 UA_String_clear(&groupIdStr); \
313 }
314
315#define UA_LOG_TRACE_WRITER(LOGGER, WRITER, ...) \
316 UA_MACRO_EXPAND(UA_LOG_WRITER_INTERNAL(LOGGER, TRACE, WRITER, __VA_ARGS__, ""))
317#define UA_LOG_DEBUG_WRITER(LOGGER, WRITER, ...) \
318 UA_MACRO_EXPAND(UA_LOG_WRITER_INTERNAL(LOGGER, DEBUG, WRITER, __VA_ARGS__, ""))
319#define UA_LOG_INFO_WRITER(LOGGER, WRITER, ...) \
320 UA_MACRO_EXPAND(UA_LOG_WRITER_INTERNAL(LOGGER, INFO, WRITER, __VA_ARGS__, ""))
321#define UA_LOG_WARNING_WRITER(LOGGER, WRITER, ...) \
322 UA_MACRO_EXPAND(UA_LOG_WRITER_INTERNAL(LOGGER, WARNING, WRITER, __VA_ARGS__, ""))
323#define UA_LOG_ERROR_WRITER(LOGGER, WRITER, ...) \
324 UA_MACRO_EXPAND(UA_LOG_WRITER_INTERNAL(LOGGER, ERROR, WRITER, __VA_ARGS__, ""))
325#define UA_LOG_FATAL_WRITER(LOGGER, WRITER, ...) \
326 UA_MACRO_EXPAND(UA_LOG_WRITER_INTERNAL(LOGGER, FATAL, WRITER, __VA_ARGS__, ""))
327
328
329/** WriterGroup */
330
331
337
340
341 UA_UInt64 publishCallbackId; /* registered if != 0 */
344 UA_UInt16 sequenceNumber; /* Increased after every succressuly sent message */
347
348 /* The ConnectionManager pointer is stored in the Connection. The channels
349 * are either stored here or in the Connection, but never both. */
351 uintptr_t sendChannel;
353
354#ifdef UA_ENABLE_PUBSUB_ENCRYPTION
355 UA_UInt32 securityTokenId;
356 UA_UInt32 nonceSequenceNumber; /* To be part of the MessageNonce */
357 void *securityPolicyContext;
358#ifdef UA_ENABLE_PUBSUB_SKS
359 UA_PubSubKeyStorage *keyStorage; /* non-owning pointer to keyStorage*/
360#endif
361#endif
362};
363
365UA_WriterGroup_create(UA_Server *server, const UA_NodeId connection,
366 const UA_WriterGroupConfig *writerGroupConfig,
367 UA_NodeId *writerGroupIdentifier);
368
371
372void
374
377 UA_Boolean validate);
378
381 UA_UInt32 securityTokenId,
382 const UA_ByteString signingKey,
383 const UA_ByteString encryptingKey,
384 const UA_ByteString keyNonce);
385
389
392
395
398
401 UA_WriterGroup *writerGroup,
402 UA_PubSubState state,
403 UA_StatusCode cause);
404
407
408void
410 UA_WriterGroup *writerGroup);
411
414 const UA_WriterGroupConfig *config);
415
416#define UA_LOG_WRITERGROUP_INTERNAL(LOGGER, LEVEL, WRITERGROUP, MSG, ...) \
417 if(UA_LOGLEVEL <= UA_LOGLEVEL_##LEVEL) { \
418 UA_String idStr = UA_STRING_NULL; \
419 if(WRITERGROUP) \
420 UA_NodeId_print(&(WRITERGROUP)->identifier, &idStr); \
421 UA_LOG_##LEVEL(LOGGER, UA_LOGCATEGORY_PUBSUB, \
422 "WriterGroup %.*s\t| " MSG "%.0s", \
423 (int)idStr.length, (char*)idStr.data, \
424 __VA_ARGS__); \
425 UA_String_clear(&idStr); \
426 }
427
428#define UA_LOG_TRACE_WRITERGROUP(LOGGER, WRITERGROUP, ...) \
429 UA_MACRO_EXPAND(UA_LOG_WRITERGROUP_INTERNAL(LOGGER, TRACE, WRITERGROUP, __VA_ARGS__, ""))
430#define UA_LOG_DEBUG_WRITERGROUP(LOGGER, WRITERGROUP, ...) \
431 UA_MACRO_EXPAND(UA_LOG_WRITERGROUP_INTERNAL(LOGGER, DEBUG, WRITERGROUP, __VA_ARGS__, ""))
432#define UA_LOG_INFO_WRITERGROUP(LOGGER, WRITERGROUP, ...) \
433 UA_MACRO_EXPAND(UA_LOG_WRITERGROUP_INTERNAL(LOGGER, INFO, WRITERGROUP, __VA_ARGS__, ""))
434#define UA_LOG_WARNING_WRITERGROUP(LOGGER, WRITERGROUP, ...) \
435 UA_MACRO_EXPAND(UA_LOG_WRITERGROUP_INTERNAL(LOGGER, WARNING, WRITERGROUP, __VA_ARGS__, ""))
436#define UA_LOG_ERROR_WRITERGROUP(LOGGER, WRITERGROUP, ...) \
437 UA_MACRO_EXPAND(UA_LOG_WRITERGROUP_INTERNAL(LOGGER, ERROR, WRITERGROUP, __VA_ARGS__, ""))
438#define UA_LOG_FATAL_WRITERGROUP(LOGGER, WRITERGROUP, ...) \
439 UA_MACRO_EXPAND(UA_LOG_WRITERGROUP_INTERNAL(LOGGER, FATAL, WRITERGROUP, __VA_ARGS__, ""))
440
441
442/** DataSetField */
443
444
455
459
462
465
467UA_DataSetField_create(UA_Server *server, const UA_NodeId publishedDataSet,
468 const UA_DataSetFieldConfig *fieldConfig,
469 UA_NodeId *fieldIdentifier);
470
471void
473 UA_DataValue *value);
474
475
476/** DataSetReader */
477
478
479/** DataSetReader Type definition */
480typedef struct UA_DataSetReader {
486
487 UA_PubSubState state; /* non std */
490
491#ifdef UA_ENABLE_PUBSUB_MONITORING
492 /* MessageReceiveTimeout handling */
493 UA_ServerCallback msgRcvTimeoutTimerCallback;
494 UA_UInt64 msgRcvTimeoutTimerId;
495 UA_Boolean msgRcvTimeoutTimerRunning;
496#endif
499
500/** Process Network Message using DataSetReader */
501void
503 UA_ReaderGroup *readerGroup,
504 UA_DataSetReader *dataSetReader,
505 UA_DataSetMessage *dataSetMsg);
506
509 UA_DataSetReader *reader,
510 UA_ReaderGroupConfig readerGroupConfig);
511
513UA_DataSetReader_create(UA_Server *server, UA_NodeId readerGroupIdentifier,
514 const UA_DataSetReaderConfig *dataSetReaderConfig,
515 UA_NodeId *readerIdentifier);
516
519
520/** Copy the configuration of Target Variables */
523
524/** Clear the Target Variables configuration */
525void UA_TargetVariables_clear(UA_TargetVariables *subscribedDataSetTarget);
526
527/** Copy the configuration of Field Target Variables */
530
533 size_t targetVariablesSize,
534 const UA_FieldTargetVariable *targetVariables);
535
538 UA_DataSetReader *dataSetReader,
539 UA_PubSubState state,
540 UA_StatusCode cause);
541
542#define UA_LOG_READER_INTERNAL(LOGGER, LEVEL, READER, MSG, ...) \
543 if(UA_LOGLEVEL <= UA_LOGLEVEL_##LEVEL) { \
544 UA_String idStr = UA_STRING_NULL; \
545 UA_String groupIdStr = UA_STRING_NULL; \
546 if(READER) { \
547 UA_NodeId_print(&(READER)->identifier, &idStr); \
548 UA_NodeId_print(&(READER)->linkedReaderGroup, &groupIdStr); \
549 } \
550 UA_LOG_##LEVEL(LOGGER, UA_LOGCATEGORY_PUBSUB, \
551 "ReaderGroup %.*s\t| Reader %.*s\t| " MSG "%.0s", \
552 (int)groupIdStr.length, (char*)groupIdStr.data, \
553 (int)idStr.length, (char*)idStr.data, \
554 __VA_ARGS__); \
555 UA_String_clear(&idStr); \
556 UA_String_clear(&groupIdStr); \
557 }
558
559#define UA_LOG_TRACE_READER(LOGGER, READER, ...) \
560 UA_MACRO_EXPAND(UA_LOG_READER_INTERNAL(LOGGER, TRACE, READER, __VA_ARGS__, ""))
561#define UA_LOG_DEBUG_READER(LOGGER, READER, ...) \
562 UA_MACRO_EXPAND(UA_LOG_READER_INTERNAL(LOGGER, DEBUG, READER, __VA_ARGS__, ""))
563#define UA_LOG_INFO_READER(LOGGER, READER, ...) \
564 UA_MACRO_EXPAND(UA_LOG_READER_INTERNAL(LOGGER, INFO, READER, __VA_ARGS__, ""))
565#define UA_LOG_WARNING_READER(LOGGER, READER, ...) \
566 UA_MACRO_EXPAND(UA_LOG_READER_INTERNAL(LOGGER, WARNING, READER, __VA_ARGS__, ""))
567#define UA_LOG_ERROR_READER(LOGGER, READER, ...) \
568 UA_MACRO_EXPAND(UA_LOG_READER_INTERNAL(LOGGER, ERROR, READER, __VA_ARGS__, ""))
569#define UA_LOG_FATAL_READER(LOGGER, READER, ...) \
570 UA_MACRO_EXPAND(UA_LOG_READER_INTERNAL(LOGGER, FATAL, READER, __VA_ARGS__, ""))
571
572
573/** ReaderGroup */
574
575
581
584
587
588 /* The ConnectionManager pointer is stored in the Connection. The channels
589 * are either stored here or in the Connection, but never both. */
594
595#ifdef UA_ENABLE_PUBSUB_ENCRYPTION
596 UA_UInt32 securityTokenId;
597 UA_UInt32 nonceSequenceNumber; /* To be part of the MessageNonce */
598 void *securityPolicyContext;
599#ifdef UA_ENABLE_PUBSUB_SKS
600 UA_PubSubKeyStorage *keyStorage;
601#endif
602#endif
603};
604
607 const UA_ReaderGroupConfig *rgc,
608 UA_NodeId *readerGroupId);
609
612
615
616void
618
621 UA_UInt32 securityTokenId,
622 const UA_ByteString signingKey,
623 const UA_ByteString encryptingKey,
624 const UA_ByteString keyNonce);
625
629
630/** Prototypes for internal util functions - some functions maybe removed later
631 * (currently moved from public to internal) */
634
637
640
643
646 UA_ReaderGroup *readerGroup,
647 UA_PubSubState state,
648 UA_StatusCode cause);
649
652 UA_ByteString *buf);
653
657
658#define UA_LOG_READERGROUP_INTERNAL(LOGGER, LEVEL, RG, MSG, ...) \
659 if(UA_LOGLEVEL <= UA_LOGLEVEL_##LEVEL) { \
660 UA_String idStr = UA_STRING_NULL; \
661 if(RG) \
662 UA_NodeId_print(&(RG)->identifier, &idStr); \
663 UA_LOG_##LEVEL(LOGGER, UA_LOGCATEGORY_PUBSUB, \
664 "ReaderGroup %.*s\t| " MSG "%.0s", (int)idStr.length, \
665 (char*)idStr.data, __VA_ARGS__); \
666 UA_String_clear(&idStr); \
667 }
668
669#define UA_LOG_TRACE_READERGROUP(LOGGER, READERGROUP, ...) \
670 UA_MACRO_EXPAND(UA_LOG_READERGROUP_INTERNAL(LOGGER, TRACE, READERGROUP, __VA_ARGS__, ""))
671#define UA_LOG_DEBUG_READERGROUP(LOGGER, READERGROUP, ...) \
672 UA_MACRO_EXPAND(UA_LOG_READERGROUP_INTERNAL(LOGGER, DEBUG, READERGROUP, __VA_ARGS__, ""))
673#define UA_LOG_INFO_READERGROUP(LOGGER, READERGROUP, ...) \
674 UA_MACRO_EXPAND(UA_LOG_READERGROUP_INTERNAL(LOGGER, INFO, READERGROUP, __VA_ARGS__, ""))
675#define UA_LOG_WARNING_READERGROUP(LOGGER, READERGROUP, ...) \
676 UA_MACRO_EXPAND(UA_LOG_READERGROUP_INTERNAL(LOGGER, WARNING, READERGROUP, __VA_ARGS__, ""))
677#define UA_LOG_ERROR_READERGROUP(LOGGER, READERGROUP, ...) \
678 UA_MACRO_EXPAND(UA_LOG_READERGROUP_INTERNAL(LOGGER, ERROR, READERGROUP, __VA_ARGS__, ""))
679#define UA_LOG_FATAL_READERGROUP(LOGGER, READERGROUP, ...) \
680 UA_MACRO_EXPAND(UA_LOG_READERGROUP_INTERNAL(LOGGER, FATAL, READERGROUP, __VA_ARGS__, ""))
681
682
683/** Reading Message handling */
684
685
686#ifdef UA_ENABLE_PUBSUB_ENCRYPTION
688verifyAndDecrypt(const UA_Logger *logger, UA_ByteString *buffer,
689 const size_t *currentPosition, const UA_NetworkMessage *nm,
690 UA_Boolean doValidate, UA_Boolean doDecrypt,
691 void *channelContext, UA_PubSubSecurityPolicy *securityPolicy);
692
694verifyAndDecryptNetworkMessage(const UA_Logger *logger, UA_ByteString *buffer,
695 size_t *currentPosition, UA_NetworkMessage *nm,
696 UA_ReaderGroup *readerGroup);
697#endif
698
699/** Takes a value (and not a pointer) to the buffer. The original buffer is
700 const. Internally we may adjust the length during decryption. */
702decodeNetworkMessage(UA_Server *server, UA_ByteString *buffer, size_t *pos,
703 UA_NetworkMessage *nm, UA_PubSubConnection *connection);
704
705#ifdef UA_ENABLE_PUBSUB_SKS
706
707/** SecurityGroup */
708
709struct UA_SecurityGroup {
710 UA_String securityGroupId;
711 UA_SecurityGroupConfig config;
712 UA_PubSubKeyStorage *keyStorage;
713 UA_NodeId securityGroupNodeId;
714 UA_UInt64 callbackId;
715 UA_DateTime baseTime;
716#ifdef UA_ENABLE_PUBSUB_INFORMATIONMODEL
717 UA_NodeId securityGroupFolderId;
718#endif
719 TAILQ_ENTRY(UA_SecurityGroup) listEntry;
720};
721
723UA_SecurityGroupConfig_copy(const UA_SecurityGroupConfig *src,
724 UA_SecurityGroupConfig *dst);
725
726/** finds the SecurityGroup within the server by SecurityGroup Name/Id*/
728UA_SecurityGroup_findSGbyName(UA_Server *server, UA_String securityGroupName);
729
730/** finds the SecurityGroup within the server by NodeId*/
732UA_SecurityGroup_findSGbyId(UA_Server *server, UA_NodeId identifier);
733
734void
735UA_SecurityGroup_delete(UA_SecurityGroup *securityGroup);
736
737void
738removeSecurityGroup(UA_Server *server, UA_SecurityGroup *securityGroup);
739
740#endif /* UA_ENABLE_PUBSUB_SKS */
741
742
743/** PubSub Manager */
744
745
751
756
764
765typedef ZIP_HEAD(UA_ReserveIdTree, UA_ReserveId) UA_ReserveIdTree;
766
767typedef struct UA_PubSubManager {
769 /* Connections and PublishedDataSets can exist alone (own lifecycle) -> top
770 * level components */
773
775 TAILQ_HEAD(, UA_PublishedDataSet) publishedDataSets;
776
779
782
784 UA_ReserveIdTree reserveIds;
785
786#ifdef UA_ENABLE_PUBSUB_SKS
787 LIST_HEAD(, UA_PubSubKeyStorage) pubSubKeyList;
788
789 size_t securityGroupsSize;
790 TAILQ_HEAD(, UA_SecurityGroup) securityGroups;
791#endif
792
793#ifndef UA_ENABLE_PUBSUB_INFORMATIONMODEL
795#endif
797
800 UA_String topic);
801
803UA_PubSubManager_reserveIds(UA_Server *server, UA_NodeId sessionId, UA_UInt16 numRegWriterGroupIds,
804 UA_UInt16 numRegDataSetWriterIds, UA_String transportProfileUri,
805 UA_UInt16 **writerGroupIds, UA_UInt16 **dataSetWriterIds);
806
807void
809
810void
812
813void
815
816void
818
819#ifndef UA_ENABLE_PUBSUB_INFORMATIONMODEL
820void
822#endif
823
824#ifdef UA_ENABLE_PUBSUB_FILE_CONFIG
825/** Decodes the information from the ByteString. If the decoded content is a
826 * PubSubConfiguration in a UABinaryFileDataType-object. It will overwrite the
827 * current PubSub configuration from the server. */
829UA_PubSubManager_loadPubSubConfigFromByteString(UA_Server *server,
830 const UA_ByteString buffer);
831
832/** Saves the current PubSub configuration of a server in a byteString. */
834UA_PubSubManager_getEncodedPubSubConfiguration(UA_Server *server,
835 UA_ByteString *buffer);
836#endif
837
840
843
844
845/** PubSub component monitoring */
846
847
848#ifdef UA_ENABLE_PUBSUB_MONITORING
849
851UA_PubSubManager_setDefaultMonitoringCallbacks(UA_PubSubMonitoringInterface *monitoringInterface);
852
853#endif /* UA_ENABLE_PUBSUB_MONITORING */
854
855#endif /* UA_ENABLE_PUBSUB */
856
858
859#endif /* UA_PUBSUB_H_ */
void(* UA_ServerCallback)(UA_Server *server, void *data)
Definition common.h:203
struct UA_Server UA_Server
Definition common.h:198
#define _UA_BEGIN_DECLS
#undef UA_DEBUG_DUMP_PKGS
Definition config.h:100
#define _UA_END_DECLS
Definition config.h:107
static UA_LogCategory const char * msg
Definition log.h:58
#define TAILQ_HEAD(name, type)
#define LIST_HEAD(name, type)
#define TAILQ_ENTRY(type)
UA_PubSubComponentEnumType
This Source Code Form is subject to the terms of the Mozilla Public License, v.
ConfigurationVersionDataType.
DataSetField
Definition ua_pubsub.h:445
UA_Boolean configurationFrozen
Definition ua_pubsub.h:453
UA_NodeId publishedDataSet
Definition ua_pubsub.h:449
UA_NodeId identifier
Definition ua_pubsub.h:448
UA_Boolean sampleCallbackIsRegistered
Definition ua_pubsub.h:452
TAILQ_ENTRY(UA_DataSetField) listEntry
UA_DataSetFieldConfig config
Definition ua_pubsub.h:446
UA_UInt64 sampleCallbackId
Definition ua_pubsub.h:451
UA_FieldMetaData fieldMetaData
Definition ua_pubsub.h:450
DataSetMetaDataType.
Parameters for PubSub DataSetReader Configuration.
DataSetReader
Definition ua_pubsub.h:480
UA_NodeId linkedReaderGroup
Definition ua_pubsub.h:484
LIST_ENTRY(UA_DataSetReader) listEntry
UA_DateTime lastHeartbeatReceived
Definition ua_pubsub.h:497
UA_PubSubState state
Definition ua_pubsub.h:487
UA_DataSetReaderConfig config
Definition ua_pubsub.h:482
UA_Boolean configurationFrozen
Definition ua_pubsub.h:488
UA_NetworkMessageOffsetBuffer bufferedMessage
Definition ua_pubsub.h:489
UA_NodeId identifier
Definition ua_pubsub.h:483
UA_PubSubComponentEnumType componentType
Definition ua_pubsub.h:481
UA_Boolean valueChanged
Definition ua_pubsub.h:237
UA_UInt16 deltaFrameCounter
Definition ua_pubsub.h:252
UA_PubSubState state
Definition ua_pubsub.h:249
UA_Boolean configurationFrozen
Definition ua_pubsub.h:257
UA_NodeId connectedDataSet
Definition ua_pubsub.h:247
UA_DataSetWriterSample * lastSamples
Definition ua_pubsub.h:254
UA_ConfigurationVersionDataType connectedDataSetVersion
Definition ua_pubsub.h:248
LIST_ENTRY(UA_DataSetWriter) listEntry
UA_UInt16 actualDataSetMessageSequenceCount
Definition ua_pubsub.h:256
UA_NodeId linkedWriterGroup
Definition ua_pubsub.h:246
size_t lastSamplesCount
Definition ua_pubsub.h:253
UA_DataSetWriterConfig config
Definition ua_pubsub.h:243
UA_PubSubComponentEnumType componentType
Definition ua_pubsub.h:242
UA_NodeId identifier
Definition ua_pubsub.h:245
Delayed callbacks are executed not when they are registered, but in the following EventLoop cycle.
Definition eventloop.h:44
UA_NodeId identifier
Definition ua_pubsub.h:137
uintptr_t sendChannel
Definition ua_pubsub.h:155
UA_PubSubConnectionConfig config
Definition ua_pubsub.h:141
UA_ConnectionManager * cm
Definition ua_pubsub.h:152
LIST_HEAD(, UA_ReaderGroup) readerGroups
UA_UInt16 configurationFreezeCounter
Definition ua_pubsub.h:163
LIST_HEAD(, UA_WriterGroup) writerGroups
UA_Boolean deleteFlag
Definition ua_pubsub.h:167
UA_PubSubState state
Definition ua_pubsub.h:140
UA_DateTime silenceErrorUntil
Definition ua_pubsub.h:165
uintptr_t recvChannels[8]
Definition ua_pubsub.h:153
TAILQ_ENTRY(UA_PubSubConnection) listEntry
UA_DelayedCallback dc
Definition ua_pubsub.h:168
UA_PubSubComponentEnumType componentType
Definition ua_pubsub.h:134
UA_ReserveIdTree reserveIds
Definition ua_pubsub.h:784
size_t subscribedDataSetsSize
Definition ua_pubsub.h:777
UA_UInt32 uniqueIdCount
Definition ua_pubsub.h:794
UA_UInt64 defaultPublisherId
Definition ua_pubsub.h:768
TAILQ_HEAD(, UA_PublishedDataSet) publishedDataSets
size_t connectionsSize
Definition ua_pubsub.h:771
TAILQ_HEAD(, UA_PubSubConnection) connections
size_t publishedDataSetsSize
Definition ua_pubsub.h:774
TAILQ_HEAD(, UA_TopicAssign) topicAssign
size_t topicAssignSize
Definition ua_pubsub.h:780
TAILQ_HEAD(, UA_StandaloneSubscribedDataSet) subscribedDataSets
size_t reserveIdsSize
Definition ua_pubsub.h:783
Configuration structure for PublishedDataSet.
PublishedDataSet
Definition ua_pubsub.h:50
UA_UInt16 configurationFreezeCounter
Definition ua_pubsub.h:57
UA_UInt16 fieldSize
Definition ua_pubsub.h:54
UA_DataSetMetaDataType dataSetMetaData
Definition ua_pubsub.h:52
UA_NodeId identifier
Definition ua_pubsub.h:55
TAILQ_ENTRY(UA_PublishedDataSet) listEntry
UA_PublishedDataSetConfig config
Definition ua_pubsub.h:51
UA_UInt16 promotedFieldsCount
Definition ua_pubsub.h:56
TAILQ_HEAD(, UA_DataSetField) fields
ReaderGroup configuration.
ReaderGroup
Definition ua_pubsub.h:576
UA_Boolean configurationFrozen
Definition ua_pubsub.h:586
UA_NodeId identifier
Definition ua_pubsub.h:579
UA_PubSubComponentEnumType componentType
Definition ua_pubsub.h:577
UA_UInt32 readersCount
Definition ua_pubsub.h:583
size_t recvChannelsSize
Definition ua_pubsub.h:592
UA_ReaderGroupConfig config
Definition ua_pubsub.h:578
UA_Boolean deleteFlag
Definition ua_pubsub.h:593
UA_PubSubConnection * linkedConnection
Definition ua_pubsub.h:590
UA_PubSubState state
Definition ua_pubsub.h:585
uintptr_t recvChannels[8]
Definition ua_pubsub.h:591
LIST_HEAD(, UA_DataSetReader) readers
LIST_ENTRY(UA_ReaderGroup) listEntry
UA_ReserveIdType reserveIdType
Definition ua_pubsub.h:759
UA_NodeId sessionId
Definition ua_pubsub.h:761
UA_String transportProfileUri
Definition ua_pubsub.h:760
UA_UInt16 id
Definition ua_pubsub.h:758
ZIP_ENTRY(UA_ReserveId) treeEntry
TAILQ_ENTRY(UA_StandaloneSubscribedDataSet) listEntry
UA_StandaloneSubscribedDataSetConfig config
Definition ua_pubsub.h:88
PubSub Manager.
Definition ua_pubsub.h:746
TAILQ_ENTRY(UA_TopicAssign) listEntry
UA_ReaderGroup * rgIdentifier
Definition ua_pubsub.h:747
UA_String topic
Definition ua_pubsub.h:748
WriterGroup
Definition ua_pubsub.h:332
UA_WriterGroupConfig config
Definition ua_pubsub.h:334
UA_PubSubState state
Definition ua_pubsub.h:342
UA_NodeId identifier
Definition ua_pubsub.h:336
UA_NetworkMessageOffsetBuffer bufferedMessage
Definition ua_pubsub.h:343
UA_Boolean configurationFrozen
Definition ua_pubsub.h:345
UA_UInt64 publishCallbackId
Definition ua_pubsub.h:341
UA_PubSubConnection * linkedConnection
Definition ua_pubsub.h:350
uintptr_t sendChannel
Definition ua_pubsub.h:351
UA_UInt32 writersCount
Definition ua_pubsub.h:339
UA_DateTime lastPublishTimeStamp
Definition ua_pubsub.h:346
LIST_HEAD(, UA_DataSetWriter) writers
UA_Boolean deleteFlag
Definition ua_pubsub.h:352
UA_UInt16 sequenceNumber
Definition ua_pubsub.h:344
LIST_ENTRY(UA_WriterGroup) listEntry
UA_PubSubComponentEnumType componentType
Definition ua_pubsub.h:333
char id nodeId
Definition types.h:440
_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
qn name
Definition types.h:517
uint64_t UA_UInt64
Definition types.h:67
UA_PubSubState
PubSubState.
UA_StatusCode UA_DataSetWriter_create(UA_Server *server, const UA_NodeId writerGroup, const UA_NodeId dataSet, const UA_DataSetWriterConfig *dataSetWriterConfig, UA_NodeId *writerIdentifier)
UA_StatusCode UA_FieldTargetVariable_copy(const UA_FieldTargetVariable *src, UA_FieldTargetVariable *dst)
Copy the configuration of Field Target Variables.
void UA_PubSubConnectionConfig_clear(UA_PubSubConnectionConfig *connectionConfig)
UA_StatusCode UA_WriterGroup_unfreezeConfiguration(UA_Server *server, UA_WriterGroup *wg)
UA_StatusCode UA_ReaderGroup_create(UA_Server *server, UA_NodeId connectionId, const UA_ReaderGroupConfig *rgc, UA_NodeId *readerGroupId)
UA_StatusCode UA_WriterGroup_remove(UA_Server *server, UA_WriterGroup *wg)
UA_ReserveIdType
Definition ua_pubsub.h:752
@ UA_WRITER_GROUP
Definition ua_pubsub.h:753
@ UA_DATA_SET_WRITER
Definition ua_pubsub.h:754
UA_StatusCode UA_PubSubManager_addPubSubTopicAssign(UA_Server *server, UA_ReaderGroup *readerGroup, UA_String topic)
UA_UInt32 UA_PubSubConfigurationVersionTimeDifference(void)
UA_StatusCode UA_PublishedDataSetConfig_copy(const UA_PublishedDataSetConfig *src, UA_PublishedDataSetConfig *dst)
UA_PubSubConnection * UA_PubSubConnection_findConnectionbyId(UA_Server *server, UA_NodeId connectionIdentifier)
UA_StandaloneSubscribedDataSet * UA_StandaloneSubscribedDataSet_findSDSbyId(UA_Server *server, UA_NodeId identifier)
#define UA_PUBSUB_MAXCHANNELS
Max number of underlying for sending and receiving.
Definition ua_pubsub.h:35
void UA_PubSubManager_init(UA_Server *server, UA_PubSubManager *pubSubManager)
UA_StatusCode UA_WriterGroup_setPubSubState(UA_Server *server, UA_WriterGroup *writerGroup, UA_PubSubState state, UA_StatusCode cause)
UA_StatusCode UA_WriterGroupConfig_copy(const UA_WriterGroupConfig *src, UA_WriterGroupConfig *dst)
struct UA_SecurityGroup UA_SecurityGroup
Definition ua_pubsub.h:44
void UA_PublishedDataSet_clear(UA_Server *server, UA_PublishedDataSet *publishedDataSet)
UA_Boolean UA_ReaderGroup_decodeAndProcessRT(UA_Server *server, UA_ReaderGroup *readerGroup, UA_ByteString *buf)
UA_PublishedDataSet * UA_PublishedDataSet_findPDSbyId(UA_Server *server, UA_NodeId identifier)
UA_ReaderGroup * UA_ReaderGroup_findRGbyId(UA_Server *server, UA_NodeId identifier)
Prototypes for internal util functions - some functions maybe removed later (currently moved from pub...
void UA_PubSubManager_generateUniqueNodeId(UA_PubSubManager *psm, UA_NodeId *nodeId)
UA_StatusCode UA_WriterGroup_create(UA_Server *server, const UA_NodeId connection, const UA_WriterGroupConfig *writerGroupConfig, UA_NodeId *writerGroupIdentifier)
UA_DataSetFieldResult UA_DataSetField_create(UA_Server *server, const UA_NodeId publishedDataSet, const UA_DataSetFieldConfig *fieldConfig, UA_NodeId *fieldIdentifier)
UA_StatusCode UA_DataSetWriter_prepareDataSet(UA_Server *server, UA_DataSetWriter *dsw, UA_DataSetMessage *dsm)
UA_StatusCode UA_PubSubConnection_connect(UA_Server *server, UA_PubSubConnection *c, UA_Boolean validate)
void UA_WriterGroup_disconnect(UA_WriterGroup *wg)
void UA_PubSubConnection_disconnect(UA_PubSubConnection *c)
UA_EventLoop * UA_PubSubConnection_getEL(UA_Server *server, UA_PubSubConnection *c)
Returns either the eventloop configured in the connection or, in its absence, for the server.
UA_StatusCode UA_ReaderGroup_freezeConfiguration(UA_Server *server, UA_ReaderGroup *rg)
void UA_DataSetWriter_freezeConfiguration(UA_Server *server, UA_DataSetWriter *dsw)
UA_StatusCode UA_ReaderGroup_remove(UA_Server *server, UA_ReaderGroup *rg)
UA_Boolean UA_ReaderGroup_process(UA_Server *server, UA_ReaderGroup *readerGroup, UA_NetworkMessage *nm)
UA_StatusCode getPublishedDataSetConfig(UA_Server *server, const UA_NodeId pds, UA_PublishedDataSetConfig *config)
UA_Guid UA_PubSubManager_generateUniqueGuid(UA_Server *server)
void UA_PubSubManager_shutdown(UA_Server *server, UA_PubSubManager *pubSubManager)
UA_StatusCode UA_ReaderGroup_connect(UA_Server *server, UA_ReaderGroup *rg, UA_Boolean validate)
UA_StatusCode UA_PubSubManager_reserveIds(UA_Server *server, UA_NodeId sessionId, UA_UInt16 numRegWriterGroupIds, UA_UInt16 numRegDataSetWriterIds, UA_String transportProfileUri, UA_UInt16 **writerGroupIds, UA_UInt16 **dataSetWriterIds)
void UA_StandaloneSubscribedDataSet_clear(UA_Server *server, UA_StandaloneSubscribedDataSet *subscribedDataSet)
UA_StatusCode UA_WriterGroup_updateConfig(UA_Server *server, UA_WriterGroup *wg, const UA_WriterGroupConfig *config)
UA_PublishedDataSet * UA_PublishedDataSet_findPDSbyName(UA_Server *server, UA_String name)
UA_StatusCode UA_DataSetFieldConfig_copy(const UA_DataSetFieldConfig *src, UA_DataSetFieldConfig *dst)
UA_StatusCode decodeNetworkMessage(UA_Server *server, UA_ByteString *buffer, size_t *pos, UA_NetworkMessage *nm, UA_PubSubConnection *connection)
Reading Message handling
void UA_PubSubDataSetField_sampleValue(UA_Server *server, UA_DataSetField *field, UA_DataValue *value)
UA_StatusCode UA_WriterGroup_addPublishCallback(UA_Server *server, UA_WriterGroup *writerGroup)
UA_StandaloneSubscribedDataSet * UA_StandaloneSubscribedDataSet_findSDSbyName(UA_Server *server, UA_String identifier)
void UA_TargetVariables_clear(UA_TargetVariables *subscribedDataSetTarget)
Clear the Target Variables configuration.
void UA_PubSubConnection_delete(UA_Server *server, UA_PubSubConnection *c)
UA_StatusCode UA_DataSetWriter_generateDataSetMessage(UA_Server *server, UA_DataSetMessage *dataSetMessage, UA_DataSetWriter *dataSetWriter)
UA_StatusCode UA_PubSubConnection_create(UA_Server *server, const UA_PubSubConnectionConfig *connectionConfig, UA_NodeId *connectionIdentifier)
UA_StatusCode UA_TargetVariables_copy(const UA_TargetVariables *src, UA_TargetVariables *dst)
Copy the configuration of Target Variables.
UA_StatusCode UA_WriterGroup_connect(UA_Server *server, UA_WriterGroup *wg, UA_Boolean validate)
UA_StatusCode UA_PubSubConnection_setPubSubState(UA_Server *server, UA_PubSubConnection *connection, UA_PubSubState state, UA_StatusCode cause)
UA_DataSetField * UA_DataSetField_findDSFbyId(UA_Server *server, UA_NodeId identifier)
UA_StatusCode UA_ReaderGroup_unfreezeConfiguration(UA_Server *server, UA_ReaderGroup *rg)
UA_StatusCode UA_StandaloneSubscribedDataSetConfig_copy(const UA_StandaloneSubscribedDataSetConfig *src, UA_StandaloneSubscribedDataSetConfig *dst)
void UA_PubSubManager_freeIds(UA_Server *server)
void UA_DataSetWriter_unfreezeConfiguration(UA_Server *server, UA_DataSetWriter *dsw)
UA_StatusCode UA_DataSetWriter_setPubSubState(UA_Server *server, UA_DataSetWriter *dataSetWriter, UA_PubSubState state, UA_StatusCode cause)
void UA_DataSetReader_process(UA_Server *server, UA_ReaderGroup *readerGroup, UA_DataSetReader *dataSetReader, UA_DataSetMessage *dataSetMsg)
Process Network Message using DataSetReader.
UA_StatusCode UA_ReaderGroupConfig_copy(const UA_ReaderGroupConfig *src, UA_ReaderGroupConfig *dst)
void UA_PubSubManager_delete(UA_Server *server, UA_PubSubManager *pubSubManager)
UA_DataSetWriter * UA_DataSetWriter_findDSWbyId(UA_Server *server, UA_NodeId identifier)
void UA_WriterGroup_publishCallback(UA_Server *server, UA_WriterGroup *writerGroup)
UA_StatusCode UA_PublishedDataSet_remove(UA_Server *server, UA_PublishedDataSet *publishedDataSet)
UA_StatusCode UA_DataSetReader_create(UA_Server *server, UA_NodeId readerGroupIdentifier, const UA_DataSetReaderConfig *dataSetReaderConfig, UA_NodeId *readerIdentifier)
void UA_ReaderGroup_disconnect(UA_ReaderGroup *rg)
UA_StatusCode UA_DataSetReader_setPubSubState(UA_Server *server, UA_DataSetReader *dataSetReader, UA_PubSubState state, UA_StatusCode cause)
UA_StatusCode DataSetReader_createTargetVariables(UA_Server *server, UA_DataSetReader *dsr, size_t targetVariablesSize, const UA_FieldTargetVariable *targetVariables)
UA_WriterGroup * UA_WriterGroup_findWGbyId(UA_Server *server, UA_NodeId identifier)
UA_StatusCode UA_DataSetReader_checkIdentifier(UA_Server *server, UA_NetworkMessage *msg, UA_DataSetReader *reader, UA_ReaderGroupConfig readerGroupConfig)
UA_StatusCode UA_DataSetWriterConfig_copy(const UA_DataSetWriterConfig *src, UA_DataSetWriterConfig *dst)
UA_DataSetFieldResult UA_DataSetField_remove(UA_Server *server, UA_DataSetField *currentField)
UA_StatusCode UA_ReaderGroup_setPubSubState(UA_Server *server, UA_ReaderGroup *readerGroup, UA_PubSubState state, UA_StatusCode cause)
UA_StatusCode UA_WriterGroup_freezeConfiguration(UA_Server *server, UA_WriterGroup *wg)
UA_DataSetReader * UA_ReaderGroup_findDSRbyId(UA_Server *server, UA_NodeId identifier)
UA_StatusCode setReaderGroupEncryptionKeys(UA_Server *server, const UA_NodeId readerGroup, UA_UInt32 securityTokenId, const UA_ByteString signingKey, const UA_ByteString encryptingKey, const UA_ByteString keyNonce)
UA_StatusCode UA_PubSubConnectionConfig_copy(const UA_PubSubConnectionConfig *src, UA_PubSubConnectionConfig *dst)
UA_StatusCode UA_DataSetReader_remove(UA_Server *server, UA_DataSetReader *dsr)
UA_AddPublishedDataSetResult UA_PublishedDataSet_create(UA_Server *server, const UA_PublishedDataSetConfig *publishedDataSetConfig, UA_NodeId *pdsIdentifier)
UA_StatusCode setWriterGroupEncryptionKeys(UA_Server *server, const UA_NodeId writerGroup, UA_UInt32 securityTokenId, const UA_ByteString signingKey, const UA_ByteString encryptingKey, const UA_ByteString keyNonce)
UA_StatusCode UA_DataSetWriter_remove(UA_Server *server, UA_DataSetWriter *dataSetWriter)
#define ZIP_HEAD(name, type)
Reusable zip tree implementation.
Definition ziptree.h:44