Coverage Report

Created: 2026-09-28 07:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/open62541_15/include/open62541/plugin/nodestore.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 2017, 2021 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
6
 *    Copyright 2017 (c) Julian Grothoff
7
 *    Copyright 2017 (c) Stefan Profanter, fortiss GmbH
8
 */
9
10
#ifndef UA_NODESTORE_H_
11
#define UA_NODESTORE_H_
12
13
#include <open62541/server.h>
14
15
_UA_BEGIN_DECLS
16
17
/* Forward declaration */
18
#ifdef UA_ENABLE_SUBSCRIPTIONS
19
struct UA_MonitoredItem;
20
typedef struct UA_MonitoredItem UA_MonitoredItem;
21
#endif
22
23
/**
24
 * Nodestore Plugin API
25
 * ====================
26
 * **Warning!!** The structures defined in this section are only relevant for
27
 * the developers of custom Nodestores. The interaction with the information
28
 * model is possible only via the OPC UA :ref:`services`. So the following
29
 * sections are mainly for users that seek to understand the underlying
30
 * representation -- which is not directly accessible.
31
 *
32
 * ReferenceType Bitfield Representation
33
 * -------------------------------------
34
 * ReferenceTypes have an alternative represention as an index into a bitfield
35
 * for fast comparison. The index is generated when the corresponding
36
 * ReferenceTypeNode is added. By bounding the number of ReferenceTypes that can
37
 * exist in the server, the bitfield can represent a set of an combination of
38
 * ReferenceTypes.
39
 *
40
 * Every ReferenceTypeNode contains a bitfield with the set of all its subtypes.
41
 * This speeds up the Browse services substantially.
42
 *
43
 * The following ReferenceTypes have a fixed index. The NS0 bootstrapping
44
 * creates these ReferenceTypes in-order. */
