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