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