45
46
#define UA_REFERENCETYPEINDEX_REFERENCES 0
47
67.8M
#define UA_REFERENCETYPEINDEX_HASSUBTYPE 1
48
3.96M
#define UA_REFERENCETYPEINDEX_AGGREGATES 2
49
#define UA_REFERENCETYPEINDEX_HIERARCHICALREFERENCES 3
50
#define UA_REFERENCETYPEINDEX_NONHIERARCHICALREFERENCES 4
51
#define UA_REFERENCETYPEINDEX_HASCHILD 5
52
#define UA_REFERENCETYPEINDEX_ORGANIZES 6
53
#define UA_REFERENCETYPEINDEX_HASEVENTSOURCE 7
54
9.60M
#define UA_REFERENCETYPEINDEX_HASMODELLINGRULE 8
55
#define UA_REFERENCETYPEINDEX_HASENCODING 9
56
#define UA_REFERENCETYPEINDEX_HASDESCRIPTION 10
57
58.2M
#define UA_REFERENCETYPEINDEX_HASTYPEDEFINITION 11
58
#define UA_REFERENCETYPEINDEX_GENERATESEVENT 12
59
0
#define UA_REFERENCETYPEINDEX_HASPROPERTY 13
60
0
#define UA_REFERENCETYPEINDEX_HASCOMPONENT 14
61
#define UA_REFERENCETYPEINDEX_HASNOTIFIER 15
62
#define UA_REFERENCETYPEINDEX_HASORDEREDCOMPONENT 16
63
15.5M
#define UA_REFERENCETYPEINDEX_HASINTERFACE 17
64
65
/* The maximum number of ReferrenceTypes. Must be a multiple of 32. */
66
13.6M
#define UA_REFERENCETYPESET_MAX 128
67
typedef struct {
68
    UA_UInt32 bits[UA_REFERENCETYPESET_MAX / 32];
69
} UA_ReferenceTypeSet;
70
71
UA_EXPORT extern const UA_ReferenceTypeSet UA_REFERENCETYPESET_NONE;
72
UA_EXPORT extern const UA_ReferenceTypeSet UA_REFERENCETYPESET_ALL;
73
74
static UA_INLINE void
75
258M
UA_ReferenceTypeSet_init(UA_ReferenceTypeSet *set) {
76
258M
    memset(set, 0, sizeof(UA_ReferenceTypeSet));
77
258M
}
Unexecuted instantiation: ua_session.c:UA_ReferenceTypeSet_init
ua_nodes.c:UA_ReferenceTypeSet_init
Line
Count
Source
75
5.97M
UA_ReferenceTypeSet_init(UA_ReferenceTypeSet *set) {
76
5.97M
    memset(set, 0, sizeof(UA_ReferenceTypeSet));
77
5.97M
}
Unexecuted instantiation: ua_server.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_server_ns0.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_server_ns0_diagnostics.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_server_ns0_gds.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_server_config.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_server_binary.c:UA_ReferenceTypeSet_init
ua_server_utils.c:UA_ReferenceTypeSet_init
Line
Count
Source
75
45.3M
UA_ReferenceTypeSet_init(UA_ReferenceTypeSet *set) {
76
45.3M
    memset(set, 0, sizeof(UA_ReferenceTypeSet));
77
45.3M
}
Unexecuted instantiation: ua_server_async.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_subscription.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_subscription_datachange.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_subscription_event.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_subscription_alarms_conditions.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_services.c:UA_ReferenceTypeSet_init
ua_services_view.c:UA_ReferenceTypeSet_init
Line
Count
Source
75
93.7M
UA_ReferenceTypeSet_init(UA_ReferenceTypeSet *set) {
76
93.7M
    memset(set, 0, sizeof(UA_ReferenceTypeSet));
77
93.7M
}
Unexecuted instantiation: ua_services_method.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_services_session.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_services_attribute.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_services_discovery.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_services_subscription.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_services_monitoreditem.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_services_securechannel.c:UA_ReferenceTypeSet_init
ua_services_nodemanagement.c:UA_ReferenceTypeSet_init
Line
Count
Source
75
113M
UA_ReferenceTypeSet_init(UA_ReferenceTypeSet *set) {
76
113M
    memset(set, 0, sizeof(UA_ReferenceTypeSet));
77
113M
}
Unexecuted instantiation: ua_pubsub_connection.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_pubsub_dataset.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_pubsub_writer.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_pubsub_writergroup.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_pubsub_reader.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_pubsub_readergroup.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_pubsub_manager.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_pubsub_ns0.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_pubsub_ns0_sks.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_discovery_mdns.c:UA_ReferenceTypeSet_init
Unexecuted instantiation: ua_discovery.c:UA_ReferenceTypeSet_init
ua_nodestore_ziptree.c:UA_ReferenceTypeSet_init
Line
Count
Source
75
590k
UA_ReferenceTypeSet_init(UA_ReferenceTypeSet *set) {
76
590k
    memset(set, 0, sizeof(UA_ReferenceTypeSet));
77
590k
}
Unexecuted instantiation: fuzz_server_services.cc:UA_ReferenceTypeSet_init(UA_ReferenceTypeSet*)
Unexecuted instantiation: fuzz_tcp_message.cc:UA_ReferenceTypeSet_init(UA_ReferenceTypeSet*)
Unexecuted instantiation: fuzz_msg_message.cc:UA_ReferenceTypeSet_init(UA_ReferenceTypeSet*)
Unexecuted instantiation: fuzz_opn_message.cc:UA_ReferenceTypeSet_init(UA_ReferenceTypeSet*)
Unexecuted instantiation: fuzz_process_request.cc:UA_ReferenceTypeSet_init(UA_ReferenceTypeSet*)
Unexecuted instantiation: fuzz_binary_message.cc:UA_ReferenceTypeSet_init(UA_ReferenceTypeSet*)
78
79
static UA_INLINE UA_ReferenceTypeSet
80
161M
UA_REFTYPESET(UA_Byte index) {
81
161M
    UA_Byte i = index / 32, j = index % 32;
82
161M
    UA_ReferenceTypeSet set;
83
161M
    UA_ReferenceTypeSet_init(&set);
84
161M
    set.bits[i] |= ((UA_UInt32)1) << j;
85
161M
    return set;
86
161M
}
Unexecuted instantiation: ua_session.c:UA_REFTYPESET
Unexecuted instantiation: ua_nodes.c:UA_REFTYPESET
Unexecuted instantiation: ua_server.c:UA_REFTYPESET
Unexecuted instantiation: ua_server_ns0.c:UA_REFTYPESET
Unexecuted instantiation: ua_server_ns0_diagnostics.c:UA_REFTYPESET
Unexecuted instantiation: ua_server_ns0_gds.c:UA_REFTYPESET
Unexecuted instantiation: ua_server_config.c:UA_REFTYPESET
Unexecuted instantiation: ua_server_binary.c:UA_REFTYPESET
ua_server_utils.c:UA_REFTYPESET
Line
Count
Source
80
45.3M
UA_REFTYPESET(UA_Byte index) {
81
45.3M
    UA_Byte i = index / 32, j = index % 32;
82
45.3M
    UA_ReferenceTypeSet set;
83
45.3M
    UA_ReferenceTypeSet_init(&set);
84
45.3M
    set.bits[i] |= ((UA_UInt32)1) << j;
85
45.3M
    return set;
86
45.3M
}
Unexecuted instantiation: ua_server_async.c:UA_REFTYPESET
Unexecuted instantiation: ua_subscription.c:UA_REFTYPESET
Unexecuted instantiation: ua_subscription_datachange.c:UA_REFTYPESET
Unexecuted instantiation: ua_subscription_event.c:UA_REFTYPESET
Unexecuted instantiation: ua_subscription_alarms_conditions.c:UA_REFTYPESET
Unexecuted instantiation: ua_services.c:UA_REFTYPESET
ua_services_view.c:UA_REFTYPESET
Line
Count
Source
80
14.9M
UA_REFTYPESET(UA_Byte index) {
81
14.9M
    UA_Byte i = index / 32, j = index % 32;
82
14.9M
    UA_ReferenceTypeSet set;
83
14.9M
    UA_ReferenceTypeSet_init(&set);
84
14.9M
    set.bits[i] |= ((UA_UInt32)1) << j;
85
14.9M
    return set;
86
14.9M
}
Unexecuted instantiation: ua_services_method.c:UA_REFTYPESET
Unexecuted instantiation: ua_services_session.c:UA_REFTYPESET
Unexecuted instantiation: ua_services_attribute.c:UA_REFTYPESET
Unexecuted instantiation: ua_services_discovery.c:UA_REFTYPESET
Unexecuted instantiation: ua_services_subscription.c:UA_REFTYPESET
Unexecuted instantiation: ua_services_monitoreditem.c:UA_REFTYPESET
Unexecuted instantiation: ua_services_securechannel.c:UA_REFTYPESET
ua_services_nodemanagement.c:UA_REFTYPESET
Line
Count
Source
80
100M
UA_REFTYPESET(UA_Byte index) {
81
100M
    UA_Byte i = index / 32, j = index % 32;
82
100M
    UA_ReferenceTypeSet set;
83
100M
    UA_ReferenceTypeSet_init(&set);
84
100M
    set.bits[i] |= ((UA_UInt32)1) << j;
85
100M
    return set;
86
100M
}
Unexecuted instantiation: ua_pubsub_connection.c:UA_REFTYPESET
Unexecuted instantiation: ua_pubsub_dataset.c:UA_REFTYPESET
Unexecuted instantiation: ua_pubsub_writer.c:UA_REFTYPESET
Unexecuted instantiation: ua_pubsub_writergroup.c:UA_REFTYPESET
Unexecuted instantiation: ua_pubsub_reader.c:UA_REFTYPESET
Unexecuted instantiation: ua_pubsub_readergroup.c:UA_REFTYPESET
Unexecuted instantiation: ua_pubsub_manager.c:UA_REFTYPESET
Unexecuted instantiation: ua_pubsub_ns0.c:UA_REFTYPESET
Unexecuted instantiation: ua_pubsub_ns0_sks.c:UA_REFTYPESET
Unexecuted instantiation: ua_discovery_mdns.c:UA_REFTYPESET
Unexecuted instantiation: ua_discovery.c:UA_REFTYPESET
ua_nodestore_ziptree.c:UA_REFTYPESET
Line
Count
Source
80
590k
UA_REFTYPESET(UA_Byte index) {
81
590k
    UA_Byte i = index / 32, j = index % 32;
82
590k
    UA_ReferenceTypeSet set;
83
590k
    UA_ReferenceTypeSet_init(&set);
84
590k
    set.bits[i] |= ((UA_UInt32)1) << j;
85
590k
    return set;
86
590k
}
Unexecuted instantiation: fuzz_server_services.cc:UA_REFTYPESET(unsigned char)
Unexecuted instantiation: fuzz_tcp_message.cc:UA_REFTYPESET(unsigned char)
Unexecuted instantiation: fuzz_msg_message.cc:UA_REFTYPESET(unsigned char)
Unexecuted instantiation: fuzz_opn_message.cc:UA_REFTYPESET(unsigned char)
Unexecuted instantiation: fuzz_process_request.cc:UA_REFTYPESET(unsigned char)
Unexecuted instantiation: fuzz_binary_message.cc:UA_REFTYPESET(unsigned char)
87
88
static UA_INLINE void
89
UA_ReferenceTypeSet_add(UA_ReferenceTypeSet *set,
90
21.9M
                        UA_Byte newIndex) {
91
21.9M
    UA_Byte i = newIndex / 32, j = newIndex % 32;
92
21.9M
    set->bits[i] |= ((UA_UInt32)1) << j;
93
21.9M
}
Unexecuted instantiation: ua_session.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_nodes.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_server.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_server_ns0.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_server_ns0_diagnostics.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_server_ns0_gds.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_server_config.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_server_binary.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_server_utils.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_server_async.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_subscription.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_subscription_datachange.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_subscription_event.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_subscription_alarms_conditions.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_services.c:UA_ReferenceTypeSet_add
ua_services_view.c:UA_ReferenceTypeSet_add
Line
Count
Source
90
20.8M
                        UA_Byte newIndex) {
91
20.8M
    UA_Byte i = newIndex / 32, j = newIndex % 32;
92
20.8M
    set->bits[i] |= ((UA_UInt32)1) << j;
93
20.8M
}
Unexecuted instantiation: ua_services_method.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_services_session.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_services_attribute.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_services_discovery.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_services_subscription.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_services_monitoreditem.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_services_securechannel.c:UA_ReferenceTypeSet_add
ua_services_nodemanagement.c:UA_ReferenceTypeSet_add
Line
Count
Source
90
1.00M
                        UA_Byte newIndex) {
91
1.00M
    UA_Byte i = newIndex / 32, j = newIndex % 32;
92
1.00M
    set->bits[i] |= ((UA_UInt32)1) << j;
93
1.00M
}
Unexecuted instantiation: ua_pubsub_connection.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_pubsub_dataset.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_pubsub_writer.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_pubsub_writergroup.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_pubsub_reader.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_pubsub_readergroup.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_pubsub_manager.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_pubsub_ns0.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_pubsub_ns0_sks.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_discovery_mdns.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_discovery.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: ua_nodestore_ziptree.c:UA_ReferenceTypeSet_add
Unexecuted instantiation: fuzz_server_services.cc:UA_ReferenceTypeSet_add(UA_ReferenceTypeSet*, unsigned char)
Unexecuted instantiation: fuzz_tcp_message.cc:UA_ReferenceTypeSet_add(UA_ReferenceTypeSet*, unsigned char)
Unexecuted instantiation: fuzz_msg_message.cc:UA_ReferenceTypeSet_add(UA_ReferenceTypeSet*, unsigned char)
Unexecuted instantiation: fuzz_opn_message.cc:UA_ReferenceTypeSet_add(UA_ReferenceTypeSet*, unsigned char)
Unexecuted instantiation: fuzz_process_request.cc:UA_ReferenceTypeSet_add(UA_ReferenceTypeSet*, unsigned char)
Unexecuted instantiation: fuzz_binary_message.cc:UA_ReferenceTypeSet_add(UA_ReferenceTypeSet*, unsigned char)
94
95
static UA_INLINE UA_ReferenceTypeSet
96
UA_ReferenceTypeSet_union(const UA_ReferenceTypeSet setA,
97
1.68M
                          const UA_ReferenceTypeSet setB) {
98
1.68M
    UA_ReferenceTypeSet set;
99
13.1M
    for(size_t i = 0; i < UA_REFERENCETYPESET_MAX / 32; i++)
100
11.4M
        set.bits[i] = setA.bits[i] | setB.bits[i];
101
1.68M
    return set;
102
1.68M
}
Unexecuted instantiation: ua_session.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_nodes.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_server.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_server_ns0.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_server_ns0_diagnostics.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_server_ns0_gds.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_server_config.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_server_binary.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_server_utils.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_server_async.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_subscription.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_subscription_datachange.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_subscription_event.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_subscription_alarms_conditions.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_services.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_services_view.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_services_method.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_services_session.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_services_attribute.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_services_discovery.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_services_subscription.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_services_monitoreditem.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_services_securechannel.c:UA_ReferenceTypeSet_union
ua_services_nodemanagement.c:UA_ReferenceTypeSet_union
Line
Count
Source
97
1.68M
                          const UA_ReferenceTypeSet setB) {
98
1.68M
    UA_ReferenceTypeSet set;
99
13.1M
    for(size_t i = 0; i < UA_REFERENCETYPESET_MAX / 32; i++)
100
11.4M
        set.bits[i] = setA.bits[i] | setB.bits[i];
101
1.68M
    return set;
102
1.68M
}
Unexecuted instantiation: ua_pubsub_connection.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_pubsub_dataset.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_pubsub_writer.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_pubsub_writergroup.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_pubsub_reader.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_pubsub_readergroup.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_pubsub_manager.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_pubsub_ns0.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_pubsub_ns0_sks.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_discovery_mdns.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_discovery.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: ua_nodestore_ziptree.c:UA_ReferenceTypeSet_union
Unexecuted instantiation: fuzz_server_services.cc:UA_ReferenceTypeSet_union(UA_ReferenceTypeSet, UA_ReferenceTypeSet)
Unexecuted instantiation: fuzz_tcp_message.cc:UA_ReferenceTypeSet_union(UA_ReferenceTypeSet, UA_ReferenceTypeSet)
Unexecuted instantiation: fuzz_msg_message.cc:UA_ReferenceTypeSet_union(UA_ReferenceTypeSet, UA_ReferenceTypeSet)
Unexecuted instantiation: fuzz_opn_message.cc:UA_ReferenceTypeSet_union(UA_ReferenceTypeSet, UA_ReferenceTypeSet)
Unexecuted instantiation: fuzz_process_request.cc:UA_ReferenceTypeSet_union(UA_ReferenceTypeSet, UA_ReferenceTypeSet)
Unexecuted instantiation: fuzz_binary_message.cc:UA_ReferenceTypeSet_union(UA_ReferenceTypeSet, UA_ReferenceTypeSet)
103
104
static UA_INLINE UA_Boolean
105
460M
UA_ReferenceTypeSet_contains(const UA_ReferenceTypeSet *set, UA_Byte index) {
106
460M
    UA_Byte i = index / 32, j = index % 32;
107
460M
    return !!(set->bits[i] & (((UA_UInt32)1) << j));
108
460M
}
Unexecuted instantiation: ua_session.c:UA_ReferenceTypeSet_contains
ua_nodes.c:UA_ReferenceTypeSet_contains
Line
Count
Source
105
17.5M
UA_ReferenceTypeSet_contains(const UA_ReferenceTypeSet *set, UA_Byte index) {
106
17.5M
    UA_Byte i = index / 32, j = index % 32;
107
17.5M
    return !!(set->bits[i] & (((UA_UInt32)1) << j));
108
17.5M
}
Unexecuted instantiation: ua_server.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_server_ns0.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_server_ns0_diagnostics.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_server_ns0_gds.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_server_config.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_server_binary.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_server_utils.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_server_async.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_subscription.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_subscription_datachange.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_subscription_event.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_subscription_alarms_conditions.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_services.c:UA_ReferenceTypeSet_contains
ua_services_view.c:UA_ReferenceTypeSet_contains
Line
Count
Source
105
387M
UA_ReferenceTypeSet_contains(const UA_ReferenceTypeSet *set, UA_Byte index) {
106
387M
    UA_Byte i = index / 32, j = index % 32;
107
387M
    return !!(set->bits[i] & (((UA_UInt32)1) << j));
108
387M
}
Unexecuted instantiation: ua_services_method.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_services_session.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_services_attribute.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_services_discovery.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_services_subscription.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_services_monitoreditem.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_services_securechannel.c:UA_ReferenceTypeSet_contains
ua_services_nodemanagement.c:UA_ReferenceTypeSet_contains
Line
Count
Source
105
55.4M
UA_ReferenceTypeSet_contains(const UA_ReferenceTypeSet *set, UA_Byte index) {
106
55.4M
    UA_Byte i = index / 32, j = index % 32;
107
55.4M
    return !!(set->bits[i] & (((UA_UInt32)1) << j));
108
55.4M
}
Unexecuted instantiation: ua_pubsub_connection.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_pubsub_dataset.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_pubsub_writer.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_pubsub_writergroup.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_pubsub_reader.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_pubsub_readergroup.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_pubsub_manager.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_pubsub_ns0.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_pubsub_ns0_sks.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_discovery_mdns.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_discovery.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: ua_nodestore_ziptree.c:UA_ReferenceTypeSet_contains
Unexecuted instantiation: fuzz_server_services.cc:UA_ReferenceTypeSet_contains(UA_ReferenceTypeSet const*, unsigned char)
Unexecuted instantiation: fuzz_tcp_message.cc:UA_ReferenceTypeSet_contains(UA_ReferenceTypeSet const*, unsigned char)
Unexecuted instantiation: fuzz_msg_message.cc:UA_ReferenceTypeSet_contains(UA_ReferenceTypeSet const*, unsigned char)
Unexecuted instantiation: fuzz_opn_message.cc:UA_ReferenceTypeSet_contains(UA_ReferenceTypeSet const*, unsigned char)
Unexecuted instantiation: fuzz_process_request.cc:UA_ReferenceTypeSet_contains(UA_ReferenceTypeSet const*, unsigned char)
Unexecuted instantiation: fuzz_binary_message.cc:UA_ReferenceTypeSet_contains(UA_ReferenceTypeSet const*, unsigned char)
109
110
/**
111
 * Node Pointer
112
 * ------------
113
 * The "native" format for reference between nodes is the ExpandedNodeId. That
114
 * is, references can also point to external servers. In practice, most
115
 * references point to local nodes using numerical NodeIds from the
116
 * standard-defined namespace zero. In order to save space (and time),
117
 * pointer-tagging is used for compressed "NodePointer" representations.
118
 * Numerical NodeIds are immediately contained in the pointer. Full NodeIds and
119
 * ExpandedNodeIds are behind a pointer indirection. If the Nodestore supports
120
 * it, a NodePointer can also be an actual pointer to the target node.
121
 *
122
 * Depending on the processor architecture, some numerical NodeIds don't fit
123
 * into an immediate encoding and are kept as pointers. ExpandedNodeIds may be
124
 * internally translated to "normal" NodeIds. Use the provided functions to
125
 * generate NodePointers that fit the assumptions for the local architecture. */
