blob: f5ddc35038929b9a5b5577b90327503c620625fd [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) */
Radek Krejcid3ca0632019-04-16 16:54:54 +0200126 uint16_t flags;
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200127};
128
129/**
130 * @brief YANG extension instance
131 */
132struct lysp_ext_instance {
133 const char *name; /**< extension identifier, including possible prefix */
134 const char *argument; /**< optional value of the extension's argument */
Radek Krejci693262f2019-04-29 15:23:20 +0200135 struct lysp_stmt *child; /**< list of the extension's substatements (linked list) */
Michal Vaskod92e42a2018-09-07 08:35:02 +0200136 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 */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200139};
140
141/**
142 * @brief YANG feature-stmt
143 */
144struct lysp_feature {
145 const char *name; /**< feature name (mandatory) */
Radek Krejci151a5b72018-10-19 14:21:44 +0200146 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200147 const char *dsc; /**< description statement */
148 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200149 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200150 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values allowed */
151};
152
153/**
154 * @brief YANG identity-stmt
155 */
156struct lysp_ident {
157 const char *name; /**< identity name (mandatory), including possible prefix */
Radek Krejci151a5b72018-10-19 14:21:44 +0200158 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
159 const char **bases; /**< list of base identifiers ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200160 const char *dsc; /**< description statement */
161 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200162 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200163 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ values are allowed */
164};
165
Michal Vasko71e64ca2018-09-07 16:30:29 +0200166/**
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200167 * @brief Covers restrictions: range, length, pattern, must
168 */
169struct lysp_restr {
170 const char *arg; /**< The restriction expression/value (mandatory);
171 in case of pattern restriction, the first byte has a special meaning:
172 0x06 (ACK) for regular match and 0x15 (NACK) for invert-match */
173 const char *emsg; /**< error-message */
174 const char *eapptag; /**< error-app-tag value */
175 const char *dsc; /**< description */
176 const char *ref; /**< reference */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200177 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200178};
179
180/**
Michal Vasko71e64ca2018-09-07 16:30:29 +0200181 * @brief YANG revision-stmt
182 */
183struct lysp_revision {
Radek Krejcib7db73a2018-10-24 14:18:40 +0200184 char date[LY_REV_SIZE]; /**< revision date (madatory) */
Michal Vasko71e64ca2018-09-07 16:30:29 +0200185 const char *dsc; /**< description statement */
186 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200187 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vasko71e64ca2018-09-07 16:30:29 +0200188};
189
190/**
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200191 * @brief Enumeration/Bit value definition
192 */
193struct lysp_type_enum {
194 const char *name; /**< name (mandatory) */
195 const char *dsc; /**< description statement */
196 const char *ref; /**< reference statement */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200197 int64_t value; /**< enum's value or bit's position */
Radek Krejci151a5b72018-10-19 14:21:44 +0200198 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200199 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200200 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ and LYS_SET_VALUE
201 values are allowed */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200202};
203
204/**
205 * @brief YANG type-stmt
206 *
207 * Some of the items in the structure may be mandatory, but it is necessary to resolve the type's base type first
208 */
209struct lysp_type {
210 const char *name; /**< name of the type (mandatory) */
211 struct lysp_restr *range; /**< allowed values range - numerical, decimal64 */
212 struct lysp_restr *length; /**< allowed length of the value - string, binary */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200213 struct lysp_restr *patterns; /**< list of patterns ([sized array](@ref sizedarrays)) - string */
214 struct lysp_type_enum *enums; /**< list of enum-stmts ([sized array](@ref sizedarrays)) - enum */
215 struct lysp_type_enum *bits; /**< list of bit-stmts ([sized array](@ref sizedarrays)) - bits */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200216 const char *path; /**< path - leafref */
Radek Krejci151a5b72018-10-19 14:21:44 +0200217 const char **bases; /**< list of base identifiers ([sized array](@ref sizedarrays)) - identityref */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200218 struct lysp_type *types; /**< list of sub-types ([sized array](@ref sizedarrays)) - union */
219 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200220
Radek Krejci2167ee12018-11-02 16:09:07 +0100221 struct lysc_type *compiled; /**< pointer to the compiled type */
222
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200223 uint8_t fraction_digits; /**< number of fraction digits - decimal64 */
224 uint8_t require_instance; /**< require-instance flag - leafref, instance */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100225 uint16_t flags; /**< [schema node flags](@ref spnodeflags) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200226};
227
228/**
229 * @brief YANG typedef-stmt
230 */
231struct lysp_tpdf {
232 const char *name; /**< name of the newly defined type (mandatory) */
233 const char *units; /**< units of the newly defined type */
234 const char *dflt; /**< default value of the newly defined type */
235 const char *dsc; /**< description statement */
236 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200237 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200238 struct lysp_type type; /**< base type from which the typedef is derived (mandatory) */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100239 uint16_t flags; /**< [schema node flags](@ref spnodeflags) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200240};
241
242/**
243 * @brief YANG grouping-stmt
244 */
245struct lysp_grp {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100246 struct lysp_node *parent; /**< parent node (NULL if this is a top-level grouping) */
247 uint16_t nodetype; /**< LYS_GROUPING */
248 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200249 const char *name; /**< grouping name (mandatory) */
250 const char *dsc; /**< description statement */
251 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200252 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
253 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200254 struct lysp_node *data; /**< list of data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200255 struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
256 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
257 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200258};
259
260/**
261 * @brief YANG when-stmt
262 */
263struct lysp_when {
264 const char *cond; /**< specified condition (mandatory) */
265 const char *dsc; /**< description statement */
266 const char *ref; /**< reference statement */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200267 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200268};
269
270/**
271 * @brief YANG refine-stmt
272 */
273struct lysp_refine {
274 const char *nodeid; /**< target descendant schema nodeid (mandatory) */
275 const char *dsc; /**< description statement */
276 const char *ref; /**< reference statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200277 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200278 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200279 const char *presence; /**< presence description */
Radek Krejci151a5b72018-10-19 14:21:44 +0200280 const char **dflts; /**< list of default values ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200281 uint32_t min; /**< min-elements constraint */
282 uint32_t max; /**< max-elements constraint, 0 means unbounded */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200283 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200284 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
285};
286
287/**
288 * @brief YANG uses-augment-stmt and augment-stmt
289 */
290struct lysp_augment {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100291 struct lysp_node *parent; /**< parent node (NULL if this is a top-level augment) */
292 uint16_t nodetype; /**< LYS_AUGMENT */
293 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200294 const char *nodeid; /**< target schema nodeid (mandatory) - absolute for global augments, descendant for uses's augments */
295 const char *dsc; /**< description statement */
296 const char *ref; /**< reference statement */
297 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200298 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200299 struct lysp_node *child; /**< list of data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200300 struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
301 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
302 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200303};
304
305/**
306 * @defgroup deviatetypes Deviate types
307 * @{
308 */
309#define LYS_DEV_NOT_SUPPORTED 1 /**< deviate type not-supported */
310#define LYS_DEV_ADD 2 /**< deviate type add */
311#define LYS_DEV_DELETE 3 /**< deviate type delete */
312#define LYS_DEV_REPLACE 4 /**< deviate type replace */
313/** @} */
314
315/**
316 * @brief Generic deviate structure to get type and cast to lysp_deviate_* structure
317 */
318struct lysp_deviate {
319 uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */
320 struct lysp_deviate *next; /**< next deviate structure in the list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200321 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200322};
323
324struct lysp_deviate_add {
325 uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */
326 struct lysp_deviate *next; /**< next deviate structure in the list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200327 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200328 const char *units; /**< units of the values */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200329 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci151a5b72018-10-19 14:21:44 +0200330 const char **uniques; /**< list of uniques specifications ([sized array](@ref sizedarrays)) */
331 const char **dflts; /**< list of default values ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200332 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
333 uint32_t min; /**< min-elements constraint */
334 uint32_t max; /**< max-elements constraint, 0 means unbounded */
335};
336
337struct lysp_deviate_del {
338 uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */
339 struct lysp_deviate *next; /**< next deviate structure in the list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200340 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200341 const char *units; /**< units of the values */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200342 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci151a5b72018-10-19 14:21:44 +0200343 const char **uniques; /**< list of uniques specifications ([sized array](@ref sizedarrays)) */
344 const char **dflts; /**< list of default values ([sized array](@ref sizedarrays)) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200345 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200346};
347
348struct lysp_deviate_rpl {
349 uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */
350 struct lysp_deviate *next; /**< next deviate structure in the list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200351 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200352 struct lysp_type *type; /**< type of the node */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200353 const char *units; /**< units of the values */
354 const char *dflt; /**< default value */
355 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
356 uint32_t min; /**< min-elements constraint */
357 uint32_t max; /**< max-elements constraint, 0 means unbounded */
358};
359
360struct lysp_deviation {
Michal Vaskob55f6c12018-09-12 11:13:15 +0200361 const char *nodeid; /**< target absolute schema nodeid (mandatory) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200362 const char *dsc; /**< description statement */
363 const char *ref; /**< reference statement */
364 struct lysp_deviate* deviates; /**< list of deviate specifications (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200365 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200366};
367
Radek Krejci4f28eda2018-11-12 11:46:16 +0100368/**
369 * @defgroup spnodeflags Parsed schema nodes flags
370 * @ingroup snodeflags
371 *
372 * Various flags for parsed schema nodes.
373 *
374 * 1 - container 6 - anydata/anyxml 11 - output 16 - grouping 21 - enum
375 * 2 - choice 7 - case 12 - feature 17 - uses 22 - type
Radek Krejcid3ca0632019-04-16 16:54:54 +0200376 * 3 - leaf 8 - notification 13 - identity 18 - refine 23 - stmt
Radek Krejci4f28eda2018-11-12 11:46:16 +0100377 * 4 - leaflist 9 - rpc 14 - extension 19 - augment
378 * 5 - list 10 - input 15 - typedef 20 - deviate
379 *
Radek Krejcid3ca0632019-04-16 16:54:54 +0200380 * 1 1 1 1 1 1 1 1 1 1 2 2 2 2
381 * 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
382 * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
383 * 1 LYS_CONFIG_W |x|x|x|x|x|x|x| | | | | | | | | | |x| |x| | | |
384 * LYS_SET_BASE | | | | | | | | | | | | | | | | | | | | | |x| |
385 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
386 * 2 LYS_CONFIG_R |x|x|x|x|x|x|x| | | | | | | | | | |x| |x| | | |
387 * LYS_SET_BIT | | | | | | | | | | | | | | | | | | | | | |x| |
388 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
389 * 3 LYS_STATUS_CURR |x|x|x|x|x|x|x|x|x| | |x|x|x|x|x|x| |x|x|x| | |
390 * LYS_SET_ENUM | | | | | | | | | | | | | | | | | | | | | |x| |
391 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
392 * 4 LYS_STATUS_DEPRC |x|x|x|x|x|x|x|x|x| | |x|x|x|x|x|x| |x|x|x| | |
393 * LYS_SET_FRDIGITS | | | | | | | | | | | | | | | | | | | | | |x| |
394 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
395 * 5 LYS_STATUS_OBSLT |x|x|x|x|x|x|x|x|x| | |x|x|x|x|x|x| |x|x|x| | |
396 * LYS_SET_LENGTH | | | | | | | | | | | | | | | | | | | | | |x| |
397 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
398 * 6 LYS_MAND_TRUE | |x|x| | |x| | | | | | | | | | | |x| |x| | | |
399 * LYS_SET_PATH | | | | | | | | | | | | | | | | | | | | | |x| |
400 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
401 * 7 LYS_MAND_FALSE | |x|x| | |x| | | | | | | | | | | |x| |x| | | |
402 * LYS_ORDBY_USER | | | |x|x| | | | | | | | | | | | | | | | | | |
403 * LYS_SET_PATTERN | | | | | | | | | | | | | | | | | | | | | |x| |
404 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
405 * 8 LYS_ORDBY_SYSTEM | | | |x|x| | | | | | | | | | | | | | | | | | |
406 * LYS_YINELEM_TRUE | | | | | | | | | | | | | |x| | | | | | | | | |
407 * LYS_SET_RANGE | | | | | | | | | | | | | | | | | | | | | |x| |
408 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
409 * 9 LYS_YINELEM_FALSE| | | | | | | | | | | | | |x| | | | | | | | | |
410 * LYS_SET_TYPE | | | | | | | | | | | | | | | | | | | | | |x| |
411 * LYS_SINGLEQUOTED | | | | | | | | | | | | | | | | | | | | | | |x|
412 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
413 * 10 LYS_SET_VALUE | | | | | | | | | | | | | | | | | | | | |x| | |
414 * LYS_SET_REQINST | | | | | | | | | | | | | | | | | | | | | |x| |
415 * LYS_SET_MIN | | | |x|x| | | | | | | | | | | | |x| |x| | | |
416 * LYS_DOUBLEQUOTED | | | | | | | | | | | | | | | | | | | | | | |x|
417 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
418 * 11 LYS_SET_MAX | | | |x|x| | | | | | | | | | | | |x| |x| | | |
Radek Krejcif2de0ed2019-05-02 14:13:18 +0200419 * LYS_USED_GRP | | | | | | | | | | | | | | | |x| | | | | | | |
Radek Krejcid3ca0632019-04-16 16:54:54 +0200420 * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Radek Krejci4f28eda2018-11-12 11:46:16 +0100421 *
422 */
423
424/**
425 * @defgroup scnodeflags Compiled schema nodes flags
426 * @ingroup snodeflags
427 *
428 * Various flags for compiled schema nodes.
429 *
430 * 1 - container 6 - anydata/anyxml 11 - output
431 * 2 - choice 7 - case 12 - feature
432 * 3 - leaf 8 - notification 13 - identity
433 * 4 - leaflist 9 - rpc 14 - extension
Radek Krejci693262f2019-04-29 15:23:20 +0200434 * 5 - list 10 - input 15 - bitenum
Radek Krejci4f28eda2018-11-12 11:46:16 +0100435 *
Radek Krejci693262f2019-04-29 15:23:20 +0200436 * 1 1 1 1 1 1
437 * bit name 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
438 * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
439 * 1 LYS_CONFIG_W |x|x|x|x|x|x|x| | | | | | | | |
440 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
441 * 2 LYS_CONFIG_R |x|x|x|x|x|x|x| | | | | | | | |
442 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
443 * 3 LYS_STATUS_CURR |x|x|x|x|x|x|x|x|x| | |x|x|x| |
444 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
445 * 4 LYS_STATUS_DEPRC |x|x|x|x|x|x|x|x|x| | |x|x|x| |
446 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
447 * 5 LYS_STATUS_OBSLT |x|x|x|x|x|x|x|x|x| | |x|x|x| |
448 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
449 * 6 LYS_MAND_TRUE |x|x|x|x|x|x| | | | | | | | | |
450 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
451 * 7 LYS_ORDBY_USER | | | |x|x| | | | | | | | | | |
452 * LYS_MAND_FALSE | |x|x| | |x| | | | | | | | | |
453 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
454 * 8 LYS_ORDBY_SYSTEM | | | |x|x| | | | | | | | | | |
455 * LYS_PRESENCE |x| | | | | | | | | | | | | | |
456 * LYS_UNIQUE | | |x| | | | | | | | | | | | |
457 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
458 * 9 LYS_KEY | | |x| | | | | | | | | | | | |
459 * LYS_FENABLED | | | | | | | | | | | |x| | | |
460 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
461 * 10 LYS_SET_DFLT | | |x|x| | |x| | | | | | | | |
462 * LYS_ISENUM | | | | | | | | | | | | | | |x|
463 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
464 * 11 LYS_SET_UNITS | | |x|x| | | | | | | | | | | |
465 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
466 * 11 LYS_SET_CONFIG |x|x|x|x|x|x|x| | |x|x| | | | |
467 * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Radek Krejci4f28eda2018-11-12 11:46:16 +0100468 *
469 */
470
471/**
472 * @defgroup snodeflags Schema nodes flags
473 * @ingroup schematree
474 * @{
475 */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200476#define LYS_CONFIG_W 0x01 /**< config true; */
477#define LYS_CONFIG_R 0x02 /**< config false; */
478#define LYS_CONFIG_MASK 0x03 /**< mask for config value */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100479#define LYS_STATUS_CURR 0x04 /**< status current; */
480#define LYS_STATUS_DEPRC 0x08 /**< status deprecated; */
481#define LYS_STATUS_OBSLT 0x10 /**< status obsolete; */
482#define LYS_STATUS_MASK 0x1C /**< mask for status value */
483#define LYS_MAND_TRUE 0x20 /**< mandatory true; applicable only to ::lysp_node_choice/::lysc_node_choice,
Radek Krejcife909632019-02-12 15:34:42 +0100484 ::lysp_node_leaf/::lysc_node_leaf and ::lysp_node_anydata/::lysc_node_anydata.
485 The ::lysc_node_leaflist and ::lysc_node_leaflist have this flag in case that min-elements > 0.
486 The ::lysc_node_container has this flag if it is not a presence container and it has at least one
487 child with LYS_MAND_TRUE. */
Radek Krejcif1421c22019-02-19 13:05:20 +0100488#define LYS_MAND_FALSE 0x40 /**< mandatory false; applicable only to ::lysp_node_choice/::lysc_node_choice,
489 ::lysp_node_leaf/::lysc_node_leaf and ::lysp_node_anydata/::lysc_node_anydata.
490 This flag is present only in case the mandatory false statement was explicitly specified. */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100491#define LYS_MAND_MASK 0x60 /**< mask for mandatory values */
Radek Krejci7adf4ff2018-12-05 08:55:00 +0100492#define LYS_PRESENCE 0x80 /**< flag for presence property of a container, applicable only to ::lysc_node_container */
493#define LYS_UNIQUE 0x80 /**< flag for leafs being part of a unique set, applicable only to ::lysc_node_leaf */
494#define LYS_KEY 0x100 /**< flag for leafs being a key of a list, applicable only to ::lysc_node_leaf */
495#define LYS_FENABLED 0x100 /**< feature enabled flag, applicable only to ::lysc_feature */
Radek Krejcife909632019-02-12 15:34:42 +0100496#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 +0100497 ::lysc_node_list/::lysp_node_list */
498#define LYS_ORDBY_USER 0x40 /**< ordered-by user lists, applicable only to ::lysc_node_leaflist/::lysp_node_leaflist and
499 ::lysc_node_list/::lysp_node_list */
500#define LYS_ORDBY_MASK 0x60 /**< mask for ordered-by values */
501#define LYS_YINELEM_TRUE 0x80 /**< yin-element true for extension's argument */
502#define LYS_YINELEM_FALSE 0x100 /**< yin-element false for extension's argument */
503#define LYS_YINELEM_MASK 0x180 /**< mask for yin-element value */
Radek Krejcif2de0ed2019-05-02 14:13:18 +0200504#define LYS_USED_GRP 0x400 /**< internal flag for validating not-instantiated groupings
505 (resp. do not validate again the instantiated groupings). */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100506#define LYS_SET_VALUE 0x200 /**< value attribute is set */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100507#define LYS_SET_MIN 0x200 /**< min attribute is set */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200508#define LYS_SET_MAX 0x400 /**< max attribute is set */
Radek Krejcid505e3d2018-11-13 09:04:17 +0100509
510#define LYS_SET_BASE 0x0001 /**< type's flag for present base substatement */
511#define LYS_SET_BIT 0x0002 /**< type's flag for present bit substatement */
512#define LYS_SET_ENUM 0x0004 /**< type's flag for present enum substatement */
513#define LYS_SET_FRDIGITS 0x0008 /**< type's flag for present fraction-digits substatement */
514#define LYS_SET_LENGTH 0x0010 /**< type's flag for present length substatement */
515#define LYS_SET_PATH 0x0020 /**< type's flag for present path substatement */
516#define LYS_SET_PATTERN 0x0040 /**< type's flag for present pattern substatement */
517#define LYS_SET_RANGE 0x0080 /**< type's flag for present range substatement */
518#define LYS_SET_TYPE 0x0100 /**< type's flag for present type substatement */
519#define LYS_SET_REQINST 0x0200 /**< type's flag for present require-instance substatement */
Radek Krejciccd20f12019-02-15 14:12:27 +0100520#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 +0100521 cases of choice. This information is important for refines, since it is prohibited to make leafs
522 with default statement mandatory. In case the default leaf value is taken from type, it is thrown
Radek Krejciccd20f12019-02-15 14:12:27 +0100523 away when it is refined to be mandatory node. Similarly it is used for deviations to distinguish
524 between own default or the default values taken from the type. */
525#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 +0100526#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 +0100527
Radek Krejcid3ca0632019-04-16 16:54:54 +0200528#define LYS_SINGLEQUOTED 0x100 /**< flag for single-quoted argument of an extension instance's substatement */
529#define LYS_DOUBLEQUOTED 0x200 /**< flag for double-quoted argument of an extension instance's substatement */
530
Radek Krejci693262f2019-04-29 15:23:20 +0200531#define LYS_ISENUM 0x200 /**< flag to simply distinguish type in struct lysc_type_bitenum_item */
532
Radek Krejcife909632019-02-12 15:34:42 +0100533#define LYS_FLAGS_COMPILED_MASK 0xff /**< mask for flags that maps to the compiled structures */
Radek Krejci4f28eda2018-11-12 11:46:16 +0100534/** @} */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200535
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200536/**
537 * @brief Generic YANG data node
538 */
539struct lysp_node {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100540 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200541 uint16_t nodetype; /**< type of the node (mandatory) */
542 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100543 struct lysp_node *next; /**< next sibling node (NULL if there is no one) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200544 const char *name; /**< node name (mandatory) */
545 const char *dsc; /**< description statement */
546 const char *ref; /**< reference statement */
547 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200548 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200549 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200550};
551
552/**
553 * @brief Extension structure of the lysp_node for YANG container
554 */
555struct lysp_node_container {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100556 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200557 uint16_t nodetype; /**< LYS_CONTAINER */
558 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
559 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
560 const char *name; /**< node name (mandatory) */
561 const char *dsc; /**< description statement */
562 const char *ref; /**< reference statement */
563 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200564 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200565 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200566
567 /* container */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200568 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200569 const char *presence; /**< presence description */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200570 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
571 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200572 struct lysp_node *child; /**< list of data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200573 struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
574 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200575};
576
577struct lysp_node_leaf {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100578 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200579 uint16_t nodetype; /**< LYS_LEAF */
580 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
581 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
582 const char *name; /**< node name (mandatory) */
583 const char *dsc; /**< description statement */
584 const char *ref; /**< reference statement */
585 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200586 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200587 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200588
589 /* leaf */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200590 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200591 struct lysp_type type; /**< type of the leaf node (mandatory) */
592 const char *units; /**< units of the leaf's type */
593 const char *dflt; /**< default value */
594};
595
596struct lysp_node_leaflist {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100597 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200598 uint16_t nodetype; /**< LYS_LEAFLIST */
599 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
600 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
601 const char *name; /**< node name (mandatory) */
602 const char *dsc; /**< description statement */
603 const char *ref; /**< reference statement */
604 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200605 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200606 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200607
608 /* leaf-list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200609 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200610 struct lysp_type type; /**< type of the leaf node (mandatory) */
611 const char *units; /**< units of the leaf's type */
Radek Krejci151a5b72018-10-19 14:21:44 +0200612 const char **dflts; /**< list of default values ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200613 uint32_t min; /**< min-elements constraint */
614 uint32_t max; /**< max-elements constraint, 0 means unbounded */
615};
616
617struct lysp_node_list {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100618 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200619 uint16_t nodetype; /**< LYS_LIST */
620 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
621 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
622 const char *name; /**< node name (mandatory) */
623 const char *dsc; /**< description statement */
624 const char *ref; /**< reference statement */
625 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200626 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200627 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200628
629 /* list */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200630 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200631 const char *key; /**< keys specification */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200632 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
633 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200634 struct lysp_node *child; /**< list of data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200635 struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
636 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
Radek Krejci151a5b72018-10-19 14:21:44 +0200637 const char **uniques; /**< list of unique specifications ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200638 uint32_t min; /**< min-elements constraint */
639 uint32_t max; /**< max-elements constraint, 0 means unbounded */
640};
641
642struct lysp_node_choice {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100643 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200644 uint16_t nodetype; /**< LYS_CHOICE */
645 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
646 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
647 const char *name; /**< node name (mandatory) */
648 const char *dsc; /**< description statement */
649 const char *ref; /**< reference statement */
650 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200651 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200652 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200653
654 /* choice */
655 struct lysp_node *child; /**< list of data nodes (linked list) */
656 const char* dflt; /**< default case */
657};
658
659struct lysp_node_case {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100660 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200661 uint16_t nodetype; /**< LYS_CASE */
662 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
663 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
664 const char *name; /**< node name (mandatory) */
665 const char *dsc; /**< description statement */
666 const char *ref; /**< reference statement */
667 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200668 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200669 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200670
671 /* case */
672 struct lysp_node *child; /**< list of data nodes (linked list) */
673};
674
675struct lysp_node_anydata {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100676 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200677 uint16_t nodetype; /**< LYS_ANYXML || LYS_ANYDATA */
678 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
679 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
680 const char *name; /**< node name (mandatory) */
681 const char *dsc; /**< description statement */
682 const char *ref; /**< reference statement */
683 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200684 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200685 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200686
687 /* anyxml/anydata */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200688 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200689};
690
691struct lysp_node_uses {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100692 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
Michal Vaskob55f6c12018-09-12 11:13:15 +0200693 uint16_t nodetype; /**< LYS_USES */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200694 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
695 struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
696 const char *name; /**< grouping name reference (mandatory) */
697 const char *dsc; /**< description statement */
698 const char *ref; /**< reference statement */
699 struct lysp_when *when; /**< when statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200700 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200701 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200702
703 /* uses */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200704 struct lysp_refine *refines; /**< list of uses's refines ([sized array](@ref sizedarrays)) */
705 struct lysp_augment *augments; /**< list of uses's augment ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200706};
707
708/**
709 * @brief YANG input-stmt and output-stmt
710 */
711struct lysp_action_inout {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100712 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
713 uint16_t nodetype; /**< LYS_INOUT */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200714 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
715 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
716 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200717 struct lysp_node *data; /**< list of data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200718 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200719};
720
721/**
722 * @brief YANG rpc-stmt and action-stmt
723 */
724struct lysp_action {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100725 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
726 uint16_t nodetype; /**< LYS_ACTION */
727 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200728 const char *name; /**< grouping name reference (mandatory) */
729 const char *dsc; /**< description statement */
730 const char *ref; /**< reference statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200731 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200732 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
733 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci6eeb58f2019-02-22 16:29:37 +0100734 struct lysp_action_inout input; /**< RPC's/Action's input */
735 struct lysp_action_inout output; /**< RPC's/Action's output */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200736 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200737};
738
739/**
740 * @brief YANG notification-stmt
741 */
742struct lysp_notif {
Radek Krejci6d9b9b52018-11-02 12:43:39 +0100743 struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */
744 uint16_t nodetype; /**< LYS_NOTIF */
745 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200746 const char *name; /**< grouping name reference (mandatory) */
747 const char *dsc; /**< description statement */
748 const char *ref; /**< reference statement */
Radek Krejci151a5b72018-10-19 14:21:44 +0200749 const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200750 struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
751 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
752 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200753 struct lysp_node *data; /**< list of data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200754 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200755};
756
757/**
Radek Krejcif0fceb62018-09-05 14:58:45 +0200758 * @brief supported YANG schema version values
759 */
760typedef enum LYS_VERSION {
761 LYS_VERSION_UNDEF = 0, /**< no specific version, YANG 1.0 as default */
762 LYS_VERSION_1_0 = 1, /**< YANG 1.0 */
763 LYS_VERSION_1_1 = 2 /**< YANG 1.1 */
764} LYS_VERSION;
765
766/**
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200767 * @brief Printable YANG schema tree structure representing YANG module.
768 *
769 * Simple structure corresponding to the YANG format. The schema is only syntactically validated.
770 */
771struct lysp_module {
Radek Krejci0bcdaed2019-01-10 10:21:34 +0100772 struct lys_module *mod; /**< covering module structure */
773
Radek Krejcib7db73a2018-10-24 14:18:40 +0200774 struct lysp_revision *revs; /**< list of the module revisions ([sized array](@ref sizedarrays)), the first revision
775 in the list is always the last (newest) revision of the module */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200776 struct lysp_import *imports; /**< list of imported modules ([sized array](@ref sizedarrays)) */
777 struct lysp_include *includes; /**< list of included submodules ([sized array](@ref sizedarrays)) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200778 struct lysp_ext *extensions; /**< list of extension statements ([sized array](@ref sizedarrays)) */
779 struct lysp_feature *features; /**< list of feature definitions ([sized array](@ref sizedarrays)) */
780 struct lysp_ident *identities; /**< list of identities ([sized array](@ref sizedarrays)) */
781 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
782 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200783 struct lysp_node *data; /**< list of module's top-level data nodes (linked list) */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200784 struct lysp_augment *augments; /**< list of augments ([sized array](@ref sizedarrays)) */
785 struct lysp_action *rpcs; /**< list of RPCs ([sized array](@ref sizedarrays)) */
786 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
787 struct lysp_deviation *deviations; /**< list of deviations ([sized array](@ref sizedarrays)) */
788 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200789
Radek Krejci0bcdaed2019-01-10 10:21:34 +0100790 uint8_t parsing:1; /**< flag for circular check */
791};
792
793struct lysp_submodule {
794 const char *belongsto; /**< belongs to parent module (submodule - mandatory) */
795
796 struct lysp_revision *revs; /**< list of the module revisions ([sized array](@ref sizedarrays)), the first revision
797 in the list is always the last (newest) revision of the module */
798 struct lysp_import *imports; /**< list of imported modules ([sized array](@ref sizedarrays)) */
799 struct lysp_include *includes; /**< list of included submodules ([sized array](@ref sizedarrays)) */
800 struct lysp_ext *extensions; /**< list of extension statements ([sized array](@ref sizedarrays)) */
801 struct lysp_feature *features; /**< list of feature definitions ([sized array](@ref sizedarrays)) */
802 struct lysp_ident *identities; /**< list of identities ([sized array](@ref sizedarrays)) */
803 struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */
804 struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */
805 struct lysp_node *data; /**< list of module's top-level data nodes (linked list) */
806 struct lysp_augment *augments; /**< list of augments ([sized array](@ref sizedarrays)) */
807 struct lysp_action *rpcs; /**< list of RPCs ([sized array](@ref sizedarrays)) */
808 struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
809 struct lysp_deviation *deviations; /**< list of deviations ([sized array](@ref sizedarrays)) */
810 struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
811
812 uint8_t parsing:1; /**< flag for circular check */
813
Radek Krejci086c7132018-10-26 15:29:04 +0200814 uint8_t latest_revision:2; /**< flag to mark the latest available revision:
815 1 - the latest revision in searchdirs was not searched yet and this is the
816 latest revision in the current context
817 2 - searchdirs were searched and this is the latest available revision */
Radek Krejci0bcdaed2019-01-10 10:21:34 +0100818 const char *name; /**< name of the module (mandatory) */
819 const char *filepath; /**< path, if the schema was read from a file, NULL in case of reading from memory */
820 const char *prefix; /**< submodule belongsto prefix of main module (mandatory) */
821 const char *org; /**< party/company responsible for the module */
822 const char *contact; /**< contact information for the module */
823 const char *dsc; /**< description of the module */
824 const char *ref; /**< cross-reference for the module */
Radek Krejci086c7132018-10-26 15:29:04 +0200825 uint8_t version; /**< yang-version (LYS_VERSION values) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200826};
827
828/**
Radek Krejci3f5e3db2018-10-11 15:57:47 +0200829 * @brief Free the printable YANG schema tree structure.
830 *
831 * @param[in] module Printable YANG schema tree structure to free.
832 */
833void lysp_module_free(struct lysp_module *module);
834
835/**
Radek Krejcice8c1592018-10-29 15:35:51 +0100836 * @brief YANG extension instance
837 */
838struct lysc_ext_instance {
839 struct lyext_plugin *plugin; /**< pointer to the plugin implementing the extension (if present) */
840 void *parent; /**< pointer to the parent element holding the extension instance(s), use
841 ::lysc_ext_instance#parent_type to access the schema element */
842 const char *argument; /**< optional value of the extension's argument */
843 LYEXT_SUBSTMT insubstmt; /**< value identifying placement of the extension instance */
844 uint32_t insubstmt_index; /**< in case the instance is in a substatement that can appear multiple times,
845 this identifies the index of the substatement for this extension instance */
Radek Krejci2a408df2018-10-29 16:32:26 +0100846 LYEXT_PARENT parent_type; /**< type of the parent structure */
Radek Krejcice8c1592018-10-29 15:35:51 +0100847#if 0
Radek Krejcice8c1592018-10-29 15:35:51 +0100848 uint8_t ext_type; /**< extension type (#LYEXT_TYPE) */
849 uint8_t padding; /**< 32b padding */
Radek Krejcice8c1592018-10-29 15:35:51 +0100850 struct lys_module *module; /**< pointer to the extension instance's module (mandatory) */
851 LYS_NODE nodetype; /**< LYS_EXT */
852#endif
Radek Krejci2a408df2018-10-29 16:32:26 +0100853 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
854 void *priv; /**< private caller's data, not used by libyang */
Radek Krejcice8c1592018-10-29 15:35:51 +0100855};
856
857/**
Radek Krejcibd8d9ba2018-11-02 16:06:26 +0100858 * @brief Compiled YANG if-feature-stmt
859 */
860struct lysc_iffeature {
861 uint8_t *expr; /**< 2bits array describing the if-feature expression in prefix format, see @ref ifftokens */
862 struct lysc_feature **features; /**< array of pointers to the features used in expression ([sized array](@ref sizedarrays)) */
863};
864
865/**
Radek Krejci151a5b72018-10-19 14:21:44 +0200866 * @brief YANG import-stmt
867 */
868struct lysc_import {
Radek Krejci6d6e4e42018-10-29 13:28:19 +0100869 struct lys_module *module; /**< link to the imported module */
Radek Krejci151a5b72018-10-19 14:21:44 +0200870 const char *prefix; /**< prefix for the data from the imported schema (mandatory) */
Radek Krejcice8c1592018-10-29 15:35:51 +0100871 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci151a5b72018-10-19 14:21:44 +0200872};
873
874/**
Radek Krejcidd4e8d42018-10-16 14:55:43 +0200875 * @brief YANG when-stmt
Radek Krejci5aeea3a2018-09-05 13:29:36 +0200876 */
Radek Krejcidd4e8d42018-10-16 14:55:43 +0200877struct lysc_when {
878 struct lyxp_expr *cond; /**< XPath when condition */
Radek Krejcic8b31002019-01-08 10:24:45 +0100879 const char *dsc; /**< description */
880 const char *ref; /**< reference */
Radek Krejci00b874b2019-02-12 10:54:50 +0100881 struct lysc_node *context; /**< context node for evaluating the expression */
Radek Krejcie53a8dc2018-10-17 12:52:40 +0200882 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci00b874b2019-02-12 10:54:50 +0100883 uint32_t refcount; /**< reference counter since some of the when statements are shared among several nodes */
Radek Krejcidd4e8d42018-10-16 14:55:43 +0200884};
885
886/**
Radek Krejci2a408df2018-10-29 16:32:26 +0100887 * @brief YANG identity-stmt
888 */
889struct lysc_ident {
890 const char *name; /**< identity name (mandatory), including possible prefix */
Radek Krejcic8b31002019-01-08 10:24:45 +0100891 const char *dsc; /**< description */
892 const char *ref; /**< reference */
Radek Krejci693262f2019-04-29 15:23:20 +0200893 struct lys_module *module; /**< module structure */
Radek Krejci2a408df2018-10-29 16:32:26 +0100894 struct lysc_ident **derived; /**< list of (pointers to the) derived identities ([sized array](@ref sizedarrays)) */
895 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +0200896 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejci2a408df2018-10-29 16:32:26 +0100897 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ values are allowed */
898};
899
900/**
Radek Krejcidd4e8d42018-10-16 14:55:43 +0200901 * @brief YANG feature-stmt
902 */
903struct lysc_feature {
904 const char *name; /**< feature name (mandatory) */
Radek Krejcic8b31002019-01-08 10:24:45 +0100905 const char *dsc; /**< description */
906 const char *ref; /**< reference */
Radek Krejci693262f2019-04-29 15:23:20 +0200907 struct lys_module *module; /**< module structure */
Radek Krejci151a5b72018-10-19 14:21:44 +0200908 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 +0100909 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +0200910 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcidd4e8d42018-10-16 14:55:43 +0200911 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* and
912 #LYS_FENABLED values allowed */
913};
914
Radek Krejci151a5b72018-10-19 14:21:44 +0200915/**
916 * @defgroup ifftokens if-feature expression tokens
917 * Tokens of if-feature expression used in ::lysc_iffeature#expr
918 *
919 * @{
920 */
921#define LYS_IFF_NOT 0x00 /**< operand "not" */
922#define LYS_IFF_AND 0x01 /**< operand "and" */
923#define LYS_IFF_OR 0x02 /**< operand "or" */
924#define LYS_IFF_F 0x03 /**< feature */
925/**
926 * @}
927 */
928
929/**
Radek Krejcib7db73a2018-10-24 14:18:40 +0200930 * @brief Compiled YANG revision statement
931 */
932struct lysc_revision {
933 char date[LY_REV_SIZE]; /**< revision-date (mandatory) */
934 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
935};
936
Radek Krejci2167ee12018-11-02 16:09:07 +0100937struct lysc_range {
Radek Krejci4f28eda2018-11-12 11:46:16 +0100938 struct lysc_range_part {
Radek Krejci693262f2019-04-29 15:23:20 +0200939 union { /**< min boundary */
Radek Krejcie7b95092019-05-15 11:03:07 +0200940 int64_t min_64; /**< for int8, int16, int32, int64 and decimal64 ( >= LY_TYPE_DEC64) */
941 uint64_t min_u64; /**< for uint8, uint16, uint32, uint64, string and binary ( < LY_TYPE_DEC64) */
Radek Krejci2167ee12018-11-02 16:09:07 +0100942 };
Radek Krejci693262f2019-04-29 15:23:20 +0200943 union { /**< max boundary */
Radek Krejcie7b95092019-05-15 11:03:07 +0200944 int64_t max_64; /**< for int8, int16, int32, int64 and decimal64 ( >= LY_TYPE_DEC64) */
945 uint64_t max_u64; /**< for uint8, uint16, uint32, uint64, string and binary ( < LY_TYPE_DEC64) */
Radek Krejci2167ee12018-11-02 16:09:07 +0100946 };
Radek Krejci4f28eda2018-11-12 11:46:16 +0100947 } *parts; /**< compiled range expression ([sized array](@ref sizedarrays)) */
Radek Krejcic8b31002019-01-08 10:24:45 +0100948 const char *dsc; /**< description */
949 const char *ref; /**< reference */
Radek Krejci2167ee12018-11-02 16:09:07 +0100950 const char *emsg; /**< error-message */
951 const char *eapptag; /**< error-app-tag value */
952 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
953};
954
955struct lysc_pattern {
Radek Krejci54579462019-04-30 12:47:06 +0200956 const char *expr; /**< original, not compiled, regular expression */
957 pcre2_code *code; /**< compiled regular expression */
Radek Krejcic8b31002019-01-08 10:24:45 +0100958 const char *dsc; /**< description */
959 const char *ref; /**< reference */
Radek Krejci2167ee12018-11-02 16:09:07 +0100960 const char *emsg; /**< error-message */
961 const char *eapptag; /**< error-app-tag value */
962 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci4586a022018-11-13 11:29:26 +0100963 uint32_t inverted:1; /**< invert-match flag */
964 uint32_t refcount:31; /**< reference counter */
Radek Krejci2167ee12018-11-02 16:09:07 +0100965};
966
967struct lysc_must {
968 struct lys_module *module; /**< module where the must was defined */
969 struct lyxp_expr *cond; /**< XPath when condition */
Radek Krejcic8b31002019-01-08 10:24:45 +0100970 const char *dsc; /**< description */
971 const char *ref; /**< reference */
Radek Krejci2167ee12018-11-02 16:09:07 +0100972 const char *emsg; /**< error-message */
973 const char *eapptag; /**< error-app-tag value */
974 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
975};
976
977struct lysc_type {
Radek Krejci4f28eda2018-11-12 11:46:16 +0100978 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +0100979 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +0200980 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 +0100981 LY_DATA_TYPE basetype; /**< Base type of the type */
982 uint32_t refcount; /**< reference counter for type sharing */
983};
984
985struct lysc_type_num {
Radek Krejci4f28eda2018-11-12 11:46:16 +0100986 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +0100987 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +0200988 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 +0100989 LY_DATA_TYPE basetype; /**< Base type of the type */
990 uint32_t refcount; /**< reference counter for type sharing */
991 struct lysc_range *range; /**< Optional range limitation */
992};
993
994struct lysc_type_dec {
Radek Krejci4f28eda2018-11-12 11:46:16 +0100995 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +0100996 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +0200997 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 +0100998 LY_DATA_TYPE basetype; /**< Base type of the type */
999 uint32_t refcount; /**< reference counter for type sharing */
Radek Krejci6cba4292018-11-15 17:33:29 +01001000 uint8_t fraction_digits; /**< fraction digits specification */
Radek Krejci2167ee12018-11-02 16:09:07 +01001001 struct lysc_range *range; /**< Optional range limitation */
1002};
1003
1004struct lysc_type_str {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001005 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +01001006 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001007 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 +01001008 LY_DATA_TYPE basetype; /**< Base type of the type */
1009 uint32_t refcount; /**< reference counter for type sharing */
1010 struct lysc_range *length; /**< Optional length limitation */
Radek Krejci4586a022018-11-13 11:29:26 +01001011 struct lysc_pattern **patterns; /**< Optional list of pointers to pattern limitations ([sized array](@ref sizedarrays)) */
Radek Krejci2167ee12018-11-02 16:09:07 +01001012};
1013
Radek Krejci693262f2019-04-29 15:23:20 +02001014struct lysc_type_bitenum_item {
1015 const char *name; /**< enumeration identifier */
1016 const char *dsc; /**< description */
1017 const char *ref; /**< reference */
1018 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
1019 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
1020 union {
1021 int32_t value; /**< integer value associated with the enumeration */
1022 uint32_t position; /**< non-negative integer value associated with the bit */
1023 };
1024 uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ and LYS_SET_VALUE
1025 values are allowed */
1026};
1027
Radek Krejci2167ee12018-11-02 16:09:07 +01001028struct lysc_type_enum {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001029 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +01001030 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001031 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 +01001032 LY_DATA_TYPE basetype; /**< Base type of the type */
1033 uint32_t refcount; /**< reference counter for type sharing */
Radek Krejci693262f2019-04-29 15:23:20 +02001034 struct lysc_type_bitenum_item *enums; /**< enumerations list ([sized array](@ref sizedarrays)), mandatory (at least 1 item) */
1035};
1036
1037struct lysc_type_bits {
1038 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
1039 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001040 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 +02001041 LY_DATA_TYPE basetype; /**< Base type of the type */
1042 uint32_t refcount; /**< reference counter for type sharing */
Radek Krejci849a62a2019-05-22 15:29:05 +02001043 struct lysc_type_bitenum_item *bits; /**< bits list ([sized array](@ref sizedarrays)), mandatory (at least 1 item),
1044 the items are ordered by their position value. */
Radek Krejci2167ee12018-11-02 16:09:07 +01001045};
1046
1047struct lysc_type_leafref {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001048 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +01001049 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001050 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 +01001051 LY_DATA_TYPE basetype; /**< Base type of the type */
1052 uint32_t refcount; /**< reference counter for type sharing */
Radek Krejcia3045382018-11-22 14:30:31 +01001053 const char* path; /**< target path */
Radek Krejci96a0bfd2018-11-22 15:25:06 +01001054 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 +01001055 struct lysc_type *realtype; /**< pointer to the real (first non-leafref in possible leafrefs chain) type. */
Radek Krejci2167ee12018-11-02 16:09:07 +01001056 uint8_t require_instance; /**< require-instance flag */
1057};
1058
1059struct lysc_type_identityref {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001060 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +01001061 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001062 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 +01001063 LY_DATA_TYPE basetype; /**< Base type of the type */
1064 uint32_t refcount; /**< reference counter for type sharing */
Radek Krejci555cb5b2018-11-16 14:54:33 +01001065 struct lysc_ident **bases; /**< list of pointers to the base identities ([sized array](@ref sizedarrays)),
Radek Krejci2167ee12018-11-02 16:09:07 +01001066 mandatory (at least 1 item) */
1067};
1068
1069struct lysc_type_instanceid {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001070 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +01001071 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001072 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 +01001073 LY_DATA_TYPE basetype; /**< Base type of the type */
1074 uint32_t refcount; /**< reference counter for type sharing */
1075 uint8_t require_instance; /**< require-instance flag */
1076};
1077
Radek Krejci2167ee12018-11-02 16:09:07 +01001078struct lysc_type_union {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001079 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +01001080 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001081 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 +01001082 LY_DATA_TYPE basetype; /**< Base type of the type */
1083 uint32_t refcount; /**< reference counter for type sharing */
1084 struct lysc_type **types; /**< list of types in the union ([sized array](@ref sizedarrays)), mandatory (at least 1 item) */
1085};
1086
1087struct lysc_type_bin {
Radek Krejci4f28eda2018-11-12 11:46:16 +01001088 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci01342af2019-01-03 15:18:08 +01001089 const char *dflt; /**< type's default value if any */
Radek Krejcie7b95092019-05-15 11:03:07 +02001090 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 +01001091 LY_DATA_TYPE basetype; /**< Base type of the type */
1092 uint32_t refcount; /**< reference counter for type sharing */
1093 struct lysc_range *length; /**< Optional length limitation */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001094};
1095
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001096struct lysc_action_inout {
1097 struct lysc_node *data; /**< first child node (linked list) */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001098 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1099};
1100
Radek Krejci056d0a82018-12-06 16:57:25 +01001101struct lysc_action {
1102 uint16_t nodetype; /**< LYS_ACTION */
1103 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Radek Krejci95710c92019-02-11 15:49:55 +01001104 struct lys_module *module; /**< module structure */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001105 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. */
1106 struct lysc_node *parent; /**< parent node (NULL in case of top level node - RPC) */
1107
Radek Krejcifc11bd72019-04-11 16:00:05 +02001108 struct lysc_ext_instance *input_exts; /**< list of the extension instances of input ([sized array](@ref sizedarrays)) */
1109 struct lysc_ext_instance *output_exts; /**< list of the extension instances of outpu ([sized array](@ref sizedarrays)) */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001110
Radek Krejci056d0a82018-12-06 16:57:25 +01001111 const char *name; /**< action/RPC name (mandatory) */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001112 const char *dsc; /**< description */
1113 const char *ref; /**< reference */
1114
Radek Krejcifc11bd72019-04-11 16:00:05 +02001115 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
1116 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
1117
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001118 struct lysc_action_inout input; /**< RPC's/action's input */
1119 struct lysc_action_inout output; /**< RPC's/action's output */
1120
Radek Krejci056d0a82018-12-06 16:57:25 +01001121};
1122
1123struct lysc_notif {
1124 uint16_t nodetype; /**< LYS_NOTIF */
1125 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Radek Krejci95710c92019-02-11 15:49:55 +01001126 struct lys_module *module; /**< module structure */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001127 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 +01001128 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1129
Radek Krejcifc11bd72019-04-11 16:00:05 +02001130 struct lysc_node *data; /**< first child node (linked list) */
1131 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1132
Radek Krejci056d0a82018-12-06 16:57:25 +01001133 const char *name; /**< Notification name (mandatory) */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001134 const char *dsc; /**< description */
1135 const char *ref; /**< reference */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001136
1137 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
1138 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejci056d0a82018-12-06 16:57:25 +01001139};
1140
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001141/**
Radek Krejci0af5f5d2018-09-07 15:00:30 +02001142 * @brief Compiled YANG data node
1143 */
1144struct lysc_node {
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001145 uint16_t nodetype; /**< type of the node (mandatory) */
1146 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001147 struct lys_module *module; /**< module structure */
1148 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. */
1149 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1150 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1151 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1152 never NULL. If there is no sibling node, pointer points to the node
1153 itself. In case of the first node, this pointer points to the last
1154 node in the list. */
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001155 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001156 const char *dsc; /**< description */
1157 const char *ref; /**< reference */
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001158 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci056d0a82018-12-06 16:57:25 +01001159 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001160 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001161};
1162
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001163struct lysc_node_container {
1164 uint16_t nodetype; /**< LYS_CONTAINER */
1165 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1166 struct lys_module *module; /**< module structure */
1167 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. */
1168 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1169 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1170 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1171 never NULL. If there is no sibling node, pointer points to the node
1172 itself. In case of the first node, this pointer points to the last
1173 node in the list. */
1174 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001175 const char *dsc; /**< description */
1176 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001177 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci4f28eda2018-11-12 11:46:16 +01001178 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001179 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejci4f28eda2018-11-12 11:46:16 +01001180
1181 struct lysc_node *child; /**< first child node (linked list) */
1182 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1183 struct lysc_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
1184 struct lysc_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001185};
1186
Radek Krejcia3045382018-11-22 14:30:31 +01001187struct lysc_node_case {
Radek Krejci056d0a82018-12-06 16:57:25 +01001188 uint16_t nodetype; /**< LYS_CASE */
1189 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1190 struct lys_module *module; /**< module structure */
1191 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. */
1192 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1193 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1194 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1195 never NULL. If there is no sibling node, pointer points to the node
1196 itself. In case of the first node, this pointer points to the last
1197 node in the list. */
Radek Krejcia3045382018-11-22 14:30:31 +01001198 const char *name; /**< name of the case, including the implicit case */
Radek Krejci12fb9142019-01-08 09:45:30 +01001199 const char *dsc; /**< description */
1200 const char *ref; /**< reference */
Radek Krejci056d0a82018-12-06 16:57:25 +01001201 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci056d0a82018-12-06 16:57:25 +01001202 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001203 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejci056d0a82018-12-06 16:57:25 +01001204
Radek Krejcia3045382018-11-22 14:30:31 +01001205 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 +01001206 each other as siblings with the parent pointer pointing to appropriate case node. */
Radek Krejcia3045382018-11-22 14:30:31 +01001207};
1208
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001209struct lysc_node_choice {
1210 uint16_t nodetype; /**< LYS_CHOICE */
1211 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1212 struct lys_module *module; /**< module structure */
1213 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. */
1214 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1215 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1216 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1217 never NULL. If there is no sibling node, pointer points to the node
1218 itself. In case of the first node, this pointer points to the last
1219 node in the list. */
1220 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001221 const char *dsc; /**< description */
1222 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001223 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci056d0a82018-12-06 16:57:25 +01001224 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001225 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001226
Radek Krejcia9026eb2018-12-12 16:04:47 +01001227 struct lysc_node_case *cases; /**< list of the cases (linked list). Note that all the children of all the cases are linked each other
1228 as siblings. Their parent pointers points to the specific case they belongs to, so distinguish the
1229 case is simple. */
Radek Krejci056d0a82018-12-06 16:57:25 +01001230 struct lysc_node_case *dflt; /**< default case of the choice, only a pointer into the cases array. */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001231};
1232
1233struct lysc_node_leaf {
1234 uint16_t nodetype; /**< LYS_LEAF */
1235 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1236 struct lys_module *module; /**< module structure */
1237 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. */
1238 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1239 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1240 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1241 never NULL. If there is no sibling node, pointer points to the node
1242 itself. In case of the first node, this pointer points to the last
1243 node in the list. */
1244 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001245 const char *dsc; /**< description */
1246 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001247 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci4f28eda2018-11-12 11:46:16 +01001248 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001249 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejci4f28eda2018-11-12 11:46:16 +01001250
1251 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1252 struct lysc_type *type; /**< type of the leaf node (mandatory) */
Radek Krejcib57cf1e2018-11-23 14:07:05 +01001253
Radek Krejci4f28eda2018-11-12 11:46:16 +01001254 const char *units; /**< units of the leaf's type */
1255 const char *dflt; /**< default value */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001256};
1257
1258struct lysc_node_leaflist {
1259 uint16_t nodetype; /**< LYS_LEAFLIST */
1260 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1261 struct lys_module *module; /**< module structure */
1262 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. */
1263 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1264 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1265 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1266 never NULL. If there is no sibling node, pointer points to the node
1267 itself. In case of the first node, this pointer points to the last
1268 node in the list. */
1269 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001270 const char *dsc; /**< description */
1271 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001272 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejcib57cf1e2018-11-23 14:07:05 +01001273 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001274 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejcib57cf1e2018-11-23 14:07:05 +01001275
1276 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1277 struct lysc_type *type; /**< type of the leaf node (mandatory) */
1278
Radek Krejci0e5d8382018-11-28 16:37:53 +01001279 const char *units; /**< units of the leaf's type */
1280 const char **dflts; /**< list of default values ([sized array](@ref sizedarrays)) */
1281 uint32_t min; /**< min-elements constraint */
1282 uint32_t max; /**< max-elements constraint */
1283
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001284};
1285
1286struct lysc_node_list {
1287 uint16_t nodetype; /**< LYS_LIST */
1288 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1289 struct lys_module *module; /**< module structure */
1290 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. */
1291 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1292 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1293 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1294 never NULL. If there is no sibling node, pointer points to the node
1295 itself. In case of the first node, this pointer points to the last
1296 node in the list. */
1297 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001298 const char *dsc; /**< description */
1299 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001300 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci9bb94eb2018-12-04 16:48:35 +01001301 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001302 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejci9bb94eb2018-12-04 16:48:35 +01001303
1304 struct lysc_node *child; /**< first child node (linked list) */
1305 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
1306 struct lysc_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */
1307 struct lysc_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
1308
1309 struct lysc_node_leaf **keys; /**< list of pointers to the keys ([sized array](@ref sizedarrays)) */
1310 struct lysc_node_leaf ***uniques; /**< list of sized arrays of pointers to the unique nodes ([sized array](@ref sizedarrays)) */
1311 uint32_t min; /**< min-elements constraint */
1312 uint32_t max; /**< max-elements constraint */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001313};
1314
1315struct lysc_node_anydata {
1316 uint16_t nodetype; /**< LYS_ANYXML or LYS_ANYDATA */
1317 uint16_t flags; /**< [schema node flags](@ref snodeflags) */
1318 struct lys_module *module; /**< module structure */
1319 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. */
1320 struct lysc_node *parent; /**< parent node (NULL in case of top level node) */
1321 struct lysc_node *next; /**< next sibling node (NULL if there is no one) */
1322 struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
1323 never NULL. If there is no sibling node, pointer points to the node
1324 itself. In case of the first node, this pointer points to the last
1325 node in the list. */
1326 const char *name; /**< node name (mandatory) */
Radek Krejci12fb9142019-01-08 09:45:30 +01001327 const char *dsc; /**< description */
1328 const char *ref; /**< reference */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001329 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci056d0a82018-12-06 16:57:25 +01001330 struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */
Radek Krejcifc11bd72019-04-11 16:00:05 +02001331 struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */
Radek Krejci9800fb82018-12-13 14:26:23 +01001332
1333 struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */
Radek Krejcibd8d9ba2018-11-02 16:06:26 +01001334};
1335
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001336/**
1337 * @brief Compiled YANG schema tree structure representing YANG module.
1338 *
1339 * Semantically validated YANG schema tree for data tree parsing.
1340 * Contains only the necessary information for the data validation.
1341 */
1342struct lysc_module {
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001343 struct lys_module *mod; /**< covering module structure */
Radek Krejci151a5b72018-10-19 14:21:44 +02001344 struct lysc_import *imports; /**< list of imported modules ([sized array](@ref sizedarrays)) */
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001345
Radek Krejcie53a8dc2018-10-17 12:52:40 +02001346 struct lysc_feature *features; /**< list of feature definitions ([sized array](@ref sizedarrays)) */
Radek Krejci2a408df2018-10-29 16:32:26 +01001347 struct lysc_ident *identities; /**< list of identities ([sized array](@ref sizedarrays)) */
1348 struct lysc_node *data; /**< list of module's top-level data nodes (linked list) */
1349 struct lysc_action *rpcs; /**< list of RPCs ([sized array](@ref sizedarrays)) */
1350 struct lysc_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */
Radek Krejcice8c1592018-10-29 15:35:51 +01001351 struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */
Radek Krejci0af5f5d2018-09-07 15:00:30 +02001352};
1353
1354/**
Radek Krejci53ea6152018-12-13 15:21:15 +01001355 * @brief Get the groupings sized array of the given (parsed) schema node.
1356 * Decides the node's type and in case it has a groupings array, returns it.
1357 * @param[in] node Node to examine.
1358 * @return The node's groupings sized array if any, NULL otherwise.
1359 */
1360const struct lysp_grp *lysp_node_groupings(const struct lysp_node *node);
1361
1362/**
Radek Krejci056d0a82018-12-06 16:57:25 +01001363 * @brief Get the typedefs sized array of the given (parsed) schema node.
1364 * Decides the node's type and in case it has a typedefs array, returns it.
1365 * @param[in] node Node to examine.
1366 * @return The node's typedefs sized array if any, NULL otherwise.
1367 */
1368const struct lysp_tpdf *lysp_node_typedefs(const struct lysp_node *node);
1369
1370/**
1371 * @brief Get the actions/RPCs sized array of the given (parsed) schema node.
1372 * Decides the node's type and in case it has a actions/RPCs array, returns it.
1373 * @param[in] node Node to examine.
1374 * @return The node's actions/RPCs sized array if any, NULL otherwise.
1375 */
1376const struct lysp_action *lysp_node_actions(const struct lysp_node *node);
1377
1378/**
1379 * @brief Get the Notifications sized array of the given (parsed) schema node.
1380 * Decides the node's type and in case it has a Notifications array, returns it.
1381 * @param[in] node Node to examine.
1382 * @return The node's Notifications sized array if any, NULL otherwise.
1383 */
1384const struct lysp_notif *lysp_node_notifs(const struct lysp_node *node);
1385
1386/**
1387 * @brief Get the children linked list of the given (parsed) schema node.
1388 * Decides the node's type and in case it has a children list, returns it.
1389 * @param[in] node Node to examine.
1390 * @return The node's children linked list if any, NULL otherwise.
1391 */
1392const struct lysp_node *lysp_node_children(const struct lysp_node *node);
1393
1394/**
1395 * @brief Get the actions/RPCs sized array of the given (compiled) schema node.
1396 * Decides the node's type and in case it has a actions/RPCs array, returns it.
1397 * @param[in] node Node to examine.
1398 * @return The node's actions/RPCs sized array if any, NULL otherwise.
1399 */
1400const struct lysc_action *lysc_node_actions(const struct lysc_node *node);
1401
1402/**
1403 * @brief Get the Notifications sized array of the given (compiled) schema node.
1404 * Decides the node's type and in case it has a Notifications array, returns it.
1405 * @param[in] node Node to examine.
1406 * @return The node's Notifications sized array if any, NULL otherwise.
1407 */
1408const struct lysc_notif *lysc_node_notifs(const struct lysc_node *node);
1409
1410/**
1411 * @brief Get the children linked list of the given (compiled) schema node.
1412 * Decides the node's type and in case it has a children list, returns it.
1413 * @param[in] node Node to examine.
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001414 * @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 +01001415 * @return The node's children linked list if any, NULL otherwise.
1416 */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001417const struct lysc_node *lysc_node_children(const struct lysc_node *node, uint16_t flags);
Radek Krejci056d0a82018-12-06 16:57:25 +01001418
1419/**
Radek Krejci151a5b72018-10-19 14:21:44 +02001420 * @brief Get how the if-feature statement currently evaluates.
1421 *
1422 * @param[in] iff Compiled if-feature statement to evaluate.
1423 * @return If the statement evaluates to true, 1 is returned. 0 is returned when the statement evaluates to false.
1424 */
1425int lysc_iffeature_value(const struct lysc_iffeature *iff);
1426
1427/**
1428 * @brief Get the current status of the provided feature.
1429 *
1430 * @param[in] feature Compiled feature statement to examine.
1431 * @return
1432 * - 1 if feature is enabled,
1433 * - 0 if feature is disabled,
1434 * - -1 in case of error (invalid argument)
1435 */
1436int lysc_feature_value(const struct lysc_feature *feature);
1437
1438/**
Radek Krejci327de162019-06-14 12:52:07 +02001439 * @brief Generate path of the given node in the requested format.
1440 *
1441 * @param[in] node Schema path of this node will be generated.
1442 * @param[in] pathtype Format of the path to generate.
1443 * @return NULL in case of memory allocation error, path of the node otherwise.
1444 * Returned string is dynamically allocated and caller is responsible to free it.
1445 */
1446char *lysc_path(struct lysc_node *node, LY_PATH_TYPE pathtype);
1447
1448/**
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001449 * @brief Available YANG schema tree structures representing YANG module.
1450 */
1451struct lys_module {
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001452 struct ly_ctx *ctx; /**< libyang context of the module (mandatory) */
1453 const char *name; /**< name of the module (mandatory) */
Radek Krejci0af46292019-01-11 16:02:31 +01001454 const char *revision; /**< revision of the module (if present) */
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001455 const char *ns; /**< namespace of the module (module - mandatory) */
1456 const char *prefix; /**< module prefix or submodule belongsto prefix of main module (mandatory) */
1457 const char *filepath; /**< path, if the schema was read from a file, NULL in case of reading from memory */
1458 const char *org; /**< party/company responsible for the module */
1459 const char *contact; /**< contact information for the module */
1460 const char *dsc; /**< description of the module */
1461 const char *ref; /**< cross-reference for the module */
1462
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001463 struct lysp_module *parsed; /**< Simply parsed (unresolved) YANG schema tree */
Radek Krejci0af46292019-01-11 16:02:31 +01001464 struct lysc_module *compiled; /**< Compiled and fully validated YANG schema tree for data parsing.
1465 Available only for implemented modules. */
1466 struct lysc_feature *off_features;/**< List of pre-compiled features of the module in non implemented modules ([sized array](@ref sizedarrays)).
1467 These features are always disabled and cannot be enabled until the module
1468 become implemented. The features are present in this form to allow their linkage
1469 from if-feature statements of the compiled schemas and their proper use in case
1470 the module became implemented in future (no matter if implicitly via augment/deviate
1471 or explicitly via ly_ctx_module_implement()). */
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001472
Radek Krejci95710c92019-02-11 15:49:55 +01001473 uint8_t implemented; /**< flag if the module is implemented, not just imported. The module is implemented if
1474 the flag has non-zero value. Specific values are used internally:
1475 1 - implemented module
1476 2 - recently implemented module by dependency, it can be reverted in rollback procedure */
1477 uint8_t latest_revision; /**< flag to mark the latest available revision:
Radek Krejci0bcdaed2019-01-10 10:21:34 +01001478 1 - the latest revision in searchdirs was not searched yet and this is the
1479 latest revision in the current context
1480 2 - searchdirs were searched and this is the latest available revision */
1481 uint8_t version; /**< yang-version (LYS_VERSION values) */
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001482};
1483
Radek Krejci151a5b72018-10-19 14:21:44 +02001484/**
1485 * @brief Enable specified feature in the module
1486 *
1487 * By default, when the module is loaded by libyang parser, all features are disabled.
1488 *
Radek Krejcica3db002018-11-01 10:31:01 +01001489 * If all features are being enabled, it must be possible respecting their if-feature conditions. For example,
1490 * enabling all features on the following feature set will fail since it is not possible to enable both features
1491 * (and it is unclear which of them should be enabled then). In this case the LY_EDENIED is returned and the feature
1492 * is untouched.
1493 *
1494 * feature f1;
1495 * feature f2 { if-feature 'not f1';}
1496 *
Radek Krejci151a5b72018-10-19 14:21:44 +02001497 * @param[in] module Module where the feature will be enabled.
1498 * @param[in] feature Name of the feature to enable. To enable all features at once, use asterisk (`*`) character.
1499 * @return LY_ERR value.
1500 */
Radek Krejcied5acc52019-04-25 15:57:04 +02001501LY_ERR lys_feature_enable(const struct lys_module *module, const char *feature);
Radek Krejci151a5b72018-10-19 14:21:44 +02001502
1503/**
1504 * @brief Disable specified feature in the module
1505 *
1506 * By default, when the module is loaded by libyang parser, all features are disabled.
1507 *
1508 * @param[in] module Module where the feature will be disabled.
1509 * @param[in] feature Name of the feature to disable. To disable all features at once, use asterisk (`*`) character.
1510 * @return LY_ERR value
1511 */
Radek Krejcied5acc52019-04-25 15:57:04 +02001512LY_ERR lys_feature_disable(const struct lys_module *module, const char *feature);
Radek Krejci151a5b72018-10-19 14:21:44 +02001513
1514/**
1515 * @brief Get the current status of the specified feature in the module.
1516 *
1517 * @param[in] module Module where the feature is defined.
1518 * @param[in] feature Name of the feature to inspect.
1519 * @return
1520 * - 1 if feature is enabled,
1521 * - 0 if feature is disabled,
1522 * - -1 in case of error (e.g. feature is not defined or invalid arguments)
1523 */
1524int lys_feature_value(const struct lys_module *module, const char *feature);
Radek Krejcidd4e8d42018-10-16 14:55:43 +02001525
1526/**
Radek Krejci86d106e2018-10-18 09:53:19 +02001527 * @brief Load a schema into the specified context.
1528 *
1529 * @param[in] ctx libyang context where to process the data model.
1530 * @param[in] data The string containing the dumped data model in the specified
1531 * format.
1532 * @param[in] format Format of the input data (YANG or YIN).
1533 * @return Pointer to the data model structure or NULL on error.
1534 */
Radek Krejcid14e9692018-11-01 11:00:37 +01001535struct lys_module *lys_parse_mem(struct ly_ctx *ctx, const char *data, LYS_INFORMAT format);
Radek Krejci86d106e2018-10-18 09:53:19 +02001536
1537/**
1538 * @brief Read a schema from file descriptor into the specified context.
1539 *
1540 * \note Current implementation supports only reading data from standard (disk) file, not from sockets, pipes, etc.
1541 *
1542 * @param[in] ctx libyang context where to process the data model.
1543 * @param[in] fd File descriptor of a regular file (e.g. sockets are not supported) containing the schema
1544 * in the specified format.
1545 * @param[in] format Format of the input data (YANG or YIN).
1546 * @return Pointer to the data model structure or NULL on error.
1547 */
Radek Krejcid14e9692018-11-01 11:00:37 +01001548struct lys_module *lys_parse_fd(struct ly_ctx *ctx, int fd, LYS_INFORMAT format);
Radek Krejci86d106e2018-10-18 09:53:19 +02001549
1550/**
Radek Krejcid33273d2018-10-25 14:55:52 +02001551 * @brief Read a schema into the specified context from a file.
Radek Krejci86d106e2018-10-18 09:53:19 +02001552 *
1553 * @param[in] ctx libyang context where to process the data model.
1554 * @param[in] path Path to the file with the model in the specified format.
1555 * @param[in] format Format of the input data (YANG or YIN).
1556 * @return Pointer to the data model structure or NULL on error.
1557 */
Radek Krejcid14e9692018-11-01 11:00:37 +01001558struct lys_module *lys_parse_path(struct ly_ctx *ctx, const char *path, LYS_INFORMAT format);
Radek Krejci86d106e2018-10-18 09:53:19 +02001559
1560/**
Radek Krejcid33273d2018-10-25 14:55:52 +02001561 * @brief Search for the schema file in the specified searchpaths.
1562 *
1563 * @param[in] searchpaths NULL-terminated array of paths to be searched (recursively). Current working
1564 * directory is searched automatically (but non-recursively if not in the provided list). Caller can use
1565 * result of the ly_ctx_get_searchdirs().
1566 * @param[in] cwd Flag to implicitly search also in the current working directory (non-recursively).
1567 * @param[in] name Name of the schema to find.
1568 * @param[in] revision Revision of the schema to find. If NULL, the newest found schema filepath is returned.
1569 * @param[out] localfile Mandatory output variable containing absolute path of the found schema. If no schema
1570 * complying the provided restriction is found, NULL is set.
1571 * @param[out] format Optional output variable containing expected format of the schema document according to the
1572 * file suffix.
1573 * @return LY_ERR value (LY_SUCCESS is returned even if the file is not found, then the *localfile is NULL).
1574 */
1575LY_ERR lys_search_localfile(const char * const *searchpaths, int cwd, const char *name, const char *revision, char **localfile, LYS_INFORMAT *format);
1576
1577/**
Radek Krejcia3045382018-11-22 14:30:31 +01001578 * @brief Get next schema tree (sibling) node element that can be instantiated in a data tree. Returned node can
1579 * be from an augment.
1580 *
1581 * lys_getnext() is supposed to be called sequentially. In the first call, the \p last parameter is usually NULL
1582 * and function starts returning i) the first \p parent's child or ii) the first top level element of the \p module.
1583 * Consequent calls suppose to provide the previously returned node as the \p last parameter and still the same
1584 * \p parent and \p module parameters.
1585 *
1586 * Without options, the function is used to traverse only the schema nodes that can be paired with corresponding
1587 * data nodes in a data tree. By setting some \p options the behavior can be modified to the extent that
1588 * all the schema nodes are iteratively returned.
1589 *
1590 * @param[in] last Previously returned schema tree node, or NULL in case of the first call.
1591 * @param[in] parent Parent of the subtree where the function starts processing.
1592 * @param[in] module In case of iterating on top level elements, the \p parent is NULL and
1593 * module must be specified.
1594 * @param[in] options [ORed options](@ref sgetnextflags).
1595 * @return Next schema tree node that can be instantiated in a data tree, NULL in case there is no such element.
1596 */
1597const struct lysc_node *lys_getnext(const struct lysc_node *last, const struct lysc_node *parent,
1598 const struct lysc_module *module, int options);
1599
1600/**
1601 * @defgroup sgetnextflags lys_getnext() flags
1602 * @ingroup schematree
1603 *
1604 * @{
1605 */
1606#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 +01001607#define LYS_GETNEXT_NOCHOICE 0x02 /**< lys_getnext() option to ignore (kind of conditional) nodes within choice node */
Radek Krejci056d0a82018-12-06 16:57:25 +01001608#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 +01001609#define LYS_GETNEXT_INTONPCONT 0x40 /**< lys_getnext() option to look into non-presence container, instead of returning container itself */
1610#define LYS_GETNEXT_NOSTATECHECK 0x100 /**< lys_getnext() option to skip checking module validity (import-only, disabled) and
1611 relevant if-feature conditions state */
Radek Krejci6eeb58f2019-02-22 16:29:37 +01001612#define LYS_GETNEXT_OUTPUT 0x200 /**< lys_getnext() option to provide RPC's/action's output schema nodes instead of input schema nodes
1613 provided by default */
Radek Krejcia3045382018-11-22 14:30:31 +01001614/** @} sgetnextflags */
1615
1616/**
1617 * @brief Get child node according to the specified criteria.
1618 *
1619 * @param[in] parent Optional parent of the node to find. If not specified, the module's top-level nodes are searched.
1620 * @param[in] module module of the node to find. It is also limitation for the children node of the given parent.
1621 * @param[in] name Name of the node to find.
1622 * @param[in] name_len Optional length of the name in case it is not NULL-terminated string.
1623 * @param[in] nodetype Optional criteria (to speedup) specifying nodetype(s) of the node to find.
1624 * Used as a bitmask, so multiple nodetypes can be specified.
1625 * @param[in] options [ORed options](@ref sgetnextflags).
1626 * @return Found node if any.
1627 */
1628const struct lysc_node *lys_child(const struct lysc_node *parent, const struct lys_module *module,
1629 const char *name, size_t name_len, uint16_t nodetype, int options);
1630
1631/**
1632 * @brief Check if the schema node is disabled in the schema tree, i.e. there is any disabled if-feature statement
1633 * affecting the node.
1634 *
1635 * @param[in] node Schema node to check.
1636 * @param[in] recursive - 0 to check if-feature only in the \p node schema node,
1637 * - 1 to check if-feature in all ascendant schema nodes until there is a node possibly having an instance in a data tree
1638 * @return - NULL if enabled,
1639 * - pointer to the node with the unsatisfied (disabling) if-feature expression.
1640 */
1641const struct lysc_iffeature *lys_is_disabled(const struct lysc_node *node, int recursive);
1642
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001643/** @} */
1644
Radek Krejci70853c52018-10-15 14:46:16 +02001645#ifdef __cplusplus
1646}
1647#endif
1648
Radek Krejci5aeea3a2018-09-05 13:29:36 +02001649#endif /* LY_TREE_SCHEMA_H_ */