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