126
127
/* Forward declaration. All node structures begin with the NodeHead. */
128
struct UA_NodeHead;
129
typedef struct UA_NodeHead UA_NodeHead;
130
131
/* Tagged Pointer structure. */
132
typedef union {
133
    uintptr_t immediate;                 /* 00: Small numerical NodeId */
134
    const UA_NodeId *id;                 /* 01: Pointer to NodeId */
135
    const UA_ExpandedNodeId *expandedId; /* 10: Pointer to ExternalNodeId */
136
    const UA_NodeHead *node;             /* 11: Pointer to a node */
137
} UA_NodePointer;
138
139
/* Sets the pointer to an immediate NodeId "ns=0;i=0" similar to a freshly
140
 * initialized UA_NodeId */
141
static UA_INLINE void
142
86.4M
UA_NodePointer_init(UA_NodePointer *np) { np->immediate = 0; }
Unexecuted instantiation: ua_session.c:UA_NodePointer_init
ua_nodes.c:UA_NodePointer_init
Line
Count
Source
142
31.2M
UA_NodePointer_init(UA_NodePointer *np) { np->immediate = 0; }
Unexecuted instantiation: ua_server.c:UA_NodePointer_init
Unexecuted instantiation: ua_server_ns0.c:UA_NodePointer_init
Unexecuted instantiation: ua_server_ns0_diagnostics.c:UA_NodePointer_init
Unexecuted instantiation: ua_server_ns0_gds.c:UA_NodePointer_init
Unexecuted instantiation: ua_server_config.c:UA_NodePointer_init
Unexecuted instantiation: ua_server_binary.c:UA_NodePointer_init
Unexecuted instantiation: ua_server_utils.c:UA_NodePointer_init
Unexecuted instantiation: ua_server_async.c:UA_NodePointer_init
Unexecuted instantiation: ua_subscription.c:UA_NodePointer_init
Unexecuted instantiation: ua_subscription_datachange.c:UA_NodePointer_init
Unexecuted instantiation: ua_subscription_event.c:UA_NodePointer_init
Unexecuted instantiation: ua_subscription_alarms_conditions.c:UA_NodePointer_init
Unexecuted instantiation: ua_services.c:UA_NodePointer_init
ua_services_view.c:UA_NodePointer_init
Line
Count
Source
142
55.1M
UA_NodePointer_init(UA_NodePointer *np) { np->immediate = 0; }
Unexecuted instantiation: ua_services_method.c:UA_NodePointer_init
Unexecuted instantiation: ua_services_session.c:UA_NodePointer_init
Unexecuted instantiation: ua_services_attribute.c:UA_NodePointer_init
Unexecuted instantiation: ua_services_discovery.c:UA_NodePointer_init
Unexecuted instantiation: ua_services_subscription.c:UA_NodePointer_init
Unexecuted instantiation: ua_services_monitoreditem.c:UA_NodePointer_init
Unexecuted instantiation: ua_services_securechannel.c:UA_NodePointer_init
Unexecuted instantiation: ua_services_nodemanagement.c:UA_NodePointer_init
Unexecuted instantiation: ua_pubsub_connection.c:UA_NodePointer_init
Unexecuted instantiation: ua_pubsub_dataset.c:UA_NodePointer_init
Unexecuted instantiation: ua_pubsub_writer.c:UA_NodePointer_init
Unexecuted instantiation: ua_pubsub_writergroup.c:UA_NodePointer_init
Unexecuted instantiation: ua_pubsub_reader.c:UA_NodePointer_init
Unexecuted instantiation: ua_pubsub_readergroup.c:UA_NodePointer_init
Unexecuted instantiation: ua_pubsub_manager.c:UA_NodePointer_init
Unexecuted instantiation: ua_pubsub_ns0.c:UA_NodePointer_init
Unexecuted instantiation: ua_pubsub_ns0_sks.c:UA_NodePointer_init
Unexecuted instantiation: ua_discovery_mdns.c:UA_NodePointer_init
Unexecuted instantiation: ua_discovery.c:UA_NodePointer_init
Unexecuted instantiation: ua_nodestore_ziptree.c:UA_NodePointer_init
Unexecuted instantiation: fuzz_server_services.cc:UA_NodePointer_init(UA_NodePointer*)
Unexecuted instantiation: fuzz_tcp_message.cc:UA_NodePointer_init(UA_NodePointer*)
Unexecuted instantiation: fuzz_msg_message.cc:UA_NodePointer_init(UA_NodePointer*)
Unexecuted instantiation: fuzz_opn_message.cc:UA_NodePointer_init(UA_NodePointer*)
Unexecuted instantiation: fuzz_process_request.cc:UA_NodePointer_init(UA_NodePointer*)
Unexecuted instantiation: fuzz_binary_message.cc:UA_NodePointer_init(UA_NodePointer*)
143
144
/* NodeId and ExpandedNodeId targets are freed */
145
void UA_EXPORT
146
UA_NodePointer_clear(UA_NodePointer *np);
147
148
/* Makes a deep copy */
149
UA_StatusCode UA_EXPORT
150
UA_NodePointer_copy(UA_NodePointer in, UA_NodePointer *out);
151
152
/* Test if an ExpandedNodeId or a local NodeId */
153
UA_Boolean UA_EXPORT
154
UA_NodePointer_isLocal(UA_NodePointer np);
155
156
UA_Order UA_EXPORT
157
UA_NodePointer_order(UA_NodePointer p1, UA_NodePointer p2);
158
159
static UA_INLINE UA_Boolean
160
238M
UA_NodePointer_equal(UA_NodePointer p1, UA_NodePointer p2) {
161
238M
    return (UA_NodePointer_order(p1, p2) == UA_ORDER_EQ);
162
238M
}
Unexecuted instantiation: ua_session.c:UA_NodePointer_equal
ua_nodes.c:UA_NodePointer_equal
Line
Count
Source
160
23.4M
UA_NodePointer_equal(UA_NodePointer p1, UA_NodePointer p2) {
161
23.4M
    return (UA_NodePointer_order(p1, p2) == UA_ORDER_EQ);
162
23.4M
}
Unexecuted instantiation: ua_server.c:UA_NodePointer_equal
Unexecuted instantiation: ua_server_ns0.c:UA_NodePointer_equal
Unexecuted instantiation: ua_server_ns0_diagnostics.c:UA_NodePointer_equal
Unexecuted instantiation: ua_server_ns0_gds.c:UA_NodePointer_equal
Unexecuted instantiation: ua_server_config.c:UA_NodePointer_equal
Unexecuted instantiation: ua_server_binary.c:UA_NodePointer_equal
Unexecuted instantiation: ua_server_utils.c:UA_NodePointer_equal
Unexecuted instantiation: ua_server_async.c:UA_NodePointer_equal
Unexecuted instantiation: ua_subscription.c:UA_NodePointer_equal
Unexecuted instantiation: ua_subscription_datachange.c:UA_NodePointer_equal
Unexecuted instantiation: ua_subscription_event.c:UA_NodePointer_equal
Unexecuted instantiation: ua_subscription_alarms_conditions.c:UA_NodePointer_equal
Unexecuted instantiation: ua_services.c:UA_NodePointer_equal
ua_services_view.c:UA_NodePointer_equal
Line
Count
Source
160
214M
UA_NodePointer_equal(UA_NodePointer p1, UA_NodePointer p2) {
161
214M
    return (UA_NodePointer_order(p1, p2) == UA_ORDER_EQ);
162
214M
}
Unexecuted instantiation: ua_services_method.c:UA_NodePointer_equal
Unexecuted instantiation: ua_services_session.c:UA_NodePointer_equal
Unexecuted instantiation: ua_services_attribute.c:UA_NodePointer_equal
Unexecuted instantiation: ua_services_discovery.c:UA_NodePointer_equal
Unexecuted instantiation: ua_services_subscription.c:UA_NodePointer_equal
Unexecuted instantiation: ua_services_monitoreditem.c:UA_NodePointer_equal
Unexecuted instantiation: ua_services_securechannel.c:UA_NodePointer_equal
Unexecuted instantiation: ua_services_nodemanagement.c:UA_NodePointer_equal
Unexecuted instantiation: ua_pubsub_connection.c:UA_NodePointer_equal
Unexecuted instantiation: ua_pubsub_dataset.c:UA_NodePointer_equal
Unexecuted instantiation: ua_pubsub_writer.c:UA_NodePointer_equal
Unexecuted instantiation: ua_pubsub_writergroup.c:UA_NodePointer_equal
Unexecuted instantiation: ua_pubsub_reader.c:UA_NodePointer_equal
Unexecuted instantiation: ua_pubsub_readergroup.c:UA_NodePointer_equal
Unexecuted instantiation: ua_pubsub_manager.c:UA_NodePointer_equal
Unexecuted instantiation: ua_pubsub_ns0.c:UA_NodePointer_equal
Unexecuted instantiation: ua_pubsub_ns0_sks.c:UA_NodePointer_equal
Unexecuted instantiation: ua_discovery_mdns.c:UA_NodePointer_equal
Unexecuted instantiation: ua_discovery.c:UA_NodePointer_equal
Unexecuted instantiation: ua_nodestore_ziptree.c:UA_NodePointer_equal
Unexecuted instantiation: fuzz_server_services.cc:UA_NodePointer_equal(UA_NodePointer, UA_NodePointer)
Unexecuted instantiation: fuzz_tcp_message.cc:UA_NodePointer_equal(UA_NodePointer, UA_NodePointer)
Unexecuted instantiation: fuzz_msg_message.cc:UA_NodePointer_equal(UA_NodePointer, UA_NodePointer)
Unexecuted instantiation: fuzz_opn_message.cc:UA_NodePointer_equal(UA_NodePointer, UA_NodePointer)
Unexecuted instantiation: fuzz_process_request.cc:UA_NodePointer_equal(UA_NodePointer, UA_NodePointer)
Unexecuted instantiation: fuzz_binary_message.cc:UA_NodePointer_equal(UA_NodePointer, UA_NodePointer)
163
164
/* Cannot fail. The resulting NodePointer can point to the memory from the
165
 * NodeId. Make a deep copy if required. */
