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