blob: 22c6554bd92c8eafed0b6b25f8b80d60af0ec29a [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 Krejci5aeea3a2018-09-05 13:29:36 +020021#include <stdint.h>
Radek Krejcid3ca0632019-04-16 16:54:54 +020022#include <stdio.h>
Radek Krejci5aeea3a2018-09-05 13:29:36 +020023
Radek Krejcie7b95092019-05-15 11:03:07 +020024#include "log.h"
25#include "tree.h"
Radek Krejcice8c1592018-10-29 15:35:51 +010026#include "extensions.h"
27
Radek Krejcie7b95092019-05-15 11:03:07 +020028struct ly_ctx;
29
Radek Krejci70853c52018-10-15 14:46:16 +020030#ifdef __cplusplus
31extern "C" {
32#endif
33
Radek Krejci5aeea3a2018-09-05 13:29:36 +020034/**
Radek Krejci0af5f5d2018-09-07 15:00:30 +020035 * @brief Schema input formats accepted by libyang [parser functions](@ref howtoschemasparsers).
36 */
37typedef enum {
38 LYS_IN_UNKNOWN = 0, /**< unknown format, used as return value in case of error */
39 LYS_IN_YANG = 1, /**< YANG schema input format */
Radek Krejci693262f2019-04-29 15:23:20 +020040 LYS_IN_YIN = 3 /**< YIN schema input format */
Radek Krejci0af5f5d2018-09-07 15:00:30 +020041} LYS_INFORMAT;
42
43/**
44 * @brief Schema output formats accepted by libyang [printer functions](@ref howtoschemasprinters).
45 */
46typedef enum {
47 LYS_OUT_UNKNOWN = 0, /**< unknown format, used as return value in case of error */
48 LYS_OUT_YANG = 1, /**< YANG schema output format */
Radek Krejci693262f2019-04-29 15:23:20 +020049 LYS_OUT_YIN = 3, /**< YIN schema output format */
50 LYS_OUT_YANG_COMPILED = 2, /**< YANG schema output format of the compiled schema tree */
Radek Krejcid3ca0632019-04-16 16:54:54 +020051
Radek Krejci0af5f5d2018-09-07 15:00:30 +020052 LYS_OUT_TREE, /**< Tree schema output format, for more information see the [printers](@ref howtoschemasprinters) page */
53 LYS_OUT_INFO, /**< Info schema output format, for more information see the [printers](@ref howtoschemasprinters) page */
54 LYS_OUT_JSON, /**< JSON schema output format, reflecting YIN format with conversion of attributes to object's members */
55} LYS_OUTFORMAT;
56
Radek Krejci5aeea3a2018-09-05 13:29:36 +020057#define LY_REV_SIZE 11 /**< revision data string length (including terminating NULL byte) */
58
Michal Vaskob55f6c12018-09-12 11:13:15 +020059#define LYS_UNKNOWN 0x0000 /**< uninitalized unknown statement node */
60#define LYS_CONTAINER 0x0001 /**< container statement node */
61#define LYS_CHOICE 0x0002 /**< choice statement node */
62#define LYS_LEAF 0x0004 /**< leaf statement node */
63#define LYS_LEAFLIST 0x0008 /**< leaf-list statement node */
64#define LYS_LIST 0x0010 /**< list statement node */
65#define LYS_ANYXML 0x0020 /**< anyxml statement node */
Michal Vaskob55f6c12018-09-12 11:13:15 +020066#define LYS_ANYDATA 0x0120 /**< anydata statement node, in tests it can be used for both #LYS_ANYXML and #LYS_ANYDATA */
Radek Krejci5aeea3a2018-09-05 13:29:36 +020067
Radek Krejcie7b95092019-05-15 11:03:07 +020068#define LYS_ACTION 0x400 /**< RPC or action */
69#define LYS_NOTIF 0x800
70
Radek Krejcia3045382018-11-22 14:30:31 +010071#define LYS_CASE 0x0040 /**< case statement node */
72#define LYS_USES 0x0080 /**< uses statement node */
Radek Krejcid3ca0632019-04-16 16:54:54 +020073#define LYS_INPUT 0x100
74#define LYS_OUTPUT 0x200
75#define LYS_INOUT 0x300
Radek Krejci6d9b9b52018-11-02 12:43:39 +010076#define LYS_GROUPING 0x1000
77#define LYS_AUGMENT 0x2000
78
Radek Krejci5aeea3a2018-09-05 13:29:36 +020079/**
80 * @brief YANG import-stmt
81 */
82struct lysp_import {
Radek Krejci086c7132018-10-26 15:29:04 +020083 struct lys_module *module; /**< pointer to the imported module
84 (mandatory, but resolved when the referring module is completely parsed) */
85 const char *name; /**< name of the imported module (mandatory) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +020086 const char *prefix; /**< prefix for the data from the imported schema (mandatory) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +020087 const char *dsc; /**< description */
88 const char *ref; /**< reference */
Radek Krejcie53a8dc2018-10-17 12:52:40 +020089 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +020090 char rev[LY_REV_SIZE]; /**< revision-date of the imported module */
91};
92
93/**
94 * @brief YANG include-stmt
95 */
96struct lysp_include {
Radek Krejci0bcdaed2019-01-10 10:21:34 +010097 struct lysp_submodule *submodule;/**< pointer to the parsed submodule structure
Radek Krejci086c7132018-10-26 15:29:04 +020098 (mandatory, but resolved when the referring module is completely parsed) */
99 const char *name; /**< name of the included submodule (mandatory) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200100 const char *dsc; /**< description */
101 const char *ref; /**< reference */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200102 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200103 char rev[LY_REV_SIZE]; /**< revision-date of the included submodule */
104};
105
106/**
107 * @brief YANG extension-stmt
108 */
109struct lysp_ext {
110 const char *name; /**< extension name */
111 const char *argument; /**< argument name, NULL if not specified */
112 const char *dsc; /**< description statement */
113 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200114 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200115 uint16_t flags; /**< LYS_STATUS_* and LYS_YINELEM values (@ref snodeflags) */
116};
117
118/**
119 * @brief Helper structure for generic storage of the extension instances content.
120 */
121struct lysp_stmt {
122 const char *stmt; /**< identifier of the statement */
123 const char *arg; /**< statement's argument */
124 struct lysp_stmt *next; /**< link to the next statement */
Michal Vaskobc2559f2018-09-07 10:17:50 +0200125 struct lysp_stmt *child; /**< list of the statement's substatements (linked list) */
David Sedlákbbd06ca2019-06-27 14:15:38 +0200126 uint16_t flags; /**< */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200127};
David Sedlákb1a78352019-06-28 16:16:29 +0200128#define LYS_YIN 0x1
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200129/**
130 * @brief YANG extension instance
131 */
132struct lysp_ext_instance {
David Sedlákbbd06ca2019-06-27 14:15:38 +0200133 const char *name; /**< extension identifier, including possible prefix */
134 const char *argument; /**< optional value of the extension's argument */
135 struct lysp_stmt *child; /**< list of the extension's substatements (linked list) */
136 LYEXT_SUBSTMT insubstmt; /**< value identifying placement of the extension instance */
137 uint32_t insubstmt_index; /**< in case the instance is in a substatement, this identifies
138 the index of that substatement */
139 uint8_t yin; /** flag for YIN source format */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200140};
141
142/**
143 * @brief YANG feature-stmt
144 */
145struct lysp_feature {
146 const char *name; /**< feature name (mandatory) */
Radek Krejci151a5b72018-10-19 14:21:44 +0200147 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200148 const char *dsc; /**< description statement */
149 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200150 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200151 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values allowed */
152};
153
154/**
155 * @brief YANG identity-stmt
156 */
157struct lysp_ident {
158 const char *name; /**< identity name (mandatory), including possible prefix */
Radek Krejci151a5b72018-10-19 14:21:44 +0200159 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
160 const char **bases; /**< list of base identifiers ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200161 const char *dsc; /**< description statement */
162 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200163 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200164 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ values are allowed */
165};
166
Michal Vasko71e64ca2018-09-07 16:30:29 +0200167/**
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200168 * @brief Covers restrictions: range, length, pattern, must
169 */
170struct lysp_restr {
171 const char *arg; /**< The restriction expression/value (mandatory);
172 in case of pattern restriction, the first byte has a special meaning:
173 0x06 (ACK) for regular match and 0x15 (NACK) for invert-match */
174 const char *emsg; /**< error-message */
175 const char *eapptag; /**< error-app-tag value */
176 const char *dsc; /**< description */
177 const char *ref; /**< reference */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200178 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200179};
180
181/**
Michal Vasko71e64ca2018-09-07 16:30:29 +0200182 * @brief YANG revision-stmt
183 */
184struct lysp_revision {
Radek Krejcib7db73a2018-10-24 14:18:40 +0200185 char date[LY_REV_SIZE]; /**< revision date (madatory) */
Michal Vasko71e64ca2018-09-07 16:30:29 +0200186 const char *dsc; /**< description statement */
187 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200188 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vasko71e64ca2018-09-07 16:30:29 +0200189};
190
191/**
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200192 * @brief Enumeration/Bit value definition
193 */
194struct lysp_type_enum {
195 const char *name; /**< name (mandatory) */
196 const char *dsc; /**< description statement */
197 const char *ref; /**< reference statement */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200198 int64_t value; /**< enum's value or bit's position */
Radek Krejci151a5b72018-10-19 14:21:44 +0200199 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200200 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200201 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ and LYS_SET_VALUE
202 values are allowed */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200203};
204
205/**
206 * @brief YANG type-stmt
207 *
208 * Some of the items in the structure may be mandatory, but it is necessary to resolve the type's base type first
209 */
210struct lysp_type {
211 const char *name; /**< name of the type (mandatory) */
212 struct lysp_restr *range; /**< allowed values range - numerical, decimal64 */
213 struct lysp_restr *length; /**< allowed length of the value - string, binary */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200214 struct lysp_restr *patterns; /**< list of patterns ([sized array](@ref sizedarrays)) - string */
215 struct lysp_type_enum *enums; /**< list of enum-stmts ([sized array](@ref sizedarrays)) - enum */
216 struct lysp_type_enum *bits; /**< list of bit-stmts ([sized array](@ref sizedarrays)) - bits */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200217 const char *path; /**< path - leafref */
Radek Krejci151a5b72018-10-19 14:21:44 +0200218 const char **bases; /**< list of base identifiers ([sized array](@ref sizedarrays)) - identityref */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200219 struct lysp_type *types; /**< list of sub-types ([sized array](@ref sizedarrays)) - union */
220 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200221
Radek Krejci2167ee12018-11-02 16:09:07 +0100222 struct lysc_type *compiled; /**< pointer to the compiled type */
223
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200224 uint8_t fraction_digits; /**< number of fraction digits - decimal64 */
225 uint8_t require_instance; /**< require-instance flag - leafref, instance */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100226 uint16_t flags; /**< [schema node flags](@ref spnodeflags) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200227};
228
229/**
230 * @brief YANG typedef-stmt
231 */
232struct lysp_tpdf {
233 const char *name; /**< name of the newly defined type (mandatory) */
234 const char *units; /**< units of the newly defined type */
235 const char *dflt; /**< default value of the newly defined type */
236 const char *dsc; /**< description statement */
237 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200238 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200239 struct lysp_type type; /**< base type from which the typedef is derived (mandatory) */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100240 uint16_t flags; /**< [schema node flags](@ref spnodeflags) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200241};
242
243/**
244 * @brief YANG grouping-stmt
245 */
246struct lysp_grp {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100247 struct lysp_node *parent; /**< parent node (NULL if this is a top-level grouping) */
248 uint16_t nodetype; /**< LYS_GROUPING */
249 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200250 const char *name; /**< grouping name (mandatory) */
251 const char *dsc; /**< description statement */
252 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200253 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
254 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200255 struct lysp_node *data; /**< list of data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200256 struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
257 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
258 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200259};
260
261/**
262 * @brief YANG when-stmt
263 */
264struct lysp_when {
265 const char *cond; /**< specified condition (mandatory) */
266 const char *dsc; /**< description statement */
267 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200268 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200269};
270
271/**
272 * @brief YANG refine-stmt
273 */
274struct lysp_refine {
275 const char *nodeid; /**< target descendant schema nodeid (mandatory) */
276 const char *dsc; /**< description statement */
277 const char *ref; /**< reference statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200278 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200279 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200280 const char *presence; /**< presence description */
Radek Krejci151a5b72018-10-19 14:21:44 +0200281 const char **dflts; /**< list of default values ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200282 uint32_t min; /**< min-elements constraint */
283 uint32_t max; /**< max-elements constraint, 0 means unbounded */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200284 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200285 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
286};
287
288/**
289 * @brief YANG uses-augment-stmt and augment-stmt
290 */
291struct lysp_augment {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100292 struct lysp_node *parent; /**< parent node (NULL if this is a top-level augment) */
293 uint16_t nodetype; /**< LYS_AUGMENT */
294 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200295 const char *nodeid; /**< target schema nodeid (mandatory) - absolute for global augments, descendant for uses's augments */
296 const char *dsc; /**< description statement */
297 const char *ref; /**< reference statement */
298 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200299 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200300 struct lysp_node *child; /**< list of data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200301 struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
302 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
303 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200304};
305
306/**
307 * @defgroup deviatetypes Deviate types
308 * @{
309 */
310#define LYS_DEV_NOT_SUPPORTED 1 /**< deviate type not-supported */
311#define LYS_DEV_ADD 2 /**< deviate type add */
312#define LYS_DEV_DELETE 3 /**< deviate type delete */
313#define LYS_DEV_REPLACE 4 /**< deviate type replace */
314/** @} */
315
316/**
317 * @brief Generic deviate structure to get type and cast to lysp_deviate_* structure
318 */
319struct lysp_deviate {
320 uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */
321 struct lysp_deviate *next; /**< next deviate structure in the list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200322 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200323};
324
325struct lysp_deviate_add {
326 uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */
327 struct lysp_deviate *next; /**< next deviate structure in the list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200328 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200329 const char *units; /**< units of the values */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200330 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci151a5b72018-10-19 14:21:44 +0200331 const char **uniques; /**< list of uniques specifications ([sized array](@ref sizedarrays)) */
332 const char **dflts; /**< list of default values ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200333 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
334 uint32_t min; /**< min-elements constraint */
335 uint32_t max; /**< max-elements constraint, 0 means unbounded */
336};
337
338struct lysp_deviate_del {
339 uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */
340 struct lysp_deviate *next; /**< next deviate structure in the list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200341 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200342 const char *units; /**< units of the values */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200343 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci151a5b72018-10-19 14:21:44 +0200344 const char **uniques; /**< list of uniques specifications ([sized array](@ref sizedarrays)) */
345 const char **dflts; /**< list of default values ([sized array](@ref sizedarrays)) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200346 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200347};
348
349struct lysp_deviate_rpl {
350 uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */
351 struct lysp_deviate *next; /**< next deviate structure in the list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200352 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200353 struct lysp_type *type; /**< type of the node */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200354 const char *units; /**< units of the values */
355 const char *dflt; /**< default value */
356 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
357 uint32_t min; /**< min-elements constraint */
358 uint32_t max; /**< max-elements constraint, 0 means unbounded */
359};
360
361struct lysp_deviation {
Michal Vaskob55f6c12018-09-12 11:13:15 +0200362 const char *nodeid; /**< target absolute schema nodeid (mandatory) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200363 const char *dsc; /**< description statement */
364 const char *ref; /**< reference statement */
365 struct lysp_deviate* deviates; /**< list of deviate specifications (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200366 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200367};
368
Radek Krejci4f28eda2018-11-12 11:46:16 +0100369/**
370 * @defgroup spnodeflags Parsed schema nodes flags
371 * @ingroup snodeflags
372 *
373 * Various flags for parsed schema nodes.
374 *
375 * 1 - container 6 - anydata/anyxml 11 - output 16 - grouping 21 - enum
376 * 2 - choice 7 - case 12 - feature 17 - uses 22 - type
Radek Krejcid3ca0632019-04-16 16:54:54 +0200377 * 3 - leaf 8 - notification 13 - identity 18 - refine 23 - stmt
Radek Krejci4f28eda2018-11-12 11:46:16 +0100378 * 4 - leaflist 9 - rpc 14 - extension 19 - augment
379 * 5 - list 10 - input 15 - typedef 20 - deviate
380 *
Radek Krejcid3ca0632019-04-16 16:54:54 +0200381 * 1 1 1 1 1 1 1 1 1 1 2 2 2 2
382 * 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
383 * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
384 * 1 LYS_CONFIG_W |x|x|x|x|x|x|x| | | | | | | | | | |x| |x| | | |
385 * LYS_SET_BASE | | | | | | | | | | | | | | | | | | | | | |x| |
386 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
387 * 2 LYS_CONFIG_R |x|x|x|x|x|x|x| | | | | | | | | | |x| |x| | | |
388 * LYS_SET_BIT | | | | | | | | | | | | | | | | | | | | | |x| |
389 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
390 * 3 LYS_STATUS_CURR |x|x|x|x|x|x|x|x|x| | |x|x|x|x|x|x| |x|x|x| | |
391 * LYS_SET_ENUM | | | | | | | | | | | | | | | | | | | | | |x| |
392 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
393 * 4 LYS_STATUS_DEPRC |x|x|x|x|x|x|x|x|x| | |x|x|x|x|x|x| |x|x|x| | |
394 * LYS_SET_FRDIGITS | | | | | | | | | | | | | | | | | | | | | |x| |
395 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
396 * 5 LYS_STATUS_OBSLT |x|x|x|x|x|x|x|x|x| | |x|x|x|x|x|x| |x|x|x| | |
397 * LYS_SET_LENGTH | | | | | | | | | | | | | | | | | | | | | |x| |
398 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
399 * 6 LYS_MAND_TRUE | |x|x| | |x| | | | | | | | | | | |x| |x| | | |
400 * LYS_SET_PATH | | | | | | | | | | | | | | | | | | | | | |x| |
401 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
402 * 7 LYS_MAND_FALSE | |x|x| | |x| | | | | | | | | | | |x| |x| | | |
403 * LYS_ORDBY_USER | | | |x|x| | | | | | | | | | | | | | | | | | |
404 * LYS_SET_PATTERN | | | | | | | | | | | | | | | | | | | | | |x| |
405 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
406 * 8 LYS_ORDBY_SYSTEM | | | |x|x| | | | | | | | | | | | | | | | | | |
407 * LYS_YINELEM_TRUE | | | | | | | | | | | | | |x| | | | | | | | | |
408 * LYS_SET_RANGE | | | | | | | | | | | | | | | | | | | | | |x| |
409 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
410 * 9 LYS_YINELEM_FALSE| | | | | | | | | | | | | |x| | | | | | | | | |
411 * LYS_SET_TYPE | | | | | | | | | | | | | | | | | | | | | |x| |
412 * LYS_SINGLEQUOTED | | | | | | | | | | | | | | | | | | | | | | |x|
413 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
414 * 10 LYS_SET_VALUE | | | | | | | | | | | | | | | | | | | | |x| | |
415 * LYS_SET_REQINST | | | | | | | | | | | | | | | | | | | | | |x| |
416 * LYS_SET_MIN | | | |x|x| | | | | | | | | | | | |x| |x| | | |
417 * LYS_DOUBLEQUOTED | | | | | | | | | | | | | | | | | | | | | | |x|
418 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
419 * 11 LYS_SET_MAX | | | |x|x| | | | | | | | | | | | |x| |x| | | |
Radek Krejcif2de0ed2019-05-02 14:13:18 +0200420 * LYS_USED_GRP | | | | | | | | | | | | | | | |x| | | | | | | |
Radek Krejcid3ca0632019-04-16 16:54:54 +0200421 * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Radek Krejci4f28eda2018-11-12 11:46:16 +0100422 *
423 */
424
425/**
426 * @defgroup scnodeflags Compiled schema nodes flags
427 * @ingroup snodeflags
428 *
429 * Various flags for compiled schema nodes.
430 *
431 * 1 - container 6 - anydata/anyxml 11 - output
432 * 2 - choice 7 - case 12 - feature
433 * 3 - leaf 8 - notification 13 - identity
434 * 4 - leaflist 9 - rpc 14 - extension
Radek Krejci693262f2019-04-29 15:23:20 +0200435 * 5 - list 10 - input 15 - bitenum
Radek Krejci4f28eda2018-11-12 11:46:16 +0100436 *
Radek Krejci693262f2019-04-29 15:23:20 +0200437 * 1 1 1 1 1 1
438 * bit name 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
439 * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
440 * 1 LYS_CONFIG_W |x|x|x|x|x|x|x| | | | | | | | |
441 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
442 * 2 LYS_CONFIG_R |x|x|x|x|x|x|x| | | | | | | | |
443 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
444 * 3 LYS_STATUS_CURR |x|x|x|x|x|x|x|x|x| | |x|x|x| |
445 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
446 * 4 LYS_STATUS_DEPRC |x|x|x|x|x|x|x|x|x| | |x|x|x| |
447 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
448 * 5 LYS_STATUS_OBSLT |x|x|x|x|x|x|x|x|x| | |x|x|x| |
449 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
450 * 6 LYS_MAND_TRUE |x|x|x|x|x|x| | | | | | | | | |
451 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
452 * 7 LYS_ORDBY_USER | | | |x|x| | | | | | | | | | |
453 * LYS_MAND_FALSE | |x|x| | |x| | | | | | | | | |
454 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
455 * 8 LYS_ORDBY_SYSTEM | | | |x|x| | | | | | | | | | |
456 * LYS_PRESENCE |x| | | | | | | | | | | | | | |
457 * LYS_UNIQUE | | |x| | | | | | | | | | | | |
458 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
459 * 9 LYS_KEY | | |x| | | | | | | | | | | | |
460 * LYS_FENABLED | | | | | | | | | | | |x| | | |
461 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
462 * 10 LYS_SET_DFLT | | |x|x| | |x| | | | | | | | |
463 * LYS_ISENUM | | | | | | | | | | | | | | |x|
464 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
465 * 11 LYS_SET_UNITS | | |x|x| | | | | | | | | | | |
466 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
467 * 11 LYS_SET_CONFIG |x|x|x|x|x|x|x| | |x|x| | | | |
468 * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Radek Krejci4f28eda2018-11-12 11:46:16 +0100469 *
470 */
471
472/**
473 * @defgroup snodeflags Schema nodes flags
474 * @ingroup schematree
475 * @{
476 */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200477#define LYS_CONFIG_W 0x01 /**< config true; */
478#define LYS_CONFIG_R 0x02 /**< config false; */
479#define LYS_CONFIG_MASK 0x03 /**< mask for config value */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100480#define LYS_STATUS_CURR 0x04 /**< status current; */
481#define LYS_STATUS_DEPRC 0x08 /**< status deprecated; */
482#define LYS_STATUS_OBSLT 0x10 /**< status obsolete; */
483#define LYS_STATUS_MASK 0x1C /**< mask for status value */
484#define LYS_MAND_TRUE 0x20 /**< mandatory true; applicable only to ::lysp_node_choice/::lysc_node_choice,
Radek Krejcife909632019-02-12 15:34:42 +0100485 ::lysp_node_leaf/::lysc_node_leaf and ::lysp_node_anydata/::lysc_node_anydata.
486 The ::lysc_node_leaflist and ::lysc_node_leaflist have this flag in case that min-elements > 0.
487 The ::lysc_node_container has this flag if it is not a presence container and it has at least one
488 child with LYS_MAND_TRUE. */
Radek Krejcif1421c22019-02-19 13:05:20 +0100489#define LYS_MAND_FALSE 0x40 /**< mandatory false; applicable only to ::lysp_node_choice/::lysc_node_choice,
490 ::lysp_node_leaf/::lysc_node_leaf and ::lysp_node_anydata/::lysc_node_anydata.
491 This flag is present only in case the mandatory false statement was explicitly specified. */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100492#define LYS_MAND_MASK 0x60 /**< mask for mandatory values */
Radek Krejci7adf4ff2018-12-05 08:55:00 +0100493#define LYS_PRESENCE 0x80 /**< flag for presence property of a container, applicable only to ::lysc_node_container */
494#define LYS_UNIQUE 0x80 /**< flag for leafs being part of a unique set, applicable only to ::lysc_node_leaf */
495#define LYS_KEY 0x100 /**< flag for leafs being a key of a list, applicable only to ::lysc_node_leaf */
496#define LYS_FENABLED 0x100 /**< feature enabled flag, applicable only to ::lysc_feature */
Radek Krejcife909632019-02-12 15:34:42 +0100497#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 +0100498 ::lysc_node_list/::lysp_node_list */
499#define LYS_ORDBY_USER 0x40 /**< ordered-by user lists, applicable only to ::lysc_node_leaflist/::lysp_node_leaflist and
500 ::lysc_node_list/::lysp_node_list */
501#define LYS_ORDBY_MASK 0x60 /**< mask for ordered-by values */
502#define LYS_YINELEM_TRUE 0x80 /**< yin-element true for extension's argument */
503#define LYS_YINELEM_FALSE 0x100 /**< yin-element false for extension's argument */
504#define LYS_YINELEM_MASK 0x180 /**< mask for yin-element value */
Radek Krejcif2de0ed2019-05-02 14:13:18 +0200505#define LYS_USED_GRP 0x400 /**< internal flag for validating not-instantiated groupings
506 (resp. do not validate again the instantiated groupings). */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100507#define LYS_SET_VALUE 0x200 /**< value attribute is set */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100508#define LYS_SET_MIN 0x200 /**< min attribute is set */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200509#define LYS_SET_MAX 0x400 /**< max attribute is set */
Radek Krejcid505e3d2018-11-13 09:04:17 +0100510
511#define LYS_SET_BASE 0x0001 /**< type's flag for present base substatement */
512#define LYS_SET_BIT 0x0002 /**< type's flag for present bit substatement */
513#define LYS_SET_ENUM 0x0004 /**< type's flag for present enum substatement */
514#define LYS_SET_FRDIGITS 0x0008 /**< type's flag for present fraction-digits substatement */
515#define LYS_SET_LENGTH 0x0010 /**< type's flag for present length substatement */
516#define LYS_SET_PATH 0x0020 /**< type's flag for present path substatement */
517#define LYS_SET_PATTERN 0x0040 /**< type's flag for present pattern substatement */
518#define LYS_SET_RANGE 0x0080 /**< type's flag for present range substatement */
519#define LYS_SET_TYPE 0x0100 /**< type's flag for present type substatement */
520#define LYS_SET_REQINST 0x0200 /**< type's flag for present require-instance substatement */
Radek Krejciccd20f12019-02-15 14:12:27 +0100521#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 +0100522 cases of choice. This information is important for refines, since it is prohibited to make leafs
523 with default statement mandatory. In case the default leaf value is taken from type, it is thrown
Radek Krejciccd20f12019-02-15 14:12:27 +0100524 away when it is refined to be mandatory node. Similarly it is used for deviations to distinguish
525 between own default or the default values taken from the type. */
526#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 +0100527#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 +0100528
Radek Krejcid3ca0632019-04-16 16:54:54 +0200529#define LYS_SINGLEQUOTED 0x100 /**< flag for single-quoted argument of an extension instance's substatement */
530#define LYS_DOUBLEQUOTED 0x200 /**< flag for double-quoted argument of an extension instance's substatement */
531
David Sedlákbbd06ca2019-06-27 14:15:38 +0200532#define LYS_YIN_ATTR 0x1000 /**< flag to identify YIN attribute */
533
Radek Krejci693262f2019-04-29 15:23:20 +0200534#define LYS_ISENUM 0x200 /**< flag to simply distinguish type in struct lysc_type_bitenum_item */
535
Radek Krejcife909632019-02-12 15:34:42 +0100536#define LYS_FLAGS_COMPILED_MASK 0xff /**< mask for flags that maps to the compiled structures */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100537/** @} */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200538
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200539/**
540 * @brief Generic YANG data node
541 */
542struct lysp_node {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100543 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200544 uint16_t nodetype; /**< type of the node (mandatory) */
545 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100546 struct lysp_node *next; /**< next sibling node (NULL if there is no one) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200547 const char *name; /**< node name (mandatory) */
548 const char *dsc; /**< description statement */
549 const char *ref; /**< reference statement */
550 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200551 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200552 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200553};
554
555/**
556 * @brief Extension structure of the lysp_node for YANG container
557 */
558struct lysp_node_container {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100559 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200560 uint16_t nodetype; /**< LYS_CONTAINER */
561 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
562 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
563 const char *name; /**< node name (mandatory) */
564 const char *dsc; /**< description statement */
565 const char *ref; /**< reference statement */
566 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200567 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200568 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200569
570 /* container */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200571 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200572 const char *presence; /**< presence description */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200573 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
574 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200575 struct lysp_node *child; /**< list of data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200576 struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
577 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200578};
579
580struct lysp_node_leaf {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100581 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200582 uint16_t nodetype; /**< LYS_LEAF */
583 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
584 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
585 const char *name; /**< node name (mandatory) */
586 const char *dsc; /**< description statement */
587 const char *ref; /**< reference statement */
588 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200589 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200590 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200591
592 /* leaf */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200593 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200594 struct lysp_type type; /**< type of the leaf node (mandatory) */
595 const char *units; /**< units of the leaf's type */
596 const char *dflt; /**< default value */
597};
598
599struct lysp_node_leaflist {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100600 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200601 uint16_t nodetype; /**< LYS_LEAFLIST */
602 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
603 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
604 const char *name; /**< node name (mandatory) */
605 const char *dsc; /**< description statement */
606 const char *ref; /**< reference statement */
607 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200608 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200609 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200610
611 /* leaf-list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200612 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200613 struct lysp_type type; /**< type of the leaf node (mandatory) */
614 const char *units; /**< units of the leaf's type */
Radek Krejci151a5b72018-10-19 14:21:44 +0200615 const char **dflts; /**< list of default values ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200616 uint32_t min; /**< min-elements constraint */
617 uint32_t max; /**< max-elements constraint, 0 means unbounded */
618};
619
620struct lysp_node_list {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100621 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200622 uint16_t nodetype; /**< LYS_LIST */
623 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
624 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
625 const char *name; /**< node name (mandatory) */
626 const char *dsc; /**< description statement */
627 const char *ref; /**< reference statement */
628 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200629 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200630 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200631
632 /* list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200633 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200634 const char *key; /**< keys specification */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200635 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
636 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200637 struct lysp_node *child; /**< list of data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200638 struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
639 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
Radek Krejci151a5b72018-10-19 14:21:44 +0200640 const char **uniques; /**< list of unique specifications ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200641 uint32_t min; /**< min-elements constraint */
642 uint32_t max; /**< max-elements constraint, 0 means unbounded */
643};
644
645struct lysp_node_choice {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100646 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200647 uint16_t nodetype; /**< LYS_CHOICE */
648 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
649 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
650 const char *name; /**< node name (mandatory) */
651 const char *dsc; /**< description statement */
652 const char *ref; /**< reference statement */
653 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200654 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200655 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200656
657 /* choice */
658 struct lysp_node *child; /**< list of data nodes (linked list) */
659 const char* dflt; /**< default case */
660};
661
662struct lysp_node_case {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100663 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200664 uint16_t nodetype; /**< LYS_CASE */
665 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
666 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
667 const char *name; /**< node name (mandatory) */
668 const char *dsc; /**< description statement */
669 const char *ref; /**< reference statement */
670 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200671 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
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
674 /* case */
675 struct lysp_node *child; /**< list of data nodes (linked list) */
676};
677
678struct lysp_node_anydata {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100679 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200680 uint16_t nodetype; /**< LYS_ANYXML || LYS_ANYDATA */
681 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
682 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
683 const char *name; /**< node name (mandatory) */
684 const char *dsc; /**< description statement */
685 const char *ref; /**< reference statement */
686 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200687 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200688 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200689
690 /* anyxml/anydata */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200691 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200692};
693
694struct lysp_node_uses {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100695 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200696 uint16_t nodetype; /**< LYS_USES */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200697 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
698 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
699 const char *name; /**< grouping name reference (mandatory) */
700 const char *dsc; /**< description statement */
701 const char *ref; /**< reference statement */
702 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200703 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200704 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200705
706 /* uses */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200707 struct lysp_refine *refines; /**< list of uses's refines ([sized array](@ref sizedarrays)) */
708 struct lysp_augment *augments; /**< list of uses's augment ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200709};
710
711/**
712 * @brief YANG input-stmt and output-stmt
713 */
714struct lysp_action_inout {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100715 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
716 uint16_t nodetype; /**< LYS_INOUT */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200717 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
718 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
719 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200720 struct lysp_node *data; /**< list of data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200721 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200722};
723
724/**
725 * @brief YANG rpc-stmt and action-stmt
726 */
727struct lysp_action {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100728 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
729 uint16_t nodetype; /**< LYS_ACTION */
730 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200731 const char *name; /**< grouping name reference (mandatory) */
732 const char *dsc; /**< description statement */
733 const char *ref; /**< reference statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200734 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200735 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
736 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci6eeb58f2019-02-22 16:29:37 +0100737 struct lysp_action_inout input; /**< RPC's/Action's input */
738 struct lysp_action_inout output; /**< RPC's/Action's output */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200739 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200740};
741
742/**
743 * @brief YANG notification-stmt
744 */
745struct lysp_notif {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100746 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
747 uint16_t nodetype; /**< LYS_NOTIF */
748 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200749 const char *name; /**< grouping name reference (mandatory) */
750 const char *dsc; /**< description statement */
751 const char *ref; /**< reference statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200752 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200753 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
754 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
755 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200756 struct lysp_node *data; /**< list of data nodes (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
760/**
Radek Krejcif0fceb62018-09-05 14:58:45 +0200761 * @brief supported YANG schema version values
762 */
763typedef enum LYS_VERSION {
764 LYS_VERSION_UNDEF = 0, /**< no specific version, YANG 1.0 as default */
765 LYS_VERSION_1_0 = 1, /**< YANG 1.0 */
766 LYS_VERSION_1_1 = 2 /**< YANG 1.1 */
767} LYS_VERSION;
768
769/**
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200770 * @brief Printable YANG schema tree structure representing YANG module.
771 *
772 * Simple structure corresponding to the YANG format. The schema is only syntactically validated.
773 */
774struct lysp_module {
Radek Krejci0bcdaed2019-01-10 10:21:34 +0100775 struct lys_module *mod; /**< covering module structure */
776
Radek Krejcib7db73a2018-10-24 14:18:40 +0200777 struct lysp_revision *revs; /**< list of the module revisions ([sized array](@ref sizedarrays)), the first revision
778 in the list is always the last (newest) revision of the module */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200779 struct lysp_import *imports; /**< list of imported modules ([sized array](@ref sizedarrays)) */
780 struct lysp_include *includes; /**< list of included submodules ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200781 struct lysp_ext *extensions; /**< list of extension statements ([sized array](@ref sizedarrays)) */
782 struct lysp_feature *features; /**< list of feature definitions ([sized array](@ref sizedarrays)) */
783 struct lysp_ident *identities; /**< list of identities ([sized array](@ref sizedarrays)) */
784 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
785 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200786 struct lysp_node *data; /**< list of module's top-level data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200787 struct lysp_augment *augments; /**< list of augments ([sized array](@ref sizedarrays)) */
788 struct lysp_action *rpcs; /**< list of RPCs ([sized array](@ref sizedarrays)) */
789 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
790 struct lysp_deviation *deviations; /**< list of deviations ([sized array](@ref sizedarrays)) */
791 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200792
Radek Krejci0bcdaed2019-01-10 10:21:34 +0100793 uint8_t parsing:1; /**< flag for circular check */
794};
795
796struct lysp_submodule {
797 const char *belongsto; /**< belongs to parent module (submodule - mandatory) */
798
799 struct lysp_revision *revs; /**< list of the module revisions ([sized array](@ref sizedarrays)), the first revision
800 in the list is always the last (newest) revision of the module */
801 struct lysp_import *imports; /**< list of imported modules ([sized array](@ref sizedarrays)) */
802 struct lysp_include *includes; /**< list of included submodules ([sized array](@ref sizedarrays)) */
803 struct lysp_ext *extensions; /**< list of extension statements ([sized array](@ref sizedarrays)) */
804 struct lysp_feature *features; /**< list of feature definitions ([sized array](@ref sizedarrays)) */
805 struct lysp_ident *identities; /**< list of identities ([sized array](@ref sizedarrays)) */
806 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
807 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
808 struct lysp_node *data; /**< list of module's top-level data nodes (linked list) */
809 struct lysp_augment *augments; /**< list of augments ([sized array](@ref sizedarrays)) */
810 struct lysp_action *rpcs; /**< list of RPCs ([sized array](@ref sizedarrays)) */
811 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
812 struct lysp_deviation *deviations; /**< list of deviations ([sized array](@ref sizedarrays)) */
813 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
814
815 uint8_t parsing:1; /**< flag for circular check */
816
Radek Krejci086c7132018-10-26 15:29:04 +0200817 uint8_t latest_revision:2; /**< flag to mark the latest available revision:
818 1 - the latest revision in searchdirs was not searched yet and this is the
819 latest revision in the current context
820 2 - searchdirs were searched and this is the latest available revision */
Radek Krejci0bcdaed2019-01-10 10:21:34 +0100821 const char *name; /**< name of the module (mandatory) */
822 const char *filepath; /**< path, if the schema was read from a file, NULL in case of reading from memory */
823 const char *prefix; /**< submodule belongsto prefix of main module (mandatory) */
824 const char *org; /**< party/company responsible for the module */
825 const char *contact; /**< contact information for the module */
826 const char *dsc; /**< description of the module */
827 const char *ref; /**< cross-reference for the module */
Radek Krejci086c7132018-10-26 15:29:04 +0200828 uint8_t version; /**< yang-version (LYS_VERSION values) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200829};
830
831/**
Radek Krejci3f5e3db2018-10-11 15:57:47 +0200832 * @brief Free the printable YANG schema tree structure.
833 *
834 * @param[in] module Printable YANG schema tree structure to free.
835 */
836void lysp_module_free(struct lysp_module *module);
837
838/**
Radek Krejcice8c1592018-10-29 15:35:51 +0100839 * @brief YANG extension instance
840 */
841struct lysc_ext_instance {
842 struct lyext_plugin *plugin; /**< pointer to the plugin implementing the extension (if present) */
843 void *parent; /**< pointer to the parent element holding the extension instance(s), use
844 ::lysc_ext_instance#parent_type to access the schema element */
845 const char *argument; /**< optional value of the extension's argument */
846 LYEXT_SUBSTMT insubstmt; /**< value identifying placement of the extension instance */
847 uint32_t insubstmt_index; /**< in case the instance is in a substatement that can appear multiple times,
848 this identifies the index of the substatement for this extension instance */
Radek Krejci2a408df2018-10-29 16:32:26 +0100849 LYEXT_PARENT parent_type; /**< type of the parent structure */
Radek Krejcice8c1592018-10-29 15:35:51 +0100850#if 0
Radek Krejcice8c1592018-10-29 15:35:51 +0100851 uint8_t ext_type; /**< extension type (#LYEXT_TYPE) */
852 uint8_t padding; /**< 32b padding */
Radek Krejcice8c1592018-10-29 15:35:51 +0100853 struct lys_module *module; /**< pointer to the extension instance's module (mandatory) */
854 LYS_NODE nodetype; /**< LYS_EXT */
855#endif
Radek Krejci2a408df2018-10-29 16:32:26 +0100856 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
857 void *priv; /**< private caller's data, not used by libyang */
Radek Krejcice8c1592018-10-29 15:35:51 +0100858};
859
860/**
Radek Krejcibd8d9ba2018-11-02 16:06:26 +0100861 * @brief Compiled YANG if-feature-stmt
862 */
863struct lysc_iffeature {
864 uint8_t *expr; /**< 2bits array describing the if-feature expression in prefix format, see @ref ifftokens */
865 struct lysc_feature **features; /**< array of pointers to the features used in expression ([sized array](@ref sizedarrays)) */
866};
867
868/**
Radek Krejci151a5b72018-10-19 14:21:44 +0200869 * @brief YANG import-stmt
870 */
871struct lysc_import {
Radek Krejci6d6e4e42018-10-29 13:28:19 +0100872 struct lys_module *module; /**< link to the imported module */
Radek Krejci151a5b72018-10-19 14:21:44 +0200873 const char *prefix; /**< prefix for the data from the imported schema (mandatory) */
Radek Krejcice8c1592018-10-29 15:35:51 +0100874 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci151a5b72018-10-19 14:21:44 +0200875};
876
877/**
Radek Krejcidd4e8d42018-10-16 14:55:43 +0200878 * @brief YANG when-stmt
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200879 */
Radek Krejcidd4e8d42018-10-16 14:55:43 +0200880struct lysc_when {
881 struct lyxp_expr *cond; /**< XPath when condition */
Radek Krejcic8b31002019-01-08 10:24:45 +0100882 const char *dsc; /**< description */
883 const char *ref; /**< reference */
Radek Krejci00b874b2019-02-12 10:54:50 +0100884 struct lysc_node *context; /**< context node for evaluating the expression */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200885 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci00b874b2019-02-12 10:54:50 +0100886 uint32_t refcount; /**< reference counter since some of the when statements are shared among several nodes */
Radek Krejcidd4e8d42018-10-16 14:55:43 +0200887};
888
889/**
Radek Krejci2a408df2018-10-29 16:32:26 +0100890 * @brief YANG identity-stmt
891 */
892struct lysc_ident {
893 const char *name; /**< identity name (mandatory), including possible prefix */
Radek Krejcic8b31002019-01-08 10:24:45 +0100894 const char *dsc; /**< description */
895 const char *ref; /**< reference */
Radek Krejci693262f2019-04-29 15:23:20 +0200896 struct lys_module *module; /**< module structure */
Radek Krejci2a408df2018-10-29 16:32:26 +0100897 struct lysc_ident **derived; /**< list of (pointers to the) derived identities ([sized array](@ref sizedarrays)) */
898 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +0200899 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejci2a408df2018-10-29 16:32:26 +0100900 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ values are allowed */
901};
902
903/**
Radek Krejcidd4e8d42018-10-16 14:55:43 +0200904 * @brief YANG feature-stmt
905 */
906struct lysc_feature {
907 const char *name; /**< feature name (mandatory) */
Radek Krejcic8b31002019-01-08 10:24:45 +0100908 const char *dsc; /**< description */
909 const char *ref; /**< reference */
Radek Krejci693262f2019-04-29 15:23:20 +0200910 struct lys_module *module; /**< module structure */
Radek Krejci151a5b72018-10-19 14:21:44 +0200911 struct lysc_feature **depfeatures;/**< list of pointers to other features depending on this one ([sized array](@ref sizedarrays)) */
Radek Krejcice8c1592018-10-29 15:35:51 +0100912 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +0200913 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcidd4e8d42018-10-16 14:55:43 +0200914 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* and
915 #LYS_FENABLED values allowed */
916};
917
Radek Krejci151a5b72018-10-19 14:21:44 +0200918/**
919 * @defgroup ifftokens if-feature expression tokens
920 * Tokens of if-feature expression used in ::lysc_iffeature#expr
921 *
922 * @{
923 */
924#define LYS_IFF_NOT 0x00 /**< operand "not" */
925#define LYS_IFF_AND 0x01 /**< operand "and" */
926#define LYS_IFF_OR 0x02 /**< operand "or" */
927#define LYS_IFF_F 0x03 /**< feature */
928/**
929 * @}
930 */
931
932/**
Radek Krejcib7db73a2018-10-24 14:18:40 +0200933 * @brief Compiled YANG revision statement
934 */
935struct lysc_revision {
936 char date[LY_REV_SIZE]; /**< revision-date (mandatory) */
937 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
938};
939
Radek Krejci2167ee12018-11-02 16:09:07 +0100940struct lysc_range {
Radek Krejci4f28eda2018-11-12 11:46:16 +0100941 struct lysc_range_part {
Radek Krejci693262f2019-04-29 15:23:20 +0200942 union { /**< min boundary */
Radek Krejcie7b95092019-05-15 11:03:07 +0200943 int64_t min_64; /**< for int8, int16, int32, int64 and decimal64 ( >= LY_TYPE_DEC64) */
944 uint64_t min_u64; /**< for uint8, uint16, uint32, uint64, string and binary ( < LY_TYPE_DEC64) */
Radek Krejci2167ee12018-11-02 16:09:07 +0100945 };
Radek Krejci693262f2019-04-29 15:23:20 +0200946 union { /**< max boundary */
Radek Krejcie7b95092019-05-15 11:03:07 +0200947 int64_t max_64; /**< for int8, int16, int32, int64 and decimal64 ( >= LY_TYPE_DEC64) */
948 uint64_t max_u64; /**< for uint8, uint16, uint32, uint64, string and binary ( < LY_TYPE_DEC64) */
Radek Krejci2167ee12018-11-02 16:09:07 +0100949 };
Radek Krejci4f28eda2018-11-12 11:46:16 +0100950 } *parts; /**< compiled range expression ([sized array](@ref sizedarrays)) */
Radek Krejcic8b31002019-01-08 10:24:45 +0100951 const char *dsc; /**< description */
952 const char *ref; /**< reference */
Radek Krejci2167ee12018-11-02 16:09:07 +0100953 const char *emsg; /**< error-message */
954 const char *eapptag; /**< error-app-tag value */
955 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
956};
957
958struct lysc_pattern {
Radek Krejci54579462019-04-30 12:47:06 +0200959 const char *expr; /**< original, not compiled, regular expression */
960 pcre2_code *code; /**< compiled regular expression */
Radek Krejcic8b31002019-01-08 10:24:45 +0100961 const char *dsc; /**< description */
962 const char *ref; /**< reference */
Radek Krejci2167ee12018-11-02 16:09:07 +0100963 const char *emsg; /**< error-message */
964 const char *eapptag; /**< error-app-tag value */
965 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci4586a022018-11-13 11:29:26 +0100966 uint32_t inverted:1; /**< invert-match flag */
967 uint32_t refcount:31; /**< reference counter */
Radek Krejci2167ee12018-11-02 16:09:07 +0100968};
969
970struct lysc_must {
971 struct lys_module *module; /**< module where the must was defined */
972 struct lyxp_expr *cond; /**< XPath when condition */
Radek Krejcic8b31002019-01-08 10:24:45 +0100973 const char *dsc; /**< description */
974 const char *ref; /**< reference */
Radek Krejci2167ee12018-11-02 16:09:07 +0100975 const char *emsg; /**< error-message */
976 const char *eapptag; /**< error-app-tag value */
977 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
978};
979
980struct lysc_type {
Radek Krejci4f28eda2018-11-12 11:46:16 +0100981 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +0100982 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +0200983 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 +0100984 LY_DATA_TYPE basetype; /**< Base type of the type */
985 uint32_t refcount; /**< reference counter for type sharing */
986};
987
988struct lysc_type_num {
Radek Krejci4f28eda2018-11-12 11:46:16 +0100989 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +0100990 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +0200991 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 +0100992 LY_DATA_TYPE basetype; /**< Base type of the type */
993 uint32_t refcount; /**< reference counter for type sharing */
994 struct lysc_range *range; /**< Optional range limitation */
995};
996
997struct lysc_type_dec {
Radek Krejci4f28eda2018-11-12 11:46:16 +0100998 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +0100999 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001000 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 +01001001 LY_DATA_TYPE basetype; /**< Base type of the type */
1002 uint32_t refcount; /**< reference counter for type sharing */
Radek Krejci6cba4292018-11-15 17:33:29 +01001003 uint8_t fraction_digits; /**< fraction digits specification */
Radek Krejci2167ee12018-11-02 16:09:07 +01001004 struct lysc_range *range; /**< Optional range limitation */
1005};
1006
1007struct lysc_type_str {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001008 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +01001009 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001010 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 +01001011 LY_DATA_TYPE basetype; /**< Base type of the type */
1012 uint32_t refcount; /**< reference counter for type sharing */
1013 struct lysc_range *length; /**< Optional length limitation */
Radek Krejci4586a022018-11-13 11:29:26 +01001014 struct lysc_pattern **patterns; /**< Optional list of pointers to pattern limitations ([sized array](@ref sizedarrays)) */
Radek Krejci2167ee12018-11-02 16:09:07 +01001015};
1016
Radek Krejci693262f2019-04-29 15:23:20 +02001017struct lysc_type_bitenum_item {
1018 const char *name; /**< enumeration identifier */
1019 const char *dsc; /**< description */
1020 const char *ref; /**< reference */
1021 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
1022 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
1023 union {
1024 int32_t value; /**< integer value associated with the enumeration */
1025 uint32_t position; /**< non-negative integer value associated with the bit */
1026 };
1027 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ and LYS_SET_VALUE
1028 values are allowed */
1029};
1030
Radek Krejci2167ee12018-11-02 16:09:07 +01001031struct lysc_type_enum {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001032 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +01001033 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001034 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 +01001035 LY_DATA_TYPE basetype; /**< Base type of the type */
1036 uint32_t refcount; /**< reference counter for type sharing */
Radek Krejci693262f2019-04-29 15:23:20 +02001037 struct lysc_type_bitenum_item *enums; /**< enumerations list ([sized array](@ref sizedarrays)), mandatory (at least 1 item) */
1038};
1039
1040struct lysc_type_bits {
1041 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
1042 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001043 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 +02001044 LY_DATA_TYPE basetype; /**< Base type of the type */
1045 uint32_t refcount; /**< reference counter for type sharing */
Radek Krejci849a62a2019-05-22 15:29:05 +02001046 struct lysc_type_bitenum_item *bits; /**< bits list ([sized array](@ref sizedarrays)), mandatory (at least 1 item),
1047 the items are ordered by their position value. */
Radek Krejci2167ee12018-11-02 16:09:07 +01001048};
1049
1050struct lysc_type_leafref {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001051 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +01001052 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001053 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 +01001054 LY_DATA_TYPE basetype; /**< Base type of the type */
1055 uint32_t refcount; /**< reference counter for type sharing */
Radek Krejcia3045382018-11-22 14:30:31 +01001056 const char* path; /**< target path */
Radek Krejci96a0bfd2018-11-22 15:25:06 +01001057 struct lys_module *path_context; /**< module where the path is defined, so it provides context to resolve prefixes */
Radek Krejci412ddfa2018-11-23 11:44:11 +01001058 struct lysc_type *realtype; /**< pointer to the real (first non-leafref in possible leafrefs chain) type. */
Radek Krejci2167ee12018-11-02 16:09:07 +01001059 uint8_t require_instance; /**< require-instance flag */
1060};
1061
1062struct lysc_type_identityref {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001063 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +01001064 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001065 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 +01001066 LY_DATA_TYPE basetype; /**< Base type of the type */
1067 uint32_t refcount; /**< reference counter for type sharing */
Radek Krejci555cb5b2018-11-16 14:54:33 +01001068 struct lysc_ident **bases; /**< list of pointers to the base identities ([sized array](@ref sizedarrays)),
Radek Krejci2167ee12018-11-02 16:09:07 +01001069 mandatory (at least 1 item) */
1070};
1071
1072struct lysc_type_instanceid {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001073 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +01001074 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001075 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 +01001076 LY_DATA_TYPE basetype; /**< Base type of the type */
1077 uint32_t refcount; /**< reference counter for type sharing */
1078 uint8_t require_instance; /**< require-instance flag */
1079};
1080
Radek Krejci2167ee12018-11-02 16:09:07 +01001081struct lysc_type_union {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001082 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +01001083 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001084 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 +01001085 LY_DATA_TYPE basetype; /**< Base type of the type */
1086 uint32_t refcount; /**< reference counter for type sharing */
1087 struct lysc_type **types; /**< list of types in the union ([sized array](@ref sizedarrays)), mandatory (at least 1 item) */
1088};
1089
1090struct lysc_type_bin {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001091 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +01001092 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001093 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 +01001094 LY_DATA_TYPE basetype; /**< Base type of the type */
1095 uint32_t refcount; /**< reference counter for type sharing */
1096 struct lysc_range *length; /**< Optional length limitation */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001097};
1098
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001099struct lysc_action_inout {
1100 struct lysc_node *data; /**< first child node (linked list) */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001101 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1102};
1103
Radek Krejci056d0a82018-12-06 16:57:25 +01001104struct lysc_action {
1105 uint16_t nodetype; /**< LYS_ACTION */
1106 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Radek Krejci95710c92019-02-11 15:49:55 +01001107 struct lys_module *module; /**< module structure */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001108 struct lysp_action *sp; /**< simply parsed (SP) original of the node, NULL if the SP schema was removed or in case of implicit case node. */
1109 struct lysc_node *parent; /**< parent node (NULL in case of top level node - RPC) */
1110
Radek Krejcifc11bd72019-04-11 16:00:05 +02001111 struct lysc_ext_instance *input_exts; /**< list of the extension instances of input ([sized array](@ref sizedarrays)) */
1112 struct lysc_ext_instance *output_exts; /**< list of the extension instances of outpu ([sized array](@ref sizedarrays)) */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001113
Radek Krejci056d0a82018-12-06 16:57:25 +01001114 const char *name; /**< action/RPC name (mandatory) */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001115 const char *dsc; /**< description */
1116 const char *ref; /**< reference */
1117
Radek Krejcifc11bd72019-04-11 16:00:05 +02001118 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
1119 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
1120
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001121 struct lysc_action_inout input; /**< RPC's/action's input */
1122 struct lysc_action_inout output; /**< RPC's/action's output */
1123
Radek Krejci056d0a82018-12-06 16:57:25 +01001124};
1125
1126struct lysc_notif {
1127 uint16_t nodetype; /**< LYS_NOTIF */
1128 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Radek Krejci95710c92019-02-11 15:49:55 +01001129 struct lys_module *module; /**< module structure */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001130 struct lysp_notif *sp; /**< simply parsed (SP) original of the node, NULL if the SP schema was removed or in case of implicit case node. */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001131 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1132
Radek Krejcifc11bd72019-04-11 16:00:05 +02001133 struct lysc_node *data; /**< first child node (linked list) */
1134 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1135
Radek Krejci056d0a82018-12-06 16:57:25 +01001136 const char *name; /**< Notification name (mandatory) */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001137 const char *dsc; /**< description */
1138 const char *ref; /**< reference */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001139
1140 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
1141 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejci056d0a82018-12-06 16:57:25 +01001142};
1143
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001144/**
Radek Krejci0af5f5d2018-09-07 15:00:30 +02001145 * @brief Compiled YANG data node
1146 */
1147struct lysc_node {
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001148 uint16_t nodetype; /**< type of the node (mandatory) */
1149 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001150 struct lys_module *module; /**< module structure */
1151 struct lysp_node *sp; /**< simply parsed (SP) original of the node, NULL if the SP schema was removed or in case of implicit case node. */
1152 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1153 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1154 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1155 never NULL. If there is no sibling node, pointer points to the node
1156 itself. In case of the first node, this pointer points to the last
1157 node in the list. */
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001158 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001159 const char *dsc; /**< description */
1160 const char *ref; /**< reference */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001161 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci056d0a82018-12-06 16:57:25 +01001162 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001163 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001164};
1165
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001166struct lysc_node_container {
1167 uint16_t nodetype; /**< LYS_CONTAINER */
1168 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1169 struct lys_module *module; /**< module structure */
1170 struct lysp_node *sp; /**< simply parsed (SP) original of the node, NULL if the SP schema was removed or in case of implicit case node. */
1171 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1172 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1173 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1174 never NULL. If there is no sibling node, pointer points to the node
1175 itself. In case of the first node, this pointer points to the last
1176 node in the list. */
1177 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001178 const char *dsc; /**< description */
1179 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001180 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci4f28eda2018-11-12 11:46:16 +01001181 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001182 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejci4f28eda2018-11-12 11:46:16 +01001183
1184 struct lysc_node *child; /**< first child node (linked list) */
1185 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1186 struct lysc_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
1187 struct lysc_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001188};
1189
Radek Krejcia3045382018-11-22 14:30:31 +01001190struct lysc_node_case {
Radek Krejci056d0a82018-12-06 16:57:25 +01001191 uint16_t nodetype; /**< LYS_CASE */
1192 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1193 struct lys_module *module; /**< module structure */
1194 struct lysp_node *sp; /**< simply parsed (SP) original of the node, NULL if the SP schema was removed or in case of implicit case node. */
1195 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1196 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1197 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1198 never NULL. If there is no sibling node, pointer points to the node
1199 itself. In case of the first node, this pointer points to the last
1200 node in the list. */
Radek Krejcia3045382018-11-22 14:30:31 +01001201 const char *name; /**< name of the case, including the implicit case */
Radek Krejci12fb9142019-01-08 09:45:30 +01001202 const char *dsc; /**< description */
1203 const char *ref; /**< reference */
Radek Krejci056d0a82018-12-06 16:57:25 +01001204 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci056d0a82018-12-06 16:57:25 +01001205 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001206 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejci056d0a82018-12-06 16:57:25 +01001207
Radek Krejcia3045382018-11-22 14:30:31 +01001208 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 +01001209 each other as siblings with the parent pointer pointing to appropriate case node. */
Radek Krejcia3045382018-11-22 14:30:31 +01001210};
1211
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001212struct lysc_node_choice {
1213 uint16_t nodetype; /**< LYS_CHOICE */
1214 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1215 struct lys_module *module; /**< module structure */
1216 struct lysp_node *sp; /**< simply parsed (SP) original of the node, NULL if the SP schema was removed or in case of implicit case node. */
1217 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1218 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1219 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1220 never NULL. If there is no sibling node, pointer points to the node
1221 itself. In case of the first node, this pointer points to the last
1222 node in the list. */
1223 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001224 const char *dsc; /**< description */
1225 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001226 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci056d0a82018-12-06 16:57:25 +01001227 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001228 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001229
Radek Krejcia9026eb2018-12-12 16:04:47 +01001230 struct lysc_node_case *cases; /**< list of the cases (linked list). Note that all the children of all the cases are linked each other
1231 as siblings. Their parent pointers points to the specific case they belongs to, so distinguish the
1232 case is simple. */
Radek Krejci056d0a82018-12-06 16:57:25 +01001233 struct lysc_node_case *dflt; /**< default case of the choice, only a pointer into the cases array. */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001234};
1235
1236struct lysc_node_leaf {
1237 uint16_t nodetype; /**< LYS_LEAF */
1238 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1239 struct lys_module *module; /**< module structure */
1240 struct lysp_node *sp; /**< simply parsed (SP) original of the node, NULL if the SP schema was removed or in case of implicit case node. */
1241 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1242 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1243 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1244 never NULL. If there is no sibling node, pointer points to the node
1245 itself. In case of the first node, this pointer points to the last
1246 node in the list. */
1247 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001248 const char *dsc; /**< description */
1249 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001250 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci4f28eda2018-11-12 11:46:16 +01001251 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001252 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejci4f28eda2018-11-12 11:46:16 +01001253
1254 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1255 struct lysc_type *type; /**< type of the leaf node (mandatory) */
Radek Krejcib57cf1e2018-11-23 14:07:05 +01001256
Radek Krejci4f28eda2018-11-12 11:46:16 +01001257 const char *units; /**< units of the leaf's type */
1258 const char *dflt; /**< default value */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001259};
1260
1261struct lysc_node_leaflist {
1262 uint16_t nodetype; /**< LYS_LEAFLIST */
1263 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1264 struct lys_module *module; /**< module structure */
1265 struct lysp_node *sp; /**< simply parsed (SP) original of the node, NULL if the SP schema was removed or in case of implicit case node. */
1266 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1267 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1268 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1269 never NULL. If there is no sibling node, pointer points to the node
1270 itself. In case of the first node, this pointer points to the last
1271 node in the list. */
1272 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001273 const char *dsc; /**< description */
1274 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001275 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcib57cf1e2018-11-23 14:07:05 +01001276 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001277 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejcib57cf1e2018-11-23 14:07:05 +01001278
1279 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1280 struct lysc_type *type; /**< type of the leaf node (mandatory) */
1281
Radek Krejci0e5d8382018-11-28 16:37:53 +01001282 const char *units; /**< units of the leaf's type */
1283 const char **dflts; /**< list of default values ([sized array](@ref sizedarrays)) */
1284 uint32_t min; /**< min-elements constraint */
1285 uint32_t max; /**< max-elements constraint */
1286
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001287};
1288
1289struct lysc_node_list {
1290 uint16_t nodetype; /**< LYS_LIST */
1291 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1292 struct lys_module *module; /**< module structure */
1293 struct lysp_node *sp; /**< simply parsed (SP) original of the node, NULL if the SP schema was removed or in case of implicit case node. */
1294 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1295 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1296 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1297 never NULL. If there is no sibling node, pointer points to the node
1298 itself. In case of the first node, this pointer points to the last
1299 node in the list. */
1300 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001301 const char *dsc; /**< description */
1302 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001303 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci9bb94eb2018-12-04 16:48:35 +01001304 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001305 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejci9bb94eb2018-12-04 16:48:35 +01001306
1307 struct lysc_node *child; /**< first child node (linked list) */
1308 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1309 struct lysc_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
1310 struct lysc_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
1311
1312 struct lysc_node_leaf **keys; /**< list of pointers to the keys ([sized array](@ref sizedarrays)) */
1313 struct lysc_node_leaf ***uniques; /**< list of sized arrays of pointers to the unique nodes ([sized array](@ref sizedarrays)) */
1314 uint32_t min; /**< min-elements constraint */
1315 uint32_t max; /**< max-elements constraint */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001316};
1317
1318struct lysc_node_anydata {
1319 uint16_t nodetype; /**< LYS_ANYXML or LYS_ANYDATA */
1320 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1321 struct lys_module *module; /**< module structure */
1322 struct lysp_node *sp; /**< simply parsed (SP) original of the node, NULL if the SP schema was removed or in case of implicit case node. */
1323 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1324 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1325 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1326 never NULL. If there is no sibling node, pointer points to the node
1327 itself. In case of the first node, this pointer points to the last
1328 node in the list. */
1329 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001330 const char *dsc; /**< description */
1331 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001332 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci056d0a82018-12-06 16:57:25 +01001333 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001334 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejci9800fb82018-12-13 14:26:23 +01001335
1336 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001337};
1338
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001339/**
1340 * @brief Compiled YANG schema tree structure representing YANG module.
1341 *
1342 * Semantically validated YANG schema tree for data tree parsing.
1343 * Contains only the necessary information for the data validation.
1344 */
1345struct lysc_module {
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001346 struct lys_module *mod; /**< covering module structure */
Radek Krejci151a5b72018-10-19 14:21:44 +02001347 struct lysc_import *imports; /**< list of imported modules ([sized array](@ref sizedarrays)) */
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001348
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001349 struct lysc_feature *features; /**< list of feature definitions ([sized array](@ref sizedarrays)) */
Radek Krejci2a408df2018-10-29 16:32:26 +01001350 struct lysc_ident *identities; /**< list of identities ([sized array](@ref sizedarrays)) */
1351 struct lysc_node *data; /**< list of module's top-level data nodes (linked list) */
1352 struct lysc_action *rpcs; /**< list of RPCs ([sized array](@ref sizedarrays)) */
1353 struct lysc_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
Radek Krejcice8c1592018-10-29 15:35:51 +01001354 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci0af5f5d2018-09-07 15:00:30 +02001355};
1356
1357/**
Radek Krejci53ea6152018-12-13 15:21:15 +01001358 * @brief Get the groupings sized array of the given (parsed) schema node.
1359 * Decides the node's type and in case it has a groupings array, returns it.
1360 * @param[in] node Node to examine.
1361 * @return The node's groupings sized array if any, NULL otherwise.
1362 */
1363const struct lysp_grp *lysp_node_groupings(const struct lysp_node *node);
1364
1365/**
Radek Krejci056d0a82018-12-06 16:57:25 +01001366 * @brief Get the typedefs sized array of the given (parsed) schema node.
1367 * Decides the node's type and in case it has a typedefs array, returns it.
1368 * @param[in] node Node to examine.
1369 * @return The node's typedefs sized array if any, NULL otherwise.
1370 */
1371const struct lysp_tpdf *lysp_node_typedefs(const struct lysp_node *node);
1372
1373/**
1374 * @brief Get the actions/RPCs sized array of the given (parsed) schema node.
1375 * Decides the node's type and in case it has a actions/RPCs array, returns it.
1376 * @param[in] node Node to examine.
1377 * @return The node's actions/RPCs sized array if any, NULL otherwise.
1378 */
1379const struct lysp_action *lysp_node_actions(const struct lysp_node *node);
1380
1381/**
1382 * @brief Get the Notifications sized array of the given (parsed) schema node.
1383 * Decides the node's type and in case it has a Notifications array, returns it.
1384 * @param[in] node Node to examine.
1385 * @return The node's Notifications sized array if any, NULL otherwise.
1386 */
1387const struct lysp_notif *lysp_node_notifs(const struct lysp_node *node);
1388
1389/**
1390 * @brief Get the children linked list of the given (parsed) schema node.
1391 * Decides the node's type and in case it has a children list, returns it.
1392 * @param[in] node Node to examine.
1393 * @return The node's children linked list if any, NULL otherwise.
1394 */
1395const struct lysp_node *lysp_node_children(const struct lysp_node *node);
1396
1397/**
1398 * @brief Get the actions/RPCs sized array of the given (compiled) schema node.
1399 * Decides the node's type and in case it has a actions/RPCs array, returns it.
1400 * @param[in] node Node to examine.
1401 * @return The node's actions/RPCs sized array if any, NULL otherwise.
1402 */
1403const struct lysc_action *lysc_node_actions(const struct lysc_node *node);
1404
1405/**
1406 * @brief Get the Notifications sized array of the given (compiled) schema node.
1407 * Decides the node's type and in case it has a Notifications array, returns it.
1408 * @param[in] node Node to examine.
1409 * @return The node's Notifications sized array if any, NULL otherwise.
1410 */
1411const struct lysc_notif *lysc_node_notifs(const struct lysc_node *node);
1412
1413/**
1414 * @brief Get the children linked list of the given (compiled) schema node.
1415 * Decides the node's type and in case it has a children list, returns it.
1416 * @param[in] node Node to examine.
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001417 * @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 +01001418 * @return The node's children linked list if any, NULL otherwise.
1419 */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001420const struct lysc_node *lysc_node_children(const struct lysc_node *node, uint16_t flags);
Radek Krejci056d0a82018-12-06 16:57:25 +01001421
1422/**
Radek Krejci151a5b72018-10-19 14:21:44 +02001423 * @brief Get how the if-feature statement currently evaluates.
1424 *
1425 * @param[in] iff Compiled if-feature statement to evaluate.
1426 * @return If the statement evaluates to true, 1 is returned. 0 is returned when the statement evaluates to false.
1427 */
1428int lysc_iffeature_value(const struct lysc_iffeature *iff);
1429
1430/**
1431 * @brief Get the current status of the provided feature.
1432 *
1433 * @param[in] feature Compiled feature statement to examine.
1434 * @return
1435 * - 1 if feature is enabled,
1436 * - 0 if feature is disabled,
1437 * - -1 in case of error (invalid argument)
1438 */
1439int lysc_feature_value(const struct lysc_feature *feature);
1440
1441/**
Radek Krejci327de162019-06-14 12:52:07 +02001442 * @brief Generate path of the given node in the requested format.
1443 *
1444 * @param[in] node Schema path of this node will be generated.
1445 * @param[in] pathtype Format of the path to generate.
1446 * @return NULL in case of memory allocation error, path of the node otherwise.
1447 * Returned string is dynamically allocated and caller is responsible to free it.
1448 */
1449char *lysc_path(struct lysc_node *node, LY_PATH_TYPE pathtype);
1450
1451/**
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001452 * @brief Available YANG schema tree structures representing YANG module.
1453 */
1454struct lys_module {
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001455 struct ly_ctx *ctx; /**< libyang context of the module (mandatory) */
1456 const char *name; /**< name of the module (mandatory) */
Radek Krejci0af46292019-01-11 16:02:31 +01001457 const char *revision; /**< revision of the module (if present) */
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001458 const char *ns; /**< namespace of the module (module - mandatory) */
1459 const char *prefix; /**< module prefix or submodule belongsto prefix of main module (mandatory) */
1460 const char *filepath; /**< path, if the schema was read from a file, NULL in case of reading from memory */
1461 const char *org; /**< party/company responsible for the module */
1462 const char *contact; /**< contact information for the module */
1463 const char *dsc; /**< description of the module */
1464 const char *ref; /**< cross-reference for the module */
1465
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001466 struct lysp_module *parsed; /**< Simply parsed (unresolved) YANG schema tree */
Radek Krejci0af46292019-01-11 16:02:31 +01001467 struct lysc_module *compiled; /**< Compiled and fully validated YANG schema tree for data parsing.
1468 Available only for implemented modules. */
1469 struct lysc_feature *off_features;/**< List of pre-compiled features of the module in non implemented modules ([sized array](@ref sizedarrays)).
1470 These features are always disabled and cannot be enabled until the module
1471 become implemented. The features are present in this form to allow their linkage
1472 from if-feature statements of the compiled schemas and their proper use in case
1473 the module became implemented in future (no matter if implicitly via augment/deviate
1474 or explicitly via ly_ctx_module_implement()). */
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001475
Radek Krejci95710c92019-02-11 15:49:55 +01001476 uint8_t implemented; /**< flag if the module is implemented, not just imported. The module is implemented if
1477 the flag has non-zero value. Specific values are used internally:
1478 1 - implemented module
1479 2 - recently implemented module by dependency, it can be reverted in rollback procedure */
1480 uint8_t latest_revision; /**< flag to mark the latest available revision:
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001481 1 - the latest revision in searchdirs was not searched yet and this is the
1482 latest revision in the current context
1483 2 - searchdirs were searched and this is the latest available revision */
1484 uint8_t version; /**< yang-version (LYS_VERSION values) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001485};
1486
Radek Krejci151a5b72018-10-19 14:21:44 +02001487/**
1488 * @brief Enable specified feature in the module
1489 *
1490 * By default, when the module is loaded by libyang parser, all features are disabled.
1491 *
Radek Krejcica3db002018-11-01 10:31:01 +01001492 * If all features are being enabled, it must be possible respecting their if-feature conditions. For example,
1493 * enabling all features on the following feature set will fail since it is not possible to enable both features
1494 * (and it is unclear which of them should be enabled then). In this case the LY_EDENIED is returned and the feature
1495 * is untouched.
1496 *
1497 * feature f1;
1498 * feature f2 { if-feature 'not f1';}
1499 *
Radek Krejci151a5b72018-10-19 14:21:44 +02001500 * @param[in] module Module where the feature will be enabled.
1501 * @param[in] feature Name of the feature to enable. To enable all features at once, use asterisk (`*`) character.
1502 * @return LY_ERR value.
1503 */
Radek Krejcied5acc52019-04-25 15:57:04 +02001504LY_ERR lys_feature_enable(const struct lys_module *module, const char *feature);
Radek Krejci151a5b72018-10-19 14:21:44 +02001505
1506/**
1507 * @brief Disable specified feature in the module
1508 *
1509 * By default, when the module is loaded by libyang parser, all features are disabled.
1510 *
1511 * @param[in] module Module where the feature will be disabled.
1512 * @param[in] feature Name of the feature to disable. To disable all features at once, use asterisk (`*`) character.
1513 * @return LY_ERR value
1514 */
Radek Krejcied5acc52019-04-25 15:57:04 +02001515LY_ERR lys_feature_disable(const struct lys_module *module, const char *feature);
Radek Krejci151a5b72018-10-19 14:21:44 +02001516
1517/**
1518 * @brief Get the current status of the specified feature in the module.
1519 *
1520 * @param[in] module Module where the feature is defined.
1521 * @param[in] feature Name of the feature to inspect.
1522 * @return
1523 * - 1 if feature is enabled,
1524 * - 0 if feature is disabled,
1525 * - -1 in case of error (e.g. feature is not defined or invalid arguments)
1526 */
1527int lys_feature_value(const struct lys_module *module, const char *feature);
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001528
1529/**
Radek Krejci86d106e2018-10-18 09:53:19 +02001530 * @brief Load a schema into the specified context.
1531 *
1532 * @param[in] ctx libyang context where to process the data model.
1533 * @param[in] data The string containing the dumped data model in the specified
1534 * format.
1535 * @param[in] format Format of the input data (YANG or YIN).
1536 * @return Pointer to the data model structure or NULL on error.
1537 */
Radek Krejcid14e9692018-11-01 11:00:37 +01001538struct lys_module *lys_parse_mem(struct ly_ctx *ctx, const char *data, LYS_INFORMAT format);
Radek Krejci86d106e2018-10-18 09:53:19 +02001539
1540/**
1541 * @brief Read a schema from file descriptor into the specified context.
1542 *
1543 * \note Current implementation supports only reading data from standard (disk) file, not from sockets, pipes, etc.
1544 *
1545 * @param[in] ctx libyang context where to process the data model.
1546 * @param[in] fd File descriptor of a regular file (e.g. sockets are not supported) containing the schema
1547 * in the specified format.
1548 * @param[in] format Format of the input data (YANG or YIN).
1549 * @return Pointer to the data model structure or NULL on error.
1550 */
Radek Krejcid14e9692018-11-01 11:00:37 +01001551struct lys_module *lys_parse_fd(struct ly_ctx *ctx, int fd, LYS_INFORMAT format);
Radek Krejci86d106e2018-10-18 09:53:19 +02001552
1553/**
Radek Krejcid33273d2018-10-25 14:55:52 +02001554 * @brief Read a schema into the specified context from a file.
Radek Krejci86d106e2018-10-18 09:53:19 +02001555 *
1556 * @param[in] ctx libyang context where to process the data model.
1557 * @param[in] path Path to the file with the model in the specified format.
1558 * @param[in] format Format of the input data (YANG or YIN).
1559 * @return Pointer to the data model structure or NULL on error.
1560 */
Radek Krejcid14e9692018-11-01 11:00:37 +01001561struct lys_module *lys_parse_path(struct ly_ctx *ctx, const char *path, LYS_INFORMAT format);
Radek Krejci86d106e2018-10-18 09:53:19 +02001562
1563/**
Radek Krejcid33273d2018-10-25 14:55:52 +02001564 * @brief Search for the schema file in the specified searchpaths.
1565 *
1566 * @param[in] searchpaths NULL-terminated array of paths to be searched (recursively). Current working
1567 * directory is searched automatically (but non-recursively if not in the provided list). Caller can use
1568 * result of the ly_ctx_get_searchdirs().
1569 * @param[in] cwd Flag to implicitly search also in the current working directory (non-recursively).
1570 * @param[in] name Name of the schema to find.
1571 * @param[in] revision Revision of the schema to find. If NULL, the newest found schema filepath is returned.
1572 * @param[out] localfile Mandatory output variable containing absolute path of the found schema. If no schema
1573 * complying the provided restriction is found, NULL is set.
1574 * @param[out] format Optional output variable containing expected format of the schema document according to the
1575 * file suffix.
1576 * @return LY_ERR value (LY_SUCCESS is returned even if the file is not found, then the *localfile is NULL).
1577 */
1578LY_ERR lys_search_localfile(const char * const *searchpaths, int cwd, const char *name, const char *revision, char **localfile, LYS_INFORMAT *format);
1579
1580/**
Radek Krejcia3045382018-11-22 14:30:31 +01001581 * @brief Get next schema tree (sibling) node element that can be instantiated in a data tree. Returned node can
1582 * be from an augment.
1583 *
1584 * lys_getnext() is supposed to be called sequentially. In the first call, the \p last parameter is usually NULL
1585 * and function starts returning i) the first \p parent's child or ii) the first top level element of the \p module.
1586 * Consequent calls suppose to provide the previously returned node as the \p last parameter and still the same
1587 * \p parent and \p module parameters.
1588 *
1589 * Without options, the function is used to traverse only the schema nodes that can be paired with corresponding
1590 * data nodes in a data tree. By setting some \p options the behavior can be modified to the extent that
1591 * all the schema nodes are iteratively returned.
1592 *
1593 * @param[in] last Previously returned schema tree node, or NULL in case of the first call.
1594 * @param[in] parent Parent of the subtree where the function starts processing.
1595 * @param[in] module In case of iterating on top level elements, the \p parent is NULL and
1596 * module must be specified.
1597 * @param[in] options [ORed options](@ref sgetnextflags).
1598 * @return Next schema tree node that can be instantiated in a data tree, NULL in case there is no such element.
1599 */
1600const struct lysc_node *lys_getnext(const struct lysc_node *last, const struct lysc_node *parent,
1601 const struct lysc_module *module, int options);
1602
1603/**
1604 * @defgroup sgetnextflags lys_getnext() flags
1605 * @ingroup schematree
1606 *
1607 * @{
1608 */
1609#define LYS_GETNEXT_WITHCHOICE 0x01 /**< lys_getnext() option to allow returning #LYS_CHOICE nodes instead of looking into them */
Radek Krejci9bb94eb2018-12-04 16:48:35 +01001610#define LYS_GETNEXT_NOCHOICE 0x02 /**< lys_getnext() option to ignore (kind of conditional) nodes within choice node */
Radek Krejci056d0a82018-12-06 16:57:25 +01001611#define LYS_GETNEXT_WITHCASE 0x04 /**< lys_getnext() option to allow returning #LYS_CASE nodes instead of looking into them */
Radek Krejcia3045382018-11-22 14:30:31 +01001612#define LYS_GETNEXT_INTONPCONT 0x40 /**< lys_getnext() option to look into non-presence container, instead of returning container itself */
1613#define LYS_GETNEXT_NOSTATECHECK 0x100 /**< lys_getnext() option to skip checking module validity (import-only, disabled) and
1614 relevant if-feature conditions state */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001615#define LYS_GETNEXT_OUTPUT 0x200 /**< lys_getnext() option to provide RPC's/action's output schema nodes instead of input schema nodes
1616 provided by default */
Radek Krejcia3045382018-11-22 14:30:31 +01001617/** @} sgetnextflags */
1618
1619/**
1620 * @brief Get child node according to the specified criteria.
1621 *
1622 * @param[in] parent Optional parent of the node to find. If not specified, the module's top-level nodes are searched.
1623 * @param[in] module module of the node to find. It is also limitation for the children node of the given parent.
1624 * @param[in] name Name of the node to find.
1625 * @param[in] name_len Optional length of the name in case it is not NULL-terminated string.
1626 * @param[in] nodetype Optional criteria (to speedup) specifying nodetype(s) of the node to find.
1627 * Used as a bitmask, so multiple nodetypes can be specified.
1628 * @param[in] options [ORed options](@ref sgetnextflags).
1629 * @return Found node if any.
1630 */
1631const struct lysc_node *lys_child(const struct lysc_node *parent, const struct lys_module *module,
1632 const char *name, size_t name_len, uint16_t nodetype, int options);
1633
1634/**
1635 * @brief Check if the schema node is disabled in the schema tree, i.e. there is any disabled if-feature statement
1636 * affecting the node.
1637 *
1638 * @param[in] node Schema node to check.
1639 * @param[in] recursive - 0 to check if-feature only in the \p node schema node,
1640 * - 1 to check if-feature in all ascendant schema nodes until there is a node possibly having an instance in a data tree
1641 * @return - NULL if enabled,
1642 * - pointer to the node with the unsatisfied (disabling) if-feature expression.
1643 */
1644const struct lysc_iffeature *lys_is_disabled(const struct lysc_node *node, int recursive);
1645
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001646/** @} */
1647
Radek Krejci70853c52018-10-15 14:46:16 +02001648#ifdef __cplusplus
1649}
1650#endif
1651
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001652#endif /* LY_TREE_SCHEMA_H_ */