166
UA_NodePointer UA_EXPORT
167
UA_NodePointer_fromNodeId(const UA_NodeId *id);
168
169
/* Cannot fail. The resulting NodePointer can point to the memory from the
170
 * ExpandedNodeId. Make a deep copy if required. */
171
UA_NodePointer UA_EXPORT
172
UA_NodePointer_fromExpandedNodeId(const UA_ExpandedNodeId *id);
173
174
/* Can point to the memory from the NodePointer */
175
UA_ExpandedNodeId UA_EXPORT
176
UA_NodePointer_toExpandedNodeId(UA_NodePointer np);
177
178
/* Can point to the memory from the NodePointer. Discards the ServerIndex and
179
 * NamespaceUri of a potential ExpandedNodeId inside the NodePointer. Test
180
 * before if the NodePointer is local. */
181
UA_NodeId UA_EXPORT
182
UA_NodePointer_toNodeId(UA_NodePointer np);
183
184
/**
185
 * Base Node Attributes
186
 * --------------------
187
 * Nodes contain attributes according to their node type. The base node
188
 * attributes are common to all node types. In the OPC UA :ref:`services`,
189
 * attributes are referred to via the :ref:`nodeid` of the containing node and
190
 * an integer :ref:`attribute-id`.
191
 *
192
 * Internally, open62541 uses ``UA_Node`` in places where the exact node type is
193
 * not known or not important. The ``nodeClass`` attribute is used to ensure the
194
 * correctness of casting from ``UA_Node`` to a specific node type. */
