Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file tree_schema.h |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
Michal Vasko | edb0fa5 | 2022-10-04 10:36:00 +0200 | [diff] [blame] | 4 | * @author Michal Vasko <mvasko@cesnet.cz> |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 5 | * @brief libyang representation of YANG schema trees. |
| 6 | * |
Michal Vasko | edb0fa5 | 2022-10-04 10:36:00 +0200 | [diff] [blame] | 7 | * Copyright (c) 2015 - 2022 CESNET, z.s.p.o. |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 8 | * |
| 9 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 10 | * You may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
| 12 | * |
| 13 | * https://opensource.org/licenses/BSD-3-Clause |
| 14 | */ |
| 15 | |
| 16 | #ifndef LY_TREE_SCHEMA_H_ |
| 17 | #define LY_TREE_SCHEMA_H_ |
| 18 | |
Radek Krejci | 5457946 | 2019-04-30 12:47:06 +0200 | [diff] [blame] | 19 | #define PCRE2_CODE_UNIT_WIDTH 8 |
| 20 | |
| 21 | #include <pcre2.h> |
Radek Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 22 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 23 | #include <stdint.h> |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 24 | #include <stdio.h> |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 25 | |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 26 | #include "log.h" |
Michal Vasko | 8f702ee | 2024-02-20 15:44:24 +0100 | [diff] [blame] | 27 | #include "ly_config.h" |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 28 | #include "tree.h" |
Radek Krejci | ce8c159 | 2018-10-29 15:35:51 +0100 | [diff] [blame] | 29 | |
Radek Krejci | 70853c5 | 2018-10-15 14:46:16 +0200 | [diff] [blame] | 30 | #ifdef __cplusplus |
| 31 | extern "C" { |
| 32 | #endif |
| 33 | |
Radek Krejci | ca376bd | 2020-06-11 16:04:06 +0200 | [diff] [blame] | 34 | struct ly_ctx; |
Radek Krejci | 47fab89 | 2020-11-05 17:02:41 +0100 | [diff] [blame] | 35 | struct ly_path; |
Radek Krejci | ca376bd | 2020-06-11 16:04:06 +0200 | [diff] [blame] | 36 | struct ly_set; |
Radek Krejci | 47fab89 | 2020-11-05 17:02:41 +0100 | [diff] [blame] | 37 | struct lys_module; |
| 38 | struct lysc_node; |
| 39 | struct lyxp_expr; |
Radek Krejci | ca376bd | 2020-06-11 16:04:06 +0200 | [diff] [blame] | 40 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 41 | /** |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 42 | * @page howtoSchema YANG Modules |
| 43 | * |
| 44 | * To be able to work with YANG data instances, libyang has to represent YANG data models. All the processed modules are stored |
| 45 | * in libyang [context](@ref howtoContext) and loaded using [parser functions](@ref howtoSchemaParsers). It means, that there is |
| 46 | * no way to create/change YANG module programmatically. However, all the YANG model definitions are available and can be examined |
| 47 | * through the C structures. All the context's modules together form YANG Schema for the data being instantiated. |
| 48 | * |
| 49 | * Any YANG module is represented as ::lys_module. In fact, the module is represented in two different formats. As ::lys_module.parsed, |
| 50 | * there is a parsed schema reflecting the source YANG module. It is exactly what is read from the input. This format is good for |
| 51 | * converting from one format to another (YANG to YIN and vice versa), but it is not very useful for validating/manipulating YANG |
| 52 | * data. Therefore, there is ::lys_module.compiled storing the compiled YANG module. It is based on the parsed module, but all the |
| 53 | * references are resolved. It means that, for example, there are no `grouping`s or `typedef`s since they are supposed to be placed instead of |
| 54 | * `uses` or `type` references. This split also means, that the YANG module is fully validated after compilation of the parsed |
| 55 | * representation of the module. YANG submodules are available only in the parsed representation. When a submodule is compiled, it |
| 56 | * is fully integrated into its main module. |
| 57 | * |
| 58 | * The context can contain even modules without the compiled representation. Such modules are still useful as imports of other |
| 59 | * modules. The grouping or typedef definition can be even compiled into the importing modules. This is actually the main |
| 60 | * difference between the imported and implemented modules in the libyang context. The implemented modules are compiled while the |
| 61 | * imported modules are only parsed. |
| 62 | * |
Radek Krejci | b100b19 | 2020-10-26 08:37:45 +0100 | [diff] [blame] | 63 | * By default, the module is implemented (and compiled) in case it is explicitly loaded or referenced in another module as |
| 64 | * target of leafref, augment or deviation. This behavior can be changed via context options ::LY_CTX_ALL_IMPLEMENTED, when |
| 65 | * all the modules in the context are marked as implemented (note the problem with multiple revisions of a single module), |
| 66 | * or by ::LY_CTX_REF_IMPLEMENTED option, extending the set of references making the module implemented by when, must and |
| 67 | * default statements. |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 68 | * |
| 69 | * All modules with deviation definition are always marked as implemented. The imported (not implemented) module can be set implemented by ::lys_set_implemented(). But |
| 70 | * the implemented module cannot be changed back to just imported module. Note also that only one revision of a specific module |
| 71 | * can be implemented in a single context. The imported modules are used only as a |
| 72 | * source of definitions for types and groupings for uses statements. The data in such modules are ignored - caller |
| 73 | * is not allowed to create the data (including instantiating identities) defined in the model via data parsers, |
| 74 | * the default nodes are not added into any data tree and mandatory nodes are not checked in the data trees. |
| 75 | * |
Michal Vasko | 14ed9cd | 2021-01-28 14:16:25 +0100 | [diff] [blame] | 76 | * The compiled schema tree nodes are able to hold private objects (::lysc_node.priv as a pointer to a structure, |
aPiecek | 9922ea9 | 2021-04-12 07:59:20 +0200 | [diff] [blame] | 77 | * function, variable, ...) used by a caller application unless ::LY_CTX_SET_PRIV_PARSED is set, in that case |
| 78 | * the ::lysc_node.priv pointers are used by libyang. |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 79 | * Note that the object is not freed by libyang when the context is being destroyed. So the caller is responsible |
| 80 | * for freeing the provided structure after the context is destroyed or the private pointer is set to NULL in |
Radek Krejci | 90ed21e | 2021-04-12 14:47:46 +0200 | [diff] [blame] | 81 | * appropriate schema nodes where the object was previously set. Also ::lysc_tree_dfs_full() can be useful to manage |
| 82 | * the private data. |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 83 | * |
| 84 | * Despite all the schema structures and their members are available as part of the libyang API and callers can use |
| 85 | * it to navigate through the schema tree structure or to obtain various information, we recommend to use the following |
| 86 | * macros for the specific actions. |
| 87 | * - ::LYSC_TREE_DFS_BEGIN and ::LYSC_TREE_DFS_END to traverse the schema tree (depth-first). |
| 88 | * - ::LY_LIST_FOR and ::LY_ARRAY_FOR as described on @ref howtoStructures page. |
| 89 | * |
| 90 | * Further information about modules handling can be found on the following pages: |
| 91 | * - @subpage howtoSchemaParsers |
| 92 | * - @subpage howtoSchemaFeatures |
| 93 | * - @subpage howtoPlugins |
| 94 | * - @subpage howtoSchemaPrinters |
| 95 | * |
| 96 | * \note There are many functions to access information from the schema trees. Details are available in |
| 97 | * the [Schema Tree module](@ref schematree). |
| 98 | * |
| 99 | * For information about difference between implemented and imported modules, see the |
| 100 | * [context description](@ref howtoContext). |
| 101 | * |
| 102 | * Functions List (not assigned to above subsections) |
| 103 | * -------------------------------------------------- |
| 104 | * - ::lys_getnext() |
| 105 | * - ::lys_nodetype2str() |
| 106 | * - ::lys_set_implemented() |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 107 | * |
Michal Vasko | d5cfa6e | 2020-11-23 16:56:08 +0100 | [diff] [blame] | 108 | * - ::lysc_has_when() |
Michal Vasko | ef53c81 | 2021-10-13 10:21:03 +0200 | [diff] [blame] | 109 | * - ::lysc_owner_module() |
Michal Vasko | d5cfa6e | 2020-11-23 16:56:08 +0100 | [diff] [blame] | 110 | * |
Michal Vasko | 544e58a | 2021-01-28 14:33:41 +0100 | [diff] [blame] | 111 | * - ::lysc_node_child() |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 112 | * - ::lysc_node_actions() |
| 113 | * - ::lysc_node_notifs() |
| 114 | * |
Michal Vasko | 544e58a | 2021-01-28 14:33:41 +0100 | [diff] [blame] | 115 | * - ::lysp_node_child() |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 116 | * - ::lysp_node_actions() |
| 117 | * - ::lysp_node_notifs() |
| 118 | * - ::lysp_node_groupings() |
| 119 | * - ::lysp_node_typedefs() |
| 120 | */ |
| 121 | |
| 122 | /** |
| 123 | * @page howtoSchemaFeatures YANG Features |
| 124 | * |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 125 | * YANG feature statement is an important part of the language which can significantly affect the meaning of the schemas. |
| 126 | * Modifying features may have similar effects as loading/removing schema from the context so it is limited to context |
| 127 | * preparation period before working with data. YANG features, respectively their use in if-feature |
| 128 | * statements, are evaluated as part of schema compilation so a feature-specific compiled schema tree is generated |
| 129 | * as a result. |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 130 | * |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 131 | * To enable any features, they must currently be specified when implementing a new schema with ::lys_parse() or |
| 132 | * ::ly_ctx_load_module(). To later examine what the status of a feature is, check its ::LYS_FENABLED flag or |
| 133 | * search for it first with ::lys_feature_value(). Lastly, to evaluate compiled if-features, use ::lysc_iffeature_value(). |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 134 | * |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 135 | * To iterate over all features of a particular YANG module, use ::lysp_feature_next(). |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 136 | * |
| 137 | * Note, that the feature's state can affect some of the output formats (e.g. Tree format). |
| 138 | * |
| 139 | * Functions List |
| 140 | * -------------- |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 141 | * - ::lys_feature_value() |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 142 | * - ::lysc_iffeature_value() |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 143 | * - ::lysp_feature_next() |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 144 | */ |
| 145 | |
| 146 | /** |
Radek Krejci | 2ff0d57 | 2020-05-21 15:27:28 +0200 | [diff] [blame] | 147 | * @ingroup trees |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 148 | * @defgroup schematree Schema Tree |
Radek Krejci | 2ff0d57 | 2020-05-21 15:27:28 +0200 | [diff] [blame] | 149 | * @{ |
| 150 | * |
| 151 | * Data structures and functions to manipulate and access schema tree. |
| 152 | */ |
| 153 | |
Michal Vasko | 64246d8 | 2020-08-19 12:35:00 +0200 | [diff] [blame] | 154 | /* *INDENT-OFF* */ |
| 155 | |
Radek Krejci | 2ff0d57 | 2020-05-21 15:27:28 +0200 | [diff] [blame] | 156 | /** |
Michal Vasko | 208a04a | 2020-10-21 15:17:12 +0200 | [diff] [blame] | 157 | * @brief Macro to iterate via all elements in a schema (sub)tree including input and output. |
| 158 | * Note that __actions__ and __notifications__ of traversed nodes __are ignored__! To traverse |
| 159 | * on all the nodes including those, use ::lysc_tree_dfs_full() instead. |
| 160 | * |
| 161 | * This is the opening part to the #LYSC_TREE_DFS_END - they always have to be used together. |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 162 | * |
| 163 | * The function follows deep-first search algorithm: |
| 164 | * <pre> |
| 165 | * 1 |
| 166 | * / \ |
| 167 | * 2 4 |
| 168 | * / / \ |
| 169 | * 3 5 6 |
| 170 | * </pre> |
| 171 | * |
| 172 | * Use the same parameters for #LYSC_TREE_DFS_BEGIN and #LYSC_TREE_DFS_END. While |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 173 | * START can be any of the lysc_node* types (including lysc_node_action and lysc_node_notif), |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 174 | * ELEM variable must be of the struct lysc_node* type. |
| 175 | * |
| 176 | * To skip a particular subtree, instead of the continue statement, set LYSC_TREE_DFS_continue |
| 177 | * variable to non-zero value. |
| 178 | * |
| 179 | * Use with opening curly bracket '{' after the macro. |
| 180 | * |
| 181 | * @param START Pointer to the starting element processed first. |
| 182 | * @param ELEM Iterator intended for use in the block. |
| 183 | */ |
| 184 | #define LYSC_TREE_DFS_BEGIN(START, ELEM) \ |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 185 | { ly_bool LYSC_TREE_DFS_continue = 0; struct lysc_node *LYSC_TREE_DFS_next; \ |
Michal Vasko | 14ed9cd | 2021-01-28 14:16:25 +0100 | [diff] [blame] | 186 | for ((ELEM) = (LYSC_TREE_DFS_next) = (struct lysc_node *)(START); \ |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 187 | (ELEM); \ |
| 188 | (ELEM) = (LYSC_TREE_DFS_next), LYSC_TREE_DFS_continue = 0) |
| 189 | |
| 190 | /** |
| 191 | * @brief Macro to iterate via all elements in a (sub)tree. This is the closing part |
| 192 | * to the #LYSC_TREE_DFS_BEGIN - they always have to be used together. |
| 193 | * |
| 194 | * Use the same parameters for #LYSC_TREE_DFS_BEGIN and #LYSC_TREE_DFS_END. While |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 195 | * START can be a pointer to any of the lysc_node* types (including lysc_node_action and lysc_node_notif), |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 196 | * ELEM variable must be pointer to the lysc_node type. |
| 197 | * |
| 198 | * Use with closing curly bracket '}' after the macro. |
| 199 | * |
| 200 | * @param START Pointer to the starting element processed first. |
| 201 | * @param ELEM Iterator intended for use in the block. |
| 202 | */ |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 203 | #define LYSC_TREE_DFS_END(START, ELEM) \ |
| 204 | /* select element for the next run - children first */ \ |
| 205 | if (LYSC_TREE_DFS_continue) { \ |
| 206 | (LYSC_TREE_DFS_next) = NULL; \ |
| 207 | } else { \ |
Michal Vasko | 544e58a | 2021-01-28 14:33:41 +0100 | [diff] [blame] | 208 | (LYSC_TREE_DFS_next) = (struct lysc_node *)lysc_node_child(ELEM); \ |
Michal Vasko | 208a04a | 2020-10-21 15:17:12 +0200 | [diff] [blame] | 209 | } \ |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 210 | if (!(LYSC_TREE_DFS_next)) { \ |
Michal Vasko | 208a04a | 2020-10-21 15:17:12 +0200 | [diff] [blame] | 211 | /* no children, try siblings */ \ |
| 212 | _LYSC_TREE_DFS_NEXT(START, ELEM, LYSC_TREE_DFS_next); \ |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 213 | } \ |
| 214 | while (!(LYSC_TREE_DFS_next)) { \ |
| 215 | /* parent is already processed, go to its sibling */ \ |
Radek Krejci | 7d95fbb | 2021-01-26 17:33:13 +0100 | [diff] [blame] | 216 | (ELEM) = (ELEM)->parent; \ |
Michal Vasko | 208a04a | 2020-10-21 15:17:12 +0200 | [diff] [blame] | 217 | _LYSC_TREE_DFS_NEXT(START, ELEM, LYSC_TREE_DFS_next); \ |
| 218 | } } |
| 219 | |
| 220 | /** |
| 221 | * @brief Helper macro for #LYSC_TREE_DFS_END, should not be used directly! |
| 222 | */ |
| 223 | #define _LYSC_TREE_DFS_NEXT(START, ELEM, NEXT) \ |
| 224 | if ((ELEM) == (struct lysc_node *)(START)) { \ |
| 225 | /* we are done, no next element to process */ \ |
| 226 | break; \ |
| 227 | } \ |
Michal Vasko | 544e58a | 2021-01-28 14:33:41 +0100 | [diff] [blame] | 228 | (NEXT) = (ELEM)->next; |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 229 | |
Michal Vasko | 64246d8 | 2020-08-19 12:35:00 +0200 | [diff] [blame] | 230 | /* *INDENT-ON* */ |
| 231 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 232 | #define LY_REV_SIZE 11 /**< revision data string length (including terminating NULL byte) */ |
| 233 | |
Radek Krejci | de7a9c4 | 2021-03-10 13:13:06 +0100 | [diff] [blame] | 234 | /** |
| 235 | * @defgroup schemanodetypes Schema Node Types |
| 236 | * Values of the ::lysp_node.nodetype and ::lysc_node.nodetype members. |
| 237 | * @{ |
| 238 | */ |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 239 | #define LYS_UNKNOWN 0x0000 /**< uninitalized unknown statement node */ |
| 240 | #define LYS_CONTAINER 0x0001 /**< container statement node */ |
| 241 | #define LYS_CHOICE 0x0002 /**< choice statement node */ |
| 242 | #define LYS_LEAF 0x0004 /**< leaf statement node */ |
| 243 | #define LYS_LEAFLIST 0x0008 /**< leaf-list statement node */ |
| 244 | #define LYS_LIST 0x0010 /**< list statement node */ |
| 245 | #define LYS_ANYXML 0x0020 /**< anyxml statement node */ |
| 246 | #define LYS_ANYDATA 0x0060 /**< anydata statement node, in tests it can be used for both #LYS_ANYXML and #LYS_ANYDATA */ |
| 247 | #define LYS_CASE 0x0080 /**< case statement node */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 248 | |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 249 | #define LYS_RPC 0x0100 /**< RPC statement node */ |
| 250 | #define LYS_ACTION 0x0200 /**< action statement node */ |
| 251 | #define LYS_NOTIF 0x0400 /**< notification statement node */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 252 | |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 253 | #define LYS_USES 0x0800 /**< uses statement node */ |
| 254 | #define LYS_INPUT 0x1000 /**< RPC/action input node */ |
| 255 | #define LYS_OUTPUT 0x2000 /**< RPC/action output node */ |
| 256 | #define LYS_GROUPING 0x4000 |
| 257 | #define LYS_AUGMENT 0x8000 |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 258 | |
Radek Krejci | f13b87b | 2020-12-01 22:02:17 +0100 | [diff] [blame] | 259 | #define LYS_NODETYPE_MASK 0xffff /**< Mask for nodetypes, the value is limited for 16 bits */ |
Radek Krejci | de7a9c4 | 2021-03-10 13:13:06 +0100 | [diff] [blame] | 260 | /** @} schemanodetypes */ |
Radek Krejci | f13b87b | 2020-12-01 22:02:17 +0100 | [diff] [blame] | 261 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 262 | /** |
| 263 | * @brief YANG import-stmt |
| 264 | */ |
| 265 | struct lysp_import { |
Radek Krejci | 086c713 | 2018-10-26 15:29:04 +0200 | [diff] [blame] | 266 | struct lys_module *module; /**< pointer to the imported module |
| 267 | (mandatory, but resolved when the referring module is completely parsed) */ |
| 268 | const char *name; /**< name of the imported module (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 269 | const char *prefix; /**< prefix for the data from the imported schema (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 270 | const char *dsc; /**< description */ |
| 271 | const char *ref; /**< reference */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 272 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | 3e9bc2f | 2020-11-04 17:13:56 +0100 | [diff] [blame] | 273 | uint16_t flags; /**< LYS_INTERNAL value (@ref snodeflags) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 274 | char rev[LY_REV_SIZE]; /**< revision-date of the imported module */ |
| 275 | }; |
| 276 | |
| 277 | /** |
| 278 | * @brief YANG include-stmt |
| 279 | */ |
| 280 | struct lysp_include { |
Radek Krejci | 0bcdaed | 2019-01-10 10:21:34 +0100 | [diff] [blame] | 281 | struct lysp_submodule *submodule;/**< pointer to the parsed submodule structure |
Radek Krejci | 086c713 | 2018-10-26 15:29:04 +0200 | [diff] [blame] | 282 | (mandatory, but resolved when the referring module is completely parsed) */ |
| 283 | const char *name; /**< name of the included submodule (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 284 | const char *dsc; /**< description */ |
| 285 | const char *ref; /**< reference */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 286 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 287 | char rev[LY_REV_SIZE]; /**< revision-date of the included submodule */ |
Radek Krejci | 771928a | 2021-01-19 13:42:36 +0100 | [diff] [blame] | 288 | ly_bool injected; /**< flag to mark includes copied into main module from submodules, |
| 289 | only for backward compatibility with YANG 1.0, which does not require the |
| 290 | main module to include all submodules. */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 291 | }; |
| 292 | |
| 293 | /** |
| 294 | * @brief YANG extension-stmt |
| 295 | */ |
| 296 | struct lysp_ext { |
| 297 | const char *name; /**< extension name */ |
Radek Krejci | 9f87b0c | 2021-03-05 14:45:26 +0100 | [diff] [blame] | 298 | const char *argname; /**< argument name, NULL if not specified */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 299 | const char *dsc; /**< description statement */ |
| 300 | const char *ref; /**< reference statement */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 301 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | f56e2a4 | 2019-09-09 14:15:25 +0200 | [diff] [blame] | 302 | uint16_t flags; /**< LYS_STATUS_* and LYS_YINELEM_* values (@ref snodeflags) */ |
Michal Vasko | 5fe75f1 | 2020-03-02 13:52:37 +0100 | [diff] [blame] | 303 | |
Radek Krejci | 720d261 | 2021-03-03 19:44:22 +0100 | [diff] [blame] | 304 | struct lysc_ext *compiled; /**< pointer to the compiled extension definition. |
| 305 | The extension definition is compiled only if there is compiled extension instance, |
| 306 | otherwise this pointer remains NULL. The compiled extension definition is shared |
| 307 | among all extension instances. */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 308 | }; |
| 309 | |
| 310 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 311 | * @brief YANG feature-stmt |
| 312 | */ |
| 313 | struct lysp_feature { |
| 314 | const char *name; /**< feature name (mandatory) */ |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 315 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 316 | struct lysc_iffeature *iffeatures_c; /**< compiled if-features */ |
| 317 | struct lysp_feature **depfeatures; /**< list of pointers to other features depending on this one |
| 318 | ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 319 | const char *dsc; /**< description statement */ |
| 320 | const char *ref; /**< reference statement */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 321 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 322 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values and |
| 323 | LYS_FENABLED are allowed */ |
| 324 | }; |
| 325 | |
| 326 | /** |
| 327 | * @brief Compiled YANG if-feature-stmt |
| 328 | */ |
| 329 | struct lysc_iffeature { |
| 330 | uint8_t *expr; /**< 2bits array describing the if-feature expression in prefix format, see @ref ifftokens */ |
| 331 | struct lysp_feature **features; /**< array of pointers to the features used in expression ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 332 | }; |
| 333 | |
| 334 | /** |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 335 | * @brief Qualified name (optional prefix followed by an identifier). |
| 336 | */ |
| 337 | struct lysp_qname { |
| 338 | const char *str; /**< qualified name string */ |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 339 | const struct lysp_module *mod; /**< module to resolve any prefixes found in the string, it must be |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 340 | stored explicitly because of deviations/refines */ |
Michal Vasko | 72c6d64 | 2024-02-27 14:59:01 +0100 | [diff] [blame^] | 341 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_SINGLEQUOTED and |
| 342 | LYS_DOUBLEQUOTED values allowed */ |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 343 | }; |
| 344 | |
| 345 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 346 | * @brief YANG identity-stmt |
| 347 | */ |
| 348 | struct lysp_ident { |
| 349 | const char *name; /**< identity name (mandatory), including possible prefix */ |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 350 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 351 | const char **bases; /**< list of base identifiers ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 352 | const char *dsc; /**< description statement */ |
| 353 | const char *ref; /**< reference statement */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 354 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 355 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ values are allowed */ |
| 356 | }; |
| 357 | |
Michal Vasko | 71e64ca | 2018-09-07 16:30:29 +0200 | [diff] [blame] | 358 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 359 | * @brief Covers restrictions: range, length, pattern, must |
| 360 | */ |
| 361 | struct lysp_restr { |
Radek Krejci | f13b87b | 2020-12-01 22:02:17 +0100 | [diff] [blame] | 362 | #define LYSP_RESTR_PATTERN_ACK 0x06 |
| 363 | #define LYSP_RESTR_PATTERN_NACK 0x15 |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 364 | struct lysp_qname arg; /**< The restriction expression/value (mandatory); |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 365 | in case of pattern restriction, the first byte has a special meaning: |
| 366 | 0x06 (ACK) for regular match and 0x15 (NACK) for invert-match */ |
| 367 | const char *emsg; /**< error-message */ |
| 368 | const char *eapptag; /**< error-app-tag value */ |
| 369 | const char *dsc; /**< description */ |
| 370 | const char *ref; /**< reference */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 371 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 372 | }; |
| 373 | |
| 374 | /** |
Michal Vasko | 71e64ca | 2018-09-07 16:30:29 +0200 | [diff] [blame] | 375 | * @brief YANG revision-stmt |
| 376 | */ |
| 377 | struct lysp_revision { |
Radek Krejci | cb3e647 | 2021-01-06 08:19:01 +0100 | [diff] [blame] | 378 | char date[LY_REV_SIZE]; /**< revision date (madatory) */ |
Michal Vasko | 71e64ca | 2018-09-07 16:30:29 +0200 | [diff] [blame] | 379 | const char *dsc; /**< description statement */ |
| 380 | const char *ref; /**< reference statement */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 381 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | 71e64ca | 2018-09-07 16:30:29 +0200 | [diff] [blame] | 382 | }; |
| 383 | |
| 384 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 385 | * @brief Enumeration/Bit value definition |
| 386 | */ |
| 387 | struct lysp_type_enum { |
| 388 | const char *name; /**< name (mandatory) */ |
| 389 | const char *dsc; /**< description statement */ |
| 390 | const char *ref; /**< reference statement */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 391 | int64_t value; /**< enum's value or bit's position */ |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 392 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 393 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 394 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ and LYS_SET_VALUE |
| 395 | values are allowed */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 396 | }; |
| 397 | |
| 398 | /** |
| 399 | * @brief YANG type-stmt |
| 400 | * |
| 401 | * Some of the items in the structure may be mandatory, but it is necessary to resolve the type's base type first |
| 402 | */ |
| 403 | struct lysp_type { |
| 404 | const char *name; /**< name of the type (mandatory) */ |
| 405 | struct lysp_restr *range; /**< allowed values range - numerical, decimal64 */ |
| 406 | struct lysp_restr *length; /**< allowed length of the value - string, binary */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 407 | struct lysp_restr *patterns; /**< list of patterns ([sized array](@ref sizedarrays)) - string */ |
| 408 | struct lysp_type_enum *enums; /**< list of enum-stmts ([sized array](@ref sizedarrays)) - enum */ |
| 409 | struct lysp_type_enum *bits; /**< list of bit-stmts ([sized array](@ref sizedarrays)) - bits */ |
Michal Vasko | 004d315 | 2020-06-11 19:59:22 +0200 | [diff] [blame] | 410 | struct lyxp_expr *path; /**< parsed path - leafref */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 411 | const char **bases; /**< list of base identifiers ([sized array](@ref sizedarrays)) - identityref */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 412 | struct lysp_type *types; /**< list of sub-types ([sized array](@ref sizedarrays)) - union */ |
| 413 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 414 | |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 415 | const struct lysp_module *pmod; /**< (sub)module where the type is defined (needed for deviations) */ |
Michal Vasko | 00e8e65 | 2022-06-08 10:09:18 +0200 | [diff] [blame] | 416 | struct lysc_type *compiled; /**< pointer to the compiled custom type, not used for built-in types */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 417 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 418 | uint8_t fraction_digits; /**< number of fraction digits - decimal64 */ |
| 419 | uint8_t require_instance; /**< require-instance flag - leafref, instance */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 420 | uint16_t flags; /**< [schema node flags](@ref spnodeflags) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 421 | }; |
| 422 | |
| 423 | /** |
| 424 | * @brief YANG typedef-stmt |
| 425 | */ |
| 426 | struct lysp_tpdf { |
| 427 | const char *name; /**< name of the newly defined type (mandatory) */ |
| 428 | const char *units; /**< units of the newly defined type */ |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 429 | struct lysp_qname dflt; /**< default value of the newly defined type, it may or may not be a qualified name */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 430 | const char *dsc; /**< description statement */ |
| 431 | const char *ref; /**< reference statement */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 432 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 433 | struct lysp_type type; /**< base type from which the typedef is derived (mandatory) */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 434 | uint16_t flags; /**< [schema node flags](@ref spnodeflags) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 435 | }; |
| 436 | |
| 437 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 438 | * @brief YANG when-stmt |
| 439 | */ |
| 440 | struct lysp_when { |
| 441 | const char *cond; /**< specified condition (mandatory) */ |
| 442 | const char *dsc; /**< description statement */ |
| 443 | const char *ref; /**< reference statement */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 444 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 445 | }; |
| 446 | |
| 447 | /** |
| 448 | * @brief YANG refine-stmt |
| 449 | */ |
| 450 | struct lysp_refine { |
| 451 | const char *nodeid; /**< target descendant schema nodeid (mandatory) */ |
| 452 | const char *dsc; /**< description statement */ |
| 453 | const char *ref; /**< reference statement */ |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 454 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 455 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 456 | const char *presence; /**< presence description */ |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 457 | struct lysp_qname *dflts; /**< list of default values ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 458 | uint32_t min; /**< min-elements constraint */ |
| 459 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 460 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 461 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 462 | }; |
| 463 | |
| 464 | /** |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 465 | * @ingroup schematree |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 466 | * @defgroup deviatetypes Deviate types |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 467 | * |
| 468 | * Type of the deviate operation (used as ::lysp_deviate.mod) |
| 469 | * |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 470 | * @{ |
| 471 | */ |
| 472 | #define LYS_DEV_NOT_SUPPORTED 1 /**< deviate type not-supported */ |
| 473 | #define LYS_DEV_ADD 2 /**< deviate type add */ |
| 474 | #define LYS_DEV_DELETE 3 /**< deviate type delete */ |
| 475 | #define LYS_DEV_REPLACE 4 /**< deviate type replace */ |
Radek Krejci | 2ff0d57 | 2020-05-21 15:27:28 +0200 | [diff] [blame] | 476 | /** @} deviatetypes */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 477 | |
| 478 | /** |
| 479 | * @brief Generic deviate structure to get type and cast to lysp_deviate_* structure |
| 480 | */ |
| 481 | struct lysp_deviate { |
| 482 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 483 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 484 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 485 | }; |
| 486 | |
| 487 | struct lysp_deviate_add { |
| 488 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 489 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 490 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 491 | const char *units; /**< units of the values */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 492 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 493 | struct lysp_qname *uniques; /**< list of uniques specifications ([sized array](@ref sizedarrays)) */ |
| 494 | struct lysp_qname *dflts; /**< list of default values ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 495 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 496 | uint32_t min; /**< min-elements constraint */ |
| 497 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 498 | }; |
| 499 | |
| 500 | struct lysp_deviate_del { |
| 501 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 502 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 503 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 504 | const char *units; /**< units of the values */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 505 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 506 | struct lysp_qname *uniques; /**< list of uniques specifications ([sized array](@ref sizedarrays)) */ |
| 507 | struct lysp_qname *dflts; /**< list of default values ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 508 | }; |
| 509 | |
| 510 | struct lysp_deviate_rpl { |
| 511 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 512 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 513 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 514 | struct lysp_type *type; /**< type of the node */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 515 | const char *units; /**< units of the values */ |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 516 | struct lysp_qname dflt; /**< default value */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 517 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 518 | uint32_t min; /**< min-elements constraint */ |
| 519 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 520 | }; |
| 521 | |
| 522 | struct lysp_deviation { |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 523 | const char *nodeid; /**< target absolute schema nodeid (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 524 | const char *dsc; /**< description statement */ |
| 525 | const char *ref; /**< reference statement */ |
Michal Vasko | 22df3f0 | 2020-08-24 13:29:22 +0200 | [diff] [blame] | 526 | struct lysp_deviate *deviates; /**< list of deviate specifications (linked list) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 527 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 528 | }; |
| 529 | |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 530 | /** |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 531 | * @ingroup snodeflags |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 532 | * @defgroup spnodeflags Parsed schema nodes flags |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 533 | * |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 534 | * Various flags for parsed schema nodes (used as ::lysp_node.flags). |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 535 | * |
| 536 | * 1 - container 6 - anydata/anyxml 11 - output 16 - grouping 21 - enum |
| 537 | * 2 - choice 7 - case 12 - feature 17 - uses 22 - type |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 538 | * 3 - leaf 8 - notification 13 - identity 18 - refine 23 - stmt |
Michal Vasko | a0ba01e | 2022-10-19 13:26:57 +0200 | [diff] [blame] | 539 | * 4 - leaflist 9 - rpc 14 - extension 19 - augment |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 540 | * 5 - list 10 - input 15 - typedef 20 - deviate |
| 541 | * |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 542 | * 1 1 1 1 1 1 1 1 1 1 2 2 2 2 |
| 543 | * 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 |
Michal Vasko | a0ba01e | 2022-10-19 13:26:57 +0200 | [diff] [blame] | 544 | * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 545 | * 1 LYS_CONFIG_W |x|x|x|x|x|x| | | | | | | | | | | |x| |x| | | | |
| 546 | * LYS_SET_BASE | | | | | | | | | | | | | | | | | | | | | |x| | |
| 547 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 548 | * 2 LYS_CONFIG_R |x|x|x|x|x|x| | | | | | | | | | | |x| |x| | | | |
| 549 | * LYS_SET_BIT | | | | | | | | | | | | | | | | | | | | | |x| | |
| 550 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 551 | * 3 LYS_STATUS_CURR |x|x|x|x|x|x|x|x|x| | |x|x|x|x|x|x| |x|x|x| | | |
| 552 | * LYS_SET_ENUM | | | | | | | | | | | | | | | | | | | | | |x| | |
| 553 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 554 | * 4 LYS_STATUS_DEPRC |x|x|x|x|x|x|x|x|x| | |x|x|x|x|x|x| |x|x|x| | | |
| 555 | * LYS_SET_FRDIGITS | | | | | | | | | | | | | | | | | | | | | |x| | |
| 556 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 557 | * 5 LYS_STATUS_OBSLT |x|x|x|x|x|x|x|x|x| | |x|x|x|x|x|x| |x|x|x| | | |
| 558 | * LYS_SET_LENGTH | | | | | | | | | | | | | | | | | | | | | |x| | |
| 559 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 560 | * 6 LYS_MAND_TRUE | |x|x| | |x| | | | | | | | | | | |x| |x| | | | |
| 561 | * LYS_SET_PATH | | | | | | | | | | | | | | | | | | | | | |x| | |
| 562 | * LYS_FENABLED | | | | | | | | | | | |x| | | | | | | | | | | | |
| 563 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 564 | * 7 LYS_MAND_FALSE | |x|x| | |x| | | | | | | | | | | |x| |x| | | | |
| 565 | * LYS_ORDBY_USER | | | |x|x| | | | | | | | | | | | | | | | | | | |
| 566 | * LYS_SET_PATTERN | | | | | | | | | | | | | | | | | | | | | |x| | |
| 567 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 568 | * 8 LYS_ORDBY_SYSTEM | | | |x|x| | | | | | | | | | | | | | | | | | | |
| 569 | * LYS_YINELEM_TRUE | | | | | | | | | | | | | |x| | | | | | | | | | |
| 570 | * LYS_SET_RANGE | | | | | | | | | | | | | | | | | | | | | |x| | |
| 571 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 572 | * 9 LYS_YINELEM_FALSE| | | | | | | | | | | | | |x| | | | | | | | | | |
| 573 | * LYS_SET_TYPE | | | | | | | | | | | | | | | | | | | | | |x| | |
| 574 | * LYS_SINGLEQUOTED | | | | | | | | | | | | | | | | | | | | | | |x| |
| 575 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 576 | * 10 LYS_SET_VALUE | | | | | | | | | | | | | | | | | | | | |x| | | |
| 577 | * LYS_SET_REQINST | | | | | | | | | | | | | | | | | | | | | |x| | |
| 578 | * LYS_SET_MIN | | | |x|x| | | | | | | | | | | | |x| |x| | | | |
| 579 | * LYS_DOUBLEQUOTED | | | | | | | | | | | | | | | | | | | | | | |x| |
| 580 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 581 | * 11 LYS_SET_MAX | | | |x|x| | | | | | | | | | | | |x| |x| | | | |
| 582 | * LYS_USED_GRP | | | | | | | | | | | | | | | |x| | | | | | | | |
| 583 | * LYS_YIN_ATTR | | | | | | | | | | | | | | | | | | | | | | |x| |
| 584 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 585 | * 12 LYS_YIN_ARGUMENT | | | | | | | | | | | | | | | | | | | | | | |x| |
| 586 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 587 | * 13 LYS_INTERNAL |x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x| |
| 588 | * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 589 | * |
| 590 | */ |
| 591 | |
| 592 | /** |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 593 | * @ingroup snodeflags |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 594 | * @defgroup scnodeflags Compiled schema nodes flags |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 595 | * |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 596 | * Various flags for compiled schema nodes (used as ::lysc_node.flags). |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 597 | * |
Radek Krejci | 61e042e | 2019-09-10 15:53:09 +0200 | [diff] [blame] | 598 | * 1 - container 6 - anydata/anyxml 11 - identity |
| 599 | * 2 - choice 7 - case 12 - extension |
| 600 | * 3 - leaf 8 - notification 13 - bitenum |
Michal Vasko | 03ff5a7 | 2019-09-11 13:49:33 +0200 | [diff] [blame] | 601 | * 4 - leaflist 9 - rpc/action 14 - when |
Michal Vasko | ecd62de | 2019-11-13 12:35:11 +0100 | [diff] [blame] | 602 | * 5 - list 10 - feature |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 603 | * |
Michal Vasko | ecd62de | 2019-11-13 12:35:11 +0100 | [diff] [blame] | 604 | * 1 1 1 1 1 |
| 605 | * bit name 1 2 3 4 5 6 7 8 9 0 1 2 3 4 |
| 606 | * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Michal Vasko | d09b762 | 2021-01-26 09:14:13 +0100 | [diff] [blame] | 607 | * 1 LYS_CONFIG_W |x|x|x|x|x|x|x| | | | | | | | |
Michal Vasko | ecd62de | 2019-11-13 12:35:11 +0100 | [diff] [blame] | 608 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Michal Vasko | d09b762 | 2021-01-26 09:14:13 +0100 | [diff] [blame] | 609 | * 2 LYS_CONFIG_R |x|x|x|x|x|x|x| | | | | | | | |
Michal Vasko | ecd62de | 2019-11-13 12:35:11 +0100 | [diff] [blame] | 610 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Michal Vasko | f4fa90d | 2021-11-11 15:05:19 +0100 | [diff] [blame] | 611 | * 3 LYS_STATUS_CURR |x|x|x|x|x|x|x|x|x|x|x|x|x|x| |
Michal Vasko | ecd62de | 2019-11-13 12:35:11 +0100 | [diff] [blame] | 612 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Michal Vasko | f4fa90d | 2021-11-11 15:05:19 +0100 | [diff] [blame] | 613 | * 4 LYS_STATUS_DEPRC |x|x|x|x|x|x|x|x|x|x|x|x|x|x| |
Michal Vasko | ecd62de | 2019-11-13 12:35:11 +0100 | [diff] [blame] | 614 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Michal Vasko | f4fa90d | 2021-11-11 15:05:19 +0100 | [diff] [blame] | 615 | * 5 LYS_STATUS_OBSLT |x|x|x|x|x|x|x|x|x|x|x|x|x|x| |
Michal Vasko | ecd62de | 2019-11-13 12:35:11 +0100 | [diff] [blame] | 616 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 617 | * 6 LYS_MAND_TRUE |x|x|x|x|x|x| | | | | | | | | |
| 618 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 619 | * 7 LYS_ORDBY_USER | | | |x|x| | | | | | | | | | |
| 620 | * LYS_MAND_FALSE | |x|x| | |x| | | | | | | | | |
| 621 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 622 | * 8 LYS_ORDBY_SYSTEM | | | |x|x| | | | | | | | | | |
| 623 | * LYS_PRESENCE |x| | | | | | | | | | | | | | |
| 624 | * LYS_UNIQUE | | |x| | | | | | | | | | | | |
| 625 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 626 | * 9 LYS_KEY | | |x| | | | | | | | | | | | |
Michal Vasko | f4fa90d | 2021-11-11 15:05:19 +0100 | [diff] [blame] | 627 | * LYS_DISABLED | | | | | | | | | | | | |x| | |
Michal Vasko | ecd62de | 2019-11-13 12:35:11 +0100 | [diff] [blame] | 628 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 629 | * 10 LYS_SET_DFLT | | |x|x| | |x| | | | | | | | |
Michal Vasko | d1e53b9 | 2021-01-28 13:11:06 +0100 | [diff] [blame] | 630 | * LYS_IS_ENUM | | | | | | | | | | | | |x| | |
Michal Vasko | ecd62de | 2019-11-13 12:35:11 +0100 | [diff] [blame] | 631 | * LYS_KEYLESS | | | | |x| | | | | | | | | | |
| 632 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 633 | * 11 LYS_SET_UNITS | | |x|x| | | | | | | | | | | |
| 634 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 635 | * 12 LYS_SET_CONFIG |x|x|x|x|x|x| | | | | | | | | |
Michal Vasko | d1e53b9 | 2021-01-28 13:11:06 +0100 | [diff] [blame] | 636 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 637 | * 13 LYS_IS_INPUT |x|x|x|x|x|x|x| | | | | | | | |
| 638 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 639 | * 14 LYS_IS_OUTPUT |x|x|x|x|x|x|x| | | | | | | | |
| 640 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 641 | * 15 LYS_IS_NOTIF |x|x|x|x|x|x|x| | | | | | | | |
Michal Vasko | ecd62de | 2019-11-13 12:35:11 +0100 | [diff] [blame] | 642 | * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 643 | * |
| 644 | */ |
| 645 | |
| 646 | /** |
| 647 | * @defgroup snodeflags Schema nodes flags |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 648 | * |
| 649 | * Various flags for schema nodes ([parsed](@ref spnodeflags) as well as [compiled](@ref scnodeflags)). |
| 650 | * |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 651 | * @{ |
| 652 | */ |
Michal Vasko | d1e53b9 | 2021-01-28 13:11:06 +0100 | [diff] [blame] | 653 | #define LYS_CONFIG_W 0x01 /**< config true; */ |
| 654 | #define LYS_CONFIG_R 0x02 /**< config false; */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 655 | #define LYS_CONFIG_MASK 0x03 /**< mask for config value */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 656 | #define LYS_STATUS_CURR 0x04 /**< status current; */ |
| 657 | #define LYS_STATUS_DEPRC 0x08 /**< status deprecated; */ |
| 658 | #define LYS_STATUS_OBSLT 0x10 /**< status obsolete; */ |
| 659 | #define LYS_STATUS_MASK 0x1C /**< mask for status value */ |
| 660 | #define LYS_MAND_TRUE 0x20 /**< mandatory true; applicable only to ::lysp_node_choice/::lysc_node_choice, |
Radek Krejci | fe90963 | 2019-02-12 15:34:42 +0100 | [diff] [blame] | 661 | ::lysp_node_leaf/::lysc_node_leaf and ::lysp_node_anydata/::lysc_node_anydata. |
| 662 | The ::lysc_node_leaflist and ::lysc_node_leaflist have this flag in case that min-elements > 0. |
| 663 | The ::lysc_node_container has this flag if it is not a presence container and it has at least one |
| 664 | child with LYS_MAND_TRUE. */ |
Radek Krejci | f1421c2 | 2019-02-19 13:05:20 +0100 | [diff] [blame] | 665 | #define LYS_MAND_FALSE 0x40 /**< mandatory false; applicable only to ::lysp_node_choice/::lysc_node_choice, |
| 666 | ::lysp_node_leaf/::lysc_node_leaf and ::lysp_node_anydata/::lysc_node_anydata. |
| 667 | This flag is present only in case the mandatory false statement was explicitly specified. */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 668 | #define LYS_MAND_MASK 0x60 /**< mask for mandatory values */ |
Michal Vasko | c118ae2 | 2020-08-06 14:51:09 +0200 | [diff] [blame] | 669 | #define LYS_PRESENCE 0x80 /**< flag for presence property of a container, but it is not only for explicit presence |
| 670 | containers, but also for NP containers with some meaning, applicable only to |
| 671 | ::lysc_node_container */ |
Radek Krejci | 7adf4ff | 2018-12-05 08:55:00 +0100 | [diff] [blame] | 672 | #define LYS_UNIQUE 0x80 /**< flag for leafs being part of a unique set, applicable only to ::lysc_node_leaf */ |
Michal Vasko | d1e53b9 | 2021-01-28 13:11:06 +0100 | [diff] [blame] | 673 | #define LYS_KEY 0x0100 /**< flag for leafs being a key of a list, applicable only to ::lysc_node_leaf */ |
| 674 | #define LYS_KEYLESS 0x0200 /**< flag for list without any key, applicable only to ::lysc_node_list */ |
Michal Vasko | f4fa90d | 2021-11-11 15:05:19 +0100 | [diff] [blame] | 675 | #define LYS_DISABLED 0x0100 /**< internal flag for a disabled statement, used only for bits/enums */ |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 676 | #define LYS_FENABLED 0x20 /**< feature enabled flag, applicable only to ::lysp_feature. */ |
Michal Vasko | e78faec | 2021-04-08 17:24:43 +0200 | [diff] [blame] | 677 | #define LYS_ORDBY_SYSTEM 0x80 /**< ordered-by system configuration lists, applicable only to |
| 678 | ::lysc_node_leaflist/::lysp_node_leaflist and ::lysc_node_list/::lysp_node_list */ |
| 679 | #define LYS_ORDBY_USER 0x40 /**< ordered-by user configuration lists, applicable only to |
| 680 | ::lysc_node_leaflist/::lysp_node_leaflist and ::lysc_node_list/::lysp_node_list; |
| 681 | is always set for state leaf-lists, and key-less lists */ |
aPiecek | 847cdcf | 2023-11-06 16:08:56 +0100 | [diff] [blame] | 682 | #define LYS_ORDBY_MASK 0xC0 /**< mask for ordered-by values */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 683 | #define LYS_YINELEM_TRUE 0x80 /**< yin-element true for extension's argument */ |
Michal Vasko | d1e53b9 | 2021-01-28 13:11:06 +0100 | [diff] [blame] | 684 | #define LYS_YINELEM_FALSE 0x0100 /**< yin-element false for extension's argument */ |
| 685 | #define LYS_YINELEM_MASK 0x0180 /**< mask for yin-element value */ |
| 686 | #define LYS_USED_GRP 0x0400 /**< internal flag for validating not-instantiated groupings |
Radek Krejci | f2de0ed | 2019-05-02 14:13:18 +0200 | [diff] [blame] | 687 | (resp. do not validate again the instantiated groupings). */ |
Michal Vasko | d1e53b9 | 2021-01-28 13:11:06 +0100 | [diff] [blame] | 688 | #define LYS_SET_VALUE 0x0200 /**< value attribute is set */ |
| 689 | #define LYS_SET_MIN 0x0200 /**< min attribute is set */ |
| 690 | #define LYS_SET_MAX 0x0400 /**< max attribute is set */ |
Radek Krejci | d505e3d | 2018-11-13 09:04:17 +0100 | [diff] [blame] | 691 | |
| 692 | #define LYS_SET_BASE 0x0001 /**< type's flag for present base substatement */ |
| 693 | #define LYS_SET_BIT 0x0002 /**< type's flag for present bit substatement */ |
| 694 | #define LYS_SET_ENUM 0x0004 /**< type's flag for present enum substatement */ |
| 695 | #define LYS_SET_FRDIGITS 0x0008 /**< type's flag for present fraction-digits substatement */ |
| 696 | #define LYS_SET_LENGTH 0x0010 /**< type's flag for present length substatement */ |
| 697 | #define LYS_SET_PATH 0x0020 /**< type's flag for present path substatement */ |
| 698 | #define LYS_SET_PATTERN 0x0040 /**< type's flag for present pattern substatement */ |
| 699 | #define LYS_SET_RANGE 0x0080 /**< type's flag for present range substatement */ |
| 700 | #define LYS_SET_TYPE 0x0100 /**< type's flag for present type substatement */ |
| 701 | #define LYS_SET_REQINST 0x0200 /**< type's flag for present require-instance substatement */ |
Radek Krejci | ccd20f1 | 2019-02-15 14:12:27 +0100 | [diff] [blame] | 702 | #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 Krejci | 76b3e96 | 2018-12-14 17:01:25 +0100 | [diff] [blame] | 703 | cases of choice. This information is important for refines, since it is prohibited to make leafs |
| 704 | with default statement mandatory. In case the default leaf value is taken from type, it is thrown |
Radek Krejci | ccd20f1 | 2019-02-15 14:12:27 +0100 | [diff] [blame] | 705 | away when it is refined to be mandatory node. Similarly it is used for deviations to distinguish |
| 706 | between own default or the default values taken from the type. */ |
| 707 | #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 Krejci | f1421c2 | 2019-02-19 13:05:20 +0100 | [diff] [blame] | 708 | #define LYS_SET_CONFIG 0x0800 /**< flag to know if the config property was set explicitly (flag set) or it is inherited. */ |
Radek Krejci | 0e5d838 | 2018-11-28 16:37:53 +0100 | [diff] [blame] | 709 | |
Michal Vasko | 72c6d64 | 2024-02-27 14:59:01 +0100 | [diff] [blame^] | 710 | #define LYS_SINGLEQUOTED 0x0100 /**< flag for single-quoted string (argument of an extension instance's substatement), |
| 711 | only when the source is YANG */ |
| 712 | #define LYS_DOUBLEQUOTED 0x0200 /**< flag for double-quoted string (argument of an extension instance's substatement), |
| 713 | only when the source is YANG */ |
Radek Krejci | d3ca063 | 2019-04-16 16:54:54 +0200 | [diff] [blame] | 714 | |
Michal Vasko | d1e53b9 | 2021-01-28 13:11:06 +0100 | [diff] [blame] | 715 | #define LYS_YIN_ATTR 0x0400 /**< flag to identify YIN attribute parsed as extension's substatement, only when the source is YIN */ |
| 716 | #define LYS_YIN_ARGUMENT 0x0800 /**< flag to identify statement representing extension's argument, only when the source is YIN */ |
David Sedlák | bbd06ca | 2019-06-27 14:15:38 +0200 | [diff] [blame] | 717 | |
Michal Vasko | 3e9bc2f | 2020-11-04 17:13:56 +0100 | [diff] [blame] | 718 | #define LYS_INTERNAL 0x1000 /**< flag to identify internal parsed statements that should not be printed */ |
| 719 | |
Michal Vasko | d1e53b9 | 2021-01-28 13:11:06 +0100 | [diff] [blame] | 720 | #define LYS_IS_ENUM 0x0200 /**< flag to simply distinguish type in struct lysc_type_bitenum_item */ |
| 721 | |
| 722 | #define LYS_IS_INPUT 0x1000 /**< flag for nodes that are in the subtree of an input statement */ |
| 723 | |
| 724 | #define LYS_IS_OUTPUT 0x2000 /**< flag for nodes that are in the subtree of an output statement */ |
| 725 | |
| 726 | #define LYS_IS_NOTIF 0x4000 /**< flag for nodes that are in the subtree of a notification statement */ |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 727 | |
Radek Krejci | fe90963 | 2019-02-12 15:34:42 +0100 | [diff] [blame] | 728 | #define LYS_FLAGS_COMPILED_MASK 0xff /**< mask for flags that maps to the compiled structures */ |
Radek Krejci | 2ff0d57 | 2020-05-21 15:27:28 +0200 | [diff] [blame] | 729 | /** @} snodeflags */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 730 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 731 | /** |
| 732 | * @brief Generic YANG data node |
| 733 | */ |
| 734 | struct lysp_node { |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 735 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */ |
Radek Krejci | de7a9c4 | 2021-03-10 13:13:06 +0100 | [diff] [blame] | 736 | uint16_t nodetype; /**< [type of the node](@ref schemanodetypes) (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 737 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 738 | struct lysp_node *next; /**< next sibling node (NULL if there is no one) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 739 | const char *name; /**< node name (mandatory) */ |
| 740 | const char *dsc; /**< description statement */ |
| 741 | const char *ref; /**< reference statement */ |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 742 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)), |
| 743 | must be qname because of refines */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 744 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 745 | }; |
| 746 | |
| 747 | /** |
| 748 | * @brief Extension structure of the lysp_node for YANG container |
| 749 | */ |
| 750 | struct lysp_node_container { |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 751 | union { |
| 752 | struct lysp_node node; /**< implicit cast for the members compatible with ::lysp_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 753 | |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 754 | struct { |
| 755 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */ |
| 756 | uint16_t nodetype; /**< LYS_CONTAINER */ |
| 757 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 758 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 759 | const char *name; /**< node name (mandatory) */ |
| 760 | const char *dsc; /**< description statement */ |
| 761 | const char *ref; /**< reference statement */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 762 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 763 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 764 | }; |
| 765 | }; /**< common part corresponding to ::lysp_node */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 766 | |
| 767 | /* container */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 768 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 769 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 770 | const char *presence; /**< presence description */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 771 | struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 772 | struct lysp_node_grp *groupings; /**< list of groupings (linked list) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 773 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 774 | struct lysp_node_action *actions;/**< list of actions (linked list) */ |
| 775 | struct lysp_node_notif *notifs; /**< list of notifications (linked list) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 776 | }; |
| 777 | |
| 778 | struct lysp_node_leaf { |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 779 | union { |
| 780 | struct lysp_node node; /**< implicit cast for the members compatible with ::lysp_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 781 | |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 782 | struct { |
| 783 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */ |
| 784 | uint16_t nodetype; /**< LYS_LEAF */ |
| 785 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 786 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 787 | const char *name; /**< node name (mandatory) */ |
| 788 | const char *dsc; /**< description statement */ |
| 789 | const char *ref; /**< reference statement */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 790 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 791 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 792 | }; |
| 793 | }; /**< common part corresponding to ::lysp_node */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 794 | |
| 795 | /* leaf */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 796 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 797 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 798 | struct lysp_type type; /**< type of the leaf node (mandatory) */ |
| 799 | const char *units; /**< units of the leaf's type */ |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 800 | struct lysp_qname dflt; /**< default value, it may or may not be a qualified name */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 801 | }; |
| 802 | |
| 803 | struct lysp_node_leaflist { |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 804 | union { |
| 805 | struct lysp_node node; /**< implicit cast for the members compatible with ::lysp_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 806 | |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 807 | struct { |
| 808 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */ |
| 809 | uint16_t nodetype; /**< LYS_LEAFLIST */ |
| 810 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 811 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 812 | const char *name; /**< node name (mandatory) */ |
| 813 | const char *dsc; /**< description statement */ |
| 814 | const char *ref; /**< reference statement */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 815 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 816 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 817 | }; |
| 818 | }; /**< common part corresponding to ::lysp_node */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 819 | |
| 820 | /* leaf-list */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 821 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 822 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 823 | struct lysp_type type; /**< type of the leaf node (mandatory) */ |
| 824 | const char *units; /**< units of the leaf's type */ |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 825 | struct lysp_qname *dflts; /**< list of default values ([sized array](@ref sizedarrays)), they may or |
| 826 | may not be qualified names */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 827 | uint32_t min; /**< min-elements constraint */ |
| 828 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 829 | }; |
| 830 | |
| 831 | struct lysp_node_list { |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 832 | union { |
| 833 | struct lysp_node node; /**< implicit cast for the members compatible with ::lysp_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 834 | |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 835 | struct { |
| 836 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */ |
| 837 | uint16_t nodetype; /**< LYS_LIST */ |
| 838 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 839 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 840 | const char *name; /**< node name (mandatory) */ |
| 841 | const char *dsc; /**< description statement */ |
| 842 | const char *ref; /**< reference statement */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 843 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 844 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 845 | }; |
| 846 | }; /**< common part corresponding to ::lysp_node */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 847 | |
| 848 | /* list */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 849 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 850 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 851 | const char *key; /**< keys specification */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 852 | struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 853 | struct lysp_node_grp *groupings; /**< list of groupings (linked list) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 854 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 855 | struct lysp_node_action *actions;/**< list of actions (linked list) */ |
| 856 | struct lysp_node_notif *notifs; /**< list of notifications (linked list) */ |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 857 | struct lysp_qname *uniques; /**< list of unique specifications ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 858 | uint32_t min; /**< min-elements constraint */ |
| 859 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 860 | }; |
| 861 | |
| 862 | struct lysp_node_choice { |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 863 | union { |
| 864 | struct lysp_node node; /**< implicit cast for the members compatible with ::lysp_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 865 | |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 866 | struct { |
| 867 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */ |
| 868 | uint16_t nodetype; /**< LYS_CHOICE */ |
| 869 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 870 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 871 | const char *name; /**< node name (mandatory) */ |
| 872 | const char *dsc; /**< description statement */ |
| 873 | const char *ref; /**< reference statement */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 874 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 875 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 876 | }; |
| 877 | }; /**< common part corresponding to ::lysp_node */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 878 | |
| 879 | /* choice */ |
| 880 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 881 | struct lysp_when *when; /**< when statement */ |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 882 | struct lysp_qname dflt; /**< default case */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 883 | }; |
| 884 | |
| 885 | struct lysp_node_case { |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 886 | union { |
| 887 | struct lysp_node node; /**< implicit cast for the members compatible with ::lysp_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 888 | |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 889 | struct { |
| 890 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */ |
| 891 | uint16_t nodetype; /**< LYS_CASE */ |
| 892 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 893 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 894 | const char *name; /**< node name (mandatory) */ |
| 895 | const char *dsc; /**< description statement */ |
| 896 | const char *ref; /**< reference statement */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 897 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 898 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 899 | }; |
| 900 | }; /**< common part corresponding to ::lysp_node */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 901 | |
| 902 | /* case */ |
| 903 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 904 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 905 | }; |
| 906 | |
| 907 | struct lysp_node_anydata { |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 908 | union { |
| 909 | struct lysp_node node; /**< implicit cast for the members compatible with ::lysp_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 910 | |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 911 | struct { |
| 912 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */ |
| 913 | uint16_t nodetype; /**< LYS_ANYXML or LYS_ANYDATA */ |
| 914 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 915 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 916 | const char *name; /**< node name (mandatory) */ |
| 917 | const char *dsc; /**< description statement */ |
| 918 | const char *ref; /**< reference statement */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 919 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 920 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 921 | }; |
| 922 | }; /**< common part corresponding to ::lysp_node */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 923 | |
| 924 | /* anyxml/anydata */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 925 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 926 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 927 | }; |
| 928 | |
| 929 | struct lysp_node_uses { |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 930 | union { |
| 931 | struct lysp_node node; /**< implicit cast for the members compatible with ::lysp_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 932 | |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 933 | struct { |
| 934 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */ |
| 935 | uint16_t nodetype; /**< LYS_USES */ |
| 936 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 937 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 938 | const char *name; /**< grouping name reference (mandatory) */ |
| 939 | const char *dsc; /**< description statement */ |
| 940 | const char *ref; /**< reference statement */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 941 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 942 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 943 | }; |
| 944 | }; /**< common part corresponding to ::lysp_node */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 945 | |
| 946 | /* uses */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 947 | struct lysp_refine *refines; /**< list of uses's refines ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 948 | struct lysp_node_augment *augments; /**< list of augments (linked list) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 949 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 950 | }; |
| 951 | |
| 952 | /** |
| 953 | * @brief YANG input-stmt and output-stmt |
| 954 | */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 955 | struct lysp_node_action_inout { |
| 956 | union { |
| 957 | struct lysp_node node; /**< implicit cast for the members compatible with ::lysp_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 958 | |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 959 | struct { |
| 960 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */ |
| 961 | uint16_t nodetype; /**< LYS_INPUT or LYS_OUTPUT */ |
| 962 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 963 | struct lysp_node *next; /**< NULL */ |
| 964 | const char *name; /**< empty string */ |
| 965 | const char *dsc; /**< ALWAYS NULL, compatibility member with ::lysp_node */ |
| 966 | const char *ref; /**< ALWAYS NULL, compatibility member with ::lysp_node */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 967 | struct lysp_qname *iffeatures; /**< ALWAYS NULL, compatibility member with ::lysp_node */ |
| 968 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 969 | }; |
| 970 | }; /**< common part corresponding to ::lysp_node */ |
| 971 | |
| 972 | /* inout */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 973 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
| 974 | struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 975 | struct lysp_node_grp *groupings; /**< list of groupings (linked list) */ |
Radek Krejci | 01180ac | 2021-01-27 08:48:22 +0100 | [diff] [blame] | 976 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 977 | }; |
| 978 | |
| 979 | /** |
| 980 | * @brief YANG rpc-stmt and action-stmt |
| 981 | */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 982 | struct lysp_node_action { |
| 983 | union { |
| 984 | struct lysp_node node; /**< implicit cast for the members compatible with ::lysp_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 985 | |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 986 | struct { |
| 987 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */ |
| 988 | uint16_t nodetype; /**< LYS_RPC or LYS_ACTION */ |
| 989 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 990 | struct lysp_node_action *next; /**< pointer to the next action (NULL if there is no one) */ |
| 991 | const char *name; /**< grouping name reference (mandatory) */ |
| 992 | const char *dsc; /**< description statement */ |
| 993 | const char *ref; /**< reference statement */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 994 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 995 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 996 | }; |
| 997 | }; /**< common part corresponding to ::lysp_node */ |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 998 | |
| 999 | /* action */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1000 | struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */ |
| 1001 | struct lysp_node_grp *groupings; /**< list of groupings (linked list) */ |
| 1002 | |
| 1003 | struct lysp_node_action_inout input; /**< RPC's/Action's input */ |
| 1004 | struct lysp_node_action_inout output; /**< RPC's/Action's output */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 1005 | }; |
| 1006 | |
| 1007 | /** |
| 1008 | * @brief YANG notification-stmt |
| 1009 | */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1010 | struct lysp_node_notif { |
| 1011 | union { |
| 1012 | struct lysp_node node; /**< implicit cast for the members compatible with ::lysp_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 1013 | |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1014 | struct { |
| 1015 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */ |
| 1016 | uint16_t nodetype; /**< LYS_NOTIF */ |
| 1017 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */ |
| 1018 | struct lysp_node_notif *next; /**< pointer to the next notification (NULL if there is no one) */ |
| 1019 | const char *name; /**< grouping name reference (mandatory) */ |
| 1020 | const char *dsc; /**< description statement */ |
| 1021 | const char *ref; /**< reference statement */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1022 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 1023 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1024 | }; |
| 1025 | }; /**< common part corresponding to ::lysp_node */ |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 1026 | |
| 1027 | /* notif */ |
| 1028 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1029 | struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */ |
| 1030 | struct lysp_node_grp *groupings; /**< list of groupings (linked list) */ |
Radek Krejci | 01180ac | 2021-01-27 08:48:22 +0100 | [diff] [blame] | 1031 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 1032 | }; |
| 1033 | |
| 1034 | /** |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1035 | * @brief YANG grouping-stmt |
| 1036 | */ |
| 1037 | struct lysp_node_grp { |
| 1038 | union { |
| 1039 | struct lysp_node node; /**< implicit cast for the members compatible with ::lysp_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 1040 | |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1041 | struct { |
| 1042 | struct lysp_node *parent;/**< parent node (NULL if this is a top-level grouping) */ |
| 1043 | uint16_t nodetype; /**< LYS_GROUPING */ |
| 1044 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */ |
| 1045 | struct lysp_node_grp *next; /**< pointer to the next grouping (NULL if there is no one) */ |
| 1046 | const char *name; /**< grouping name (mandatory) */ |
| 1047 | const char *dsc; /**< description statement */ |
| 1048 | const char *ref; /**< reference statement */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1049 | struct lysp_qname *iffeatures; /**< ALWAYS NULL, compatibility member with ::lysp_node */ |
| 1050 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1051 | }; |
| 1052 | }; /**< common part corresponding to ::lysp_node */ |
| 1053 | |
| 1054 | /* grp */ |
| 1055 | struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */ |
| 1056 | struct lysp_node_grp *groupings; /**< list of groupings (linked list) */ |
Radek Krejci | 01180ac | 2021-01-27 08:48:22 +0100 | [diff] [blame] | 1057 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1058 | struct lysp_node_action *actions; /**< list of actions (linked list) */ |
| 1059 | struct lysp_node_notif *notifs; /**< list of notifications (linked list) */ |
| 1060 | }; |
| 1061 | |
| 1062 | /** |
| 1063 | * @brief YANG uses-augment-stmt and augment-stmt (compatible with struct lysp_node ) |
| 1064 | */ |
| 1065 | struct lysp_node_augment { |
| 1066 | union { |
| 1067 | struct lysp_node node; /**< implicit cast for the members compatible with ::lysp_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 1068 | |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1069 | struct { |
| 1070 | struct lysp_node *parent;/**< parent node (NULL if this is a top-level augment) */ |
| 1071 | uint16_t nodetype; /**< LYS_AUGMENT */ |
| 1072 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */ |
| 1073 | struct lysp_node_augment *next; /**< pointer to the next augment (NULL if there is no one) */ |
| 1074 | const char *nodeid; /**< target schema nodeid (mandatory) - absolute for global augments, descendant for uses's augments */ |
| 1075 | const char *dsc; /**< description statement */ |
| 1076 | const char *ref; /**< reference statement */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1077 | struct lysp_qname *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 1078 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1079 | }; |
| 1080 | }; /**< common part corresponding to ::lysp_node */ |
| 1081 | |
| 1082 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 1083 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1084 | struct lysp_node_action *actions;/**< list of actions (linked list) */ |
| 1085 | struct lysp_node_notif *notifs; /**< list of notifications (linked list) */ |
| 1086 | }; |
| 1087 | |
| 1088 | /** |
Radek Krejci | f0fceb6 | 2018-09-05 14:58:45 +0200 | [diff] [blame] | 1089 | * @brief supported YANG schema version values |
| 1090 | */ |
| 1091 | typedef enum LYS_VERSION { |
| 1092 | LYS_VERSION_UNDEF = 0, /**< no specific version, YANG 1.0 as default */ |
Radek Krejci | 96e48da | 2020-09-04 13:18:06 +0200 | [diff] [blame] | 1093 | LYS_VERSION_1_0 = 1, /**< YANG 1 (1.0) */ |
Radek Krejci | f0fceb6 | 2018-09-05 14:58:45 +0200 | [diff] [blame] | 1094 | LYS_VERSION_1_1 = 2 /**< YANG 1.1 */ |
| 1095 | } LYS_VERSION; |
| 1096 | |
| 1097 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 1098 | * @brief Printable YANG schema tree structure representing YANG module. |
| 1099 | * |
| 1100 | * Simple structure corresponding to the YANG format. The schema is only syntactically validated. |
| 1101 | */ |
| 1102 | struct lysp_module { |
Radek Krejci | 0bcdaed | 2019-01-10 10:21:34 +0100 | [diff] [blame] | 1103 | struct lys_module *mod; /**< covering module structure */ |
| 1104 | |
Radek Krejci | b7db73a | 2018-10-24 14:18:40 +0200 | [diff] [blame] | 1105 | struct lysp_revision *revs; /**< list of the module revisions ([sized array](@ref sizedarrays)), the first revision |
| 1106 | in the list is always the last (newest) revision of the module */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 1107 | struct lysp_import *imports; /**< list of imported modules ([sized array](@ref sizedarrays)) */ |
| 1108 | struct lysp_include *includes; /**< list of included submodules ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 1109 | struct lysp_ext *extensions; /**< list of extension statements ([sized array](@ref sizedarrays)) */ |
| 1110 | struct lysp_feature *features; /**< list of feature definitions ([sized array](@ref sizedarrays)) */ |
| 1111 | struct lysp_ident *identities; /**< list of identities ([sized array](@ref sizedarrays)) */ |
| 1112 | struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1113 | struct lysp_node_grp *groupings; /**< list of groupings (linked list) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 1114 | struct lysp_node *data; /**< list of module's top-level data nodes (linked list) */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1115 | struct lysp_node_augment *augments; /**< list of augments (linked list) */ |
| 1116 | struct lysp_node_action *rpcs; /**< list of RPCs (linked list) */ |
| 1117 | struct lysp_node_notif *notifs; /**< list of notifications (linked list) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 1118 | struct lysp_deviation *deviations; /**< list of deviations ([sized array](@ref sizedarrays)) */ |
Michal Vasko | c3781c3 | 2020-10-06 14:04:08 +0200 | [diff] [blame] | 1119 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 1120 | |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 1121 | uint8_t version; /**< yang-version (LYS_VERSION values) */ |
Michal Vasko | c3781c3 | 2020-10-06 14:04:08 +0200 | [diff] [blame] | 1122 | uint8_t parsing : 1; /**< flag for circular check */ |
| 1123 | uint8_t is_submod : 1; /**< always 0 */ |
Radek Krejci | 0bcdaed | 2019-01-10 10:21:34 +0100 | [diff] [blame] | 1124 | }; |
| 1125 | |
| 1126 | struct lysp_submodule { |
Michal Vasko | c3781c3 | 2020-10-06 14:04:08 +0200 | [diff] [blame] | 1127 | struct lys_module *mod; /**< belongs to parent module (submodule - mandatory) */ |
Radek Krejci | 0bcdaed | 2019-01-10 10:21:34 +0100 | [diff] [blame] | 1128 | |
| 1129 | struct lysp_revision *revs; /**< list of the module revisions ([sized array](@ref sizedarrays)), the first revision |
| 1130 | in the list is always the last (newest) revision of the module */ |
| 1131 | struct lysp_import *imports; /**< list of imported modules ([sized array](@ref sizedarrays)) */ |
| 1132 | struct lysp_include *includes; /**< list of included submodules ([sized array](@ref sizedarrays)) */ |
| 1133 | struct lysp_ext *extensions; /**< list of extension statements ([sized array](@ref sizedarrays)) */ |
| 1134 | struct lysp_feature *features; /**< list of feature definitions ([sized array](@ref sizedarrays)) */ |
| 1135 | struct lysp_ident *identities; /**< list of identities ([sized array](@ref sizedarrays)) */ |
| 1136 | struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1137 | struct lysp_node_grp *groupings; /**< list of groupings (linked list) */ |
Radek Krejci | 0bcdaed | 2019-01-10 10:21:34 +0100 | [diff] [blame] | 1138 | struct lysp_node *data; /**< list of module's top-level data nodes (linked list) */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1139 | struct lysp_node_augment *augments; /**< list of augments (linked list) */ |
| 1140 | struct lysp_node_action *rpcs; /**< list of RPCs (linked list) */ |
| 1141 | struct lysp_node_notif *notifs; /**< list of notifications (linked list) */ |
Radek Krejci | 0bcdaed | 2019-01-10 10:21:34 +0100 | [diff] [blame] | 1142 | struct lysp_deviation *deviations; /**< list of deviations ([sized array](@ref sizedarrays)) */ |
Michal Vasko | c3781c3 | 2020-10-06 14:04:08 +0200 | [diff] [blame] | 1143 | struct lysp_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 0bcdaed | 2019-01-10 10:21:34 +0100 | [diff] [blame] | 1144 | |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 1145 | uint8_t version; /**< yang-version (LYS_VERSION values) */ |
Michal Vasko | c3781c3 | 2020-10-06 14:04:08 +0200 | [diff] [blame] | 1146 | uint8_t parsing : 1; /**< flag for circular check */ |
| 1147 | uint8_t is_submod : 1; /**< always 1 */ |
Radek Krejci | 0bcdaed | 2019-01-10 10:21:34 +0100 | [diff] [blame] | 1148 | |
Michal Vasko | c3781c3 | 2020-10-06 14:04:08 +0200 | [diff] [blame] | 1149 | uint8_t latest_revision : 2; /**< flag to mark the latest available revision: |
Radek Krejci | 086c713 | 2018-10-26 15:29:04 +0200 | [diff] [blame] | 1150 | 1 - the latest revision in searchdirs was not searched yet and this is the |
| 1151 | latest revision in the current context |
| 1152 | 2 - searchdirs were searched and this is the latest available revision */ |
Radek Krejci | 0bcdaed | 2019-01-10 10:21:34 +0100 | [diff] [blame] | 1153 | const char *name; /**< name of the module (mandatory) */ |
| 1154 | const char *filepath; /**< path, if the schema was read from a file, NULL in case of reading from memory */ |
| 1155 | const char *prefix; /**< submodule belongsto prefix of main module (mandatory) */ |
| 1156 | const char *org; /**< party/company responsible for the module */ |
| 1157 | const char *contact; /**< contact information for the module */ |
| 1158 | const char *dsc; /**< description of the module */ |
| 1159 | const char *ref; /**< cross-reference for the module */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 1160 | }; |
| 1161 | |
| 1162 | /** |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 1163 | * @brief Get the parsed module or submodule name. |
| 1164 | * |
| 1165 | * @param[in] PMOD Parsed module or submodule. |
| 1166 | * @return Module or submodule name. |
| 1167 | */ |
| 1168 | #define LYSP_MODULE_NAME(PMOD) (PMOD->is_submod ? ((struct lysp_submodule *)PMOD)->name : ((struct lysp_module *)PMOD)->mod->name) |
| 1169 | |
| 1170 | /** |
Radek Krejci | 8df109d | 2021-04-23 12:19:08 +0200 | [diff] [blame] | 1171 | * @brief Compiled prefix data pair mapping of prefixes to modules. In case the format is ::LY_VALUE_SCHEMA_RESOLVED, |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 1172 | * the expected prefix data is a sized array of these structures. |
| 1173 | */ |
| 1174 | struct lysc_prefix { |
| 1175 | char *prefix; /**< used prefix */ |
| 1176 | const struct lys_module *mod; /**< mapping to a module */ |
| 1177 | }; |
| 1178 | |
| 1179 | /** |
Radek Krejci | 0e59c31 | 2019-08-15 15:34:15 +0200 | [diff] [blame] | 1180 | * @brief Compiled YANG extension-stmt |
Radek Krejci | 9f87b0c | 2021-03-05 14:45:26 +0100 | [diff] [blame] | 1181 | * |
| 1182 | * Note that the compiled extension definition is created only in case the extension is instantiated. It is not available |
| 1183 | * from the compiled schema, but from the parsed extension definition which is being searched when an extension instance |
| 1184 | * is being compiled. |
Radek Krejci | 0e59c31 | 2019-08-15 15:34:15 +0200 | [diff] [blame] | 1185 | */ |
| 1186 | struct lysc_ext { |
| 1187 | const char *name; /**< extension name */ |
Radek Krejci | 9f87b0c | 2021-03-05 14:45:26 +0100 | [diff] [blame] | 1188 | const char *argname; /**< argument name, NULL if not specified */ |
Radek Krejci | 0e59c31 | 2019-08-15 15:34:15 +0200 | [diff] [blame] | 1189 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | cc9e30f | 2021-03-29 12:45:08 +0200 | [diff] [blame] | 1190 | struct lyplg_ext *plugin; /**< Plugin implementing the specific extension */ |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 1191 | struct lys_module *module; /**< module structure */ |
Radek Krejci | 0e59c31 | 2019-08-15 15:34:15 +0200 | [diff] [blame] | 1192 | uint16_t flags; /**< LYS_STATUS_* value (@ref snodeflags) */ |
| 1193 | }; |
| 1194 | |
| 1195 | /** |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1196 | * @brief YANG when-stmt |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 1197 | */ |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1198 | struct lysc_when { |
| 1199 | struct lyxp_expr *cond; /**< XPath when condition */ |
Michal Vasko | 175012e | 2019-11-06 15:49:14 +0100 | [diff] [blame] | 1200 | struct lysc_node *context; /**< context node for evaluating the expression, NULL if the context is root node */ |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 1201 | struct lysc_prefix *prefixes; /**< compiled used prefixes in the condition */ |
Radek Krejci | c8b3100 | 2019-01-08 10:24:45 +0100 | [diff] [blame] | 1202 | const char *dsc; /**< description */ |
| 1203 | const char *ref; /**< reference */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 1204 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 00b874b | 2019-02-12 10:54:50 +0100 | [diff] [blame] | 1205 | uint32_t refcount; /**< reference counter since some of the when statements are shared among several nodes */ |
Michal Vasko | ecd62de | 2019-11-13 12:35:11 +0100 | [diff] [blame] | 1206 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS is allowed */ |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1207 | }; |
| 1208 | |
| 1209 | /** |
Radek Krejci | 2a408df | 2018-10-29 16:32:26 +0100 | [diff] [blame] | 1210 | * @brief YANG identity-stmt |
| 1211 | */ |
| 1212 | struct lysc_ident { |
Michal Vasko | e313c38 | 2022-03-14 13:04:47 +0100 | [diff] [blame] | 1213 | const char *name; /**< identity name (mandatory, no prefix) */ |
Radek Krejci | c8b3100 | 2019-01-08 10:24:45 +0100 | [diff] [blame] | 1214 | const char *dsc; /**< description */ |
| 1215 | const char *ref; /**< reference */ |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1216 | struct lys_module *module; /**< module structure */ |
aPiecek | 6b3d542 | 2021-07-30 15:55:43 +0200 | [diff] [blame] | 1217 | struct lysc_ident **derived; /**< list of (pointers to the) derived identities ([sized array](@ref sizedarrays)) |
| 1218 | It also contains references to identities located in unimplemented modules. */ |
Radek Krejci | 2a408df | 2018-10-29 16:32:26 +0100 | [diff] [blame] | 1219 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1220 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ values are allowed */ |
| 1221 | }; |
| 1222 | |
| 1223 | /** |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 1224 | * @defgroup ifftokens if-feature expression tokens |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 1225 | * Tokens of if-feature expression used in ::lysc_iffeature.expr. |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 1226 | * |
| 1227 | * @{ |
| 1228 | */ |
| 1229 | #define LYS_IFF_NOT 0x00 /**< operand "not" */ |
| 1230 | #define LYS_IFF_AND 0x01 /**< operand "and" */ |
| 1231 | #define LYS_IFF_OR 0x02 /**< operand "or" */ |
| 1232 | #define LYS_IFF_F 0x03 /**< feature */ |
Radek Krejci | 2ff0d57 | 2020-05-21 15:27:28 +0200 | [diff] [blame] | 1233 | /** @} ifftokens */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 1234 | |
| 1235 | /** |
Radek Krejci | b7db73a | 2018-10-24 14:18:40 +0200 | [diff] [blame] | 1236 | * @brief Compiled YANG revision statement |
| 1237 | */ |
| 1238 | struct lysc_revision { |
| 1239 | char date[LY_REV_SIZE]; /**< revision-date (mandatory) */ |
| 1240 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1241 | }; |
| 1242 | |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1243 | struct lysc_range { |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1244 | struct lysc_range_part { |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1245 | union { /**< min boundary */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 1246 | int64_t min_64; /**< for int8, int16, int32, int64 and decimal64 ( >= LY_TYPE_DEC64) */ |
| 1247 | uint64_t min_u64; /**< for uint8, uint16, uint32, uint64, string and binary ( < LY_TYPE_DEC64) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1248 | }; |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1249 | union { /**< max boundary */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 1250 | int64_t max_64; /**< for int8, int16, int32, int64 and decimal64 ( >= LY_TYPE_DEC64) */ |
| 1251 | uint64_t max_u64; /**< for uint8, uint16, uint32, uint64, string and binary ( < LY_TYPE_DEC64) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1252 | }; |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1253 | } *parts; /**< compiled range expression ([sized array](@ref sizedarrays)) */ |
Radek Krejci | c8b3100 | 2019-01-08 10:24:45 +0100 | [diff] [blame] | 1254 | const char *dsc; /**< description */ |
| 1255 | const char *ref; /**< reference */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1256 | const char *emsg; /**< error-message */ |
| 1257 | const char *eapptag; /**< error-app-tag value */ |
| 1258 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1259 | }; |
| 1260 | |
| 1261 | struct lysc_pattern { |
Radek Krejci | 5457946 | 2019-04-30 12:47:06 +0200 | [diff] [blame] | 1262 | const char *expr; /**< original, not compiled, regular expression */ |
| 1263 | pcre2_code *code; /**< compiled regular expression */ |
Radek Krejci | c8b3100 | 2019-01-08 10:24:45 +0100 | [diff] [blame] | 1264 | const char *dsc; /**< description */ |
| 1265 | const char *ref; /**< reference */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1266 | const char *emsg; /**< error-message */ |
| 1267 | const char *eapptag; /**< error-app-tag value */ |
| 1268 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 1269 | uint32_t inverted : 1; /**< invert-match flag */ |
| 1270 | uint32_t refcount : 31; /**< reference counter */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1271 | }; |
| 1272 | |
| 1273 | struct lysc_must { |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1274 | struct lyxp_expr *cond; /**< XPath when condition */ |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 1275 | struct lysc_prefix *prefixes; /**< compiled used prefixes in the condition */ |
Radek Krejci | c8b3100 | 2019-01-08 10:24:45 +0100 | [diff] [blame] | 1276 | const char *dsc; /**< description */ |
| 1277 | const char *ref; /**< reference */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1278 | const char *emsg; /**< error-message */ |
| 1279 | const char *eapptag; /**< error-app-tag value */ |
| 1280 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1281 | }; |
| 1282 | |
| 1283 | struct lysc_type { |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1284 | const char *name; /**< referenced typedef name (without prefix, if any), NULL for built-in types */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1285 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1286 | struct lyplg_type *plugin; /**< type's manipulation callbacks plugin */ |
| 1287 | LY_DATA_TYPE basetype; /**< base type of the type */ |
Michal Vasko | 080064b | 2021-08-31 15:20:44 +0200 | [diff] [blame] | 1288 | uint32_t refcount; /**< reference counter for type sharing, it may be accessed concurrently when |
Michal Vasko | babf0bd | 2021-08-31 14:55:39 +0200 | [diff] [blame] | 1289 | creating/freeing data node values that reference it (instance-identifier) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1290 | }; |
| 1291 | |
| 1292 | struct lysc_type_num { |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1293 | const char *name; /**< referenced typedef name (without prefix, if any), NULL for built-in types */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1294 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1295 | struct lyplg_type *plugin; /**< type's manipulation callbacks plugin */ |
| 1296 | LY_DATA_TYPE basetype; /**< base type of the type */ |
Michal Vasko | 080064b | 2021-08-31 15:20:44 +0200 | [diff] [blame] | 1297 | uint32_t refcount; /**< reference counter for type sharing */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1298 | |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1299 | struct lysc_range *range; /**< Optional range limitation */ |
| 1300 | }; |
| 1301 | |
| 1302 | struct lysc_type_dec { |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1303 | const char *name; /**< referenced typedef name (without prefix, if any), NULL for built-in types */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1304 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1305 | struct lyplg_type *plugin; /**< type's manipulation callbacks plugin */ |
| 1306 | LY_DATA_TYPE basetype; /**< base type of the type */ |
Michal Vasko | 080064b | 2021-08-31 15:20:44 +0200 | [diff] [blame] | 1307 | uint32_t refcount; /**< reference counter for type sharing */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1308 | |
Radek Krejci | 6cba429 | 2018-11-15 17:33:29 +0100 | [diff] [blame] | 1309 | uint8_t fraction_digits; /**< fraction digits specification */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1310 | struct lysc_range *range; /**< Optional range limitation */ |
| 1311 | }; |
| 1312 | |
| 1313 | struct lysc_type_str { |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1314 | const char *name; /**< referenced typedef name (without prefix, if any), NULL for built-in types */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1315 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1316 | struct lyplg_type *plugin; /**< type's manipulation callbacks plugin */ |
| 1317 | LY_DATA_TYPE basetype; /**< base type of the type */ |
Michal Vasko | 080064b | 2021-08-31 15:20:44 +0200 | [diff] [blame] | 1318 | uint32_t refcount; /**< reference counter for type sharing */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1319 | |
| 1320 | struct lysc_range *length; /**< optional length limitation */ |
| 1321 | struct lysc_pattern **patterns; /**< optional list of pointers to pattern limitations ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1322 | }; |
| 1323 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1324 | struct lysc_type_bitenum_item { |
| 1325 | const char *name; /**< enumeration identifier */ |
| 1326 | const char *dsc; /**< description */ |
| 1327 | const char *ref; /**< reference */ |
| 1328 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 1329 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1330 | union { |
| 1331 | int32_t value; /**< integer value associated with the enumeration */ |
| 1332 | uint32_t position; /**< non-negative integer value associated with the bit */ |
| 1333 | }; |
Michal Vasko | f4fa90d | 2021-11-11 15:05:19 +0100 | [diff] [blame] | 1334 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ and LYS_IS_ENUM values |
| 1335 | are allowed */ |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1336 | }; |
| 1337 | |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1338 | struct lysc_type_enum { |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1339 | const char *name; /**< referenced typedef name (without prefix, if any), NULL for built-in types */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1340 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1341 | struct lyplg_type *plugin; /**< type's manipulation callbacks plugin */ |
| 1342 | LY_DATA_TYPE basetype; /**< base type of the type */ |
Michal Vasko | 080064b | 2021-08-31 15:20:44 +0200 | [diff] [blame] | 1343 | uint32_t refcount; /**< reference counter for type sharing */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1344 | |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1345 | struct lysc_type_bitenum_item *enums; /**< enumerations list ([sized array](@ref sizedarrays)), mandatory (at least 1 item) */ |
| 1346 | }; |
| 1347 | |
| 1348 | struct lysc_type_bits { |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1349 | const char *name; /**< referenced typedef name (without prefix, if any), NULL for built-in types */ |
Radek Krejci | 693262f | 2019-04-29 15:23:20 +0200 | [diff] [blame] | 1350 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1351 | struct lyplg_type *plugin; /**< type's manipulation callbacks plugin */ |
| 1352 | LY_DATA_TYPE basetype; /**< base type of the type */ |
Michal Vasko | 080064b | 2021-08-31 15:20:44 +0200 | [diff] [blame] | 1353 | uint32_t refcount; /**< reference counter for type sharing */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1354 | |
Radek Krejci | 849a62a | 2019-05-22 15:29:05 +0200 | [diff] [blame] | 1355 | struct lysc_type_bitenum_item *bits; /**< bits list ([sized array](@ref sizedarrays)), mandatory (at least 1 item), |
| 1356 | the items are ordered by their position value. */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1357 | }; |
| 1358 | |
| 1359 | struct lysc_type_leafref { |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1360 | const char *name; /**< referenced typedef name (without prefix, if any), NULL for built-in types */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1361 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1362 | struct lyplg_type *plugin; /**< type's manipulation callbacks plugin */ |
| 1363 | LY_DATA_TYPE basetype; /**< base type of the type */ |
Michal Vasko | 080064b | 2021-08-31 15:20:44 +0200 | [diff] [blame] | 1364 | uint32_t refcount; /**< reference counter for type sharing */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1365 | |
Michal Vasko | 004d315 | 2020-06-11 19:59:22 +0200 | [diff] [blame] | 1366 | struct lyxp_expr *path; /**< parsed target path, compiled path cannot be stored because of type sharing */ |
Michal Vasko | 5d24f6c | 2020-10-13 13:49:06 +0200 | [diff] [blame] | 1367 | struct lysc_prefix *prefixes; /**< resolved prefixes used in the path */ |
Radek Krejci | 412ddfa | 2018-11-23 11:44:11 +0100 | [diff] [blame] | 1368 | struct lysc_type *realtype; /**< pointer to the real (first non-leafref in possible leafrefs chain) type. */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1369 | uint8_t require_instance; /**< require-instance flag */ |
| 1370 | }; |
| 1371 | |
| 1372 | struct lysc_type_identityref { |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1373 | const char *name; /**< referenced typedef name (without prefix, if any), NULL for built-in types */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1374 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1375 | struct lyplg_type *plugin; /**< type's manipulation callbacks plugin */ |
| 1376 | LY_DATA_TYPE basetype; /**< base type of the type */ |
Michal Vasko | 080064b | 2021-08-31 15:20:44 +0200 | [diff] [blame] | 1377 | uint32_t refcount; /**< reference counter for type sharing */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1378 | |
Radek Krejci | 555cb5b | 2018-11-16 14:54:33 +0100 | [diff] [blame] | 1379 | struct lysc_ident **bases; /**< list of pointers to the base identities ([sized array](@ref sizedarrays)), |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1380 | mandatory (at least 1 item) */ |
| 1381 | }; |
| 1382 | |
| 1383 | struct lysc_type_instanceid { |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1384 | const char *name; /**< referenced typedef name (without prefix, if any), NULL for built-in types */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1385 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1386 | struct lyplg_type *plugin; /**< type's manipulation callbacks plugin */ |
| 1387 | LY_DATA_TYPE basetype; /**< base type of the type */ |
Michal Vasko | 080064b | 2021-08-31 15:20:44 +0200 | [diff] [blame] | 1388 | uint32_t refcount; /**< reference counter for type sharing */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1389 | |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1390 | uint8_t require_instance; /**< require-instance flag */ |
| 1391 | }; |
| 1392 | |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1393 | struct lysc_type_union { |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1394 | const char *name; /**< referenced typedef name (without prefix, if any), NULL for built-in types */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1395 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1396 | struct lyplg_type *plugin; /**< type's manipulation callbacks plugin */ |
| 1397 | LY_DATA_TYPE basetype; /**< base type of the type */ |
Michal Vasko | 080064b | 2021-08-31 15:20:44 +0200 | [diff] [blame] | 1398 | uint32_t refcount; /**< reference counter for type sharing */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1399 | |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1400 | struct lysc_type **types; /**< list of types in the union ([sized array](@ref sizedarrays)), mandatory (at least 1 item) */ |
| 1401 | }; |
| 1402 | |
| 1403 | struct lysc_type_bin { |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1404 | const char *name; /**< referenced typedef name (without prefix, if any), NULL for built-in types */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1405 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1406 | struct lyplg_type *plugin; /**< type's manipulation callbacks plugin */ |
| 1407 | LY_DATA_TYPE basetype; /**< base type of the type */ |
Michal Vasko | 080064b | 2021-08-31 15:20:44 +0200 | [diff] [blame] | 1408 | uint32_t refcount; /**< reference counter for type sharing */ |
Michal Vasko | f309c48 | 2024-01-22 12:07:00 +0100 | [diff] [blame] | 1409 | |
| 1410 | struct lysc_range *length; /**< optional length limitation */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 1411 | }; |
| 1412 | |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 1413 | /** |
| 1414 | * @brief Maximum number of hashes stored in a schema node. |
| 1415 | */ |
| 1416 | #define LYS_NODE_HASH_COUNT 4 |
| 1417 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 1418 | /** |
Radek Krejci | 0af5f5d | 2018-09-07 15:00:30 +0200 | [diff] [blame] | 1419 | * @brief Compiled YANG data node |
| 1420 | */ |
| 1421 | struct lysc_node { |
Radek Krejci | de7a9c4 | 2021-03-10 13:13:06 +0100 | [diff] [blame] | 1422 | uint16_t nodetype; /**< [type of the node](@ref schemanodetypes) (mandatory) */ |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1423 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 1424 | uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */ |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1425 | struct lys_module *module; /**< module structure */ |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1426 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1427 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1428 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 1429 | never NULL. If there is no sibling node, pointer points to the node |
| 1430 | itself. In case of the first node, this pointer points to the last |
| 1431 | node in the list. */ |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1432 | const char *name; /**< node name (mandatory) */ |
Radek Krejci | 12fb914 | 2019-01-08 09:45:30 +0100 | [diff] [blame] | 1433 | const char *dsc; /**< description */ |
| 1434 | const char *ref; /**< reference */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 1435 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
aPiecek | 9922ea9 | 2021-04-12 07:59:20 +0200 | [diff] [blame] | 1436 | void *priv; /**< private arbitrary user data, not used by libyang unless ::LY_CTX_SET_PRIV_PARSED is set */ |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1437 | }; |
| 1438 | |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1439 | struct lysc_node_action_inout { |
| 1440 | union { |
| 1441 | struct lysc_node node; /**< implicit cast for the members compatible with ::lysc_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 1442 | |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1443 | struct { |
| 1444 | uint16_t nodetype; /**< LYS_INPUT or LYS_OUTPUT */ |
| 1445 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1446 | uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */ |
| 1447 | struct lys_module *module; /**< module structure */ |
Radek Krejci | 5960c31 | 2021-01-27 20:24:22 +0100 | [diff] [blame] | 1448 | struct lysc_node *parent;/**< parent node (NULL in case of top level node) */ |
Michal Vasko | 544e58a | 2021-01-28 14:33:41 +0100 | [diff] [blame] | 1449 | struct lysc_node *next; /**< next sibling node (output node for input, NULL for output) */ |
| 1450 | struct lysc_node *prev; /**< pointer to the previous sibling node (input and output node pointing to each other) */ |
Radek Krejci | 5960c31 | 2021-01-27 20:24:22 +0100 | [diff] [blame] | 1451 | const char *name; /**< "input" or "output" */ |
| 1452 | const char *dsc; /**< ALWAYS NULL, compatibility member with ::lysc_node */ |
| 1453 | const char *ref; /**< ALWAYS NULL, compatibility member with ::lysc_node */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1454 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
aPiecek | 9922ea9 | 2021-04-12 07:59:20 +0200 | [diff] [blame] | 1455 | void *priv; /** private arbitrary user data, not used by libyang unless ::LY_CTX_SET_PRIV_PARSED is set */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1456 | }; |
| 1457 | }; |
| 1458 | |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 1459 | struct lysc_node *child; /**< first child node (linked list) */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1460 | struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
| 1461 | }; |
| 1462 | |
| 1463 | struct lysc_node_action { |
| 1464 | union { |
| 1465 | struct lysc_node node; /**< implicit cast for the members compatible with ::lysc_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 1466 | |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1467 | struct { |
| 1468 | uint16_t nodetype; /**< LYS_RPC or LYS_ACTION */ |
| 1469 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1470 | uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */ |
| 1471 | struct lys_module *module; /**< module structure */ |
| 1472 | struct lysc_node *parent; /**< parent node (NULL in case of top level node - RPC) */ |
| 1473 | struct lysc_node_action *next; /**< next sibling node (NULL if there is no one) */ |
| 1474 | struct lysc_node_action *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 1475 | never NULL. If there is no sibling node, pointer points to the node |
| 1476 | itself. In case of the first node, this pointer points to the last |
| 1477 | node in the list. */ |
| 1478 | const char *name; /**< action/RPC name (mandatory) */ |
| 1479 | const char *dsc; /**< description */ |
| 1480 | const char *ref; /**< reference */ |
| 1481 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
aPiecek | 9922ea9 | 2021-04-12 07:59:20 +0200 | [diff] [blame] | 1482 | void *priv; /** private arbitrary user data, not used by libyang unless ::LY_CTX_SET_PRIV_PARSED is set */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1483 | }; |
| 1484 | }; |
| 1485 | |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 1486 | struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)), |
| 1487 | the action/RPC nodes do not contain the when statement on their own, but they can |
| 1488 | inherit it from the parent's uses. */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1489 | struct lysc_node_action_inout input; /**< RPC's/action's input */ |
| 1490 | struct lysc_node_action_inout output; /**< RPC's/action's output */ |
| 1491 | |
| 1492 | }; |
| 1493 | |
| 1494 | struct lysc_node_notif { |
| 1495 | union { |
| 1496 | struct lysc_node node; /**< implicit cast for the members compatible with ::lysc_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 1497 | |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1498 | struct { |
| 1499 | uint16_t nodetype; /**< LYS_NOTIF */ |
| 1500 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1501 | uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */ |
| 1502 | struct lys_module *module; /**< module structure */ |
| 1503 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1504 | struct lysc_node_notif *next; /**< next sibling node (NULL if there is no one) */ |
| 1505 | struct lysc_node_notif *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 1506 | never NULL. If there is no sibling node, pointer points to the node |
| 1507 | itself. In case of the first node, this pointer points to the last |
| 1508 | node in the list. */ |
| 1509 | const char *name; /**< Notification name (mandatory) */ |
| 1510 | const char *dsc; /**< description */ |
| 1511 | const char *ref; /**< reference */ |
| 1512 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
aPiecek | 9922ea9 | 2021-04-12 07:59:20 +0200 | [diff] [blame] | 1513 | void *priv; /** private arbitrary user data, not used by libyang unless ::LY_CTX_SET_PRIV_PARSED is set */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1514 | }; |
| 1515 | }; |
| 1516 | |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 1517 | struct lysc_node *child; /**< first child node (linked list) */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1518 | struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 1519 | struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)), |
| 1520 | the notification nodes do not contain the when statement on their own, but they can |
| 1521 | inherit it from the parent's uses. */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1522 | }; |
| 1523 | |
| 1524 | struct lysc_node_container { |
| 1525 | union { |
| 1526 | struct lysc_node node; /**< implicit cast for the members compatible with ::lysc_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 1527 | |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1528 | struct { |
| 1529 | uint16_t nodetype; /**< LYS_CONTAINER */ |
| 1530 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1531 | uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */ |
| 1532 | struct lys_module *module; /**< module structure */ |
| 1533 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1534 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1535 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 1536 | never NULL. If there is no sibling node, pointer points to the node |
| 1537 | itself. In case of the first node, this pointer points to the last |
| 1538 | node in the list. */ |
| 1539 | const char *name; /**< node name (mandatory) */ |
| 1540 | const char *dsc; /**< description */ |
| 1541 | const char *ref; /**< reference */ |
| 1542 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
aPiecek | 9922ea9 | 2021-04-12 07:59:20 +0200 | [diff] [blame] | 1543 | void *priv; /**< private arbitrary user data, not used by libyang unless ::LY_CTX_SET_PRIV_PARSED is set */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1544 | }; |
| 1545 | }; |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1546 | |
| 1547 | struct lysc_node *child; /**< first child node (linked list) */ |
| 1548 | struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 1549 | struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1550 | struct lysc_node_action *actions;/**< first of actions nodes (linked list) */ |
| 1551 | struct lysc_node_notif *notifs; /**< first of notifications nodes (linked list) */ |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1552 | }; |
| 1553 | |
Radek Krejci | a304538 | 2018-11-22 14:30:31 +0100 | [diff] [blame] | 1554 | struct lysc_node_case { |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1555 | union { |
| 1556 | struct lysc_node node; /**< implicit cast for the members compatible with ::lysc_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 1557 | |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1558 | struct { |
| 1559 | uint16_t nodetype; /**< LYS_CASE */ |
| 1560 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1561 | uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser, unused */ |
| 1562 | struct lys_module *module; /**< module structure */ |
| 1563 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1564 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1565 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1566 | never NULL. If there is no sibling node, pointer points to the node |
| 1567 | itself. In case of the first node, this pointer points to the last |
| 1568 | node in the list. */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1569 | const char *name; /**< name of the case, including the implicit case */ |
| 1570 | const char *dsc; /**< description */ |
| 1571 | const char *ref; /**< reference */ |
| 1572 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
aPiecek | 9922ea9 | 2021-04-12 07:59:20 +0200 | [diff] [blame] | 1573 | void *priv; /**< private arbitrary user data, not used by libyang unless ::LY_CTX_SET_PRIV_PARSED is set */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1574 | }; |
| 1575 | }; |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1576 | |
Radek Krejci | a304538 | 2018-11-22 14:30:31 +0100 | [diff] [blame] | 1577 | 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 Krejci | fe13da4 | 2019-02-15 14:51:01 +0100 | [diff] [blame] | 1578 | each other as siblings with the parent pointer pointing to appropriate case node. */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 1579 | struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */ |
Radek Krejci | a304538 | 2018-11-22 14:30:31 +0100 | [diff] [blame] | 1580 | }; |
| 1581 | |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1582 | struct lysc_node_choice { |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1583 | union { |
| 1584 | struct lysc_node node; /**< implicit cast for the members compatible with ::lysc_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 1585 | |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1586 | struct { |
| 1587 | uint16_t nodetype; /**< LYS_CHOICE */ |
| 1588 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1589 | uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser, unused */ |
| 1590 | struct lys_module *module; /**< module structure */ |
| 1591 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1592 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1593 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1594 | never NULL. If there is no sibling node, pointer points to the node |
| 1595 | itself. In case of the first node, this pointer points to the last |
| 1596 | node in the list. */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1597 | const char *name; /**< node name (mandatory) */ |
| 1598 | const char *dsc; /**< description */ |
| 1599 | const char *ref; /**< reference */ |
| 1600 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
aPiecek | 9922ea9 | 2021-04-12 07:59:20 +0200 | [diff] [blame] | 1601 | void *priv; /**< private arbitrary user data, not used by libyang unless ::LY_CTX_SET_PRIV_PARSED is set */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1602 | }; |
| 1603 | }; |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1604 | |
Michal Vasko | d098f5d | 2024-01-11 08:51:31 +0100 | [diff] [blame] | 1605 | struct lysc_node_case *cases; /**< list of all the cases (linked list) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 1606 | struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1607 | struct lysc_node_case *dflt; /**< default case of the choice, only a pointer into the cases array. */ |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1608 | }; |
| 1609 | |
| 1610 | struct lysc_node_leaf { |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1611 | union { |
| 1612 | struct lysc_node node; /**< implicit cast for the members compatible with ::lysc_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 1613 | |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1614 | struct { |
| 1615 | uint16_t nodetype; /**< LYS_LEAF */ |
| 1616 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1617 | uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */ |
| 1618 | struct lys_module *module; /**< module structure */ |
| 1619 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1620 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1621 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1622 | never NULL. If there is no sibling node, pointer points to the node |
| 1623 | itself. In case of the first node, this pointer points to the last |
| 1624 | node in the list. */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1625 | const char *name; /**< node name (mandatory) */ |
| 1626 | const char *dsc; /**< description */ |
| 1627 | const char *ref; /**< reference */ |
| 1628 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
aPiecek | 9922ea9 | 2021-04-12 07:59:20 +0200 | [diff] [blame] | 1629 | void *priv; /**< private arbitrary user data, not used by libyang unless ::LY_CTX_SET_PRIV_PARSED is set */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1630 | }; |
| 1631 | }; |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1632 | |
| 1633 | struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 1634 | struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1635 | struct lysc_type *type; /**< type of the leaf node (mandatory) */ |
Radek Krejci | b57cf1e | 2018-11-23 14:07:05 +0100 | [diff] [blame] | 1636 | |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1637 | const char *units; /**< units of the leaf's type */ |
Michal Vasko | 3387602 | 2021-04-27 16:42:24 +0200 | [diff] [blame] | 1638 | struct lyd_value *dflt; /**< default value, use ::lyd_value_get_canonical() to get the canonical string */ |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1639 | }; |
| 1640 | |
| 1641 | struct lysc_node_leaflist { |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1642 | union { |
| 1643 | struct lysc_node node; /**< implicit cast for the members compatible with ::lysc_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 1644 | |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1645 | struct { |
| 1646 | uint16_t nodetype; /**< LYS_LEAFLIST */ |
| 1647 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1648 | uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */ |
| 1649 | struct lys_module *module; /**< module structure */ |
| 1650 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1651 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1652 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1653 | never NULL. If there is no sibling node, pointer points to the node |
| 1654 | itself. In case of the first node, this pointer points to the last |
| 1655 | node in the list. */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1656 | const char *name; /**< node name (mandatory) */ |
| 1657 | const char *dsc; /**< description */ |
| 1658 | const char *ref; /**< reference */ |
| 1659 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
aPiecek | 9922ea9 | 2021-04-12 07:59:20 +0200 | [diff] [blame] | 1660 | void *priv; /**< private arbitrary user data, not used by libyang unless ::LY_CTX_SET_PRIV_PARSED is set */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1661 | }; |
| 1662 | }; |
Radek Krejci | b57cf1e | 2018-11-23 14:07:05 +0100 | [diff] [blame] | 1663 | |
| 1664 | struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 1665 | struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */ |
Radek Krejci | b57cf1e | 2018-11-23 14:07:05 +0100 | [diff] [blame] | 1666 | struct lysc_type *type; /**< type of the leaf node (mandatory) */ |
| 1667 | |
Radek Krejci | 0e5d838 | 2018-11-28 16:37:53 +0100 | [diff] [blame] | 1668 | const char *units; /**< units of the leaf's type */ |
Michal Vasko | 3387602 | 2021-04-27 16:42:24 +0200 | [diff] [blame] | 1669 | struct lyd_value **dflts; /**< list ([sized array](@ref sizedarrays)) of default values, use |
| 1670 | ::lyd_value_get_canonical() to get the canonical strings */ |
Michal Vasko | ba99a3e | 2020-08-18 15:50:05 +0200 | [diff] [blame] | 1671 | |
Radek Krejci | 0e5d838 | 2018-11-28 16:37:53 +0100 | [diff] [blame] | 1672 | uint32_t min; /**< min-elements constraint */ |
| 1673 | uint32_t max; /**< max-elements constraint */ |
| 1674 | |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1675 | }; |
| 1676 | |
| 1677 | struct lysc_node_list { |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1678 | union { |
| 1679 | struct lysc_node node; /**< implicit cast for the members compatible with ::lysc_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 1680 | |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1681 | struct { |
| 1682 | uint16_t nodetype; /**< LYS_LIST */ |
| 1683 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1684 | uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */ |
| 1685 | struct lys_module *module; /**< module structure */ |
| 1686 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1687 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1688 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1689 | never NULL. If there is no sibling node, pointer points to the node |
| 1690 | itself. In case of the first node, this pointer points to the last |
| 1691 | node in the list. */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1692 | const char *name; /**< node name (mandatory) */ |
| 1693 | const char *dsc; /**< description */ |
| 1694 | const char *ref; /**< reference */ |
| 1695 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
aPiecek | 9922ea9 | 2021-04-12 07:59:20 +0200 | [diff] [blame] | 1696 | void *priv; /**< private arbitrary user data, not used by libyang unless ::LY_CTX_SET_PRIV_PARSED is set */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1697 | }; |
| 1698 | }; |
Radek Krejci | 9bb94eb | 2018-12-04 16:48:35 +0100 | [diff] [blame] | 1699 | |
| 1700 | struct lysc_node *child; /**< first child node (linked list) */ |
| 1701 | struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 1702 | struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1703 | struct lysc_node_action *actions;/**< first of actions nodes (linked list) */ |
| 1704 | struct lysc_node_notif *notifs; /**< first of notifications nodes (linked list) */ |
Radek Krejci | 9bb94eb | 2018-12-04 16:48:35 +0100 | [diff] [blame] | 1705 | |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1706 | struct lysc_node_leaf ***uniques;/**< list of sized arrays of pointers to the unique nodes ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 9bb94eb | 2018-12-04 16:48:35 +0100 | [diff] [blame] | 1707 | uint32_t min; /**< min-elements constraint */ |
| 1708 | uint32_t max; /**< max-elements constraint */ |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1709 | }; |
| 1710 | |
| 1711 | struct lysc_node_anydata { |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1712 | union { |
| 1713 | struct lysc_node node; /**< implicit cast for the members compatible with ::lysc_node */ |
Michal Vasko | 26bbb27 | 2022-08-02 14:54:33 +0200 | [diff] [blame] | 1714 | |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1715 | struct { |
| 1716 | uint16_t nodetype; /**< LYS_ANYXML or LYS_ANYDATA */ |
| 1717 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1718 | uint8_t hash[LYS_NODE_HASH_COUNT]; /**< schema hash required for LYB printer/parser */ |
| 1719 | struct lys_module *module; /**< module structure */ |
| 1720 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1721 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1722 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1723 | never NULL. If there is no sibling node, pointer points to the node |
| 1724 | itself. In case of the first node, this pointer points to the last |
| 1725 | node in the list. */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1726 | const char *name; /**< node name (mandatory) */ |
| 1727 | const char *dsc; /**< description */ |
| 1728 | const char *ref; /**< reference */ |
| 1729 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
aPiecek | 9922ea9 | 2021-04-12 07:59:20 +0200 | [diff] [blame] | 1730 | void *priv; /**< private arbitrary user data, not used by libyang unless ::LY_CTX_SET_PRIV_PARSED is set */ |
Radek Krejci | 00a3e8a | 2021-01-27 08:24:49 +0100 | [diff] [blame] | 1731 | }; |
| 1732 | }; |
Radek Krejci | 9800fb8 | 2018-12-13 14:26:23 +0100 | [diff] [blame] | 1733 | |
| 1734 | struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 1735 | struct lysc_when **when; /**< list of pointers to when statements ([sized array](@ref sizedarrays)) */ |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1736 | }; |
| 1737 | |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1738 | /** |
| 1739 | * @brief Compiled YANG schema tree structure representing YANG module. |
| 1740 | * |
| 1741 | * Semantically validated YANG schema tree for data tree parsing. |
| 1742 | * Contains only the necessary information for the data validation. |
| 1743 | */ |
| 1744 | struct lysc_module { |
Radek Krejci | 0bcdaed | 2019-01-10 10:21:34 +0100 | [diff] [blame] | 1745 | struct lys_module *mod; /**< covering module structure */ |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1746 | |
Radek Krejci | 2a408df | 2018-10-29 16:32:26 +0100 | [diff] [blame] | 1747 | struct lysc_node *data; /**< list of module's top-level data nodes (linked list) */ |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1748 | struct lysc_node_action *rpcs; /**< first of actions nodes (linked list) */ |
| 1749 | struct lysc_node_notif *notifs; /**< first of notifications nodes (linked list) */ |
Radek Krejci | ce8c159 | 2018-10-29 15:35:51 +0100 | [diff] [blame] | 1750 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 0af5f5d | 2018-09-07 15:00:30 +0200 | [diff] [blame] | 1751 | }; |
| 1752 | |
| 1753 | /** |
Radek Krejci | 490a546 | 2020-11-05 08:44:42 +0100 | [diff] [blame] | 1754 | * @brief Examine whether a node is user-ordered list or leaf-list. |
| 1755 | * |
| 1756 | * @param[in] lysc_node Schema node to examine. |
| 1757 | * @return Boolean value whether the @p node is user-ordered or not. |
| 1758 | */ |
| 1759 | #define lysc_is_userordered(lysc_node) \ |
| 1760 | ((!lysc_node || !(lysc_node->nodetype & (LYS_LEAFLIST | LYS_LIST)) || !(lysc_node->flags & LYS_ORDBY_USER)) ? 0 : 1) |
| 1761 | |
| 1762 | /** |
| 1763 | * @brief Examine whether a node is a list's key. |
| 1764 | * |
| 1765 | * @param[in] lysc_node Schema node to examine. |
| 1766 | * @return Boolean value whether the @p node is a key or not. |
| 1767 | */ |
| 1768 | #define lysc_is_key(lysc_node) \ |
Michal Vasko | bce7ee3 | 2021-02-04 11:05:25 +0100 | [diff] [blame] | 1769 | ((!lysc_node || (lysc_node->nodetype != LYS_LEAF) || !(lysc_node->flags & LYS_KEY)) ? 0 : 1) |
Radek Krejci | 490a546 | 2020-11-05 08:44:42 +0100 | [diff] [blame] | 1770 | |
| 1771 | /** |
Michal Vasko | 5c123b0 | 2020-12-04 14:34:04 +0100 | [diff] [blame] | 1772 | * @brief Examine whether a node is a non-presence container. |
| 1773 | * |
| 1774 | * @param[in] lysc_node Schema node to examine. |
| 1775 | * @return Boolean value whether the @p node is a NP container or not. |
| 1776 | */ |
| 1777 | #define lysc_is_np_cont(lysc_node) \ |
Michal Vasko | bce7ee3 | 2021-02-04 11:05:25 +0100 | [diff] [blame] | 1778 | ((!lysc_node || (lysc_node->nodetype != LYS_CONTAINER) || (lysc_node->flags & LYS_PRESENCE)) ? 0 : 1) |
| 1779 | |
| 1780 | /** |
Michal Vasko | e78faec | 2021-04-08 17:24:43 +0200 | [diff] [blame] | 1781 | * @brief Examine whether a node is a key-less list or a non-configuration leaf-list. |
Michal Vasko | bce7ee3 | 2021-02-04 11:05:25 +0100 | [diff] [blame] | 1782 | * |
| 1783 | * @param[in] lysc_node Schema node to examine. |
| 1784 | * @return Boolean value whether the @p node is a list with duplicate instances allowed. |
| 1785 | */ |
| 1786 | #define lysc_is_dup_inst_list(lysc_node) \ |
| 1787 | ((lysc_node && (((lysc_node->nodetype == LYS_LIST) && (lysc_node->flags & LYS_KEYLESS)) || \ |
Michal Vasko | e78faec | 2021-04-08 17:24:43 +0200 | [diff] [blame] | 1788 | ((lysc_node->nodetype == LYS_LEAFLIST) && !(lysc_node->flags & LYS_CONFIG_W)))) ? 1 : 0) |
Michal Vasko | 5c123b0 | 2020-12-04 14:34:04 +0100 | [diff] [blame] | 1789 | |
| 1790 | /** |
Michal Vasko | f8ded14 | 2022-02-17 10:48:01 +0100 | [diff] [blame] | 1791 | * @brief Get nearest @p schema parent (including the node itself) that can be instantiated in data. |
| 1792 | * |
| 1793 | * @param[in] schema Schema node to get the nearest data node for. |
| 1794 | * @return Schema data node, NULL if top-level (in data). |
| 1795 | */ |
| 1796 | LIBYANG_API_DECL const struct lysc_node *lysc_data_node(const struct lysc_node *schema); |
| 1797 | |
| 1798 | /** |
| 1799 | * @brief Same as ::lysc_data_node() but never returns the node itself. |
| 1800 | */ |
| 1801 | #define lysc_data_parent(SCHEMA) lysc_data_node((SCHEMA) ? (SCHEMA)->parent : NULL) |
| 1802 | |
| 1803 | /** |
Michal Vasko | d5cfa6e | 2020-11-23 16:56:08 +0100 | [diff] [blame] | 1804 | * @brief Check whether the schema node data instance existence depends on any when conditions. |
| 1805 | * This node and any direct parent choice and case schema nodes are also examined for when conditions. |
| 1806 | * |
| 1807 | * Be careful, this function is not recursive and checks only conditions that apply to this node directly. |
| 1808 | * Meaning if there are any conditions associated with any data parent instance of @p node, they are not returned. |
| 1809 | * |
| 1810 | * @param[in] node Schema node to examine. |
| 1811 | * @return When condition associated with the node data instance, NULL if there is none. |
| 1812 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1813 | LIBYANG_API_DECL const struct lysc_when *lysc_has_when(const struct lysc_node *node); |
Michal Vasko | d5cfa6e | 2020-11-23 16:56:08 +0100 | [diff] [blame] | 1814 | |
| 1815 | /** |
Michal Vasko | ef53c81 | 2021-10-13 10:21:03 +0200 | [diff] [blame] | 1816 | * @brief Get the owner module of the schema node. It is the module of the top-level node. Generally, |
| 1817 | * in case of augments it is the target module, recursively, otherwise it is the module where the node is defined. |
| 1818 | * |
| 1819 | * @param[in] node Schema node to examine. |
| 1820 | * @return Module owner of the node. |
| 1821 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1822 | LIBYANG_API_DECL const struct lys_module *lysc_owner_module(const struct lysc_node *node); |
Michal Vasko | ef53c81 | 2021-10-13 10:21:03 +0200 | [diff] [blame] | 1823 | |
| 1824 | /** |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1825 | * @brief Get the groupings linked list of the given (parsed) schema node. |
Radek Krejci | 53ea615 | 2018-12-13 15:21:15 +0100 | [diff] [blame] | 1826 | * Decides the node's type and in case it has a groupings array, returns it. |
| 1827 | * @param[in] node Node to examine. |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1828 | * @return The node's groupings linked list if any, NULL otherwise. |
Radek Krejci | 53ea615 | 2018-12-13 15:21:15 +0100 | [diff] [blame] | 1829 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1830 | LIBYANG_API_DECL const struct lysp_node_grp *lysp_node_groupings(const struct lysp_node *node); |
Radek Krejci | 53ea615 | 2018-12-13 15:21:15 +0100 | [diff] [blame] | 1831 | |
| 1832 | /** |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1833 | * @brief Get the typedefs sized array of the given (parsed) schema node. |
| 1834 | * Decides the node's type and in case it has a typedefs array, returns it. |
| 1835 | * @param[in] node Node to examine. |
| 1836 | * @return The node's typedefs sized array if any, NULL otherwise. |
| 1837 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1838 | LIBYANG_API_DECL const struct lysp_tpdf *lysp_node_typedefs(const struct lysp_node *node); |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1839 | |
| 1840 | /** |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1841 | * @brief Get the actions/RPCs linked list of the given (parsed) schema node. |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1842 | * Decides the node's type and in case it has a actions/RPCs array, returns it. |
| 1843 | * @param[in] node Node to examine. |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1844 | * @return The node's actions/RPCs linked list if any, NULL otherwise. |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1845 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1846 | LIBYANG_API_DECL const struct lysp_node_action *lysp_node_actions(const struct lysp_node *node); |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1847 | |
| 1848 | /** |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1849 | * @brief Get the Notifications linked list of the given (parsed) schema node. |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1850 | * Decides the node's type and in case it has a Notifications array, returns it. |
| 1851 | * @param[in] node Node to examine. |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1852 | * @return The node's Notifications linked list if any, NULL otherwise. |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1853 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1854 | LIBYANG_API_DECL const struct lysp_node_notif *lysp_node_notifs(const struct lysp_node *node); |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1855 | |
| 1856 | /** |
| 1857 | * @brief Get the children linked list of the given (parsed) schema node. |
| 1858 | * Decides the node's type and in case it has a children list, returns it. |
| 1859 | * @param[in] node Node to examine. |
| 1860 | * @return The node's children linked list if any, NULL otherwise. |
| 1861 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1862 | LIBYANG_API_DECL const struct lysp_node *lysp_node_child(const struct lysp_node *node); |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1863 | |
| 1864 | /** |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1865 | * @brief Get the actions/RPCs linked list of the given (compiled) schema node. |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1866 | * Decides the node's type and in case it has a actions/RPCs array, returns it. |
| 1867 | * @param[in] node Node to examine. |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1868 | * @return The node's actions/RPCs linked list if any, NULL otherwise. |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1869 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1870 | LIBYANG_API_DECL const struct lysc_node_action *lysc_node_actions(const struct lysc_node *node); |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1871 | |
| 1872 | /** |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1873 | * @brief Get the Notifications linked list of the given (compiled) schema node. |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1874 | * Decides the node's type and in case it has a Notifications array, returns it. |
| 1875 | * @param[in] node Node to examine. |
Radek Krejci | 2a9fc65 | 2021-01-22 17:44:34 +0100 | [diff] [blame] | 1876 | * @return The node's Notifications linked list if any, NULL otherwise. |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1877 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1878 | LIBYANG_API_DECL const struct lysc_node_notif *lysc_node_notifs(const struct lysc_node *node); |
Radek Krejci | 056d0a8 | 2018-12-06 16:57:25 +0100 | [diff] [blame] | 1879 | |
| 1880 | /** |
| 1881 | * @brief Get the children linked list of the given (compiled) schema node. |
Michal Vasko | 2a66871 | 2020-10-21 11:48:09 +0200 | [diff] [blame] | 1882 | * |
Michal Vasko | 544e58a | 2021-01-28 14:33:41 +0100 | [diff] [blame] | 1883 | * Note that ::LYS_CHOICE has only ::LYS_CASE children. |
| 1884 | * Also, ::LYS_RPC and ::LYS_ACTION have the first child ::LYS_INPUT, its sibling is ::LYS_OUTPUT. |
| 1885 | * |
Michal Vasko | 2a66871 | 2020-10-21 11:48:09 +0200 | [diff] [blame] | 1886 | * @param[in] node Node to examine. |
Michal Vasko | 2a66871 | 2020-10-21 11:48:09 +0200 | [diff] [blame] | 1887 | * @return Children linked list if any, |
| 1888 | * @return NULL otherwise. |
| 1889 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1890 | LIBYANG_API_DECL const struct lysc_node *lysc_node_child(const struct lysc_node *node); |
Michal Vasko | 2a66871 | 2020-10-21 11:48:09 +0200 | [diff] [blame] | 1891 | |
| 1892 | /** |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 1893 | * @brief Get the must statements list if present in the @p node |
| 1894 | * |
| 1895 | * @param[in] node Node to examine. |
| 1896 | * @return Pointer to the list of must restrictions ([sized array](@ref sizedarrays)) |
| 1897 | * @return NULL if there is no must statement in the node, no matter if it is not even allowed or just present |
| 1898 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1899 | LIBYANG_API_DECL struct lysc_must *lysc_node_musts(const struct lysc_node *node); |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 1900 | |
| 1901 | /** |
| 1902 | * @brief Get the when statements list if present in the @p node |
| 1903 | * |
| 1904 | * @param[in] node Node to examine. |
| 1905 | * @return Pointer to the list of pointers to when statements ([sized array](@ref sizedarrays)) |
| 1906 | * @return NULL if there is no when statement in the node, no matter if it is not even allowed or just present |
| 1907 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1908 | LIBYANG_API_DECL struct lysc_when **lysc_node_when(const struct lysc_node *node); |
Radek Krejci | 9a3823e | 2021-01-27 20:26:46 +0100 | [diff] [blame] | 1909 | |
| 1910 | /** |
Michal Vasko | 510554a | 2023-09-11 09:03:29 +0200 | [diff] [blame] | 1911 | * @brief Get the target node of a leafref node. |
| 1912 | * |
| 1913 | * @param[in] node Leafref node. |
| 1914 | * @return Leafref target, NULL on any error. |
| 1915 | */ |
| 1916 | LIBYANG_API_DECL const struct lysc_node *lysc_node_lref_target(const struct lysc_node *node); |
| 1917 | |
| 1918 | /** |
Michal Vasko | f1ab44f | 2020-10-22 08:58:32 +0200 | [diff] [blame] | 1919 | * @brief Callback to be called for every schema node in a DFS traversal. |
| 1920 | * |
| 1921 | * @param[in] node Current node. |
| 1922 | * @param[in] data Arbitrary user data. |
| 1923 | * @param[out] dfs_continue Set to true if the current subtree should be skipped and continue with siblings instead. |
| 1924 | * @return LY_SUCCESS on success, |
| 1925 | * @return LY_ERR value to terminate DFS and return this value. |
| 1926 | */ |
Michal Vasko | 8f07dfe | 2021-03-02 16:10:24 +0100 | [diff] [blame] | 1927 | typedef LY_ERR (*lysc_dfs_clb)(struct lysc_node *node, void *data, ly_bool *dfs_continue); |
Michal Vasko | f1ab44f | 2020-10-22 08:58:32 +0200 | [diff] [blame] | 1928 | |
| 1929 | /** |
| 1930 | * @brief DFS traversal of all the schema nodes in a (sub)tree including any actions and nested notifications. |
| 1931 | * |
| 1932 | * Node with children, actions, and notifications is traversed in this order: |
| 1933 | * 1) each child subtree; |
| 1934 | * 2) each action subtree; |
| 1935 | * 3) each notification subtree. |
| 1936 | * |
| 1937 | * For algorithm illustration or traversal with actions and notifications skipped, see ::LYSC_TREE_DFS_BEGIN. |
| 1938 | * |
| 1939 | * @param[in] root Schema root to fully traverse. |
| 1940 | * @param[in] dfs_clb Callback to call for each node. |
| 1941 | * @param[in] data Arbitrary user data passed to @p dfs_clb. |
| 1942 | * @return LY_SUCCESS on success, |
| 1943 | * @return LY_ERR value returned by @p dfs_clb. |
| 1944 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1945 | LIBYANG_API_DECL LY_ERR lysc_tree_dfs_full(const struct lysc_node *root, lysc_dfs_clb dfs_clb, void *data); |
Michal Vasko | f1ab44f | 2020-10-22 08:58:32 +0200 | [diff] [blame] | 1946 | |
| 1947 | /** |
| 1948 | * @brief DFS traversal of all the schema nodes in a module including RPCs and notifications. |
| 1949 | * |
| 1950 | * For more details, see ::lysc_tree_dfs_full(). |
| 1951 | * |
| 1952 | * @param[in] mod Module to fully traverse. |
| 1953 | * @param[in] dfs_clb Callback to call for each node. |
| 1954 | * @param[in] data Arbitrary user data passed to @p dfs_clb. |
| 1955 | * @return LY_SUCCESS on success, |
| 1956 | * @return LY_ERR value returned by @p dfs_clb. |
| 1957 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1958 | LIBYANG_API_DECL LY_ERR lysc_module_dfs_full(const struct lys_module *mod, lysc_dfs_clb dfs_clb, void *data); |
Michal Vasko | f1ab44f | 2020-10-22 08:58:32 +0200 | [diff] [blame] | 1959 | |
| 1960 | /** |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 1961 | * @brief Get how the if-feature statement currently evaluates. |
| 1962 | * |
| 1963 | * @param[in] iff Compiled if-feature statement to evaluate. |
Michal Vasko | 28d7843 | 2020-05-26 13:10:53 +0200 | [diff] [blame] | 1964 | * @return LY_SUCCESS if the statement evaluates to true, |
| 1965 | * @return LY_ENOT if it evaluates to false, |
| 1966 | * @return LY_ERR on error. |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 1967 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1968 | LIBYANG_API_DECL LY_ERR lysc_iffeature_value(const struct lysc_iffeature *iff); |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 1969 | |
| 1970 | /** |
aPiecek | f4a0a19 | 2021-08-03 15:14:17 +0200 | [diff] [blame] | 1971 | * @brief Get how the if-feature statement is evaluated for certain identity. |
| 1972 | * |
| 1973 | * The function can be called even if the identity does not contain |
| 1974 | * if-features, in which case ::LY_SUCCESS is returned. |
| 1975 | * |
| 1976 | * @param[in] ident Compiled identity statement to evaluate. |
| 1977 | * @return LY_SUCCESS if the statement evaluates to true, |
| 1978 | * @return LY_ENOT if it evaluates to false, |
| 1979 | * @return LY_ERR on error. |
| 1980 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 1981 | LIBYANG_API_DECL LY_ERR lys_identity_iffeature_value(const struct lysc_ident *ident); |
aPiecek | f4a0a19 | 2021-08-03 15:14:17 +0200 | [diff] [blame] | 1982 | |
| 1983 | /** |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 1984 | * @brief Get the next feature in the module or submodules. |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 1985 | * |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 1986 | * @param[in] last Last returned feature. |
Michal Vasko | 4ec4bc0 | 2021-10-12 10:17:28 +0200 | [diff] [blame] | 1987 | * @param[in] pmod Parsed module and submodules whose features to iterate over. |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 1988 | * @param[in,out] idx Submodule index, set to 0 on first call. |
| 1989 | * @return Next found feature, NULL if the last has already been returned. |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 1990 | */ |
Michal Vasko | c1a0ff6 | 2022-02-28 14:27:16 +0100 | [diff] [blame] | 1991 | LIBYANG_API_DECL struct lysp_feature *lysp_feature_next(const struct lysp_feature *last, const struct lysp_module *pmod, |
| 1992 | uint32_t *idx); |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 1993 | |
Radek Krejci | bed1394 | 2020-10-19 16:06:28 +0200 | [diff] [blame] | 1994 | /** |
| 1995 | * @defgroup findxpathoptions Atomize XPath options |
| 1996 | * Options to modify behavior of ::lys_find_xpath() and ::lys_find_xpath_atoms() searching for schema nodes in schema tree. |
| 1997 | * @{ |
| 1998 | */ |
Michal Vasko | 4ad69e7 | 2021-10-26 16:25:55 +0200 | [diff] [blame] | 1999 | #define LYS_FIND_XP_SCHEMA 0x08 /**< Apply node access restrictions defined for 'when' and 'must' evaluation. */ |
| 2000 | #define LYS_FIND_XP_OUTPUT 0x10 /**< Search RPC/action output nodes instead of input ones. */ |
Michal Vasko | a2fe081 | 2022-05-26 09:24:32 +0200 | [diff] [blame] | 2001 | #define LYS_FIND_NO_MATCH_ERROR 0x40 /**< Return error if a path segment matches no nodes, otherwise only warning |
Michal Vasko | 4ad69e7 | 2021-10-26 16:25:55 +0200 | [diff] [blame] | 2002 | is printed. */ |
Michal Vasko | e482bb9 | 2023-02-01 11:41:41 +0100 | [diff] [blame] | 2003 | #define LYS_FIND_SCHEMAMOUNT 0x0200 /**< Traverse also nodes from mounted modules. If any such nodes are returned, |
| 2004 | the caller **must free** their context! */ |
Radek Krejci | 576f8fa | 2020-10-26 21:23:58 +0100 | [diff] [blame] | 2005 | /** @} findxpathoptions */ |
Michal Vasko | 072de48 | 2020-08-05 13:27:21 +0200 | [diff] [blame] | 2006 | |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 2007 | /** |
Michal Vasko | 40308e7 | 2020-10-20 16:38:40 +0200 | [diff] [blame] | 2008 | * @brief Get all the schema nodes that are required for @p xpath to be evaluated (atoms). |
Michal Vasko | 519fd60 | 2020-05-26 12:17:39 +0200 | [diff] [blame] | 2009 | * |
Michal Vasko | 2651268 | 2021-01-11 11:35:40 +0100 | [diff] [blame] | 2010 | * @param[in] ctx libyang context to use. May be NULL if @p ctx_node is set. |
| 2011 | * @param[in] ctx_node XPath schema context node. Use NULL for the root node. |
Radek Krejci | 8df109d | 2021-04-23 12:19:08 +0200 | [diff] [blame] | 2012 | * @param[in] xpath Data XPath expression filtering the matching nodes. ::LY_VALUE_JSON prefix format is expected. |
Radek Krejci | bed1394 | 2020-10-19 16:06:28 +0200 | [diff] [blame] | 2013 | * @param[in] options Whether to apply some node access restrictions, see @ref findxpathoptions. |
Michal Vasko | 519fd60 | 2020-05-26 12:17:39 +0200 | [diff] [blame] | 2014 | * @param[out] set Set of found atoms (schema nodes). |
| 2015 | * @return LY_SUCCESS on success, @p set is returned. |
Michal Vasko | 40308e7 | 2020-10-20 16:38:40 +0200 | [diff] [blame] | 2016 | * @return LY_ERR value on error. |
Michal Vasko | 519fd60 | 2020-05-26 12:17:39 +0200 | [diff] [blame] | 2017 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 2018 | LIBYANG_API_DECL LY_ERR lys_find_xpath_atoms(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *xpath, |
Michal Vasko | 2651268 | 2021-01-11 11:35:40 +0100 | [diff] [blame] | 2019 | uint32_t options, struct ly_set **set); |
Michal Vasko | 519fd60 | 2020-05-26 12:17:39 +0200 | [diff] [blame] | 2020 | |
Michal Vasko | 072de48 | 2020-08-05 13:27:21 +0200 | [diff] [blame] | 2021 | /** |
Michal Vasko | 40308e7 | 2020-10-20 16:38:40 +0200 | [diff] [blame] | 2022 | * @brief Get all the schema nodes that are required for @p expr to be evaluated (atoms). |
Michal Vasko | 072de48 | 2020-08-05 13:27:21 +0200 | [diff] [blame] | 2023 | * |
Michal Vasko | 2651268 | 2021-01-11 11:35:40 +0100 | [diff] [blame] | 2024 | * @param[in] ctx_node XPath schema context node. Use NULL for the root node. |
Michal Vasko | 40308e7 | 2020-10-20 16:38:40 +0200 | [diff] [blame] | 2025 | * @param[in] cur_mod Current module for the expression (where it was "instantiated"). |
| 2026 | * @param[in] expr Parsed expression to use. |
| 2027 | * @param[in] prefixes Sized array of compiled prefixes. |
| 2028 | * @param[in] options Whether to apply some node access restrictions, see @ref findxpathoptions. |
| 2029 | * @param[out] set Set of found atoms (schema nodes). |
| 2030 | * @return LY_SUCCESS on success, @p set is returned. |
| 2031 | * @return LY_ERR value on error. |
| 2032 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 2033 | LIBYANG_API_DECL LY_ERR lys_find_expr_atoms(const struct lysc_node *ctx_node, const struct lys_module *cur_mod, |
Michal Vasko | 40308e7 | 2020-10-20 16:38:40 +0200 | [diff] [blame] | 2034 | const struct lyxp_expr *expr, const struct lysc_prefix *prefixes, uint32_t options, struct ly_set **set); |
| 2035 | |
| 2036 | /** |
| 2037 | * @brief Evaluate an @p xpath expression on schema nodes. |
| 2038 | * |
Michal Vasko | 2651268 | 2021-01-11 11:35:40 +0100 | [diff] [blame] | 2039 | * @param[in] ctx libyang context to use for absolute @p xpath. May be NULL if @p ctx_node is set. |
| 2040 | * @param[in] ctx_node XPath schema context node for relative @p xpath. Use NULL for the root node. |
Radek Krejci | 8df109d | 2021-04-23 12:19:08 +0200 | [diff] [blame] | 2041 | * @param[in] xpath Data XPath expression filtering the matching nodes. ::LY_VALUE_JSON prefix format is expected. |
Radek Krejci | bed1394 | 2020-10-19 16:06:28 +0200 | [diff] [blame] | 2042 | * @param[in] options Whether to apply some node access restrictions, see @ref findxpathoptions. |
Michal Vasko | 072de48 | 2020-08-05 13:27:21 +0200 | [diff] [blame] | 2043 | * @param[out] set Set of found schema nodes. |
| 2044 | * @return LY_SUCCESS on success, @p set is returned. |
| 2045 | * @return LY_ERR value if an error occurred. |
| 2046 | */ |
Michal Vasko | c1a0ff6 | 2022-02-28 14:27:16 +0100 | [diff] [blame] | 2047 | LIBYANG_API_DECL LY_ERR lys_find_xpath(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *xpath, |
| 2048 | uint32_t options, struct ly_set **set); |
Michal Vasko | 519fd60 | 2020-05-26 12:17:39 +0200 | [diff] [blame] | 2049 | |
| 2050 | /** |
Radek Krejci | bc5644c | 2020-10-27 14:53:17 +0100 | [diff] [blame] | 2051 | * @brief Get all the schema nodes that are required for @p path to be evaluated (atoms). |
| 2052 | * |
| 2053 | * @param[in] path Compiled path to use. |
| 2054 | * @param[out] set Set of found atoms (schema nodes). |
| 2055 | * @return LY_SUCCESS on success, @p set is returned. |
| 2056 | * @return LY_ERR value on error. |
| 2057 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 2058 | LIBYANG_API_DECL LY_ERR lys_find_lypath_atoms(const struct ly_path *path, struct ly_set **set); |
Radek Krejci | bc5644c | 2020-10-27 14:53:17 +0100 | [diff] [blame] | 2059 | |
| 2060 | /** |
| 2061 | * @brief Get all the schema nodes that are required for @p path to be evaluated (atoms). |
| 2062 | * |
Michal Vasko | 2651268 | 2021-01-11 11:35:40 +0100 | [diff] [blame] | 2063 | * @param[in] ctx libyang context to use for absolute @p path. May be NULL if @p ctx_node is set. |
| 2064 | * @param[in] ctx_node XPath schema context node for relative @p path. Use NULL for the root node. |
Radek Krejci | bc5644c | 2020-10-27 14:53:17 +0100 | [diff] [blame] | 2065 | * @param[in] path JSON path to examine. |
| 2066 | * @param[in] output Search operation output instead of input. |
| 2067 | * @param[out] set Set of found atoms (schema nodes). |
| 2068 | * @return LY_ERR value on error. |
| 2069 | */ |
Michal Vasko | c1a0ff6 | 2022-02-28 14:27:16 +0100 | [diff] [blame] | 2070 | LIBYANG_API_DECL LY_ERR lys_find_path_atoms(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *path, |
| 2071 | ly_bool output, struct ly_set **set); |
Radek Krejci | bc5644c | 2020-10-27 14:53:17 +0100 | [diff] [blame] | 2072 | |
| 2073 | /** |
| 2074 | * @brief Get a schema node based on the given data path (JSON format, see @ref howtoXPath). |
| 2075 | * |
Michal Vasko | 2651268 | 2021-01-11 11:35:40 +0100 | [diff] [blame] | 2076 | * @param[in] ctx libyang context to use for absolute @p path. May be NULL if @p ctx_node is set. |
| 2077 | * @param[in] ctx_node XPath schema context node for relative @p path. Use NULL for the root node. |
Radek Krejci | bc5644c | 2020-10-27 14:53:17 +0100 | [diff] [blame] | 2078 | * @param[in] path JSON path of the node to get. |
| 2079 | * @param[in] output Search operation output instead of input. |
| 2080 | * @return Found schema node or NULL. |
| 2081 | */ |
Michal Vasko | c1a0ff6 | 2022-02-28 14:27:16 +0100 | [diff] [blame] | 2082 | LIBYANG_API_DECL const struct lysc_node *lys_find_path(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, |
| 2083 | const char *path, ly_bool output); |
Radek Krejci | bc5644c | 2020-10-27 14:53:17 +0100 | [diff] [blame] | 2084 | |
| 2085 | /** |
Michal Vasko | 03ff5a7 | 2019-09-11 13:49:33 +0200 | [diff] [blame] | 2086 | * @brief Types of the different schema paths. |
| 2087 | */ |
| 2088 | typedef enum { |
Michal Vasko | 65de040 | 2020-08-03 16:34:19 +0200 | [diff] [blame] | 2089 | LYSC_PATH_LOG, /**< Descriptive path format used in log messages */ |
Michal Vasko | bde22b6 | 2022-03-22 15:32:56 +0100 | [diff] [blame] | 2090 | LYSC_PATH_DATA, /**< Similar to ::LYSC_PATH_LOG except that schema-only nodes (choice, case) are skipped */ |
| 2091 | LYSC_PATH_DATA_PATTERN /**< Similar to ::LYSC_PATH_DATA but there are predicates for all list keys added with |
| 2092 | "%s" where their values should be so that they can be printed there */ |
Michal Vasko | 03ff5a7 | 2019-09-11 13:49:33 +0200 | [diff] [blame] | 2093 | } LYSC_PATH_TYPE; |
| 2094 | |
| 2095 | /** |
Radek Krejci | 327de16 | 2019-06-14 12:52:07 +0200 | [diff] [blame] | 2096 | * @brief Generate path of the given node in the requested format. |
| 2097 | * |
| 2098 | * @param[in] node Schema path of this node will be generated. |
| 2099 | * @param[in] pathtype Format of the path to generate. |
Radek Krejci | 1c0c344 | 2019-07-23 16:08:47 +0200 | [diff] [blame] | 2100 | * @param[in,out] buffer Prepared buffer of the @p buflen length to store the generated path. |
| 2101 | * If NULL, memory for the complete path is allocated. |
| 2102 | * @param[in] buflen Size of the provided @p buffer. |
Radek Krejci | 327de16 | 2019-06-14 12:52:07 +0200 | [diff] [blame] | 2103 | * @return NULL in case of memory allocation error, path of the node otherwise. |
Radek Krejci | 1c0c344 | 2019-07-23 16:08:47 +0200 | [diff] [blame] | 2104 | * In case the @p buffer is NULL, the returned string is dynamically allocated and caller is responsible to free it. |
Radek Krejci | 327de16 | 2019-06-14 12:52:07 +0200 | [diff] [blame] | 2105 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 2106 | LIBYANG_API_DECL char *lysc_path(const struct lysc_node *node, LYSC_PATH_TYPE pathtype, char *buffer, size_t buflen); |
Radek Krejci | 327de16 | 2019-06-14 12:52:07 +0200 | [diff] [blame] | 2107 | |
| 2108 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 2109 | * @brief Available YANG schema tree structures representing YANG module. |
| 2110 | */ |
| 2111 | struct lys_module { |
Radek Krejci | 0bcdaed | 2019-01-10 10:21:34 +0100 | [diff] [blame] | 2112 | struct ly_ctx *ctx; /**< libyang context of the module (mandatory) */ |
| 2113 | const char *name; /**< name of the module (mandatory) */ |
Radek Krejci | 0af4629 | 2019-01-11 16:02:31 +0100 | [diff] [blame] | 2114 | const char *revision; /**< revision of the module (if present) */ |
Radek Krejci | 0bcdaed | 2019-01-10 10:21:34 +0100 | [diff] [blame] | 2115 | const char *ns; /**< namespace of the module (module - mandatory) */ |
| 2116 | const char *prefix; /**< module prefix or submodule belongsto prefix of main module (mandatory) */ |
| 2117 | const char *filepath; /**< path, if the schema was read from a file, NULL in case of reading from memory */ |
| 2118 | const char *org; /**< party/company responsible for the module */ |
| 2119 | const char *contact; /**< contact information for the module */ |
| 2120 | const char *dsc; /**< description of the module */ |
| 2121 | const char *ref; /**< cross-reference for the module */ |
| 2122 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 2123 | struct lysp_module *parsed; /**< Simply parsed (unresolved) YANG schema tree */ |
Radek Krejci | 0af4629 | 2019-01-11 16:02:31 +0100 | [diff] [blame] | 2124 | struct lysc_module *compiled; /**< Compiled and fully validated YANG schema tree for data parsing. |
| 2125 | Available only for implemented modules. */ |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 2126 | |
Radek Krejci | 80d281e | 2020-09-14 17:42:54 +0200 | [diff] [blame] | 2127 | struct lysc_ident *identities; /**< List of compiled identities of the module ([sized array](@ref sizedarrays)) |
aPiecek | 6b3d542 | 2021-07-30 15:55:43 +0200 | [diff] [blame] | 2128 | also contains the disabled identities when their if-feature(s) are evaluated to \"false\", |
| 2129 | and also the list is filled even if the module is not implemented. |
| 2130 | The list is located here because it avoids problems when the module became implemented in |
Radek Krejci | 80d281e | 2020-09-14 17:42:54 +0200 | [diff] [blame] | 2131 | future (no matter if implicitly via augment/deviate or explicitly via |
| 2132 | ::lys_set_implemented()). Note that if the module is not implemented (compiled), the |
| 2133 | identities cannot be instantiated in data (in identityrefs). */ |
Michal Vasko | 7f45cf2 | 2020-10-01 12:49:44 +0200 | [diff] [blame] | 2134 | |
| 2135 | struct lys_module **augmented_by;/**< List of modules that augment this module ([sized array](@ref sizedarrays)) */ |
| 2136 | struct lys_module **deviated_by; /**< List of modules that deviate this module ([sized array](@ref sizedarrays)) */ |
| 2137 | |
Michal Vasko | 89b5c07 | 2020-10-06 13:52:44 +0200 | [diff] [blame] | 2138 | ly_bool implemented; /**< flag if the module is implemented, not just imported */ |
Michal Vasko | 01db7de | 2021-04-16 12:23:30 +0200 | [diff] [blame] | 2139 | ly_bool to_compile; /**< flag marking a module that was changed but not (re)compiled, see |
| 2140 | ::LY_CTX_EXPLICIT_COMPILE. */ |
aPiecek | 8ca21bd | 2021-07-26 14:31:01 +0200 | [diff] [blame] | 2141 | uint8_t latest_revision; /**< Flag to mark the latest available revision, see [latest_revision options](@ref latestrevflags). */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 2142 | }; |
| 2143 | |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 2144 | /** |
aPiecek | 8ca21bd | 2021-07-26 14:31:01 +0200 | [diff] [blame] | 2145 | * @defgroup latestrevflags Options for ::lys_module.latest_revision. |
| 2146 | * |
| 2147 | * Various information bits of ::lys_module.latest_revision. |
| 2148 | * |
| 2149 | * @{ |
| 2150 | */ |
aPiecek | 94d330b | 2021-08-04 11:57:31 +0200 | [diff] [blame] | 2151 | #define LYS_MOD_LATEST_REV 0x01 /**< This is the latest revision of the module in the current context. */ |
| 2152 | #define LYS_MOD_LATEST_SEARCHDIRS 0x02 /**< This is the latest revision of the module found in searchdirs. */ |
Michal Vasko | bdac23f | 2022-01-12 14:02:35 +0100 | [diff] [blame] | 2153 | #define LYS_MOD_IMPORTED_REV 0x04 /**< This is the module revision used when importing the module without |
| 2154 | an explicit revision-date. It is used for all such imports regardless of |
| 2155 | any changes made in the context. */ |
| 2156 | #define LYS_MOD_LATEST_IMPCLB 0x08 /**< This is the latest revision of the module obtained from import callback. */ |
aPiecek | 8ca21bd | 2021-07-26 14:31:01 +0200 | [diff] [blame] | 2157 | /** @} latestrevflags */ |
| 2158 | |
| 2159 | /** |
Michal Vasko | 82c31e6 | 2020-07-17 15:30:40 +0200 | [diff] [blame] | 2160 | * @brief Get the current real status of the specified feature in the module. |
| 2161 | * |
| 2162 | * If the feature is enabled, but some of its if-features are false, the feature is considered |
| 2163 | * disabled. |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 2164 | * |
| 2165 | * @param[in] module Module where the feature is defined. |
| 2166 | * @param[in] feature Name of the feature to inspect. |
Michal Vasko | 82c31e6 | 2020-07-17 15:30:40 +0200 | [diff] [blame] | 2167 | * @return LY_SUCCESS if the feature is enabled, |
| 2168 | * @return LY_ENOT if the feature is disabled, |
| 2169 | * @return LY_ENOTFOUND if the feature was not found. |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 2170 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 2171 | LIBYANG_API_DECL LY_ERR lys_feature_value(const struct lys_module *module, const char *feature); |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 2172 | |
| 2173 | /** |
Michal Vasko | 3608d25 | 2022-02-28 14:28:12 +0100 | [diff] [blame] | 2174 | * @brief Get next schema (sibling) node element in the schema order that can be instantiated in a data tree. |
| 2175 | * Returned node may be from an augment. |
Radek Krejci | a304538 | 2018-11-22 14:30:31 +0100 | [diff] [blame] | 2176 | * |
Michal Vasko | 3608d25 | 2022-02-28 14:28:12 +0100 | [diff] [blame] | 2177 | * ::lys_getnext() is supposed to be called sequentially. In the first call, the @p last parameter is usually NULL |
| 2178 | * and function starts returning 1) the first @p parent child (if it is set) or 2) the first top level element of |
| 2179 | * @p module. Consequent calls should provide the previously returned node as @p last and the same @p parent and |
| 2180 | * @p module parameters. |
Radek Krejci | a304538 | 2018-11-22 14:30:31 +0100 | [diff] [blame] | 2181 | * |
| 2182 | * Without options, the function is used to traverse only the schema nodes that can be paired with corresponding |
Michal Vasko | 3608d25 | 2022-02-28 14:28:12 +0100 | [diff] [blame] | 2183 | * data nodes in a data tree. By setting some @p options the behavior can be modified to the extent that |
Radek Krejci | a304538 | 2018-11-22 14:30:31 +0100 | [diff] [blame] | 2184 | * all the schema nodes are iteratively returned. |
| 2185 | * |
| 2186 | * @param[in] last Previously returned schema tree node, or NULL in case of the first call. |
Michal Vasko | 3608d25 | 2022-02-28 14:28:12 +0100 | [diff] [blame] | 2187 | * @param[in] parent Parent of the subtree to iterate over. If set, @p module is ignored. |
| 2188 | * @param[in] module Module of the top level elements to iterate over. If @p parent is NULL, it must be specified. |
Radek Krejci | a304538 | 2018-11-22 14:30:31 +0100 | [diff] [blame] | 2189 | * @param[in] options [ORed options](@ref sgetnextflags). |
Michal Vasko | 3608d25 | 2022-02-28 14:28:12 +0100 | [diff] [blame] | 2190 | * @return Next schema tree node, NULL in case there are no more. |
Radek Krejci | a304538 | 2018-11-22 14:30:31 +0100 | [diff] [blame] | 2191 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 2192 | LIBYANG_API_DECL const struct lysc_node *lys_getnext(const struct lysc_node *last, const struct lysc_node *parent, |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 2193 | const struct lysc_module *module, uint32_t options); |
Radek Krejci | a304538 | 2018-11-22 14:30:31 +0100 | [diff] [blame] | 2194 | |
| 2195 | /** |
Michal Vasko | 3608d25 | 2022-02-28 14:28:12 +0100 | [diff] [blame] | 2196 | * @brief Get next schema (sibling) node element in the schema order of an extension that can be instantiated in |
| 2197 | * a data tree. |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 2198 | * |
Michal Vasko | 3608d25 | 2022-02-28 14:28:12 +0100 | [diff] [blame] | 2199 | * It is just ::lys_getnext() for extensions. |
Radek Krejci | 035dacf | 2021-02-12 18:25:53 +0100 | [diff] [blame] | 2200 | * |
| 2201 | * @param[in] last Previously returned schema tree node, or NULL in case of the first call. |
Michal Vasko | 3608d25 | 2022-02-28 14:28:12 +0100 | [diff] [blame] | 2202 | * @param[in] parent Parent of the subtree to iterate over. If set, @p ext is ignored. |
| 2203 | * @param[in] ext Extension instance with schema nodes to iterate over. If @p parent is NULL, it must be specified. |
Radek Krejci | 035dacf | 2021-02-12 18:25:53 +0100 | [diff] [blame] | 2204 | * @param[in] options [ORed options](@ref sgetnextflags). |
Michal Vasko | 3608d25 | 2022-02-28 14:28:12 +0100 | [diff] [blame] | 2205 | * @return Next schema tree node, NULL in case there are no more. |
Radek Krejci | 035dacf | 2021-02-12 18:25:53 +0100 | [diff] [blame] | 2206 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 2207 | LIBYANG_API_DECL const struct lysc_node *lys_getnext_ext(const struct lysc_node *last, const struct lysc_node *parent, |
Radek Krejci | 035dacf | 2021-02-12 18:25:53 +0100 | [diff] [blame] | 2208 | const struct lysc_ext_instance *ext, uint32_t options); |
| 2209 | |
| 2210 | /** |
| 2211 | * @defgroup sgetnextflags Options for ::lys_getnext() and ::lys_getnext_ext(). |
| 2212 | * |
| 2213 | * Various options setting behavior of ::lys_getnext() and ::lys_getnext_ext(). |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 2214 | * |
Radek Krejci | a304538 | 2018-11-22 14:30:31 +0100 | [diff] [blame] | 2215 | * @{ |
| 2216 | */ |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 2217 | #define LYS_GETNEXT_WITHCHOICE 0x01 /**< ::lys_getnext() option to allow returning #LYS_CHOICE nodes instead of looking into them */ |
| 2218 | #define LYS_GETNEXT_NOCHOICE 0x02 /**< ::lys_getnext() option to ignore (kind of conditional) nodes within choice node */ |
| 2219 | #define LYS_GETNEXT_WITHCASE 0x04 /**< ::lys_getnext() option to allow returning #LYS_CASE nodes instead of looking into them */ |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 2220 | #define LYS_GETNEXT_INTONPCONT 0x08 /**< ::lys_getnext() option to look into non-presence container, instead of returning container itself */ |
| 2221 | #define LYS_GETNEXT_OUTPUT 0x10 /**< ::lys_getnext() option to provide RPC's/action's output schema nodes instead of input schema nodes |
Radek Krejci | 6eeb58f | 2019-02-22 16:29:37 +0100 | [diff] [blame] | 2222 | provided by default */ |
Michal Vasko | e482bb9 | 2023-02-01 11:41:41 +0100 | [diff] [blame] | 2223 | #define LYS_GETNEXT_WITHSCHEMAMOUNT 0x20 /**< ::lys_getnext() option to also traverse top-level nodes of all the mounted modules |
| 2224 | on the parent mount point but note that if any such nodes are returned, |
| 2225 | the caller **must free** their context */ |
Radek Krejci | a304538 | 2018-11-22 14:30:31 +0100 | [diff] [blame] | 2226 | /** @} sgetnextflags */ |
| 2227 | |
| 2228 | /** |
| 2229 | * @brief Get child node according to the specified criteria. |
| 2230 | * |
| 2231 | * @param[in] parent Optional parent of the node to find. If not specified, the module's top-level nodes are searched. |
| 2232 | * @param[in] module module of the node to find. It is also limitation for the children node of the given parent. |
| 2233 | * @param[in] name Name of the node to find. |
| 2234 | * @param[in] name_len Optional length of the name in case it is not NULL-terminated string. |
| 2235 | * @param[in] nodetype Optional criteria (to speedup) specifying nodetype(s) of the node to find. |
| 2236 | * Used as a bitmask, so multiple nodetypes can be specified. |
| 2237 | * @param[in] options [ORed options](@ref sgetnextflags). |
| 2238 | * @return Found node if any. |
| 2239 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 2240 | LIBYANG_API_DECL const struct lysc_node *lys_find_child(const struct lysc_node *parent, const struct lys_module *module, |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 2241 | const char *name, size_t name_len, uint16_t nodetype, uint32_t options); |
Radek Krejci | a304538 | 2018-11-22 14:30:31 +0100 | [diff] [blame] | 2242 | |
| 2243 | /** |
Radek Krejci | 77a8bcd | 2019-09-11 11:20:02 +0200 | [diff] [blame] | 2244 | * @brief Make the specific module implemented. |
| 2245 | * |
Michal Vasko | e8988e9 | 2021-01-25 11:26:29 +0100 | [diff] [blame] | 2246 | * If the module is already implemented but with a different set of features, the whole context is recompiled. |
| 2247 | * |
Radek Krejci | 77a8bcd | 2019-09-11 11:20:02 +0200 | [diff] [blame] | 2248 | * @param[in] mod Module to make implemented. It is not an error |
| 2249 | * to provide already implemented module, it just does nothing. |
Michal Vasko | e8988e9 | 2021-01-25 11:26:29 +0100 | [diff] [blame] | 2250 | * @param[in] features Optional array specifying the enabled features terminated with NULL overriding any previous |
| 2251 | * feature setting. The feature string '*' enables all the features and array of length 1 with only the terminating |
| 2252 | * NULL explicitly disables all the features. In case the parameter is NULL, the features are untouched - left disabled |
| 2253 | * in a newly implemented module or with the current features settings in case the module is already implemented. |
Michal Vasko | e444f75 | 2020-02-10 12:20:06 +0100 | [diff] [blame] | 2254 | * @return LY_SUCCESS on success. |
| 2255 | * @return LY_EDENIED in case the context contains some other revision of the same module which is already implemented. |
Michal Vasko | 7b1ad1a | 2020-11-02 15:41:27 +0100 | [diff] [blame] | 2256 | * @return LY_ERR on other errors during module compilation. |
Radek Krejci | 77a8bcd | 2019-09-11 11:20:02 +0200 | [diff] [blame] | 2257 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 2258 | LIBYANG_API_DECL LY_ERR lys_set_implemented(struct lys_module *mod, const char **features); |
Radek Krejci | a304538 | 2018-11-22 14:30:31 +0100 | [diff] [blame] | 2259 | |
Radek Krejci | 084289f | 2019-07-09 17:35:30 +0200 | [diff] [blame] | 2260 | /** |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 2261 | * @brief Stringify schema nodetype. |
Michal Vasko | d43d71a | 2020-08-07 14:54:58 +0200 | [diff] [blame] | 2262 | * |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 2263 | * @param[in] nodetype Nodetype to stringify. |
| 2264 | * @return Constant string with the name of the node's type. |
| 2265 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 2266 | LIBYANG_API_DECL const char *lys_nodetype2str(uint16_t nodetype); |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 2267 | |
Michal Vasko | d43d71a | 2020-08-07 14:54:58 +0200 | [diff] [blame] | 2268 | /** |
| 2269 | * @brief Getter for original XPath expression from a parsed expression. |
| 2270 | * |
| 2271 | * @param[in] path Parsed expression. |
| 2272 | * @return Original string expression. |
| 2273 | */ |
Jan Kundrát | c53a7ec | 2021-12-09 16:01:19 +0100 | [diff] [blame] | 2274 | LIBYANG_API_DECL const char *lyxp_get_expr(const struct lyxp_expr *path); |
Michal Vasko | d43d71a | 2020-08-07 14:54:58 +0200 | [diff] [blame] | 2275 | |
Radek Krejci | 2ff0d57 | 2020-05-21 15:27:28 +0200 | [diff] [blame] | 2276 | /** @} schematree */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 2277 | |
Radek Krejci | 70853c5 | 2018-10-15 14:46:16 +0200 | [diff] [blame] | 2278 | #ifdef __cplusplus |
| 2279 | } |
| 2280 | #endif |
| 2281 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 2282 | #endif /* LY_TREE_SCHEMA_H_ */ |