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