195
196
typedef struct {
197
    UA_NodePointer targetId;  /* Has to be the first entry */
198
    UA_UInt32 targetNameHash; /* Hash of the target's BrowseName. Set to zero
199
                               * if the target is remote. */
200
} UA_ReferenceTarget;
201
202
typedef struct UA_ReferenceTargetTreeElem {
203
    UA_ReferenceTarget target;   /* Has to be the first entry */
204
    UA_UInt32 targetIdHash;      /* Hash of the targetId */
205
    struct {
206
        struct UA_ReferenceTargetTreeElem *left;
207
        struct UA_ReferenceTargetTreeElem *right;
208
    } idTreeEntry;
209
    struct {
210
        struct UA_ReferenceTargetTreeElem *left;
211
        struct UA_ReferenceTargetTreeElem *right;
212
    } nameTreeEntry;
213
} UA_ReferenceTargetTreeElem;
214
215
/* List of reference targets with the same reference type and direction. Uses
216
 * either an array or a tree structure. The SDK will not change the type of
217
 * reference target structure internally. The nodestore implementations may
218
 * switch internally when a node is updated.
219
 *
220
 * The recommendation is to switch to a tree once the number of refs > 8. */
221
typedef struct {
222
    union {
223
        /* Organize the references in an array. Uses less memory, but incurs
224
         * lookups in linear time. Recommended if the number of references is
225
         * known to be small. */
226
        UA_ReferenceTarget *array;
227
228
        /* Organize the references in a tree for fast lookup. Use
229
         * UA_Node_addReference and UA_Node_deleteReference to modify the
230
         * tree-structure. The binary tree implementation (and absolute ordering
231
         * / duplicate browseNames are allowed) are not exposed otherwise in the
232
         * public API. */
233
        struct {
234
            UA_ReferenceTargetTreeElem *idRoot;   /* Lookup based on target id */
235
            UA_ReferenceTargetTreeElem *nameRoot; /* Lookup based on browseName*/
236
        } tree;
237
    } targets;
238
    size_t targetsSize;
239
    UA_Boolean hasRefTree; /* RefTree or RefArray? */
240
    UA_Byte referenceTypeIndex;
241
    UA_Boolean isInverse;
242
} UA_NodeReferenceKind;
243
244
/* Iterate over the references. Aborts when the first callback return a non-NULL
245
 * pointer and returns that pointer. Do not modify the reference targets during
246
 * the iteration. */
