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