blob: 9458541388cc4448e5647c380f5c374861b33b9b [file] [log] [blame]
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001/**
2 * @file tree_schema.h
3 * @author Radek Krejci <rkrejci@cesnet.cz>
4 * @brief libyang representation of YANG schema trees.
5 *
6 * Copyright (c) 2015 - 2018 CESNET, z.s.p.o.
7 *
8 * This source code is licensed under BSD 3-Clause License (the "License").
9 * You may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * https://opensource.org/licenses/BSD-3-Clause
13 */
14
15#ifndef LY_TREE_SCHEMA_H_
16#define LY_TREE_SCHEMA_H_
17
Radek Krejci54579462019-04-30 12:47:06 +020018#define PCRE2_CODE_UNIT_WIDTH 8
19
20#include <pcre2.h>
Radek Krejci535ea9f2020-05-29 16:01:05 +020021
Radek Krejci5aeea3a2018-09-05 13:29:36 +020022#include <stdint.h>
Radek Krejcid3ca0632019-04-16 16:54:54 +020023#include <stdio.h>
Radek Krejci5aeea3a2018-09-05 13:29:36 +020024
Radek Krejcie7b95092019-05-15 11:03:07 +020025#include "log.h"
26#include "tree.h"
Radek Krejcice8c1592018-10-29 15:35:51 +010027
Radek Krejci70853c52018-10-15 14:46:16 +020028#ifdef __cplusplus
29extern "C" {
30#endif
31
Radek Krejcica376bd2020-06-11 16:04:06 +020032struct ly_ctx;
Radek Krejci47fab892020-11-05 17:02:41 +010033struct ly_path;
Radek Krejcica376bd2020-06-11 16:04:06 +020034struct ly_set;
Radek Krejci47fab892020-11-05 17:02:41 +010035struct lys_module;
36struct lysc_node;
37struct lyxp_expr;
Radek Krejcica376bd2020-06-11 16:04:06 +020038
Radek Krejci5aeea3a2018-09-05 13:29:36 +020039/**
Radek Krejci8678fa42020-08-18 16:07:28 +020040 * @page howtoSchema YANG Modules
41 *
42 * To be able to work with YANG data instances, libyang has to represent YANG data models. All the processed modules are stored
43 * in libyang [context](@ref howtoContext) and loaded using [parser functions](@ref howtoSchemaParsers). It means, that there is
44 * no way to create/change YANG module programmatically. However, all the YANG model definitions are available and can be examined
45 * through the C structures. All the context's modules together form YANG Schema for the data being instantiated.
46 *
47 * Any YANG module is represented as ::lys_module. In fact, the module is represented in two different formats. As ::lys_module.parsed,
48 * there is a parsed schema reflecting the source YANG module. It is exactly what is read from the input. This format is good for
49 * converting from one format to another (YANG to YIN and vice versa), but it is not very useful for validating/manipulating YANG
50 * data. Therefore, there is ::lys_module.compiled storing the compiled YANG module. It is based on the parsed module, but all the
51 * references are resolved. It means that, for example, there are no `grouping`s or `typedef`s since they are supposed to be placed instead of
52 * `uses` or `type` references. This split also means, that the YANG module is fully validated after compilation of the parsed
53 * representation of the module. YANG submodules are available only in the parsed representation. When a submodule is compiled, it
54 * is fully integrated into its main module.
55 *
56 * The context can contain even modules without the compiled representation. Such modules are still useful as imports of other
57 * modules. The grouping or typedef definition can be even compiled into the importing modules. This is actually the main
58 * difference between the imported and implemented modules in the libyang context. The implemented modules are compiled while the
59 * imported modules are only parsed.
60 *
Radek Krejcib100b192020-10-26 08:37:45 +010061 * By default, the module is implemented (and compiled) in case it is explicitly loaded or referenced in another module as
62 * target of leafref, augment or deviation. This behavior can be changed via context options ::LY_CTX_ALL_IMPLEMENTED, when
63 * all the modules in the context are marked as implemented (note the problem with multiple revisions of a single module),
64 * or by ::LY_CTX_REF_IMPLEMENTED option, extending the set of references making the module implemented by when, must and
65 * default statements.
Radek Krejci8678fa42020-08-18 16:07:28 +020066 *
67 * All modules with deviation definition are always marked as implemented. The imported (not implemented) module can be set implemented by ::lys_set_implemented(). But
68 * the implemented module cannot be changed back to just imported module. Note also that only one revision of a specific module
69 * can be implemented in a single context. The imported modules are used only as a
70 * source of definitions for types and groupings for uses statements. The data in such modules are ignored - caller
71 * is not allowed to create the data (including instantiating identities) defined in the model via data parsers,
72 * the default nodes are not added into any data tree and mandatory nodes are not checked in the data trees.
73 *
74 * The compiled schema tree nodes are able to hold private objects (::lysc_node.priv as a pointer to a structure, function, variable, ...) used by
75 * a caller application. Such an object can be assigned to a specific node using ::lysc_set_private() function.
76 * Note that the object is not freed by libyang when the context is being destroyed. So the caller is responsible
77 * for freeing the provided structure after the context is destroyed or the private pointer is set to NULL in
78 * appropriate schema nodes where the object was previously set. This can be automated via destructor function
79 * to free these private objects. The destructor is passed to the ::ly_ctx_destroy() function.
80 *
81 * Despite all the schema structures and their members are available as part of the libyang API and callers can use
82 * it to navigate through the schema tree structure or to obtain various information, we recommend to use the following
83 * macros for the specific actions.
84 * - ::LYSC_TREE_DFS_BEGIN and ::LYSC_TREE_DFS_END to traverse the schema tree (depth-first).
85 * - ::LY_LIST_FOR and ::LY_ARRAY_FOR as described on @ref howtoStructures page.
86 *
87 * Further information about modules handling can be found on the following pages:
88 * - @subpage howtoSchemaParsers
89 * - @subpage howtoSchemaFeatures
90 * - @subpage howtoPlugins
91 * - @subpage howtoSchemaPrinters
92 *
93 * \note There are many functions to access information from the schema trees. Details are available in
94 * the [Schema Tree module](@ref schematree).
95 *
96 * For information about difference between implemented and imported modules, see the
97 * [context description](@ref howtoContext).
98 *
99 * Functions List (not assigned to above subsections)
100 * --------------------------------------------------
101 * - ::lys_getnext()
102 * - ::lys_nodetype2str()
103 * - ::lys_set_implemented()
104 * - ::lys_value_validate()
105 *
106 * - ::lysc_set_private()
107 *
108 * - ::lysc_node_children()
Michal Vasko208a04a2020-10-21 15:17:12 +0200109 * - ::lysc_node_children_full()
110 * - ::lysc_node_parent_full()
Radek Krejci8678fa42020-08-18 16:07:28 +0200111 * - ::lysc_node_actions()
112 * - ::lysc_node_notifs()
113 *
114 * - ::lysp_node_children()
115 * - ::lysp_node_actions()
116 * - ::lysp_node_notifs()
117 * - ::lysp_node_groupings()
118 * - ::lysp_node_typedefs()
119 */
120
121/**
122 * @page howtoSchemaFeatures YANG Features
123 *
Michal Vasko7b1ad1a2020-11-02 15:41:27 +0100124 * YANG feature statement is an important part of the language which can significantly affect the meaning of the schemas.
125 * Modifying features may have similar effects as loading/removing schema from the context so it is limited to context
126 * preparation period before working with data. YANG features, respectively their use in if-feature
127 * statements, are evaluated as part of schema compilation so a feature-specific compiled schema tree is generated
128 * as a result.
Radek Krejci8678fa42020-08-18 16:07:28 +0200129 *
Michal Vasko7b1ad1a2020-11-02 15:41:27 +0100130 * To enable any features, they must currently be specified when implementing a new schema with ::lys_parse() or
131 * ::ly_ctx_load_module(). To later examine what the status of a feature is, check its ::LYS_FENABLED flag or
132 * search for it first with ::lys_feature_value(). Lastly, to evaluate compiled if-features, use ::lysc_iffeature_value().
Radek Krejci8678fa42020-08-18 16:07:28 +0200133 *
Michal Vasko7b1ad1a2020-11-02 15:41:27 +0100134 * To iterate over all features of a particular YANG module, use ::lysp_feature_next().
Radek Krejci8678fa42020-08-18 16:07:28 +0200135 *
136 * Note, that the feature's state can affect some of the output formats (e.g. Tree format).
137 *
138 * Functions List
139 * --------------
Radek Krejci8678fa42020-08-18 16:07:28 +0200140 * - ::lys_feature_value()
Radek Krejci8678fa42020-08-18 16:07:28 +0200141 * - ::lysc_iffeature_value()
Michal Vasko7b1ad1a2020-11-02 15:41:27 +0100142 * - ::lysp_feature_next()
Radek Krejci8678fa42020-08-18 16:07:28 +0200143 */
144
145/**
Radek Krejci2ff0d572020-05-21 15:27:28 +0200146 * @ingroup trees
Radek Krejci8678fa42020-08-18 16:07:28 +0200147 * @defgroup schematree Schema Tree
Radek Krejci2ff0d572020-05-21 15:27:28 +0200148 * @{
149 *
150 * Data structures and functions to manipulate and access schema tree.
151 */
152
Michal Vasko64246d82020-08-19 12:35:00 +0200153/* *INDENT-OFF* */
154
Radek Krejci2ff0d572020-05-21 15:27:28 +0200155/**
Michal Vasko208a04a2020-10-21 15:17:12 +0200156 * @brief Macro to iterate via all elements in a schema (sub)tree including input and output.
157 * Note that __actions__ and __notifications__ of traversed nodes __are ignored__! To traverse
158 * on all the nodes including those, use ::lysc_tree_dfs_full() instead.
159 *
160 * This is the opening part to the #LYSC_TREE_DFS_END - they always have to be used together.
Radek Krejci0935f412019-08-20 16:15:18 +0200161 *
162 * The function follows deep-first search algorithm:
163 * <pre>
164 * 1
165 * / \
166 * 2 4
167 * / / \
168 * 3 5 6
169 * </pre>
170 *
171 * Use the same parameters for #LYSC_TREE_DFS_BEGIN and #LYSC_TREE_DFS_END. While
172 * START can be any of the lysc_node* types (including lysc_action and lysc_notif),
173 * ELEM variable must be of the struct lysc_node* type.
174 *
175 * To skip a particular subtree, instead of the continue statement, set LYSC_TREE_DFS_continue
176 * variable to non-zero value.
177 *
178 * Use with opening curly bracket '{' after the macro.
179 *
180 * @param START Pointer to the starting element processed first.
181 * @param ELEM Iterator intended for use in the block.
182 */
183#define LYSC_TREE_DFS_BEGIN(START, ELEM) \
Radek Krejci857189e2020-09-01 13:26:36 +0200184 { ly_bool LYSC_TREE_DFS_continue = 0; struct lysc_node *LYSC_TREE_DFS_next; \
Michal Vasko1c9e79f2020-08-10 11:08:03 +0200185 for ((ELEM) = (LYSC_TREE_DFS_next) = (struct lysc_node*)(START); \
Radek Krejci0935f412019-08-20 16:15:18 +0200186 (ELEM); \
187 (ELEM) = (LYSC_TREE_DFS_next), LYSC_TREE_DFS_continue = 0)
188
189/**
190 * @brief Macro to iterate via all elements in a (sub)tree. This is the closing part
191 * to the #LYSC_TREE_DFS_BEGIN - they always have to be used together.
192 *
193 * Use the same parameters for #LYSC_TREE_DFS_BEGIN and #LYSC_TREE_DFS_END. While
194 * START can be a pointer to any of the lysc_node* types (including lysc_action and lysc_notif),
195 * ELEM variable must be pointer to the lysc_node type.
196 *
197 * Use with closing curly bracket '}' after the macro.
198 *
199 * @param START Pointer to the starting element processed first.
200 * @param ELEM Iterator intended for use in the block.
201 */
Radek Krejci0935f412019-08-20 16:15:18 +0200202#define LYSC_TREE_DFS_END(START, ELEM) \
203 /* select element for the next run - children first */ \
204 if (LYSC_TREE_DFS_continue) { \
205 (LYSC_TREE_DFS_next) = NULL; \
206 } else { \
Michal Vasko208a04a2020-10-21 15:17:12 +0200207 (LYSC_TREE_DFS_next) = (struct lysc_node *)lysc_node_children_full(ELEM, 0); \
208 } \
Radek Krejci0935f412019-08-20 16:15:18 +0200209 if (!(LYSC_TREE_DFS_next)) { \
Michal Vasko208a04a2020-10-21 15:17:12 +0200210 /* no children, try siblings */ \
211 _LYSC_TREE_DFS_NEXT(START, ELEM, LYSC_TREE_DFS_next); \
Radek Krejci0935f412019-08-20 16:15:18 +0200212 } \
213 while (!(LYSC_TREE_DFS_next)) { \
214 /* parent is already processed, go to its sibling */ \
Michal Vasko208a04a2020-10-21 15:17:12 +0200215 (ELEM) = (struct lysc_node *)lysc_node_parent_full(ELEM); \
216 _LYSC_TREE_DFS_NEXT(START, ELEM, LYSC_TREE_DFS_next); \
217 } }
218
219/**
220 * @brief Helper macro for #LYSC_TREE_DFS_END, should not be used directly!
221 */
222#define _LYSC_TREE_DFS_NEXT(START, ELEM, NEXT) \
223 if ((ELEM) == (struct lysc_node *)(START)) { \
224 /* we are done, no next element to process */ \
225 break; \
226 } \
227 if ((ELEM)->nodetype == LYS_INPUT) { \
228 /* after input, get output */ \
229 (NEXT) = (struct lysc_node *)lysc_node_children_full(lysc_node_parent_full(ELEM), LYS_CONFIG_R); \
230 } else if ((ELEM)->nodetype == LYS_OUTPUT) { \
231 /* no sibling of output */ \
232 (NEXT) = NULL; \
233 } else { \
234 (NEXT) = (ELEM)->next; \
235 }
Radek Krejci0935f412019-08-20 16:15:18 +0200236
Michal Vasko64246d82020-08-19 12:35:00 +0200237/* *INDENT-ON* */
238
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200239#define LY_REV_SIZE 11 /**< revision data string length (including terminating NULL byte) */
240
Michal Vasko7f45cf22020-10-01 12:49:44 +0200241#define LYS_UNKNOWN 0x0000 /**< uninitalized unknown statement node */
242#define LYS_CONTAINER 0x0001 /**< container statement node */
243#define LYS_CHOICE 0x0002 /**< choice statement node */
244#define LYS_LEAF 0x0004 /**< leaf statement node */
245#define LYS_LEAFLIST 0x0008 /**< leaf-list statement node */
246#define LYS_LIST 0x0010 /**< list statement node */
247#define LYS_ANYXML 0x0020 /**< anyxml statement node */
248#define LYS_ANYDATA 0x0060 /**< anydata statement node, in tests it can be used for both #LYS_ANYXML and #LYS_ANYDATA */
249#define LYS_CASE 0x0080 /**< case statement node */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200250
Michal Vasko7f45cf22020-10-01 12:49:44 +0200251#define LYS_RPC 0x0100 /**< RPC statement node */
252#define LYS_ACTION 0x0200 /**< action statement node */
253#define LYS_NOTIF 0x0400 /**< notification statement node */
Radek Krejcie7b95092019-05-15 11:03:07 +0200254
Michal Vasko7f45cf22020-10-01 12:49:44 +0200255#define LYS_USES 0x0800 /**< uses statement node */
256#define LYS_INPUT 0x1000 /**< RPC/action input node */
257#define LYS_OUTPUT 0x2000 /**< RPC/action output node */
258#define LYS_GROUPING 0x4000
259#define LYS_AUGMENT 0x8000
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100260
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200261/**
Radek Krejcid6b76452019-09-03 17:03:03 +0200262 * @brief List of YANG statements
263 */
264enum ly_stmt {
265 LY_STMT_NONE = 0,
Radek Krejci8678fa42020-08-18 16:07:28 +0200266 LY_STMT_STATUS, /**< in ::lysc_ext_substmt.storage stored as a pointer to `uint16_t`, only cardinality < #LY_STMT_CARD_SOME is allowed */
267 LY_STMT_CONFIG, /**< in ::lysc_ext_substmt.storage stored as a pointer to `uint16_t`, only cardinality < #LY_STMT_CARD_SOME is allowed */
Radek Krejci335332a2019-09-05 13:03:35 +0200268 LY_STMT_MANDATORY,
Radek Krejci8678fa42020-08-18 16:07:28 +0200269 LY_STMT_UNITS, /**< in ::lysc_ext_substmt.storage stored as a pointer to `const char *` (cardinality < #LY_STMT_CARD_SOME)
Radek Krejciad5963b2019-09-06 16:03:05 +0200270 or as a pointer to a [sized array](@ref sizedarrays) `const char **` */
Radek Krejci335332a2019-09-05 13:03:35 +0200271 LY_STMT_DEFAULT,
Radek Krejci8678fa42020-08-18 16:07:28 +0200272 LY_STMT_TYPE, /**< in ::lysc_ext_substmt.storage stored as a pointer to `struct lysc_type *` (cardinality < #LY_STMT_CARD_SOME)
Radek Krejciad5963b2019-09-06 16:03:05 +0200273 or as a pointer to a [sized array](@ref sizedarrays) `struct lysc_type **` */
Radek Krejci335332a2019-09-05 13:03:35 +0200274
Radek Krejcid6b76452019-09-03 17:03:03 +0200275 LY_STMT_ACTION,
276 LY_STMT_ANYDATA,
277 LY_STMT_ANYXML,
278 LY_STMT_ARGUMENT,
279 LY_STMT_AUGMENT,
280 LY_STMT_BASE,
281 LY_STMT_BELONGS_TO,
282 LY_STMT_BIT,
283 LY_STMT_CASE,
284 LY_STMT_CHOICE,
Radek Krejcid6b76452019-09-03 17:03:03 +0200285 LY_STMT_CONTACT,
286 LY_STMT_CONTAINER,
Radek Krejcid6b76452019-09-03 17:03:03 +0200287 LY_STMT_DESCRIPTION,
288 LY_STMT_DEVIATE,
289 LY_STMT_DEVIATION,
290 LY_STMT_ENUM,
291 LY_STMT_ERROR_APP_TAG,
292 LY_STMT_ERROR_MESSAGE,
293 LY_STMT_EXTENSION,
294 LY_STMT_FEATURE,
295 LY_STMT_FRACTION_DIGITS,
296 LY_STMT_GROUPING,
297 LY_STMT_IDENTITY,
Radek Krejci8678fa42020-08-18 16:07:28 +0200298 LY_STMT_IF_FEATURE, /**< in ::lysc_ext_substmt.storage stored as a pointer to `struct lysc_iffeature` (cardinality < #LY_STMT_CARD_SOME)
Radek Krejciad5963b2019-09-06 16:03:05 +0200299 or as a pointer to a [sized array](@ref sizedarrays) `struct lysc_iffeature *` */
Radek Krejcid6b76452019-09-03 17:03:03 +0200300 LY_STMT_IMPORT,
301 LY_STMT_INCLUDE,
302 LY_STMT_INPUT,
303 LY_STMT_KEY,
304 LY_STMT_LEAF,
305 LY_STMT_LEAF_LIST,
306 LY_STMT_LENGTH,
307 LY_STMT_LIST,
Radek Krejcid6b76452019-09-03 17:03:03 +0200308 LY_STMT_MAX_ELEMENTS,
309 LY_STMT_MIN_ELEMENTS,
310 LY_STMT_MODIFIER,
311 LY_STMT_MODULE,
312 LY_STMT_MUST,
313 LY_STMT_NAMESPACE,
314 LY_STMT_NOTIFICATION,
315 LY_STMT_ORDERED_BY,
316 LY_STMT_ORGANIZATION,
317 LY_STMT_OUTPUT,
318 LY_STMT_PATH,
319 LY_STMT_PATTERN,
320 LY_STMT_POSITION,
321 LY_STMT_PREFIX,
322 LY_STMT_PRESENCE,
323 LY_STMT_RANGE,
324 LY_STMT_REFERENCE,
325 LY_STMT_REFINE,
326 LY_STMT_REQUIRE_INSTANCE,
327 LY_STMT_REVISION,
328 LY_STMT_REVISION_DATE,
329 LY_STMT_RPC,
Radek Krejcid6b76452019-09-03 17:03:03 +0200330 LY_STMT_SUBMODULE,
Radek Krejcid6b76452019-09-03 17:03:03 +0200331 LY_STMT_TYPEDEF,
332 LY_STMT_UNIQUE,
Radek Krejcid6b76452019-09-03 17:03:03 +0200333 LY_STMT_USES,
334 LY_STMT_VALUE,
335 LY_STMT_WHEN,
336 LY_STMT_YANG_VERSION,
337 LY_STMT_YIN_ELEMENT,
338 LY_STMT_EXTENSION_INSTANCE,
339
340 LY_STMT_SYNTAX_SEMICOLON,
341 LY_STMT_SYNTAX_LEFT_BRACE,
342 LY_STMT_SYNTAX_RIGHT_BRACE,
343
344 LY_STMT_ARG_TEXT,
345 LY_STMT_ARG_VALUE
346};
347
348/**
Radek Krejci0e59c312019-08-15 15:34:15 +0200349 * @brief Extension instance structure parent enumeration
350 */
351typedef enum {
Radek Krejci0935f412019-08-20 16:15:18 +0200352 LYEXT_PAR_MODULE, /**< ::lysc_module */
353 LYEXT_PAR_NODE, /**< ::lysc_node (and the derived structures including ::lysc_action and ::lysc_notif) */
354 LYEXT_PAR_INPUT, /**< ::lysc_action_inout */
355 LYEXT_PAR_OUTPUT, /**< ::lysc_action_inout */
356 LYEXT_PAR_TYPE, /**< ::lysc_type */
357 LYEXT_PAR_TYPE_BIT, /**< ::lysc_type_bitenum_item */
358 LYEXT_PAR_TYPE_ENUM, /**< ::lysc_type_bitenum_item */
Radek Krejci0935f412019-08-20 16:15:18 +0200359 LYEXT_PAR_MUST, /**< ::lysc_must */
360 LYEXT_PAR_PATTERN, /**< ::lysc_pattern */
361 LYEXT_PAR_LENGTH, /**< ::lysc_range */
362 LYEXT_PAR_RANGE, /**< ::lysc_range */
363 LYEXT_PAR_WHEN, /**< ::lysc_when */
364 LYEXT_PAR_IDENT, /**< ::lysc_ident */
365 LYEXT_PAR_EXT, /**< ::lysc_ext */
Michal Vasko69730152020-10-09 16:30:07 +0200366 LYEXT_PAR_IMPORT /**< ::lysp_import */
Michal Vasko033278d2020-08-24 11:24:52 +0200367// LYEXT_PAR_TPDF, /**< ::lysp_tpdf */
368// LYEXT_PAR_EXTINST, /**< ::lysp_ext_instance */
369// LYEXT_PAR_REFINE, /**< ::lysp_refine */
370// LYEXT_PAR_DEVIATION, /**< ::lysp_deviation */
371// LYEXT_PAR_DEVIATE, /**< ::lysp_deviate */
372// LYEXT_PAR_INCLUDE, /**< ::lysp_include */
373// LYEXT_PAR_REVISION, /**< ::lysp_revision */
Radek Krejci0e59c312019-08-15 15:34:15 +0200374} LYEXT_PARENT;
375
376/**
Radek Krejci0935f412019-08-20 16:15:18 +0200377 * @brief Stringify extension instance parent type.
378 * @param[in] type Parent type to stringify.
379 * @return Constant string with the name of the parent statement.
380 */
381const char *lyext_parent2str(LYEXT_PARENT type);
382
383/**
Radek Krejci0e59c312019-08-15 15:34:15 +0200384 * @brief Enum of substatements in which extension instances can appear.
385 */
386typedef enum {
387 LYEXT_SUBSTMT_SELF = 0, /**< extension of the structure itself, not substatement's */
388 LYEXT_SUBSTMT_ARGUMENT, /**< extension of the argument statement, can appear in lys_ext */
389 LYEXT_SUBSTMT_BASE, /**< extension of the base statement, can appear (repeatedly) in lys_type and lys_ident */
390 LYEXT_SUBSTMT_BELONGSTO, /**< extension of the belongs-to statement, can appear in lys_submodule */
391 LYEXT_SUBSTMT_CONTACT, /**< extension of the contact statement, can appear in lys_module */
392 LYEXT_SUBSTMT_DEFAULT, /**< extension of the default statement, can appear in lys_node_leaf, lys_node_leaflist,
393 lys_node_choice and lys_deviate */
394 LYEXT_SUBSTMT_DESCRIPTION, /**< extension of the description statement, can appear in lys_module, lys_submodule,
395 lys_node, lys_import, lys_include, lys_ext, lys_feature, lys_tpdf, lys_restr,
396 lys_ident, lys_deviation, lys_type_enum, lys_type_bit, lys_when and lys_revision */
397 LYEXT_SUBSTMT_ERRTAG, /**< extension of the error-app-tag statement, can appear in lys_restr */
398 LYEXT_SUBSTMT_ERRMSG, /**< extension of the error-message statement, can appear in lys_restr */
399 LYEXT_SUBSTMT_KEY, /**< extension of the key statement, can appear in lys_node_list */
400 LYEXT_SUBSTMT_NAMESPACE, /**< extension of the namespace statement, can appear in lys_module */
401 LYEXT_SUBSTMT_ORGANIZATION, /**< extension of the organization statement, can appear in lys_module and lys_submodule */
402 LYEXT_SUBSTMT_PATH, /**< extension of the path statement, can appear in lys_type */
403 LYEXT_SUBSTMT_PREFIX, /**< extension of the prefix statement, can appear in lys_module, lys_submodule (for
404 belongs-to's prefix) and lys_import */
405 LYEXT_SUBSTMT_PRESENCE, /**< extension of the presence statement, can appear in lys_node_container */
406 LYEXT_SUBSTMT_REFERENCE, /**< extension of the reference statement, can appear in lys_module, lys_submodule,
407 lys_node, lys_import, lys_include, lys_revision, lys_tpdf, lys_restr, lys_ident,
408 lys_ext, lys_feature, lys_deviation, lys_type_enum, lys_type_bit and lys_when */
409 LYEXT_SUBSTMT_REVISIONDATE, /**< extension of the revision-date statement, can appear in lys_import and lys_include */
410 LYEXT_SUBSTMT_UNITS, /**< extension of the units statement, can appear in lys_tpdf, lys_node_leaf,
411 lys_node_leaflist and lys_deviate */
412 LYEXT_SUBSTMT_VALUE, /**< extension of the value statement, can appear in lys_type_enum */
413 LYEXT_SUBSTMT_VERSION, /**< extension of the yang-version statement, can appear in lys_module and lys_submodule */
414 LYEXT_SUBSTMT_MODIFIER, /**< extension of the modifier statement, can appear in lys_restr */
415 LYEXT_SUBSTMT_REQINSTANCE, /**< extension of the require-instance statement, can appear in lys_type */
416 LYEXT_SUBSTMT_YINELEM, /**< extension of the yin-element statement, can appear in lys_ext */
417 LYEXT_SUBSTMT_CONFIG, /**< extension of the config statement, can appear in lys_node and lys_deviate */
418 LYEXT_SUBSTMT_MANDATORY, /**< extension of the mandatory statement, can appear in lys_node_leaf, lys_node_choice,
419 lys_node_anydata and lys_deviate */
420 LYEXT_SUBSTMT_ORDEREDBY, /**< extension of the ordered-by statement, can appear in lys_node_list and lys_node_leaflist */
421 LYEXT_SUBSTMT_STATUS, /**< extension of the status statement, can appear in lys_tpdf, lys_node, lys_ident,
422 lys_ext, lys_feature, lys_type_enum and lys_type_bit */
423 LYEXT_SUBSTMT_FRACDIGITS, /**< extension of the fraction-digits statement, can appear in lys_type */
424 LYEXT_SUBSTMT_MAX, /**< extension of the max-elements statement, can appear in lys_node_list,
425 lys_node_leaflist and lys_deviate */
426 LYEXT_SUBSTMT_MIN, /**< extension of the min-elements statement, can appear in lys_node_list,
427 lys_node_leaflist and lys_deviate */
428 LYEXT_SUBSTMT_POSITION, /**< extension of the position statement, can appear in lys_type_bit */
429 LYEXT_SUBSTMT_UNIQUE, /**< extension of the unique statement, can appear in lys_node_list and lys_deviate */
Michal Vasko69730152020-10-09 16:30:07 +0200430 LYEXT_SUBSTMT_IFFEATURE /**< extension of the if-feature statement */
Radek Krejci0e59c312019-08-15 15:34:15 +0200431} LYEXT_SUBSTMT;
432
433/**
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200434 * @brief YANG import-stmt
435 */
436struct lysp_import {
Radek Krejci086c7132018-10-26 15:29:04 +0200437 struct lys_module *module; /**< pointer to the imported module
438 (mandatory, but resolved when the referring module is completely parsed) */
439 const char *name; /**< name of the imported module (mandatory) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200440 const char *prefix; /**< prefix for the data from the imported schema (mandatory) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200441 const char *dsc; /**< description */
442 const char *ref; /**< reference */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200443 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vasko3e9bc2f2020-11-04 17:13:56 +0100444 uint16_t flags; /**< LYS_INTERNAL value (@ref snodeflags) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200445 char rev[LY_REV_SIZE]; /**< revision-date of the imported module */
446};
447
448/**
449 * @brief YANG include-stmt
450 */
451struct lysp_include {
Radek Krejci0bcdaed2019-01-10 10:21:34 +0100452 struct lysp_submodule *submodule;/**< pointer to the parsed submodule structure
Radek Krejci086c7132018-10-26 15:29:04 +0200453 (mandatory, but resolved when the referring module is completely parsed) */
454 const char *name; /**< name of the included submodule (mandatory) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200455 const char *dsc; /**< description */
456 const char *ref; /**< reference */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200457 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200458 char rev[LY_REV_SIZE]; /**< revision-date of the included submodule */
459};
460
461/**
462 * @brief YANG extension-stmt
463 */
464struct lysp_ext {
465 const char *name; /**< extension name */
466 const char *argument; /**< argument name, NULL if not specified */
467 const char *dsc; /**< description statement */
468 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200469 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcif56e2a42019-09-09 14:15:25 +0200470 uint16_t flags; /**< LYS_STATUS_* and LYS_YINELEM_* values (@ref snodeflags) */
Michal Vasko5fe75f12020-03-02 13:52:37 +0100471
472 struct lysc_ext *compiled; /**< pointer to the compiled extension definition */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200473};
474
475/**
476 * @brief Helper structure for generic storage of the extension instances content.
477 */
478struct lysp_stmt {
479 const char *stmt; /**< identifier of the statement */
480 const char *arg; /**< statement's argument */
481 struct lysp_stmt *next; /**< link to the next statement */
Michal Vaskobc2559f2018-09-07 10:17:50 +0200482 struct lysp_stmt *child; /**< list of the statement's substatements (linked list) */
David Sedlákb9d75c42019-08-14 10:49:42 +0200483 uint16_t flags; /**< statement flags, can be set to LYS_YIN_ATTR */
Radek Krejci335332a2019-09-05 13:03:35 +0200484 enum ly_stmt kw; /**< numeric respresentation of the stmt value */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200485};
486
David Sedlákae4b4512019-08-14 10:45:56 +0200487#define LYS_YIN 0x1 /**< used to specify input format of extension instance */
488
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200489/**
490 * @brief YANG extension instance
491 */
492struct lysp_ext_instance {
David Sedlákbbd06ca2019-06-27 14:15:38 +0200493 const char *name; /**< extension identifier, including possible prefix */
494 const char *argument; /**< optional value of the extension's argument */
Radek Krejci335332a2019-09-05 13:03:35 +0200495 void *parent; /**< pointer to the parent element holding the extension instance(s), use
496 ::lysp_ext_instance#parent_type to access the schema element */
David Sedlákbbd06ca2019-06-27 14:15:38 +0200497 struct lysp_stmt *child; /**< list of the extension's substatements (linked list) */
Radek Krejcif56e2a42019-09-09 14:15:25 +0200498 struct lysc_ext_instance *compiled; /**< pointer to the compiled data if any - in case the source format is YIN,
499 some of the information (argument) are available only after compilation */
David Sedlákbbd06ca2019-06-27 14:15:38 +0200500 LYEXT_SUBSTMT insubstmt; /**< value identifying placement of the extension instance */
Michal Vaskofd69e1d2020-07-03 11:57:17 +0200501 LY_ARRAY_COUNT_TYPE insubstmt_index; /**< in case the instance is in a substatement, this identifies
David Sedlákbbd06ca2019-06-27 14:15:38 +0200502 the index of that substatement */
Michal Vasko3e9bc2f2020-11-04 17:13:56 +0100503 uint16_t flags; /**< LYS_INTERNAL value (@ref snodeflags) */
504 uint8_t yin; /**< flag for YIN source format, can be set to LYS_YIN */
Radek Krejci335332a2019-09-05 13:03:35 +0200505 LYEXT_PARENT parent_type; /**< type of the parent structure */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200506};
507
508/**
509 * @brief YANG feature-stmt
510 */
511struct lysp_feature {
512 const char *name; /**< feature name (mandatory) */
Michal Vasko7b1ad1a2020-11-02 15:41:27 +0100513 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
514 struct lysc_iffeature *iffeatures_c; /**< compiled if-features */
515 struct lysp_feature **depfeatures; /**< list of pointers to other features depending on this one
516 ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200517 const char *dsc; /**< description statement */
518 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200519 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vasko7b1ad1a2020-11-02 15:41:27 +0100520 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values and
521 LYS_FENABLED are allowed */
522};
523
524/**
525 * @brief Compiled YANG if-feature-stmt
526 */
527struct lysc_iffeature {
528 uint8_t *expr; /**< 2bits array describing the if-feature expression in prefix format, see @ref ifftokens */
529 struct lysp_feature **features; /**< array of pointers to the features used in expression ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200530};
531
532/**
Michal Vasko7f45cf22020-10-01 12:49:44 +0200533 * @brief Qualified name (optional prefix followed by an identifier).
534 */
535struct lysp_qname {
536 const char *str; /**< qualified name string */
Michal Vasko5d24f6c2020-10-13 13:49:06 +0200537 const struct lysp_module *mod; /**< module to resolve any prefixes found in the string, it must be
Michal Vasko7f45cf22020-10-01 12:49:44 +0200538 stored explicitly because of deviations/refines */
539};
540
541/**
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200542 * @brief YANG identity-stmt
543 */
544struct lysp_ident {
545 const char *name; /**< identity name (mandatory), including possible prefix */
Michal Vasko7f45cf22020-10-01 12:49:44 +0200546 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejci151a5b72018-10-19 14:21:44 +0200547 const char **bases; /**< list of base identifiers ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200548 const char *dsc; /**< description statement */
549 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200550 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200551 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ values are allowed */
552};
553
Michal Vasko71e64ca2018-09-07 16:30:29 +0200554/**
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200555 * @brief Covers restrictions: range, length, pattern, must
556 */
557struct lysp_restr {
Michal Vasko7f45cf22020-10-01 12:49:44 +0200558 struct lysp_qname arg; /**< The restriction expression/value (mandatory);
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200559 in case of pattern restriction, the first byte has a special meaning:
560 0x06 (ACK) for regular match and 0x15 (NACK) for invert-match */
561 const char *emsg; /**< error-message */
562 const char *eapptag; /**< error-app-tag value */
563 const char *dsc; /**< description */
564 const char *ref; /**< reference */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200565 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200566};
567
568/**
Michal Vasko71e64ca2018-09-07 16:30:29 +0200569 * @brief YANG revision-stmt
570 */
571struct lysp_revision {
Radek Krejcib7db73a2018-10-24 14:18:40 +0200572 char date[LY_REV_SIZE]; /**< revision date (madatory) */
Michal Vasko71e64ca2018-09-07 16:30:29 +0200573 const char *dsc; /**< description statement */
574 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200575 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vasko71e64ca2018-09-07 16:30:29 +0200576};
577
578/**
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200579 * @brief Enumeration/Bit value definition
580 */
581struct lysp_type_enum {
582 const char *name; /**< name (mandatory) */
583 const char *dsc; /**< description statement */
584 const char *ref; /**< reference statement */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200585 int64_t value; /**< enum's value or bit's position */
Michal Vasko7f45cf22020-10-01 12:49:44 +0200586 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200587 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200588 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ and LYS_SET_VALUE
589 values are allowed */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200590};
591
592/**
593 * @brief YANG type-stmt
594 *
595 * Some of the items in the structure may be mandatory, but it is necessary to resolve the type's base type first
596 */
597struct lysp_type {
598 const char *name; /**< name of the type (mandatory) */
599 struct lysp_restr *range; /**< allowed values range - numerical, decimal64 */
600 struct lysp_restr *length; /**< allowed length of the value - string, binary */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200601 struct lysp_restr *patterns; /**< list of patterns ([sized array](@ref sizedarrays)) - string */
602 struct lysp_type_enum *enums; /**< list of enum-stmts ([sized array](@ref sizedarrays)) - enum */
603 struct lysp_type_enum *bits; /**< list of bit-stmts ([sized array](@ref sizedarrays)) - bits */
Michal Vasko004d3152020-06-11 19:59:22 +0200604 struct lyxp_expr *path; /**< parsed path - leafref */
Radek Krejci151a5b72018-10-19 14:21:44 +0200605 const char **bases; /**< list of base identifiers ([sized array](@ref sizedarrays)) - identityref */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200606 struct lysp_type *types; /**< list of sub-types ([sized array](@ref sizedarrays)) - union */
607 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200608
Michal Vasko5d24f6c2020-10-13 13:49:06 +0200609 const struct lysp_module *pmod; /**< (sub)module where the type is defined (needed for deviations) */
Radek Krejci2167ee12018-11-02 16:09:07 +0100610 struct lysc_type *compiled; /**< pointer to the compiled type */
611
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200612 uint8_t fraction_digits; /**< number of fraction digits - decimal64 */
613 uint8_t require_instance; /**< require-instance flag - leafref, instance */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100614 uint16_t flags; /**< [schema node flags](@ref spnodeflags) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200615};
616
617/**
618 * @brief YANG typedef-stmt
619 */
620struct lysp_tpdf {
621 const char *name; /**< name of the newly defined type (mandatory) */
622 const char *units; /**< units of the newly defined type */
Michal Vasko7f45cf22020-10-01 12:49:44 +0200623 struct lysp_qname dflt; /**< default value of the newly defined type, it may or may not be a qualified name */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200624 const char *dsc; /**< description statement */
625 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200626 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200627 struct lysp_type type; /**< base type from which the typedef is derived (mandatory) */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100628 uint16_t flags; /**< [schema node flags](@ref spnodeflags) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200629};
630
631/**
632 * @brief YANG grouping-stmt
633 */
634struct lysp_grp {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100635 struct lysp_node *parent; /**< parent node (NULL if this is a top-level grouping) */
636 uint16_t nodetype; /**< LYS_GROUPING */
637 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200638 const char *name; /**< grouping name (mandatory) */
639 const char *dsc; /**< description statement */
640 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200641 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
642 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200643 struct lysp_node *data; /**< list of data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200644 struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
645 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
646 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200647};
648
649/**
650 * @brief YANG when-stmt
651 */
652struct lysp_when {
653 const char *cond; /**< specified condition (mandatory) */
654 const char *dsc; /**< description statement */
655 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200656 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200657};
658
659/**
660 * @brief YANG refine-stmt
661 */
662struct lysp_refine {
663 const char *nodeid; /**< target descendant schema nodeid (mandatory) */
664 const char *dsc; /**< description statement */
665 const char *ref; /**< reference statement */
Michal Vasko7f45cf22020-10-01 12:49:44 +0200666 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200667 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200668 const char *presence; /**< presence description */
Michal Vasko5d24f6c2020-10-13 13:49:06 +0200669 struct lysp_qname *dflts; /**< list of default values ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200670 uint32_t min; /**< min-elements constraint */
671 uint32_t max; /**< max-elements constraint, 0 means unbounded */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200672 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200673 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
674};
675
676/**
Michal Vasko82a83432019-11-14 12:33:04 +0100677 * @brief YANG uses-augment-stmt and augment-stmt (compatible with struct lysp_node )
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200678 */
679struct lysp_augment {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100680 struct lysp_node *parent; /**< parent node (NULL if this is a top-level augment) */
681 uint16_t nodetype; /**< LYS_AUGMENT */
682 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */
Michal Vasko82a83432019-11-14 12:33:04 +0100683 struct lysp_node *child; /**< list of data nodes (linked list) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200684 const char *nodeid; /**< target schema nodeid (mandatory) - absolute for global augments, descendant for uses's augments */
685 const char *dsc; /**< description statement */
686 const char *ref; /**< reference statement */
687 struct lysp_when *when; /**< when statement */
Michal Vasko7f45cf22020-10-01 12:49:44 +0200688 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Michal Vasko82a83432019-11-14 12:33:04 +0100689 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200690 struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
691 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200692};
693
694/**
Radek Krejci8678fa42020-08-18 16:07:28 +0200695 * @ingroup schematree
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200696 * @defgroup deviatetypes Deviate types
Radek Krejci8678fa42020-08-18 16:07:28 +0200697 *
698 * Type of the deviate operation (used as ::lysp_deviate.mod)
699 *
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200700 * @{
701 */
702#define LYS_DEV_NOT_SUPPORTED 1 /**< deviate type not-supported */
703#define LYS_DEV_ADD 2 /**< deviate type add */
704#define LYS_DEV_DELETE 3 /**< deviate type delete */
705#define LYS_DEV_REPLACE 4 /**< deviate type replace */
Radek Krejci2ff0d572020-05-21 15:27:28 +0200706/** @} deviatetypes */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200707
708/**
709 * @brief Generic deviate structure to get type and cast to lysp_deviate_* structure
710 */
711struct lysp_deviate {
712 uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */
713 struct lysp_deviate *next; /**< next deviate structure in the list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200714 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200715};
716
717struct lysp_deviate_add {
718 uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */
719 struct lysp_deviate *next; /**< next deviate structure in the list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200720 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200721 const char *units; /**< units of the values */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200722 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Michal Vasko5d24f6c2020-10-13 13:49:06 +0200723 struct lysp_qname *uniques; /**< list of uniques specifications ([sized array](@ref sizedarrays)) */
724 struct lysp_qname *dflts; /**< list of default values ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200725 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
726 uint32_t min; /**< min-elements constraint */
727 uint32_t max; /**< max-elements constraint, 0 means unbounded */
728};
729
730struct lysp_deviate_del {
731 uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */
732 struct lysp_deviate *next; /**< next deviate structure in the list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200733 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200734 const char *units; /**< units of the values */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200735 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Michal Vasko5d24f6c2020-10-13 13:49:06 +0200736 struct lysp_qname *uniques; /**< list of uniques specifications ([sized array](@ref sizedarrays)) */
737 struct lysp_qname *dflts; /**< list of default values ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200738};
739
740struct lysp_deviate_rpl {
741 uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */
742 struct lysp_deviate *next; /**< next deviate structure in the list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200743 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200744 struct lysp_type *type; /**< type of the node */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200745 const char *units; /**< units of the values */
Michal Vasko5d24f6c2020-10-13 13:49:06 +0200746 struct lysp_qname dflt; /**< default value */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200747 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
748 uint32_t min; /**< min-elements constraint */
749 uint32_t max; /**< max-elements constraint, 0 means unbounded */
750};
751
752struct lysp_deviation {
Michal Vaskob55f6c12018-09-12 11:13:15 +0200753 const char *nodeid; /**< target absolute schema nodeid (mandatory) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200754 const char *dsc; /**< description statement */
755 const char *ref; /**< reference statement */
Michal Vasko22df3f02020-08-24 13:29:22 +0200756 struct lysp_deviate *deviates; /**< list of deviate specifications (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200757 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200758};
759
Radek Krejci4f28eda2018-11-12 11:46:16 +0100760/**
Radek Krejci4f28eda2018-11-12 11:46:16 +0100761 * @ingroup snodeflags
Radek Krejci8678fa42020-08-18 16:07:28 +0200762 * @defgroup spnodeflags Parsed schema nodes flags
Radek Krejci4f28eda2018-11-12 11:46:16 +0100763 *
Radek Krejci8678fa42020-08-18 16:07:28 +0200764 * Various flags for parsed schema nodes (used as ::lysp_node.flags).
Radek Krejci4f28eda2018-11-12 11:46:16 +0100765 *
766 * 1 - container 6 - anydata/anyxml 11 - output 16 - grouping 21 - enum
767 * 2 - choice 7 - case 12 - feature 17 - uses 22 - type
Radek Krejcid3ca0632019-04-16 16:54:54 +0200768 * 3 - leaf 8 - notification 13 - identity 18 - refine 23 - stmt
Radek Krejci4f28eda2018-11-12 11:46:16 +0100769 * 4 - leaflist 9 - rpc 14 - extension 19 - augment
770 * 5 - list 10 - input 15 - typedef 20 - deviate
771 *
Radek Krejcid3ca0632019-04-16 16:54:54 +0200772 * 1 1 1 1 1 1 1 1 1 1 2 2 2 2
773 * bit name 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
774 * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Michal Vasko5297a432020-08-31 12:27:51 +0200775 * 1 LYS_CONFIG_W |x|x|x|x|x|x| | | | | | | | | | | |x| |x| | | |
Radek Krejcid3ca0632019-04-16 16:54:54 +0200776 * LYS_SET_BASE | | | | | | | | | | | | | | | | | | | | | |x| |
777 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Michal Vasko5297a432020-08-31 12:27:51 +0200778 * 2 LYS_CONFIG_R |x|x|x|x|x|x| | | | | | | | | | | |x| |x| | | |
Radek Krejcid3ca0632019-04-16 16:54:54 +0200779 * LYS_SET_BIT | | | | | | | | | | | | | | | | | | | | | |x| |
780 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
781 * 3 LYS_STATUS_CURR |x|x|x|x|x|x|x|x|x| | |x|x|x|x|x|x| |x|x|x| | |
782 * LYS_SET_ENUM | | | | | | | | | | | | | | | | | | | | | |x| |
783 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
784 * 4 LYS_STATUS_DEPRC |x|x|x|x|x|x|x|x|x| | |x|x|x|x|x|x| |x|x|x| | |
785 * LYS_SET_FRDIGITS | | | | | | | | | | | | | | | | | | | | | |x| |
786 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
787 * 5 LYS_STATUS_OBSLT |x|x|x|x|x|x|x|x|x| | |x|x|x|x|x|x| |x|x|x| | |
788 * LYS_SET_LENGTH | | | | | | | | | | | | | | | | | | | | | |x| |
789 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
790 * 6 LYS_MAND_TRUE | |x|x| | |x| | | | | | | | | | | |x| |x| | | |
791 * LYS_SET_PATH | | | | | | | | | | | | | | | | | | | | | |x| |
Michal Vasko7b1ad1a2020-11-02 15:41:27 +0100792 * LYS_FENABLED | | | | | | | | | | | |x| | | | | | | | | | | |
Radek Krejcid3ca0632019-04-16 16:54:54 +0200793 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
794 * 7 LYS_MAND_FALSE | |x|x| | |x| | | | | | | | | | | |x| |x| | | |
795 * LYS_ORDBY_USER | | | |x|x| | | | | | | | | | | | | | | | | | |
796 * LYS_SET_PATTERN | | | | | | | | | | | | | | | | | | | | | |x| |
797 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
798 * 8 LYS_ORDBY_SYSTEM | | | |x|x| | | | | | | | | | | | | | | | | | |
799 * LYS_YINELEM_TRUE | | | | | | | | | | | | | |x| | | | | | | | | |
800 * LYS_SET_RANGE | | | | | | | | | | | | | | | | | | | | | |x| |
801 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
802 * 9 LYS_YINELEM_FALSE| | | | | | | | | | | | | |x| | | | | | | | | |
803 * LYS_SET_TYPE | | | | | | | | | | | | | | | | | | | | | |x| |
804 * LYS_SINGLEQUOTED | | | | | | | | | | | | | | | | | | | | | | |x|
805 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
806 * 10 LYS_SET_VALUE | | | | | | | | | | | | | | | | | | | | |x| | |
807 * LYS_SET_REQINST | | | | | | | | | | | | | | | | | | | | | |x| |
808 * LYS_SET_MIN | | | |x|x| | | | | | | | | | | | |x| |x| | | |
809 * LYS_DOUBLEQUOTED | | | | | | | | | | | | | | | | | | | | | | |x|
810 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
811 * 11 LYS_SET_MAX | | | |x|x| | | | | | | | | | | | |x| |x| | | |
Radek Krejcif2de0ed2019-05-02 14:13:18 +0200812 * LYS_USED_GRP | | | | | | | | | | | | | | | |x| | | | | | | |
David Sedlákae4b4512019-08-14 10:45:56 +0200813 * LYS_YIN_ATTR | | | | | | | | | | | | | | | | | | | | | | |x|
Michal Vasko5297a432020-08-31 12:27:51 +0200814 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
815 * 12 LYS_YIN_ARGUMENT | | | | | | | | | | | | | | | | | | | | | | |x|
Michal Vasko3e9bc2f2020-11-04 17:13:56 +0100816 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
817 * 13 LYS_INTERNAL |x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|
Radek Krejcif56e2a42019-09-09 14:15:25 +0200818 * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Radek Krejci4f28eda2018-11-12 11:46:16 +0100819 *
820 */
821
822/**
Radek Krejci4f28eda2018-11-12 11:46:16 +0100823 * @ingroup snodeflags
Radek Krejci8678fa42020-08-18 16:07:28 +0200824 * @defgroup scnodeflags Compiled schema nodes flags
Radek Krejci4f28eda2018-11-12 11:46:16 +0100825 *
Radek Krejci8678fa42020-08-18 16:07:28 +0200826 * Various flags for compiled schema nodes (used as ::lysc_node.flags).
Radek Krejci4f28eda2018-11-12 11:46:16 +0100827 *
Radek Krejci61e042e2019-09-10 15:53:09 +0200828 * 1 - container 6 - anydata/anyxml 11 - identity
829 * 2 - choice 7 - case 12 - extension
830 * 3 - leaf 8 - notification 13 - bitenum
Michal Vasko03ff5a72019-09-11 13:49:33 +0200831 * 4 - leaflist 9 - rpc/action 14 - when
Michal Vaskoecd62de2019-11-13 12:35:11 +0100832 * 5 - list 10 - feature
Radek Krejci4f28eda2018-11-12 11:46:16 +0100833 *
Michal Vaskoecd62de2019-11-13 12:35:11 +0100834 * 1 1 1 1 1
835 * bit name 1 2 3 4 5 6 7 8 9 0 1 2 3 4
836 * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
837 * 1 LYS_CONFIG_W |x|x|x|x|x|x|x| | | | | | | |
838 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+
839 * 2 LYS_CONFIG_R |x|x|x|x|x|x|x| | | | | | | |
840 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+
841 * 3 LYS_STATUS_CURR |x|x|x|x|x|x|x|x|x|x|x|x| |x|
842 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+
843 * 4 LYS_STATUS_DEPRC |x|x|x|x|x|x|x|x|x|x|x|x| |x|
844 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+
845 * 5 LYS_STATUS_OBSLT |x|x|x|x|x|x|x|x|x|x|x|x| |x|
846 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+
847 * 6 LYS_MAND_TRUE |x|x|x|x|x|x| | | | | | | | |
848 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+
849 * 7 LYS_ORDBY_USER | | | |x|x| | | | | | | | | |
850 * LYS_MAND_FALSE | |x|x| | |x| | | | | | | | |
851 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+
852 * 8 LYS_ORDBY_SYSTEM | | | |x|x| | | | | | | | | |
853 * LYS_PRESENCE |x| | | | | | | | | | | | | |
854 * LYS_UNIQUE | | |x| | | | | | | | | | | |
855 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+
856 * 9 LYS_KEY | | |x| | | | | | | | | | | |
Michal Vaskoecd62de2019-11-13 12:35:11 +0100857 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+
858 * 10 LYS_SET_DFLT | | |x|x| | |x| | | | | | | |
859 * LYS_ISENUM | | | | | | | | | | | | |x| |
860 * LYS_KEYLESS | | | | |x| | | | | | | | | |
861 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+
862 * 11 LYS_SET_UNITS | | |x|x| | | | | | | | | | |
863 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+
864 * 12 LYS_SET_CONFIG |x|x|x|x|x|x| | | | | | | | |
865 * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Radek Krejci4f28eda2018-11-12 11:46:16 +0100866 *
867 */
868
869/**
870 * @defgroup snodeflags Schema nodes flags
Radek Krejci8678fa42020-08-18 16:07:28 +0200871 *
872 * Various flags for schema nodes ([parsed](@ref spnodeflags) as well as [compiled](@ref scnodeflags)).
873 *
Radek Krejci4f28eda2018-11-12 11:46:16 +0100874 * @{
875 */
Michal Vasko1bf09392020-03-27 12:38:10 +0100876#define LYS_CONFIG_W 0x01 /**< config true; also set for input children nodes */
877#define LYS_CONFIG_R 0x02 /**< config false; also set for output and notification children nodes */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200878#define LYS_CONFIG_MASK 0x03 /**< mask for config value */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100879#define LYS_STATUS_CURR 0x04 /**< status current; */
880#define LYS_STATUS_DEPRC 0x08 /**< status deprecated; */
881#define LYS_STATUS_OBSLT 0x10 /**< status obsolete; */
882#define LYS_STATUS_MASK 0x1C /**< mask for status value */
883#define LYS_MAND_TRUE 0x20 /**< mandatory true; applicable only to ::lysp_node_choice/::lysc_node_choice,
Radek Krejcife909632019-02-12 15:34:42 +0100884 ::lysp_node_leaf/::lysc_node_leaf and ::lysp_node_anydata/::lysc_node_anydata.
885 The ::lysc_node_leaflist and ::lysc_node_leaflist have this flag in case that min-elements > 0.
886 The ::lysc_node_container has this flag if it is not a presence container and it has at least one
887 child with LYS_MAND_TRUE. */
Radek Krejcif1421c22019-02-19 13:05:20 +0100888#define LYS_MAND_FALSE 0x40 /**< mandatory false; applicable only to ::lysp_node_choice/::lysc_node_choice,
889 ::lysp_node_leaf/::lysc_node_leaf and ::lysp_node_anydata/::lysc_node_anydata.
890 This flag is present only in case the mandatory false statement was explicitly specified. */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100891#define LYS_MAND_MASK 0x60 /**< mask for mandatory values */
Michal Vaskoc118ae22020-08-06 14:51:09 +0200892#define LYS_PRESENCE 0x80 /**< flag for presence property of a container, but it is not only for explicit presence
893 containers, but also for NP containers with some meaning, applicable only to
894 ::lysc_node_container */
Radek Krejci7adf4ff2018-12-05 08:55:00 +0100895#define LYS_UNIQUE 0x80 /**< flag for leafs being part of a unique set, applicable only to ::lysc_node_leaf */
896#define LYS_KEY 0x100 /**< flag for leafs being a key of a list, applicable only to ::lysc_node_leaf */
Radek Krejci0fe9b512019-07-26 17:51:05 +0200897#define LYS_KEYLESS 0x200 /**< flag for list without any key, applicable only to ::lysc_node_list */
Michal Vasko7b1ad1a2020-11-02 15:41:27 +0100898#define LYS_FENABLED 0x20 /**< feature enabled flag, applicable only to ::lysp_feature. */
Radek Krejcife909632019-02-12 15:34:42 +0100899#define LYS_ORDBY_SYSTEM 0x80 /**< ordered-by user lists, applicable only to ::lysc_node_leaflist/::lysp_node_leaflist and
Radek Krejci4f28eda2018-11-12 11:46:16 +0100900 ::lysc_node_list/::lysp_node_list */
901#define LYS_ORDBY_USER 0x40 /**< ordered-by user lists, applicable only to ::lysc_node_leaflist/::lysp_node_leaflist and
902 ::lysc_node_list/::lysp_node_list */
903#define LYS_ORDBY_MASK 0x60 /**< mask for ordered-by values */
904#define LYS_YINELEM_TRUE 0x80 /**< yin-element true for extension's argument */
905#define LYS_YINELEM_FALSE 0x100 /**< yin-element false for extension's argument */
906#define LYS_YINELEM_MASK 0x180 /**< mask for yin-element value */
Radek Krejcif2de0ed2019-05-02 14:13:18 +0200907#define LYS_USED_GRP 0x400 /**< internal flag for validating not-instantiated groupings
908 (resp. do not validate again the instantiated groupings). */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100909#define LYS_SET_VALUE 0x200 /**< value attribute is set */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100910#define LYS_SET_MIN 0x200 /**< min attribute is set */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200911#define LYS_SET_MAX 0x400 /**< max attribute is set */
Radek Krejcid505e3d2018-11-13 09:04:17 +0100912
913#define LYS_SET_BASE 0x0001 /**< type's flag for present base substatement */
914#define LYS_SET_BIT 0x0002 /**< type's flag for present bit substatement */
915#define LYS_SET_ENUM 0x0004 /**< type's flag for present enum substatement */
916#define LYS_SET_FRDIGITS 0x0008 /**< type's flag for present fraction-digits substatement */
917#define LYS_SET_LENGTH 0x0010 /**< type's flag for present length substatement */
918#define LYS_SET_PATH 0x0020 /**< type's flag for present path substatement */
919#define LYS_SET_PATTERN 0x0040 /**< type's flag for present pattern substatement */
920#define LYS_SET_RANGE 0x0080 /**< type's flag for present range substatement */
921#define LYS_SET_TYPE 0x0100 /**< type's flag for present type substatement */
922#define LYS_SET_REQINST 0x0200 /**< type's flag for present require-instance substatement */
Radek Krejciccd20f12019-02-15 14:12:27 +0100923#define LYS_SET_DFLT 0x0200 /**< flag to mark leaf/leaflist with own (or refined) default value, not a default value taken from its type, and default
Radek Krejci76b3e962018-12-14 17:01:25 +0100924 cases of choice. This information is important for refines, since it is prohibited to make leafs
925 with default statement mandatory. In case the default leaf value is taken from type, it is thrown
Radek Krejciccd20f12019-02-15 14:12:27 +0100926 away when it is refined to be mandatory node. Similarly it is used for deviations to distinguish
927 between own default or the default values taken from the type. */
928#define LYS_SET_UNITS 0x0400 /**< flag to know if the leaf's/leaflist's units are their own (flag set) or it is taken from the type. */
Radek Krejcif1421c22019-02-19 13:05:20 +0100929#define LYS_SET_CONFIG 0x0800 /**< flag to know if the config property was set explicitly (flag set) or it is inherited. */
Radek Krejci0e5d8382018-11-28 16:37:53 +0100930
Radek Krejcif56e2a42019-09-09 14:15:25 +0200931#define LYS_SINGLEQUOTED 0x100 /**< flag for single-quoted argument of an extension instance's substatement, only when the source is YANG */
932#define LYS_DOUBLEQUOTED 0x200 /**< flag for double-quoted argument of an extension instance's substatement, only when the source is YANG */
Radek Krejcid3ca0632019-04-16 16:54:54 +0200933
Radek Krejcif56e2a42019-09-09 14:15:25 +0200934#define LYS_YIN_ATTR 0x400 /**< flag to identify YIN attribute parsed as extension's substatement, only when the source is YIN */
935#define LYS_YIN_ARGUMENT 0x800 /**< flag to identify statement representing extension's argument, only when the source is YIN */
David Sedlákbbd06ca2019-06-27 14:15:38 +0200936
Michal Vasko3e9bc2f2020-11-04 17:13:56 +0100937#define LYS_INTERNAL 0x1000 /**< flag to identify internal parsed statements that should not be printed */
938
Radek Krejci693262f2019-04-29 15:23:20 +0200939#define LYS_ISENUM 0x200 /**< flag to simply distinguish type in struct lysc_type_bitenum_item */
940
Radek Krejcife909632019-02-12 15:34:42 +0100941#define LYS_FLAGS_COMPILED_MASK 0xff /**< mask for flags that maps to the compiled structures */
Radek Krejci2ff0d572020-05-21 15:27:28 +0200942/** @} snodeflags */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200943
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200944/**
945 * @brief Generic YANG data node
946 */
947struct lysp_node {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100948 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200949 uint16_t nodetype; /**< type of the node (mandatory) */
950 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100951 struct lysp_node *next; /**< next sibling node (NULL if there is no one) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200952 const char *name; /**< node name (mandatory) */
953 const char *dsc; /**< description statement */
954 const char *ref; /**< reference statement */
955 struct lysp_when *when; /**< when statement */
Michal Vasko7f45cf22020-10-01 12:49:44 +0200956 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)),
957 must be qname because of refines */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200958 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200959};
960
961/**
962 * @brief Extension structure of the lysp_node for YANG container
963 */
964struct lysp_node_container {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100965 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200966 uint16_t nodetype; /**< LYS_CONTAINER */
967 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
968 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
969 const char *name; /**< node name (mandatory) */
970 const char *dsc; /**< description statement */
971 const char *ref; /**< reference statement */
972 struct lysp_when *when; /**< when statement */
Michal Vasko7f45cf22020-10-01 12:49:44 +0200973 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200974 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200975
976 /* container */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200977 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200978 const char *presence; /**< presence description */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200979 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
980 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200981 struct lysp_node *child; /**< list of data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200982 struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
983 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200984};
985
986struct lysp_node_leaf {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100987 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200988 uint16_t nodetype; /**< LYS_LEAF */
989 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
990 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
991 const char *name; /**< node name (mandatory) */
992 const char *dsc; /**< description statement */
993 const char *ref; /**< reference statement */
994 struct lysp_when *when; /**< when statement */
Michal Vasko7f45cf22020-10-01 12:49:44 +0200995 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200996 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200997
998 /* leaf */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200999 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001000 struct lysp_type type; /**< type of the leaf node (mandatory) */
1001 const char *units; /**< units of the leaf's type */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001002 struct lysp_qname dflt; /**< default value, it may or may not be a qualified name */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001003};
1004
1005struct lysp_node_leaflist {
Radek Krejci6d9b9b52018-11-02 12:43:39 +01001006 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001007 uint16_t nodetype; /**< LYS_LEAFLIST */
1008 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1009 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
1010 const char *name; /**< node name (mandatory) */
1011 const char *dsc; /**< description statement */
1012 const char *ref; /**< reference statement */
1013 struct lysp_when *when; /**< when statement */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001014 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001015 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001016
1017 /* leaf-list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001018 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001019 struct lysp_type type; /**< type of the leaf node (mandatory) */
1020 const char *units; /**< units of the leaf's type */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001021 struct lysp_qname *dflts; /**< list of default values ([sized array](@ref sizedarrays)), they may or
1022 may not be qualified names */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001023 uint32_t min; /**< min-elements constraint */
1024 uint32_t max; /**< max-elements constraint, 0 means unbounded */
1025};
1026
1027struct lysp_node_list {
Radek Krejci6d9b9b52018-11-02 12:43:39 +01001028 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001029 uint16_t nodetype; /**< LYS_LIST */
1030 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1031 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
1032 const char *name; /**< node name (mandatory) */
1033 const char *dsc; /**< description statement */
1034 const char *ref; /**< reference statement */
1035 struct lysp_when *when; /**< when statement */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001036 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001037 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001038
1039 /* list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001040 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001041 const char *key; /**< keys specification */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001042 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
1043 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001044 struct lysp_node *child; /**< list of data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001045 struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
1046 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001047 struct lysp_qname *uniques; /**< list of unique specifications ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001048 uint32_t min; /**< min-elements constraint */
1049 uint32_t max; /**< max-elements constraint, 0 means unbounded */
1050};
1051
1052struct lysp_node_choice {
Radek Krejci6d9b9b52018-11-02 12:43:39 +01001053 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001054 uint16_t nodetype; /**< LYS_CHOICE */
1055 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1056 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
1057 const char *name; /**< node name (mandatory) */
1058 const char *dsc; /**< description statement */
1059 const char *ref; /**< reference statement */
1060 struct lysp_when *when; /**< when statement */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001061 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001062 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001063
1064 /* choice */
1065 struct lysp_node *child; /**< list of data nodes (linked list) */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001066 struct lysp_qname dflt; /**< default case */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001067};
1068
1069struct lysp_node_case {
Radek Krejci6d9b9b52018-11-02 12:43:39 +01001070 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001071 uint16_t nodetype; /**< LYS_CASE */
1072 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1073 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
1074 const char *name; /**< node name (mandatory) */
1075 const char *dsc; /**< description statement */
1076 const char *ref; /**< reference statement */
1077 struct lysp_when *when; /**< when statement */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001078 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001079 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001080
1081 /* case */
1082 struct lysp_node *child; /**< list of data nodes (linked list) */
1083};
1084
1085struct lysp_node_anydata {
Radek Krejci6d9b9b52018-11-02 12:43:39 +01001086 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001087 uint16_t nodetype; /**< LYS_ANYXML or LYS_ANYDATA */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001088 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1089 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
1090 const char *name; /**< node name (mandatory) */
1091 const char *dsc; /**< description statement */
1092 const char *ref; /**< reference statement */
1093 struct lysp_when *when; /**< when statement */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001094 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001095 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001096
1097 /* anyxml/anydata */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001098 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001099};
1100
1101struct lysp_node_uses {
Radek Krejci6d9b9b52018-11-02 12:43:39 +01001102 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Michal Vaskob55f6c12018-09-12 11:13:15 +02001103 uint16_t nodetype; /**< LYS_USES */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001104 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1105 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
1106 const char *name; /**< grouping name reference (mandatory) */
1107 const char *dsc; /**< description statement */
1108 const char *ref; /**< reference statement */
1109 struct lysp_when *when; /**< when statement */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001110 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001111 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001112
1113 /* uses */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001114 struct lysp_refine *refines; /**< list of uses's refines ([sized array](@ref sizedarrays)) */
1115 struct lysp_augment *augments; /**< list of uses's augment ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001116};
1117
1118/**
1119 * @brief YANG input-stmt and output-stmt
1120 */
1121struct lysp_action_inout {
Radek Krejci6d9b9b52018-11-02 12:43:39 +01001122 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001123 uint16_t nodetype; /**< LYS_INPUT or LYS_OUTPUT */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001124 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1125 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
1126 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001127 struct lysp_node *data; /**< list of data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001128 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001129};
1130
1131/**
1132 * @brief YANG rpc-stmt and action-stmt
1133 */
1134struct lysp_action {
Radek Krejci6d9b9b52018-11-02 12:43:39 +01001135 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Michal Vasko1bf09392020-03-27 12:38:10 +01001136 uint16_t nodetype; /**< LYS_RPC or LYS_ACTION */
Radek Krejci6d9b9b52018-11-02 12:43:39 +01001137 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001138 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001139 const char *name; /**< grouping name reference (mandatory) */
1140 const char *dsc; /**< description statement */
1141 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001142 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001143 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
1144 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
1145
1146 /* action */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001147 struct lysp_action_inout input; /**< RPC's/Action's input */
1148 struct lysp_action_inout output; /**< RPC's/Action's output */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001149};
1150
1151/**
1152 * @brief YANG notification-stmt
1153 */
1154struct lysp_notif {
Radek Krejci6d9b9b52018-11-02 12:43:39 +01001155 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
1156 uint16_t nodetype; /**< LYS_NOTIF */
1157 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001158 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001159 const char *name; /**< grouping name reference (mandatory) */
1160 const char *dsc; /**< description statement */
1161 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001162 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001163 struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001164 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vasko7f45cf22020-10-01 12:49:44 +02001165
1166 /* notif */
1167 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1168 struct lysp_node *data; /**< list of data nodes (linked list) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001169};
1170
1171/**
Radek Krejcif0fceb62018-09-05 14:58:45 +02001172 * @brief supported YANG schema version values
1173 */
1174typedef enum LYS_VERSION {
1175 LYS_VERSION_UNDEF = 0, /**< no specific version, YANG 1.0 as default */
Radek Krejci96e48da2020-09-04 13:18:06 +02001176 LYS_VERSION_1_0 = 1, /**< YANG 1 (1.0) */
Radek Krejcif0fceb62018-09-05 14:58:45 +02001177 LYS_VERSION_1_1 = 2 /**< YANG 1.1 */
1178} LYS_VERSION;
1179
1180/**
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001181 * @brief Printable YANG schema tree structure representing YANG module.
1182 *
1183 * Simple structure corresponding to the YANG format. The schema is only syntactically validated.
1184 */
1185struct lysp_module {
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001186 struct lys_module *mod; /**< covering module structure */
1187
Radek Krejcib7db73a2018-10-24 14:18:40 +02001188 struct lysp_revision *revs; /**< list of the module revisions ([sized array](@ref sizedarrays)), the first revision
1189 in the list is always the last (newest) revision of the module */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001190 struct lysp_import *imports; /**< list of imported modules ([sized array](@ref sizedarrays)) */
1191 struct lysp_include *includes; /**< list of included submodules ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001192 struct lysp_ext *extensions; /**< list of extension statements ([sized array](@ref sizedarrays)) */
1193 struct lysp_feature *features; /**< list of feature definitions ([sized array](@ref sizedarrays)) */
1194 struct lysp_ident *identities; /**< list of identities ([sized array](@ref sizedarrays)) */
1195 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
1196 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001197 struct lysp_node *data; /**< list of module's top-level data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001198 struct lysp_augment *augments; /**< list of augments ([sized array](@ref sizedarrays)) */
1199 struct lysp_action *rpcs; /**< list of RPCs ([sized array](@ref sizedarrays)) */
1200 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
1201 struct lysp_deviation *deviations; /**< list of deviations ([sized array](@ref sizedarrays)) */
Michal Vaskoc3781c32020-10-06 14:04:08 +02001202 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001203
Michal Vasko5d24f6c2020-10-13 13:49:06 +02001204 uint8_t version; /**< yang-version (LYS_VERSION values) */
Michal Vaskoc3781c32020-10-06 14:04:08 +02001205 uint8_t parsing : 1; /**< flag for circular check */
1206 uint8_t is_submod : 1; /**< always 0 */
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001207};
1208
1209struct lysp_submodule {
Michal Vaskoc3781c32020-10-06 14:04:08 +02001210 struct lys_module *mod; /**< belongs to parent module (submodule - mandatory) */
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001211
1212 struct lysp_revision *revs; /**< list of the module revisions ([sized array](@ref sizedarrays)), the first revision
1213 in the list is always the last (newest) revision of the module */
1214 struct lysp_import *imports; /**< list of imported modules ([sized array](@ref sizedarrays)) */
1215 struct lysp_include *includes; /**< list of included submodules ([sized array](@ref sizedarrays)) */
1216 struct lysp_ext *extensions; /**< list of extension statements ([sized array](@ref sizedarrays)) */
1217 struct lysp_feature *features; /**< list of feature definitions ([sized array](@ref sizedarrays)) */
1218 struct lysp_ident *identities; /**< list of identities ([sized array](@ref sizedarrays)) */
1219 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
1220 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
1221 struct lysp_node *data; /**< list of module's top-level data nodes (linked list) */
1222 struct lysp_augment *augments; /**< list of augments ([sized array](@ref sizedarrays)) */
1223 struct lysp_action *rpcs; /**< list of RPCs ([sized array](@ref sizedarrays)) */
1224 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
1225 struct lysp_deviation *deviations; /**< list of deviations ([sized array](@ref sizedarrays)) */
Michal Vaskoc3781c32020-10-06 14:04:08 +02001226 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001227
Michal Vasko5d24f6c2020-10-13 13:49:06 +02001228 uint8_t version; /**< yang-version (LYS_VERSION values) */
Michal Vaskoc3781c32020-10-06 14:04:08 +02001229 uint8_t parsing : 1; /**< flag for circular check */
1230 uint8_t is_submod : 1; /**< always 1 */
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001231
Michal Vaskoc3781c32020-10-06 14:04:08 +02001232 uint8_t latest_revision : 2; /**< flag to mark the latest available revision:
Radek Krejci086c7132018-10-26 15:29:04 +02001233 1 - the latest revision in searchdirs was not searched yet and this is the
1234 latest revision in the current context
1235 2 - searchdirs were searched and this is the latest available revision */
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001236 const char *name; /**< name of the module (mandatory) */
1237 const char *filepath; /**< path, if the schema was read from a file, NULL in case of reading from memory */
1238 const char *prefix; /**< submodule belongsto prefix of main module (mandatory) */
1239 const char *org; /**< party/company responsible for the module */
1240 const char *contact; /**< contact information for the module */
1241 const char *dsc; /**< description of the module */
1242 const char *ref; /**< cross-reference for the module */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001243};
1244
1245/**
Michal Vasko5d24f6c2020-10-13 13:49:06 +02001246 * @brief Get the parsed module or submodule name.
1247 *
1248 * @param[in] PMOD Parsed module or submodule.
1249 * @return Module or submodule name.
1250 */
1251#define LYSP_MODULE_NAME(PMOD) (PMOD->is_submod ? ((struct lysp_submodule *)PMOD)->name : ((struct lysp_module *)PMOD)->mod->name)
1252
1253/**
Michal Vasko5d24f6c2020-10-13 13:49:06 +02001254 * @brief Compiled prefix data pair mapping of prefixes to modules. In case the format is ::LY_PREF_SCHEMA_RESOLVED,
1255 * the expected prefix data is a sized array of these structures.
1256 */
1257struct lysc_prefix {
1258 char *prefix; /**< used prefix */
1259 const struct lys_module *mod; /**< mapping to a module */
1260};
1261
1262/**
Radek Krejci0e59c312019-08-15 15:34:15 +02001263 * @brief Compiled YANG extension-stmt
1264 */
1265struct lysc_ext {
1266 const char *name; /**< extension name */
1267 const char *argument; /**< argument name, NULL if not specified */
Radek Krejci0e59c312019-08-15 15:34:15 +02001268 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
1269 struct lyext_plugin *plugin; /**< Plugin implementing the specific extension */
Radek Krejci0935f412019-08-20 16:15:18 +02001270 struct lys_module *module; /**< module structure */
Michal Vasko6f4cbb62020-02-28 11:15:47 +01001271 uint32_t refcount; /**< reference counter since extension definition is shared among all its instances */
Radek Krejci0e59c312019-08-15 15:34:15 +02001272 uint16_t flags; /**< LYS_STATUS_* value (@ref snodeflags) */
1273};
1274
1275/**
Radek Krejcice8c1592018-10-29 15:35:51 +01001276 * @brief YANG extension instance
1277 */
1278struct lysc_ext_instance {
Radek Krejciad5963b2019-09-06 16:03:05 +02001279 uint32_t insubstmt_index; /**< in case the instance is in a substatement that can appear multiple times,
1280 this identifies the index of the substatement for this extension instance */
Radek Krejci28681fa2019-09-06 13:08:45 +02001281 struct lys_module *module; /**< module where the extension instantiated is defined */
Radek Krejciad5963b2019-09-06 16:03:05 +02001282 struct lysc_ext *def; /**< pointer to the extension definition */
Radek Krejcice8c1592018-10-29 15:35:51 +01001283 void *parent; /**< pointer to the parent element holding the extension instance(s), use
1284 ::lysc_ext_instance#parent_type to access the schema element */
1285 const char *argument; /**< optional value of the extension's argument */
1286 LYEXT_SUBSTMT insubstmt; /**< value identifying placement of the extension instance */
Radek Krejci2a408df2018-10-29 16:32:26 +01001287 LYEXT_PARENT parent_type; /**< type of the parent structure */
Radek Krejci2a408df2018-10-29 16:32:26 +01001288 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci0e59c312019-08-15 15:34:15 +02001289 void *data; /**< private plugins's data, not used by libyang */
Radek Krejcice8c1592018-10-29 15:35:51 +01001290};
1291
1292/**
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001293 * @brief YANG when-stmt
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001294 */
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001295struct lysc_when {
1296 struct lyxp_expr *cond; /**< XPath when condition */
Michal Vasko175012e2019-11-06 15:49:14 +01001297 struct lysc_node *context; /**< context node for evaluating the expression, NULL if the context is root node */
Michal Vasko5d24f6c2020-10-13 13:49:06 +02001298 struct lysc_prefix *prefixes; /**< compiled used prefixes in the condition */
Radek Krejcic8b31002019-01-08 10:24:45 +01001299 const char *dsc; /**< description */
1300 const char *ref; /**< reference */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001301 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci00b874b2019-02-12 10:54:50 +01001302 uint32_t refcount; /**< reference counter since some of the when statements are shared among several nodes */
Michal Vaskoecd62de2019-11-13 12:35:11 +01001303 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS is allowed */
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001304};
1305
1306/**
Radek Krejci2a408df2018-10-29 16:32:26 +01001307 * @brief YANG identity-stmt
1308 */
1309struct lysc_ident {
1310 const char *name; /**< identity name (mandatory), including possible prefix */
Radek Krejcic8b31002019-01-08 10:24:45 +01001311 const char *dsc; /**< description */
1312 const char *ref; /**< reference */
Radek Krejci693262f2019-04-29 15:23:20 +02001313 struct lys_module *module; /**< module structure */
Radek Krejci2a408df2018-10-29 16:32:26 +01001314 struct lysc_ident **derived; /**< list of (pointers to the) derived identities ([sized array](@ref sizedarrays)) */
1315 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
1316 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ values are allowed */
1317};
1318
1319/**
Radek Krejci151a5b72018-10-19 14:21:44 +02001320 * @defgroup ifftokens if-feature expression tokens
Radek Krejci8678fa42020-08-18 16:07:28 +02001321 * Tokens of if-feature expression used in ::lysc_iffeature.expr.
Radek Krejci151a5b72018-10-19 14:21:44 +02001322 *
1323 * @{
1324 */
1325#define LYS_IFF_NOT 0x00 /**< operand "not" */
1326#define LYS_IFF_AND 0x01 /**< operand "and" */
1327#define LYS_IFF_OR 0x02 /**< operand "or" */
1328#define LYS_IFF_F 0x03 /**< feature */
Radek Krejci2ff0d572020-05-21 15:27:28 +02001329/** @} ifftokens */
Radek Krejci151a5b72018-10-19 14:21:44 +02001330
1331/**
Radek Krejcib7db73a2018-10-24 14:18:40 +02001332 * @brief Compiled YANG revision statement
1333 */
1334struct lysc_revision {
1335 char date[LY_REV_SIZE]; /**< revision-date (mandatory) */
1336 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
1337};
1338
Radek Krejci2167ee12018-11-02 16:09:07 +01001339struct lysc_range {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001340 struct lysc_range_part {
Radek Krejci693262f2019-04-29 15:23:20 +02001341 union { /**< min boundary */
Radek Krejcie7b95092019-05-15 11:03:07 +02001342 int64_t min_64; /**< for int8, int16, int32, int64 and decimal64 ( >= LY_TYPE_DEC64) */
1343 uint64_t min_u64; /**< for uint8, uint16, uint32, uint64, string and binary ( < LY_TYPE_DEC64) */
Radek Krejci2167ee12018-11-02 16:09:07 +01001344 };
Radek Krejci693262f2019-04-29 15:23:20 +02001345 union { /**< max boundary */
Radek Krejcie7b95092019-05-15 11:03:07 +02001346 int64_t max_64; /**< for int8, int16, int32, int64 and decimal64 ( >= LY_TYPE_DEC64) */
1347 uint64_t max_u64; /**< for uint8, uint16, uint32, uint64, string and binary ( < LY_TYPE_DEC64) */
Radek Krejci2167ee12018-11-02 16:09:07 +01001348 };
Radek Krejci4f28eda2018-11-12 11:46:16 +01001349 } *parts; /**< compiled range expression ([sized array](@ref sizedarrays)) */
Radek Krejcic8b31002019-01-08 10:24:45 +01001350 const char *dsc; /**< description */
1351 const char *ref; /**< reference */
Radek Krejci2167ee12018-11-02 16:09:07 +01001352 const char *emsg; /**< error-message */
1353 const char *eapptag; /**< error-app-tag value */
1354 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
1355};
1356
1357struct lysc_pattern {
Radek Krejci54579462019-04-30 12:47:06 +02001358 const char *expr; /**< original, not compiled, regular expression */
1359 pcre2_code *code; /**< compiled regular expression */
Radek Krejcic8b31002019-01-08 10:24:45 +01001360 const char *dsc; /**< description */
1361 const char *ref; /**< reference */
Radek Krejci2167ee12018-11-02 16:09:07 +01001362 const char *emsg; /**< error-message */
1363 const char *eapptag; /**< error-app-tag value */
1364 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci0f969882020-08-21 16:56:47 +02001365 uint32_t inverted : 1; /**< invert-match flag */
1366 uint32_t refcount : 31; /**< reference counter */
Radek Krejci2167ee12018-11-02 16:09:07 +01001367};
1368
1369struct lysc_must {
Radek Krejci2167ee12018-11-02 16:09:07 +01001370 struct lyxp_expr *cond; /**< XPath when condition */
Michal Vasko5d24f6c2020-10-13 13:49:06 +02001371 struct lysc_prefix *prefixes; /**< compiled used prefixes in the condition */
Radek Krejcic8b31002019-01-08 10:24:45 +01001372 const char *dsc; /**< description */
1373 const char *ref; /**< reference */
Radek Krejci2167ee12018-11-02 16:09:07 +01001374 const char *emsg; /**< error-message */
1375 const char *eapptag; /**< error-app-tag value */
1376 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
1377};
1378
1379struct lysc_type {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001380 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcie7b95092019-05-15 11:03:07 +02001381 struct lysc_type_plugin *plugin; /**< type's plugin with built-in as well as user functions to canonize or validate the value of the type */
Radek Krejci2167ee12018-11-02 16:09:07 +01001382 LY_DATA_TYPE basetype; /**< Base type of the type */
1383 uint32_t refcount; /**< reference counter for type sharing */
1384};
1385
1386struct lysc_type_num {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001387 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcie7b95092019-05-15 11:03:07 +02001388 struct lysc_type_plugin *plugin; /**< type's plugin with built-in as well as user functions to canonize or validate the value of the type */
Radek Krejci2167ee12018-11-02 16:09:07 +01001389 LY_DATA_TYPE basetype; /**< Base type of the type */
1390 uint32_t refcount; /**< reference counter for type sharing */
1391 struct lysc_range *range; /**< Optional range limitation */
1392};
1393
1394struct lysc_type_dec {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001395 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcie7b95092019-05-15 11:03:07 +02001396 struct lysc_type_plugin *plugin; /**< type's plugin with built-in as well as user functions to canonize or validate the value of the type */
Radek Krejci2167ee12018-11-02 16:09:07 +01001397 LY_DATA_TYPE basetype; /**< Base type of the type */
1398 uint32_t refcount; /**< reference counter for type sharing */
Radek Krejci6cba4292018-11-15 17:33:29 +01001399 uint8_t fraction_digits; /**< fraction digits specification */
Radek Krejci2167ee12018-11-02 16:09:07 +01001400 struct lysc_range *range; /**< Optional range limitation */
1401};
1402
1403struct lysc_type_str {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001404 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcie7b95092019-05-15 11:03:07 +02001405 struct lysc_type_plugin *plugin; /**< type's plugin with built-in as well as user functions to canonize or validate the value of the type */
Radek Krejci2167ee12018-11-02 16:09:07 +01001406 LY_DATA_TYPE basetype; /**< Base type of the type */
1407 uint32_t refcount; /**< reference counter for type sharing */
1408 struct lysc_range *length; /**< Optional length limitation */
Radek Krejci4586a022018-11-13 11:29:26 +01001409 struct lysc_pattern **patterns; /**< Optional list of pointers to pattern limitations ([sized array](@ref sizedarrays)) */
Radek Krejci2167ee12018-11-02 16:09:07 +01001410};
1411
Radek Krejci693262f2019-04-29 15:23:20 +02001412struct lysc_type_bitenum_item {
1413 const char *name; /**< enumeration identifier */
1414 const char *dsc; /**< description */
1415 const char *ref; /**< reference */
1416 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci693262f2019-04-29 15:23:20 +02001417 union {
1418 int32_t value; /**< integer value associated with the enumeration */
1419 uint32_t position; /**< non-negative integer value associated with the bit */
1420 };
1421 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ and LYS_SET_VALUE
1422 values are allowed */
1423};
1424
Radek Krejci2167ee12018-11-02 16:09:07 +01001425struct lysc_type_enum {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001426 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcie7b95092019-05-15 11:03:07 +02001427 struct lysc_type_plugin *plugin; /**< type's plugin with built-in as well as user functions to canonize or validate the value of the type */
Radek Krejci2167ee12018-11-02 16:09:07 +01001428 LY_DATA_TYPE basetype; /**< Base type of the type */
1429 uint32_t refcount; /**< reference counter for type sharing */
Radek Krejci693262f2019-04-29 15:23:20 +02001430 struct lysc_type_bitenum_item *enums; /**< enumerations list ([sized array](@ref sizedarrays)), mandatory (at least 1 item) */
1431};
1432
1433struct lysc_type_bits {
1434 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcie7b95092019-05-15 11:03:07 +02001435 struct lysc_type_plugin *plugin; /**< type's plugin with built-in as well as user functions to canonize or validate the value of the type */
Radek Krejci693262f2019-04-29 15:23:20 +02001436 LY_DATA_TYPE basetype; /**< Base type of the type */
1437 uint32_t refcount; /**< reference counter for type sharing */
Radek Krejci849a62a2019-05-22 15:29:05 +02001438 struct lysc_type_bitenum_item *bits; /**< bits list ([sized array](@ref sizedarrays)), mandatory (at least 1 item),
1439 the items are ordered by their position value. */
Radek Krejci2167ee12018-11-02 16:09:07 +01001440};
1441
1442struct lysc_type_leafref {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001443 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcie7b95092019-05-15 11:03:07 +02001444 struct lysc_type_plugin *plugin; /**< type's plugin with built-in as well as user functions to canonize or validate the value of the type */
Radek Krejci2167ee12018-11-02 16:09:07 +01001445 LY_DATA_TYPE basetype; /**< Base type of the type */
1446 uint32_t refcount; /**< reference counter for type sharing */
Michal Vasko004d3152020-06-11 19:59:22 +02001447 struct lyxp_expr *path; /**< parsed target path, compiled path cannot be stored because of type sharing */
Michal Vasko5d24f6c2020-10-13 13:49:06 +02001448 struct lysc_prefix *prefixes; /**< resolved prefixes used in the path */
Radek Krejci412ddfa2018-11-23 11:44:11 +01001449 struct lysc_type *realtype; /**< pointer to the real (first non-leafref in possible leafrefs chain) type. */
Radek Krejci2167ee12018-11-02 16:09:07 +01001450 uint8_t require_instance; /**< require-instance flag */
1451};
1452
1453struct lysc_type_identityref {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001454 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcie7b95092019-05-15 11:03:07 +02001455 struct lysc_type_plugin *plugin; /**< type's plugin with built-in as well as user functions to canonize or validate the value of the type */
Radek Krejci2167ee12018-11-02 16:09:07 +01001456 LY_DATA_TYPE basetype; /**< Base type of the type */
1457 uint32_t refcount; /**< reference counter for type sharing */
Radek Krejci555cb5b2018-11-16 14:54:33 +01001458 struct lysc_ident **bases; /**< list of pointers to the base identities ([sized array](@ref sizedarrays)),
Radek Krejci2167ee12018-11-02 16:09:07 +01001459 mandatory (at least 1 item) */
1460};
1461
1462struct lysc_type_instanceid {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001463 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcie7b95092019-05-15 11:03:07 +02001464 struct lysc_type_plugin *plugin; /**< type's plugin with built-in as well as user functions to canonize or validate the value of the type */
Radek Krejci2167ee12018-11-02 16:09:07 +01001465 LY_DATA_TYPE basetype; /**< Base type of the type */
1466 uint32_t refcount; /**< reference counter for type sharing */
1467 uint8_t require_instance; /**< require-instance flag */
1468};
1469
Radek Krejci2167ee12018-11-02 16:09:07 +01001470struct lysc_type_union {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001471 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcie7b95092019-05-15 11:03:07 +02001472 struct lysc_type_plugin *plugin; /**< type's plugin with built-in as well as user functions to canonize or validate the value of the type */
Radek Krejci2167ee12018-11-02 16:09:07 +01001473 LY_DATA_TYPE basetype; /**< Base type of the type */
1474 uint32_t refcount; /**< reference counter for type sharing */
1475 struct lysc_type **types; /**< list of types in the union ([sized array](@ref sizedarrays)), mandatory (at least 1 item) */
1476};
1477
1478struct lysc_type_bin {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001479 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcie7b95092019-05-15 11:03:07 +02001480 struct lysc_type_plugin *plugin; /**< type's plugin with built-in as well as user functions to canonize or validate the value of the type */
Radek Krejci2167ee12018-11-02 16:09:07 +01001481 LY_DATA_TYPE basetype; /**< Base type of the type */
1482 uint32_t refcount; /**< reference counter for type sharing */
1483 struct lysc_range *length; /**< Optional length limitation */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001484};
1485
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001486struct lysc_action_inout {
Michal Vasko7f45cf22020-10-01 12:49:44 +02001487 uint16_t nodetype; /**< LYS_INPUT or LYS_OUTPUT */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001488 struct lysc_node *data; /**< first child node (linked list) */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001489 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1490};
1491
Michal Vasko60ea6352020-06-29 13:39:39 +02001492/**
1493 * @brief Maximum number of hashes stored in a schema node.
1494 */
1495#define LYS_NODE_HASH_COUNT 4
1496
Radek Krejci056d0a82018-12-06 16:57:25 +01001497struct lysc_action {
Michal Vasko1bf09392020-03-27 12:38:10 +01001498 uint16_t nodetype; /**< LYS_RPC or LYS_ACTION */
Radek Krejci056d0a82018-12-06 16:57:25 +01001499 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Michal Vasko60ea6352020-06-29 13:39:39 +02001500 uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */
Radek Krejci95710c92019-02-11 15:49:55 +01001501 struct lys_module *module; /**< module structure */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001502 struct lysc_node *parent; /**< parent node (NULL in case of top level node - RPC) */
1503
Radek Krejcifc11bd72019-04-11 16:00:05 +02001504 struct lysc_ext_instance *input_exts; /**< list of the extension instances of input ([sized array](@ref sizedarrays)) */
1505 struct lysc_ext_instance *output_exts; /**< list of the extension instances of outpu ([sized array](@ref sizedarrays)) */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001506
Radek Krejci056d0a82018-12-06 16:57:25 +01001507 const char *name; /**< action/RPC name (mandatory) */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001508 const char *dsc; /**< description */
1509 const char *ref; /**< reference */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001510 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001511
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001512 struct lysc_action_inout input; /**< RPC's/action's input */
1513 struct lysc_action_inout output; /**< RPC's/action's output */
Michal Vaskoceab6dd2020-10-09 16:53:36 +02001514 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Michal Vasko2fd91b92020-07-17 16:39:02 +02001515 void *priv; /** private arbitrary user data, not used by libyang */
1516
Radek Krejci056d0a82018-12-06 16:57:25 +01001517};
1518
1519struct lysc_notif {
1520 uint16_t nodetype; /**< LYS_NOTIF */
1521 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Michal Vasko60ea6352020-06-29 13:39:39 +02001522 uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */
Radek Krejci95710c92019-02-11 15:49:55 +01001523 struct lys_module *module; /**< module structure */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001524 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1525
Radek Krejcifc11bd72019-04-11 16:00:05 +02001526 struct lysc_node *data; /**< first child node (linked list) */
1527 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1528
Radek Krejci056d0a82018-12-06 16:57:25 +01001529 const char *name; /**< Notification name (mandatory) */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001530 const char *dsc; /**< description */
1531 const char *ref; /**< reference */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001532 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vaskoceab6dd2020-10-09 16:53:36 +02001533 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Michal Vasko2fd91b92020-07-17 16:39:02 +02001534 void *priv; /** private arbitrary user data, not used by libyang */
Radek Krejci056d0a82018-12-06 16:57:25 +01001535};
1536
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001537/**
Radek Krejci0af5f5d2018-09-07 15:00:30 +02001538 * @brief Compiled YANG data node
1539 */
1540struct lysc_node {
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001541 uint16_t nodetype; /**< type of the node (mandatory) */
1542 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Michal Vasko60ea6352020-06-29 13:39:39 +02001543 uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001544 struct lys_module *module; /**< module structure */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001545 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1546 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1547 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1548 never NULL. If there is no sibling node, pointer points to the node
1549 itself. In case of the first node, this pointer points to the last
1550 node in the list. */
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001551 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001552 const char *dsc; /**< description */
1553 const char *ref; /**< reference */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001554 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001555 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Michal Vasko2fd91b92020-07-17 16:39:02 +02001556 void *priv; /**< private arbitrary user data, not used by libyang */
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001557};
1558
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001559struct lysc_node_container {
1560 uint16_t nodetype; /**< LYS_CONTAINER */
1561 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Michal Vasko60ea6352020-06-29 13:39:39 +02001562 uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001563 struct lys_module *module; /**< module structure */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001564 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1565 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1566 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1567 never NULL. If there is no sibling node, pointer points to the node
1568 itself. In case of the first node, this pointer points to the last
1569 node in the list. */
1570 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001571 const char *dsc; /**< description */
1572 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001573 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001574 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Michal Vasko2fd91b92020-07-17 16:39:02 +02001575 void *priv; /**< private arbitrary user data, not used by libyang */
Radek Krejci4f28eda2018-11-12 11:46:16 +01001576
1577 struct lysc_node *child; /**< first child node (linked list) */
1578 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1579 struct lysc_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
1580 struct lysc_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001581};
1582
Radek Krejcia3045382018-11-22 14:30:31 +01001583struct lysc_node_case {
Radek Krejci056d0a82018-12-06 16:57:25 +01001584 uint16_t nodetype; /**< LYS_CASE */
1585 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Michal Vasko60ea6352020-06-29 13:39:39 +02001586 uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser, unused */
Radek Krejci056d0a82018-12-06 16:57:25 +01001587 struct lys_module *module; /**< module structure */
Radek Krejci056d0a82018-12-06 16:57:25 +01001588 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1589 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1590 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1591 never NULL. If there is no sibling node, pointer points to the node
1592 itself. In case of the first node, this pointer points to the last
1593 node in the list. */
Radek Krejcia3045382018-11-22 14:30:31 +01001594 const char *name; /**< name of the case, including the implicit case */
Radek Krejci12fb9142019-01-08 09:45:30 +01001595 const char *dsc; /**< description */
1596 const char *ref; /**< reference */
Radek Krejci056d0a82018-12-06 16:57:25 +01001597 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001598 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Michal Vasko2fd91b92020-07-17 16:39:02 +02001599 void *priv; /**< private arbitrary user data, not used by libyang */
Radek Krejci056d0a82018-12-06 16:57:25 +01001600
Radek Krejcia3045382018-11-22 14:30:31 +01001601 struct lysc_node *child; /**< first child node of the case (linked list). Note that all the children of all the sibling cases are linked
Radek Krejcife13da42019-02-15 14:51:01 +01001602 each other as siblings with the parent pointer pointing to appropriate case node. */
Radek Krejcia3045382018-11-22 14:30:31 +01001603};
1604
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001605struct lysc_node_choice {
1606 uint16_t nodetype; /**< LYS_CHOICE */
1607 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Michal Vasko60ea6352020-06-29 13:39:39 +02001608 uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser, unused */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001609 struct lys_module *module; /**< module structure */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001610 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1611 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1612 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1613 never NULL. If there is no sibling node, pointer points to the node
1614 itself. In case of the first node, this pointer points to the last
1615 node in the list. */
1616 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001617 const char *dsc; /**< description */
1618 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001619 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001620 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Michal Vasko2fd91b92020-07-17 16:39:02 +02001621 void *priv; /**< private arbitrary user data, not used by libyang */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001622
Radek Krejcia9026eb2018-12-12 16:04:47 +01001623 struct lysc_node_case *cases; /**< list of the cases (linked list). Note that all the children of all the cases are linked each other
1624 as siblings. Their parent pointers points to the specific case they belongs to, so distinguish the
1625 case is simple. */
Radek Krejci056d0a82018-12-06 16:57:25 +01001626 struct lysc_node_case *dflt; /**< default case of the choice, only a pointer into the cases array. */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001627};
1628
1629struct lysc_node_leaf {
1630 uint16_t nodetype; /**< LYS_LEAF */
1631 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Michal Vasko60ea6352020-06-29 13:39:39 +02001632 uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001633 struct lys_module *module; /**< module structure */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001634 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1635 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1636 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1637 never NULL. If there is no sibling node, pointer points to the node
1638 itself. In case of the first node, this pointer points to the last
1639 node in the list. */
1640 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001641 const char *dsc; /**< description */
1642 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001643 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001644 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Michal Vasko2fd91b92020-07-17 16:39:02 +02001645 void *priv; /**< private arbitrary user data, not used by libyang */
Radek Krejci4f28eda2018-11-12 11:46:16 +01001646
1647 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1648 struct lysc_type *type; /**< type of the leaf node (mandatory) */
Radek Krejcib57cf1e2018-11-23 14:07:05 +01001649
Radek Krejci4f28eda2018-11-12 11:46:16 +01001650 const char *units; /**< units of the leaf's type */
Radek Krejcia1911222019-07-22 17:24:50 +02001651 struct lyd_value *dflt; /**< default value */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001652};
1653
1654struct lysc_node_leaflist {
1655 uint16_t nodetype; /**< LYS_LEAFLIST */
1656 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Michal Vasko60ea6352020-06-29 13:39:39 +02001657 uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001658 struct lys_module *module; /**< module structure */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001659 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1660 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1661 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1662 never NULL. If there is no sibling node, pointer points to the node
1663 itself. In case of the first node, this pointer points to the last
1664 node in the list. */
1665 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001666 const char *dsc; /**< description */
1667 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001668 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001669 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Michal Vasko2fd91b92020-07-17 16:39:02 +02001670 void *priv; /**< private arbitrary user data, not used by libyang */
Radek Krejcib57cf1e2018-11-23 14:07:05 +01001671
1672 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1673 struct lysc_type *type; /**< type of the leaf node (mandatory) */
1674
Radek Krejci0e5d8382018-11-28 16:37:53 +01001675 const char *units; /**< units of the leaf's type */
Radek Krejcid0ef1af2019-07-23 12:22:05 +02001676 struct lyd_value **dflts; /**< list ([sized array](@ref sizedarrays)) of default values */
Michal Vaskoba99a3e2020-08-18 15:50:05 +02001677
Radek Krejci0e5d8382018-11-28 16:37:53 +01001678 uint32_t min; /**< min-elements constraint */
1679 uint32_t max; /**< max-elements constraint */
1680
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001681};
1682
1683struct lysc_node_list {
1684 uint16_t nodetype; /**< LYS_LIST */
1685 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Michal Vasko60ea6352020-06-29 13:39:39 +02001686 uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001687 struct lys_module *module; /**< module structure */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001688 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1689 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1690 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1691 never NULL. If there is no sibling node, pointer points to the node
1692 itself. In case of the first node, this pointer points to the last
1693 node in the list. */
1694 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001695 const char *dsc; /**< description */
1696 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001697 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001698 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Michal Vasko2fd91b92020-07-17 16:39:02 +02001699 void *priv; /**< private arbitrary user data, not used by libyang */
Radek Krejci9bb94eb2018-12-04 16:48:35 +01001700
1701 struct lysc_node *child; /**< first child node (linked list) */
1702 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1703 struct lysc_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
1704 struct lysc_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
1705
Radek Krejci9bb94eb2018-12-04 16:48:35 +01001706 struct lysc_node_leaf ***uniques; /**< list of sized arrays of pointers to the unique nodes ([sized array](@ref sizedarrays)) */
1707 uint32_t min; /**< min-elements constraint */
1708 uint32_t max; /**< max-elements constraint */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001709};
1710
1711struct lysc_node_anydata {
1712 uint16_t nodetype; /**< LYS_ANYXML or LYS_ANYDATA */
1713 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Michal Vasko60ea6352020-06-29 13:39:39 +02001714 uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001715 struct lys_module *module; /**< module structure */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001716 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1717 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1718 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1719 never NULL. If there is no sibling node, pointer points to the node
1720 itself. In case of the first node, this pointer points to the last
1721 node in the list. */
1722 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001723 const char *dsc; /**< description */
1724 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001725 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001726 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Michal Vasko2fd91b92020-07-17 16:39:02 +02001727 void *priv; /**< private arbitrary user data, not used by libyang */
Radek Krejci9800fb82018-12-13 14:26:23 +01001728
1729 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001730};
1731
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001732/**
1733 * @brief Compiled YANG schema tree structure representing YANG module.
1734 *
1735 * Semantically validated YANG schema tree for data tree parsing.
1736 * Contains only the necessary information for the data validation.
1737 */
1738struct lysc_module {
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001739 struct lys_module *mod; /**< covering module structure */
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001740
Radek Krejci2a408df2018-10-29 16:32:26 +01001741 struct lysc_node *data; /**< list of module's top-level data nodes (linked list) */
1742 struct lysc_action *rpcs; /**< list of RPCs ([sized array](@ref sizedarrays)) */
1743 struct lysc_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
Radek Krejcice8c1592018-10-29 15:35:51 +01001744 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci0af5f5d2018-09-07 15:00:30 +02001745};
1746
1747/**
Radek Krejci490a5462020-11-05 08:44:42 +01001748 * @brief Examine whether a node is user-ordered list or leaf-list.
1749 *
1750 * @param[in] lysc_node Schema node to examine.
1751 * @return Boolean value whether the @p node is user-ordered or not.
1752 */
1753#define lysc_is_userordered(lysc_node) \
1754 ((!lysc_node || !(lysc_node->nodetype & (LYS_LEAFLIST | LYS_LIST)) || !(lysc_node->flags & LYS_ORDBY_USER)) ? 0 : 1)
1755
1756/**
1757 * @brief Examine whether a node is a list's key.
1758 *
1759 * @param[in] lysc_node Schema node to examine.
1760 * @return Boolean value whether the @p node is a key or not.
1761 */
1762#define lysc_is_key(lysc_node) \
1763 ((!lysc_node || !(lysc_node->nodetype & (LYS_LEAF)) || !(lysc_node->flags & LYS_KEY)) ? 0 : 1)
1764
1765/**
Radek Krejci53ea6152018-12-13 15:21:15 +01001766 * @brief Get the groupings sized array of the given (parsed) schema node.
1767 * Decides the node's type and in case it has a groupings array, returns it.
1768 * @param[in] node Node to examine.
1769 * @return The node's groupings sized array if any, NULL otherwise.
1770 */
1771const struct lysp_grp *lysp_node_groupings(const struct lysp_node *node);
1772
1773/**
Radek Krejci056d0a82018-12-06 16:57:25 +01001774 * @brief Get the typedefs sized array of the given (parsed) schema node.
1775 * Decides the node's type and in case it has a typedefs array, returns it.
1776 * @param[in] node Node to examine.
1777 * @return The node's typedefs sized array if any, NULL otherwise.
1778 */
1779const struct lysp_tpdf *lysp_node_typedefs(const struct lysp_node *node);
1780
1781/**
1782 * @brief Get the actions/RPCs sized array of the given (parsed) schema node.
1783 * Decides the node's type and in case it has a actions/RPCs array, returns it.
1784 * @param[in] node Node to examine.
1785 * @return The node's actions/RPCs sized array if any, NULL otherwise.
1786 */
1787const struct lysp_action *lysp_node_actions(const struct lysp_node *node);
1788
1789/**
1790 * @brief Get the Notifications sized array of the given (parsed) schema node.
1791 * Decides the node's type and in case it has a Notifications array, returns it.
1792 * @param[in] node Node to examine.
1793 * @return The node's Notifications sized array if any, NULL otherwise.
1794 */
1795const struct lysp_notif *lysp_node_notifs(const struct lysp_node *node);
1796
1797/**
1798 * @brief Get the children linked list of the given (parsed) schema node.
1799 * Decides the node's type and in case it has a children list, returns it.
1800 * @param[in] node Node to examine.
1801 * @return The node's children linked list if any, NULL otherwise.
1802 */
1803const struct lysp_node *lysp_node_children(const struct lysp_node *node);
1804
1805/**
1806 * @brief Get the actions/RPCs sized array of the given (compiled) schema node.
1807 * Decides the node's type and in case it has a actions/RPCs array, returns it.
1808 * @param[in] node Node to examine.
1809 * @return The node's actions/RPCs sized array if any, NULL otherwise.
1810 */
1811const struct lysc_action *lysc_node_actions(const struct lysc_node *node);
1812
1813/**
1814 * @brief Get the Notifications sized array of the given (compiled) schema node.
1815 * Decides the node's type and in case it has a Notifications array, returns it.
1816 * @param[in] node Node to examine.
1817 * @return The node's Notifications sized array if any, NULL otherwise.
1818 */
1819const struct lysc_notif *lysc_node_notifs(const struct lysc_node *node);
1820
1821/**
1822 * @brief Get the children linked list of the given (compiled) schema node.
Michal Vasko208a04a2020-10-21 15:17:12 +02001823 * Skips over input and output nodes. To return them, use ::lysc_node_children_full().
Michal Vasko2a668712020-10-21 11:48:09 +02001824 *
Radek Krejci056d0a82018-12-06 16:57:25 +01001825 * @param[in] node Node to examine.
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001826 * @param[in] flags Config flag to distinguish input (LYS_CONFIG_W) and output (LYS_CONFIG_R) data in case of RPC/action node.
Radek Krejci056d0a82018-12-06 16:57:25 +01001827 * @return The node's children linked list if any, NULL otherwise.
1828 */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001829const struct lysc_node *lysc_node_children(const struct lysc_node *node, uint16_t flags);
Radek Krejci056d0a82018-12-06 16:57:25 +01001830
1831/**
Michal Vasko2a668712020-10-21 11:48:09 +02001832 * @brief Get the children linked list of the given (compiled) schema node.
Michal Vasko208a04a2020-10-21 15:17:12 +02001833 * Returns all children node types including input and output. To skip them, use ::lysc_node_children().
Michal Vasko2a668712020-10-21 11:48:09 +02001834 *
1835 * @param[in] node Node to examine.
1836 * @param[in] flags Config flag to distinguish input (LYS_CONFIG_W) and output (LYS_CONFIG_R) child in case of RPC/action node.
1837 * @return Children linked list if any,
1838 * @return NULL otherwise.
1839 */
Michal Vasko208a04a2020-10-21 15:17:12 +02001840const struct lysc_node *lysc_node_children_full(const struct lysc_node *node, uint16_t flags);
Michal Vasko2a668712020-10-21 11:48:09 +02001841
1842/**
1843 * @brief Get the parent pointer from any type of (compiled) schema node.
Michal Vasko208a04a2020-10-21 15:17:12 +02001844 * Returns input or output for direct descendants of RPC/action nodes.
1845 * To skip them, use ::lysc_node.parent pointer directly.
Michal Vasko2a668712020-10-21 11:48:09 +02001846 *
1847 * @param[in] node Node whose parent to get.
1848 * @return Node parent.
1849 * @return NULL is there is none.
1850 */
Michal Vasko208a04a2020-10-21 15:17:12 +02001851const struct lysc_node *lysc_node_parent_full(const struct lysc_node *node);
Michal Vasko2a668712020-10-21 11:48:09 +02001852
1853/**
Michal Vaskof1ab44f2020-10-22 08:58:32 +02001854 * @brief Callback to be called for every schema node in a DFS traversal.
1855 *
1856 * @param[in] node Current node.
1857 * @param[in] data Arbitrary user data.
1858 * @param[out] dfs_continue Set to true if the current subtree should be skipped and continue with siblings instead.
1859 * @return LY_SUCCESS on success,
1860 * @return LY_ERR value to terminate DFS and return this value.
1861 */
1862typedef LY_ERR (*lysc_dfs_clb)(struct lysc_node *node, void *data, ly_bool *dfs_continue);
1863
1864/**
1865 * @brief DFS traversal of all the schema nodes in a (sub)tree including any actions and nested notifications.
1866 *
1867 * Node with children, actions, and notifications is traversed in this order:
1868 * 1) each child subtree;
1869 * 2) each action subtree;
1870 * 3) each notification subtree.
1871 *
1872 * For algorithm illustration or traversal with actions and notifications skipped, see ::LYSC_TREE_DFS_BEGIN.
1873 *
1874 * @param[in] root Schema root to fully traverse.
1875 * @param[in] dfs_clb Callback to call for each node.
1876 * @param[in] data Arbitrary user data passed to @p dfs_clb.
1877 * @return LY_SUCCESS on success,
1878 * @return LY_ERR value returned by @p dfs_clb.
1879 */
1880LY_ERR lysc_tree_dfs_full(const struct lysc_node *root, lysc_dfs_clb dfs_clb, void *data);
1881
1882/**
1883 * @brief DFS traversal of all the schema nodes in a module including RPCs and notifications.
1884 *
1885 * For more details, see ::lysc_tree_dfs_full().
1886 *
1887 * @param[in] mod Module to fully traverse.
1888 * @param[in] dfs_clb Callback to call for each node.
1889 * @param[in] data Arbitrary user data passed to @p dfs_clb.
1890 * @return LY_SUCCESS on success,
1891 * @return LY_ERR value returned by @p dfs_clb.
1892 */
1893LY_ERR lysc_module_dfs_full(const struct lys_module *mod, lysc_dfs_clb dfs_clb, void *data);
1894
1895/**
Michal Vasko2fd91b92020-07-17 16:39:02 +02001896 * @brief Set a schema private pointer to a user pointer.
1897 *
1898 * @param[in] node Node, whose private field will be assigned. Works also for RPCs, actions, and notifications.
1899 * @param[in] priv Arbitrary user-specified pointer.
Radek Krejciaf9cd802020-10-06 21:59:47 +02001900 * @param[out] prev_priv_p Optional previous private object of the \p node. Note, that
Michal Vasko2fd91b92020-07-17 16:39:02 +02001901 * the caller is in this case responsible (if it is necessary) for freeing the replaced private object.
1902 * @return LY_ERR value.
1903 */
Radek Krejciaf9cd802020-10-06 21:59:47 +02001904LY_ERR lysc_set_private(const struct lysc_node *node, void *priv, void **prev_priv_p);
Michal Vasko2fd91b92020-07-17 16:39:02 +02001905
1906/**
Radek Krejci151a5b72018-10-19 14:21:44 +02001907 * @brief Get how the if-feature statement currently evaluates.
1908 *
1909 * @param[in] iff Compiled if-feature statement to evaluate.
Michal Vasko28d78432020-05-26 13:10:53 +02001910 * @return LY_SUCCESS if the statement evaluates to true,
1911 * @return LY_ENOT if it evaluates to false,
1912 * @return LY_ERR on error.
Radek Krejci151a5b72018-10-19 14:21:44 +02001913 */
Michal Vasko28d78432020-05-26 13:10:53 +02001914LY_ERR lysc_iffeature_value(const struct lysc_iffeature *iff);
Radek Krejci151a5b72018-10-19 14:21:44 +02001915
1916/**
Michal Vasko7b1ad1a2020-11-02 15:41:27 +01001917 * @brief Get the next feature in the module or submodules.
Radek Krejci151a5b72018-10-19 14:21:44 +02001918 *
Michal Vasko7b1ad1a2020-11-02 15:41:27 +01001919 * @param[in] last Last returned feature.
1920 * @param[in] pmod Parsed module and submodoules whose features to iterate over.
1921 * @param[in,out] idx Submodule index, set to 0 on first call.
1922 * @return Next found feature, NULL if the last has already been returned.
Radek Krejci151a5b72018-10-19 14:21:44 +02001923 */
Michal Vasko7b1ad1a2020-11-02 15:41:27 +01001924struct lysp_feature *lysp_feature_next(const struct lysp_feature *last, const struct lysp_module *pmod, uint32_t *idx);
Radek Krejci151a5b72018-10-19 14:21:44 +02001925
Radek Krejcibed13942020-10-19 16:06:28 +02001926/**
1927 * @defgroup findxpathoptions Atomize XPath options
1928 * Options to modify behavior of ::lys_find_xpath() and ::lys_find_xpath_atoms() searching for schema nodes in schema tree.
1929 * @{
1930 */
Michal Vaskocdad7122020-11-09 21:04:44 +01001931#define LYS_FIND_XP_SCHEMA 0x08 /**< Apply node access restrictions defined for 'when' and 'must' evaluation. */
1932#define LYS_FIND_XP_OUTPUT 0x10 /**< Search RPC/action output nodes instead of input ones. */
Radek Krejci576f8fa2020-10-26 21:23:58 +01001933/** @} findxpathoptions */
Michal Vasko072de482020-08-05 13:27:21 +02001934
Radek Krejci151a5b72018-10-19 14:21:44 +02001935/**
Michal Vasko40308e72020-10-20 16:38:40 +02001936 * @brief Get all the schema nodes that are required for @p xpath to be evaluated (atoms).
Michal Vasko519fd602020-05-26 12:17:39 +02001937 *
1938 * @param[in] ctx_node XPath schema context node.
Michal Vasko40308e72020-10-20 16:38:40 +02001939 * @param[in] xpath Data XPath expression filtering the matching nodes. ::LY_PREF_JSON prefix format is expected.
Radek Krejcibed13942020-10-19 16:06:28 +02001940 * @param[in] options Whether to apply some node access restrictions, see @ref findxpathoptions.
Michal Vasko519fd602020-05-26 12:17:39 +02001941 * @param[out] set Set of found atoms (schema nodes).
1942 * @return LY_SUCCESS on success, @p set is returned.
Michal Vasko40308e72020-10-20 16:38:40 +02001943 * @return LY_ERR value on error.
Michal Vasko519fd602020-05-26 12:17:39 +02001944 */
Radek Krejcibed13942020-10-19 16:06:28 +02001945LY_ERR lys_find_xpath_atoms(const struct lysc_node *ctx_node, const char *xpath, uint32_t options, struct ly_set **set);
Michal Vasko519fd602020-05-26 12:17:39 +02001946
Michal Vasko072de482020-08-05 13:27:21 +02001947/**
Michal Vasko40308e72020-10-20 16:38:40 +02001948 * @brief Get all the schema nodes that are required for @p expr to be evaluated (atoms).
Michal Vasko072de482020-08-05 13:27:21 +02001949 *
1950 * @param[in] ctx_node XPath schema context node.
Michal Vasko40308e72020-10-20 16:38:40 +02001951 * @param[in] cur_mod Current module for the expression (where it was "instantiated").
1952 * @param[in] expr Parsed expression to use.
1953 * @param[in] prefixes Sized array of compiled prefixes.
1954 * @param[in] options Whether to apply some node access restrictions, see @ref findxpathoptions.
1955 * @param[out] set Set of found atoms (schema nodes).
1956 * @return LY_SUCCESS on success, @p set is returned.
1957 * @return LY_ERR value on error.
1958 */
1959LY_ERR lys_find_expr_atoms(const struct lysc_node *ctx_node, const struct lys_module *cur_mod,
1960 const struct lyxp_expr *expr, const struct lysc_prefix *prefixes, uint32_t options, struct ly_set **set);
1961
1962/**
1963 * @brief Evaluate an @p xpath expression on schema nodes.
1964 *
1965 * @param[in] ctx_node XPath schema context node.
1966 * @param[in] xpath Data XPath expression filtering the matching nodes. ::LY_PREF_JSON prefix format is expected.
Radek Krejcibed13942020-10-19 16:06:28 +02001967 * @param[in] options Whether to apply some node access restrictions, see @ref findxpathoptions.
Michal Vasko072de482020-08-05 13:27:21 +02001968 * @param[out] set Set of found schema nodes.
1969 * @return LY_SUCCESS on success, @p set is returned.
1970 * @return LY_ERR value if an error occurred.
1971 */
Radek Krejci1deb5be2020-08-26 16:43:36 +02001972LY_ERR lys_find_xpath(const struct lysc_node *ctx_node, const char *xpath, uint32_t options, struct ly_set **set);
Michal Vasko519fd602020-05-26 12:17:39 +02001973
1974/**
Radek Krejcibc5644c2020-10-27 14:53:17 +01001975 * @brief Get all the schema nodes that are required for @p path to be evaluated (atoms).
1976 *
1977 * @param[in] path Compiled path to use.
1978 * @param[out] set Set of found atoms (schema nodes).
1979 * @return LY_SUCCESS on success, @p set is returned.
1980 * @return LY_ERR value on error.
1981 */
1982LY_ERR lys_find_lypath_atoms(const struct ly_path *path, struct ly_set **set);
1983
1984/**
1985 * @brief Get all the schema nodes that are required for @p path to be evaluated (atoms).
1986 *
1987 * @param[in] ctx libyang context, set for absolute paths.
1988 * @param[in] ctx_node Starting context node for a relative data path, set for relative paths.
1989 * @param[in] path JSON path to examine.
1990 * @param[in] output Search operation output instead of input.
1991 * @param[out] set Set of found atoms (schema nodes).
1992 * @return LY_ERR value on error.
1993 */
1994LY_ERR lys_find_path_atoms(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *path, ly_bool output,
1995 struct ly_set **set);
1996
1997/**
1998 * @brief Get a schema node based on the given data path (JSON format, see @ref howtoXPath).
1999 *
2000 * @param[in] ctx libyang context, set for absolute paths.
2001 * @param[in] ctx_node Starting context node for a relative data path, set for relative paths.
2002 * @param[in] path JSON path of the node to get.
2003 * @param[in] output Search operation output instead of input.
2004 * @return Found schema node or NULL.
2005 */
2006const struct lysc_node *lys_find_path(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *path,
2007 ly_bool output);
2008
2009/**
Michal Vasko03ff5a72019-09-11 13:49:33 +02002010 * @brief Types of the different schema paths.
2011 */
2012typedef enum {
Michal Vasko65de0402020-08-03 16:34:19 +02002013 LYSC_PATH_LOG, /**< Descriptive path format used in log messages */
2014 LYSC_PATH_DATA /**< Similar to ::LYSC_PATH_LOG except that schema-only nodes (choice, case) are skipped */
Michal Vasko03ff5a72019-09-11 13:49:33 +02002015} LYSC_PATH_TYPE;
2016
2017/**
Radek Krejci327de162019-06-14 12:52:07 +02002018 * @brief Generate path of the given node in the requested format.
2019 *
2020 * @param[in] node Schema path of this node will be generated.
2021 * @param[in] pathtype Format of the path to generate.
Radek Krejci1c0c3442019-07-23 16:08:47 +02002022 * @param[in,out] buffer Prepared buffer of the @p buflen length to store the generated path.
2023 * If NULL, memory for the complete path is allocated.
2024 * @param[in] buflen Size of the provided @p buffer.
Radek Krejci327de162019-06-14 12:52:07 +02002025 * @return NULL in case of memory allocation error, path of the node otherwise.
Radek Krejci1c0c3442019-07-23 16:08:47 +02002026 * In case the @p buffer is NULL, the returned string is dynamically allocated and caller is responsible to free it.
Radek Krejci327de162019-06-14 12:52:07 +02002027 */
Michal Vasko03ff5a72019-09-11 13:49:33 +02002028char *lysc_path(const struct lysc_node *node, LYSC_PATH_TYPE pathtype, char *buffer, size_t buflen);
Radek Krejci327de162019-06-14 12:52:07 +02002029
2030/**
Radek Krejci5aeea3a2018-09-05 13:29:36 +02002031 * @brief Available YANG schema tree structures representing YANG module.
2032 */
2033struct lys_module {
Radek Krejci0bcdaed2019-01-10 10:21:34 +01002034 struct ly_ctx *ctx; /**< libyang context of the module (mandatory) */
2035 const char *name; /**< name of the module (mandatory) */
Radek Krejci0af46292019-01-11 16:02:31 +01002036 const char *revision; /**< revision of the module (if present) */
Radek Krejci0bcdaed2019-01-10 10:21:34 +01002037 const char *ns; /**< namespace of the module (module - mandatory) */
2038 const char *prefix; /**< module prefix or submodule belongsto prefix of main module (mandatory) */
2039 const char *filepath; /**< path, if the schema was read from a file, NULL in case of reading from memory */
2040 const char *org; /**< party/company responsible for the module */
2041 const char *contact; /**< contact information for the module */
2042 const char *dsc; /**< description of the module */
2043 const char *ref; /**< cross-reference for the module */
2044
Radek Krejci5aeea3a2018-09-05 13:29:36 +02002045 struct lysp_module *parsed; /**< Simply parsed (unresolved) YANG schema tree */
Radek Krejci0af46292019-01-11 16:02:31 +01002046 struct lysc_module *compiled; /**< Compiled and fully validated YANG schema tree for data parsing.
2047 Available only for implemented modules. */
Michal Vasko7f45cf22020-10-01 12:49:44 +02002048
Radek Krejci80d281e2020-09-14 17:42:54 +02002049 struct lysc_ident *identities; /**< List of compiled identities of the module ([sized array](@ref sizedarrays))
2050 Identities are outside the compiled tree to allow their linkage to the identities from
2051 the implemented modules. This avoids problems when the module became implemented in
2052 future (no matter if implicitly via augment/deviate or explicitly via
2053 ::lys_set_implemented()). Note that if the module is not implemented (compiled), the
2054 identities cannot be instantiated in data (in identityrefs). */
Michal Vasko7f45cf22020-10-01 12:49:44 +02002055
2056 struct lys_module **augmented_by;/**< List of modules that augment this module ([sized array](@ref sizedarrays)) */
2057 struct lys_module **deviated_by; /**< List of modules that deviate this module ([sized array](@ref sizedarrays)) */
2058
Michal Vasko89b5c072020-10-06 13:52:44 +02002059 ly_bool implemented; /**< flag if the module is implemented, not just imported */
Radek Krejci95710c92019-02-11 15:49:55 +01002060 uint8_t latest_revision; /**< flag to mark the latest available revision:
Radek Krejci0bcdaed2019-01-10 10:21:34 +01002061 1 - the latest revision in searchdirs was not searched yet and this is the
2062 latest revision in the current context
2063 2 - searchdirs were searched and this is the latest available revision */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02002064};
2065
Radek Krejci151a5b72018-10-19 14:21:44 +02002066/**
Michal Vasko82c31e62020-07-17 15:30:40 +02002067 * @brief Get the current real status of the specified feature in the module.
2068 *
2069 * If the feature is enabled, but some of its if-features are false, the feature is considered
2070 * disabled.
Radek Krejci151a5b72018-10-19 14:21:44 +02002071 *
2072 * @param[in] module Module where the feature is defined.
2073 * @param[in] feature Name of the feature to inspect.
Michal Vasko82c31e62020-07-17 15:30:40 +02002074 * @return LY_SUCCESS if the feature is enabled,
2075 * @return LY_ENOT if the feature is disabled,
2076 * @return LY_ENOTFOUND if the feature was not found.
Radek Krejci151a5b72018-10-19 14:21:44 +02002077 */
Michal Vasko82c31e62020-07-17 15:30:40 +02002078LY_ERR lys_feature_value(const struct lys_module *module, const char *feature);
Radek Krejcidd4e8d42018-10-16 14:55:43 +02002079
2080/**
Radek Krejcia3045382018-11-22 14:30:31 +01002081 * @brief Get next schema tree (sibling) node element that can be instantiated in a data tree. Returned node can
2082 * be from an augment.
2083 *
Radek Krejci8678fa42020-08-18 16:07:28 +02002084 * ::lys_getnext() is supposed to be called sequentially. In the first call, the \p last parameter is usually NULL
Radek Krejcia3045382018-11-22 14:30:31 +01002085 * and function starts returning i) the first \p parent's child or ii) the first top level element of the \p module.
2086 * Consequent calls suppose to provide the previously returned node as the \p last parameter and still the same
2087 * \p parent and \p module parameters.
2088 *
2089 * Without options, the function is used to traverse only the schema nodes that can be paired with corresponding
2090 * data nodes in a data tree. By setting some \p options the behavior can be modified to the extent that
2091 * all the schema nodes are iteratively returned.
2092 *
2093 * @param[in] last Previously returned schema tree node, or NULL in case of the first call.
2094 * @param[in] parent Parent of the subtree where the function starts processing.
2095 * @param[in] module In case of iterating on top level elements, the \p parent is NULL and
2096 * module must be specified.
2097 * @param[in] options [ORed options](@ref sgetnextflags).
2098 * @return Next schema tree node that can be instantiated in a data tree, NULL in case there is no such element.
2099 */
2100const struct lysc_node *lys_getnext(const struct lysc_node *last, const struct lysc_node *parent,
Radek Krejci1deb5be2020-08-26 16:43:36 +02002101 const struct lysc_module *module, uint32_t options);
Radek Krejcia3045382018-11-22 14:30:31 +01002102
2103/**
Radek Krejci8678fa42020-08-18 16:07:28 +02002104 * @defgroup sgetnextflags Options for ::lys_getnext().
2105 *
2106 * Various options setting behavior of ::lys_getnext().
2107 *
Radek Krejcia3045382018-11-22 14:30:31 +01002108 * @{
2109 */
Radek Krejci8678fa42020-08-18 16:07:28 +02002110#define LYS_GETNEXT_WITHCHOICE 0x01 /**< ::lys_getnext() option to allow returning #LYS_CHOICE nodes instead of looking into them */
2111#define LYS_GETNEXT_NOCHOICE 0x02 /**< ::lys_getnext() option to ignore (kind of conditional) nodes within choice node */
2112#define LYS_GETNEXT_WITHCASE 0x04 /**< ::lys_getnext() option to allow returning #LYS_CASE nodes instead of looking into them */
Michal Vasko7b1ad1a2020-11-02 15:41:27 +01002113#define LYS_GETNEXT_INTONPCONT 0x08 /**< ::lys_getnext() option to look into non-presence container, instead of returning container itself */
2114#define LYS_GETNEXT_OUTPUT 0x10 /**< ::lys_getnext() option to provide RPC's/action's output schema nodes instead of input schema nodes
Radek Krejci6eeb58f2019-02-22 16:29:37 +01002115 provided by default */
Radek Krejcia3045382018-11-22 14:30:31 +01002116/** @} sgetnextflags */
2117
2118/**
2119 * @brief Get child node according to the specified criteria.
2120 *
2121 * @param[in] parent Optional parent of the node to find. If not specified, the module's top-level nodes are searched.
2122 * @param[in] module module of the node to find. It is also limitation for the children node of the given parent.
2123 * @param[in] name Name of the node to find.
2124 * @param[in] name_len Optional length of the name in case it is not NULL-terminated string.
2125 * @param[in] nodetype Optional criteria (to speedup) specifying nodetype(s) of the node to find.
2126 * Used as a bitmask, so multiple nodetypes can be specified.
2127 * @param[in] options [ORed options](@ref sgetnextflags).
2128 * @return Found node if any.
2129 */
Michal Vaskoe444f752020-02-10 12:20:06 +01002130const struct lysc_node *lys_find_child(const struct lysc_node *parent, const struct lys_module *module,
Radek Krejci1deb5be2020-08-26 16:43:36 +02002131 const char *name, size_t name_len, uint16_t nodetype, uint32_t options);
Radek Krejcia3045382018-11-22 14:30:31 +01002132
2133/**
Radek Krejci77a8bcd2019-09-11 11:20:02 +02002134 * @brief Make the specific module implemented.
2135 *
2136 * @param[in] mod Module to make implemented. It is not an error
2137 * to provide already implemented module, it just does nothing.
Michal Vasko7b1ad1a2020-11-02 15:41:27 +01002138 * @param[in] features Optional array of features ended with NULL to be enabled if the module is being implemented.
2139 * NULL for all features disabled and '*' for all enabled.
Michal Vaskoe444f752020-02-10 12:20:06 +01002140 * @return LY_SUCCESS on success.
2141 * @return LY_EDENIED in case the context contains some other revision of the same module which is already implemented.
Michal Vasko7b1ad1a2020-11-02 15:41:27 +01002142 * @return LY_ERR on other errors during module compilation.
Radek Krejci77a8bcd2019-09-11 11:20:02 +02002143 */
Michal Vasko7b1ad1a2020-11-02 15:41:27 +01002144LY_ERR lys_set_implemented(struct lys_module *mod, const char **features);
Radek Krejcia3045382018-11-22 14:30:31 +01002145
Radek Krejci084289f2019-07-09 17:35:30 +02002146/**
2147 * @brief Check type restrictions applicable to the particular leaf/leaf-list with the given string @p value.
2148 *
2149 * This function check just the type's restriction, if you want to check also the data tree context (e.g. in case of
Radek Krejci8678fa42020-08-18 16:07:28 +02002150 * require-instance restriction), use ::lyd_value_validate().
Radek Krejci084289f2019-07-09 17:35:30 +02002151 *
2152 * @param[in] ctx libyang context for logging (function does not log errors when @p ctx is NULL)
2153 * @param[in] node Schema node for the @p value.
Michal Vaskof937cfe2020-08-03 16:07:12 +02002154 * @param[in] value String value to be checked, expected to be in JSON format.
Radek Krejci084289f2019-07-09 17:35:30 +02002155 * @param[in] value_len Length of the given @p value (mandatory).
Radek Krejci084289f2019-07-09 17:35:30 +02002156 * @return LY_SUCCESS on success
2157 * @return LY_ERR value if an error occurred.
2158 */
Michal Vaskof937cfe2020-08-03 16:07:12 +02002159LY_ERR lys_value_validate(const struct ly_ctx *ctx, const struct lysc_node *node, const char *value, size_t value_len);
Radek Krejci084289f2019-07-09 17:35:30 +02002160
Radek Krejci0935f412019-08-20 16:15:18 +02002161/**
2162 * @brief Stringify schema nodetype.
Michal Vaskod43d71a2020-08-07 14:54:58 +02002163 *
Radek Krejci0935f412019-08-20 16:15:18 +02002164 * @param[in] nodetype Nodetype to stringify.
2165 * @return Constant string with the name of the node's type.
2166 */
2167const char *lys_nodetype2str(uint16_t nodetype);
2168
Michal Vaskod43d71a2020-08-07 14:54:58 +02002169/**
2170 * @brief Getter for original XPath expression from a parsed expression.
2171 *
2172 * @param[in] path Parsed expression.
2173 * @return Original string expression.
2174 */
2175const char *lyxp_get_expr(const struct lyxp_expr *path);
2176
Radek Krejci2ff0d572020-05-21 15:27:28 +02002177/** @} schematree */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02002178
Radek Krejci70853c52018-10-15 14:46:16 +02002179#ifdef __cplusplus
2180}
2181#endif
2182
Radek Krejci5aeea3a2018-09-05 13:29:36 +02002183#endif /* LY_TREE_SCHEMA_H_ */