247
typedef void *
248
(*UA_NodeReferenceKind_iterateCallback)(void *context, UA_ReferenceTarget *target);
249
250
UA_EXPORT void *
251
UA_NodeReferenceKind_iterate(UA_NodeReferenceKind *rk,
252
                             UA_NodeReferenceKind_iterateCallback callback,
253
                             void *context);
254
255
/* Returns the entry for the targetId or NULL if not found */
256
UA_EXPORT const UA_ReferenceTarget *
257
UA_NodeReferenceKind_findTarget(const UA_NodeReferenceKind *rk,
258
                                const UA_ExpandedNodeId *targetId);
259
260
/* Switch between array and tree representation. Does nothing upon error (e.g.
261
 * out-of-memory). */
262
UA_EXPORT UA_StatusCode
263
UA_NodeReferenceKind_switch(UA_NodeReferenceKind *rk);
264
265
/* Singly-linked LocalizedText list */
266
typedef struct UA_LocalizedTextListEntry {
267
    struct UA_LocalizedTextListEntry *next;
268
    UA_LocalizedText localizedText;
269
} UA_LocalizedTextListEntry;
270
271
/* Every Node starts with these attributes */
272
struct UA_NodeHead {
273
    UA_NodeId nodeId;
274
    UA_NodeClass nodeClass;
275
    UA_QualifiedName browseName;
276
277
    /* A node can have different localizations for displayName and description.
278
     * The server selects a suitable localization depending on the locale ids
279
     * that are set for the current session.
280
     *
281
     * Locales are added simply by writing a LocalizedText value with a new
282
     * locale. A locale can be removed by writing a LocalizedText value of the
283
     * corresponding locale with an empty text field. */
284
    UA_LocalizedTextListEntry *displayName;
285
    UA_LocalizedTextListEntry *description;
286
287
    UA_UInt32 writeMask;
288
    size_t referencesSize;
289
    UA_NodeReferenceKind *references;
290
291
    /* Members specific to open62541 */
292
    void *context;
293
    UA_Boolean constructed; /* Constructors were called */
294
#ifdef UA_ENABLE_SUBSCRIPTIONS
295
    UA_MonitoredItem *monitoredItems; /* MonitoredItems for Events and immediate
296
                                       * DataChanges (no sampling interval). */
297
#endif
298
};
299
300
/**
301
 * VariableNode
302
 * ------------ */
303
304
#define UA_NODE_VARIABLEATTRIBUTES                                      \
305
    /* Constraints on possible values */                                \
