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