306
    UA_NodeId dataType;                                                 \
307
    UA_Int32 valueRank;                                                 \
308
    size_t arrayDimensionsSize;                                         \
309
    UA_UInt32 *arrayDimensions;                                         \
310
                                                                        \
311
    /* The current value */                                             \
312
    UA_ValueSourceType valueSourceType;                                 \
313
    union {                                                             \
314
        struct {                                                        \
315
            UA_DataValue value;                                         \
316
            UA_ValueSourceNotifications notifications;                  \
317
        } internal;                                                     \
318
        struct {                                                        \
319
            UA_DataValue **value; /* double-pointer */                  \
320
            UA_ValueSourceNotifications notifications;                  \
321
        } external;                                                     \
322
        UA_CallbackValueSource callback;                                \
323
    } valueSource;
324
325
typedef struct {
326
    UA_NodeHead head;
327
    UA_NODE_VARIABLEATTRIBUTES
328
    UA_Byte accessLevel;
329
    UA_Double minimumSamplingInterval;
330
    UA_Boolean historizing;
331
332
    /* Members specific to open62541 */
333
    UA_Boolean isDynamic; /* Some variables are "static" in the sense that they
334
                           * are not attached to a dynamic process in the
335
                           * background. Only dynamic variables conserve source
336
                           * and server timestamp for the value attribute.
337
                           * Static variables have timestamps of "now". */
338
} UA_VariableNode;
339
340
/**
341
 * VariableTypeNode
342
 * ---------------- */
343
344
typedef struct {
345
    UA_NodeHead head;
346
    UA_NODE_VARIABLEATTRIBUTES
347
    UA_Boolean isAbstract;
348
349
    /* Members specific to open62541 */
350
    UA_NodeTypeLifecycle lifecycle;
351
} UA_VariableTypeNode;
352
353
/**
354
 * MethodNode
355
 * ---------- */
356
357
typedef struct {
358
    UA_NodeHead head;
359
    UA_Boolean executable;
360
361
    /* Members specific to open62541 */
362
    UA_MethodCallback method;
363
} UA_MethodNode;
364
365
/**
366
 * ObjectNode
367
 * ---------- */
368
369
typedef struct {
370
    UA_NodeHead head;
371
    UA_Byte eventNotifier;
372
} UA_ObjectNode;
373
374
/**
375
 * ObjectTypeNode
376
 * -------------- */
377
378
typedef struct {
379
    UA_NodeHead head;
380
    UA_Boolean isAbstract;
381
382
    /* Members specific to open62541 */
383
    UA_NodeTypeLifecycle lifecycle;
384
} UA_ObjectTypeNode;
385
386
/**
387
 * ReferenceTypeNode
388
 * ----------------- */
389
390
typedef struct {
391
    UA_NodeHead head;
392
    UA_Boolean isAbstract;
393
    UA_Boolean symmetric;
394
    UA_LocalizedText inverseName;
395
396
    /* Members specific to open62541 */
397
    UA_Byte referenceTypeIndex;
398
    UA_ReferenceTypeSet subTypes; /* contains the type itself as well */
399
} UA_ReferenceTypeNode;
400
401
/**
402
 * DataTypeNode
403
 * ------------ */
404
405
typedef struct {
406
    UA_NodeHead head;
407
    UA_Boolean isAbstract;
408
} UA_DataTypeNode;
409
410
/**
411
 * ViewNode
412
 * -------- */
413
414
typedef struct {
415
    UA_NodeHead head;
416
    UA_Byte eventNotifier;
417
    UA_Boolean containsNoLoops;
418
} UA_ViewNode;
419
420
/**
421
 * Node Union
422
 * ----------
423
 * A union that represents any kind of node. The node head can always be used.
424
 * Check the NodeClass before accessing specific content.
425
 */
426
427
typedef union {
428
    UA_NodeHead head;
429
    UA_VariableNode variableNode;
430
    UA_VariableTypeNode variableTypeNode;
431
    UA_MethodNode methodNode;
432
    UA_ObjectNode objectNode;
433
    UA_ObjectTypeNode objectTypeNode;
434
    UA_ReferenceTypeNode referenceTypeNode;
435
    UA_DataTypeNode dataTypeNode;
436
    UA_ViewNode viewNode;
437
} UA_Node;
438
439
/**
440
 * Nodestore
441
 * ---------
442
 * The following structurere defines the interaction between the server and
443
 * Nodestore backends. */
444
445
typedef void (*UA_NodestoreVisitor)(void *visitorCtx, const UA_Node *node);
446
447
struct UA_Nodestore {
448
    /* Nodestore context and lifecycle */
449
    void (*free)(UA_Nodestore *ns);
450
451
    /* The following definitions are used to create empty nodes of the different
452
     * node types. The memory is managed by the nodestore. Therefore, the node
453
     * has to be removed via a special deleteNode function. (If the new node is
454
     * not added to the nodestore.) */
455
    UA_Node * (*newNode)(UA_Nodestore *ns, UA_NodeClass nodeClass);
456
457
    void (*deleteNode)(UA_Nodestore *ns, UA_Node *node);
458
459
    /* _getNode returns a pointer to an immutable node. Call _releaseNode to
460
     * indicate when the pointer is no longer accessed.
461
     *
462
     * It can be indicated if only a subset of the attributes and referencs need
463
     * to be accessed. That is relevant when the nodestore accesses a slow
464
     * storage backend for the attributes. The attribute mask is a bitfield with
465
     * ORed entries from UA_NodeAttributesMask. If the attributes mask is empty,
466
     * then only the non-standard entries (context-pointer, callbacks, etc.) are
467
     * returned.
468
     *
469
     * The returned node always contains the context-pointer and other fields
470
     * specific to open626541 (not official attributes).
471
     *
472
     * The NodeStore does not complain if attributes and references that don't
473
     * exist (for that node) are requested. Attributes and references in
474
     * addition to those specified can be returned. For example, if the full
475
     * node already is kept in memory by the Nodestore. */
476
    const UA_Node * (*getNode)(UA_Nodestore *ns, const UA_NodeId *nodeId,
477
                               UA_UInt32 attributeMask,
478
                               UA_ReferenceTypeSet references,
479
                               UA_BrowseDirection referenceDirections);
480
481
    /* Similar to the normal _getNode. But it can take advantage of the
482
     * NodePointer structure, e.g. if it contains a direct pointer. */
483
    const UA_Node * (*getNodeFromPtr)(UA_Nodestore *ns, UA_NodePointer ptr,
484
                                      UA_UInt32 attributeMask,
485
                                      UA_ReferenceTypeSet references,
486
                                      UA_BrowseDirection referenceDirections);
487
488
    /* _getEditNode returns a pointer to a mutable version of the node. A
489
     * plugin implementation that keeps all nodes in RAM can return the same
490
     * pointer from _getNode and _getEditNode. The differences are more
491
     * important if, for example, nodes are stored in a backend database. Then
492
     * the _getEditNode version is used to indicate that modifications are
493
     * being made.
494
     *
495
     * Call _releaseNode to indicate when editing is done and the pointer is
496
     * no longer used. Note that changes are not (necessarily) visible in other
497
     * (const) node-pointers that were previously retrieved. Changes are however
498
     * visible in all newly retrieved node-pointers for the given NodeId after
499
     * calling _releaseNode.
500
     *
501
     * The attribute-mask and reference-description indicate if only a subset of
502
     * the attributes and referencs are to be modified. Other attributes and
503
     * references shall not be changed. */
504
    UA_Node * (*getEditNode)(UA_Nodestore *ns, const UA_NodeId *nodeId,
505
                             UA_UInt32 attributeMask,
506
                             UA_ReferenceTypeSet references,
507
                             UA_BrowseDirection referenceDirections);
508
509
    /* Similar to _getEditNode. But it can take advantage of the NodePointer
510
     * structure, e.g. if it contains a direct pointer. */
511
    UA_Node * (*getEditNodeFromPtr)(UA_Nodestore *ns, UA_NodePointer ptr,
512
                                    UA_UInt32 attributeMask,
513
                                    UA_ReferenceTypeSet references,
514
                                    UA_BrowseDirection referenceDirections);
515
516
    /* Release a node that has been retrieved with ``getNode`` or
517
     * ``getNodeFromPtr``. */
518
    void (*releaseNode)(UA_Nodestore *ns, const UA_Node *node);
519
520
    /* Returns an editable copy of the same logical node (needs to be deleted
521
     * with the deleteNode function or inserted / replaced into the nodestore).
522
     * Runtime state such as MonitoredItem associations is not copied. A
523
     * successful replacement must move that state from the old node to the
524
     * replacement with UA_Node_moveMonitoredItems. */
525
    UA_StatusCode (*getNodeCopy)(UA_Nodestore *ns, const UA_NodeId *nodeId,
526
                                 UA_Node **outNode);
527
528
    /* Inserts a new node into the nodestore. If the NodeId is zero, then a
529
     * fresh numeric NodeId is assigned. If insertion fails, the node is
530
     * deleted. */
531
    UA_StatusCode (*insertNode)(UA_Nodestore *ns, UA_Node *node,
532
                                UA_NodeId *addedNodeId);
533
534
    /* To replace a node, get an editable copy of the node, edit and replace
535
     * with this function. If the node was already replaced since the copy was
536
     * made, UA_STATUSCODE_BADINTERNALERROR is returned. If the NodeId is not
537
     * found, UA_STATUSCODE_BADNODEIDUNKNOWN is returned. In both error cases,
538
     * the editable node is deleted. */
539
    UA_StatusCode (*replaceNode)(UA_Nodestore *ns, UA_Node *node);
540
541
    /* Removes a node from the nodestore. */
542
    UA_StatusCode (*removeNode)(UA_Nodestore *ns, const UA_NodeId *nodeId);
543
544
    /* Maps the ReferenceTypeIndex used for the references to the NodeId of the
545
     * ReferenceType. The returned pointer is stable until the Nodestore is
546
     * deleted. */
547
    const UA_NodeId * (*getReferenceTypeId)(UA_Nodestore *ns,
548
                                            UA_Byte refTypeIndex);
549
550
    /* Execute a callback for every node in the nodestore. */
551
    void (*iterate)(UA_Nodestore *ns, UA_NodestoreVisitor visitor,
552
                    void *visitorCtx);
553
};
554
555
/* Attributes must be of a matching type (VariableAttributes, ObjectAttributes,
556
 * and so on). The attributes are copied. Note that the attributes structs do
557
 * not contain NodeId, NodeClass and BrowseName. The NodeClass of the node needs
558
 * to be correctly set before calling this method. This method does not call
559
 * UA_Node_clear internally when an error is encountered. */
560
UA_StatusCode UA_EXPORT
561
UA_Node_setAttributes(UA_Node *node, const void *attributes,
562
                      const UA_DataType *attributeType);
563
564
/* Nodes can carry multiples locales for DisplayName and Description. The
565
 * following inserts a new locales or updates an existing one with new text. */
566
UA_EXPORT UA_StatusCode
567
UA_Node_insertOrUpdateDisplayName(UA_Node *node,
568
                                  const UA_LocalizedText *displayName);
569
570
UA_EXPORT UA_StatusCode
571
UA_Node_insertOrUpdateDescription(UA_Node *node,
572
                                  const UA_LocalizedText *description);
573
574
/* Reset the destination node and copy the content of the source. Runtime
575
 * MonitoredItem associations are not copied. */
576
UA_StatusCode UA_EXPORT
577
UA_Node_copy(const UA_Node *src, UA_Node *dst);
578
579
/* Move the runtime MonitoredItem associations from a node to its replacement.
580
 * The destination must not have MonitoredItems attached. This is a no-op if
581
 * source and destination are the same node. */
582
UA_EXPORT void
583
UA_Node_moveMonitoredItems(UA_Node *src, UA_Node *dst);
584
585
/* Allocate new node and copy the values from src */
586
UA_EXPORT UA_Node *
587
UA_Node_copy_alloc(const UA_Node *src);
588
589
/* Add a single reference to the node */
590
UA_StatusCode UA_EXPORT
591
UA_Node_addReference(UA_Node *node, UA_Byte refTypeIndex, UA_Boolean isForward,
592
                     const UA_ExpandedNodeId *targetNodeId,
593
                     UA_UInt32 targetBrowseNameHash);
594
595
/* Delete a single reference from the node */
596
UA_StatusCode UA_EXPORT
597
UA_Node_deleteReference(UA_Node *node, UA_Byte refTypeIndex, UA_Boolean isForward,
598
                        const UA_ExpandedNodeId *targetNodeId);
599
600
/* Deletes references from the node which are not matching any type in the given
601
 * array. Could be used to e.g. delete all the references, except
602
 * 'HASMODELINGRULE' */
603
void UA_EXPORT
604
UA_Node_deleteReferencesSubset(UA_Node *node, const UA_ReferenceTypeSet *keepSet);
605
606
/* Delete all references of the node */
607
void UA_EXPORT
608
UA_Node_deleteReferences(UA_Node *node);
609
610
/* Remove all malloc'ed members of the node and reset */
611
void UA_EXPORT
612
UA_Node_clear(UA_Node *node);
613
614
_UA_END_DECLS
615
616
#endif /* UA_NODESTORE_H_ */