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 | |
| 18 | #include <stdint.h> |
| 19 | |
| 20 | /** |
| 21 | * @defgroup schematree Schema Tree |
| 22 | * @{ |
| 23 | * |
| 24 | * Data structures and functions to manipulate and access schema tree. |
| 25 | */ |
| 26 | |
Radek Krejci | 0af5f5d | 2018-09-07 15:00:30 +0200 | [diff] [blame] | 27 | /** |
Radek Krejci | 5fac359 | 2018-10-12 15:23:45 +0200 | [diff] [blame] | 28 | * @brief Helper macro to go through 0-terminated arrays |
| 29 | * |
| 30 | * Use with opening curly bracket '{'. |
| 31 | * |
| 32 | * @param[in] ARRAY Array to go through |
| 33 | * @param[out] ITER Numeric iterator storing available indexes of the ARRAY |
| 34 | */ |
Michal Vasko | 4f3980b | 2018-10-15 10:50:48 +0200 | [diff] [blame] | 35 | #define LY_ARRAY_FOR(ARRAY, ITER) for (ITER = 0; (ARRAY) && *((void **)((ARRAY) + ITER)); ++ITER) |
Radek Krejci | 5fac359 | 2018-10-12 15:23:45 +0200 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * @brief Macro to iterate via all sibling elements without affecting the list itself |
| 39 | * |
| 40 | * Works for all types of nodes despite it is data or schema tree, but all the |
| 41 | * parameters must be pointers to the same type. |
| 42 | * |
| 43 | * Use with opening curly bracket '{'. All parameters must be of the same type. |
| 44 | * |
| 45 | * @param START Pointer to the starting element. |
| 46 | * @param ELEM Iterator. |
| 47 | */ |
| 48 | #define LY_LIST_FOR(START, ELEM) \ |
| 49 | for ((ELEM) = (START); \ |
| 50 | (ELEM); \ |
| 51 | (ELEM) = (ELEM)->next) |
| 52 | |
| 53 | /** |
| 54 | * @ingroup datatree |
| 55 | * @brief Macro to iterate via all sibling elements allowing to modify the list itself (e.g. removing elements) |
| 56 | * |
| 57 | * Use with opening curly bracket '{'. All parameters must be of the same type. |
| 58 | * |
| 59 | * @param START Pointer to the starting element. |
| 60 | * @param NEXT Temporary storage to allow removing of the current iterator content. |
| 61 | * @param ELEM Iterator. |
| 62 | */ |
| 63 | #define LY_LIST_FOR_SAFE(START, NEXT, ELEM) \ |
| 64 | for ((ELEM) = (START); \ |
| 65 | (ELEM) ? (NEXT = (ELEM)->next, 1) : 0; \ |
| 66 | (ELEM) = (NEXT)) |
| 67 | |
| 68 | /** |
Radek Krejci | 0af5f5d | 2018-09-07 15:00:30 +0200 | [diff] [blame] | 69 | * @brief Schema input formats accepted by libyang [parser functions](@ref howtoschemasparsers). |
| 70 | */ |
| 71 | typedef enum { |
| 72 | LYS_IN_UNKNOWN = 0, /**< unknown format, used as return value in case of error */ |
| 73 | LYS_IN_YANG = 1, /**< YANG schema input format */ |
| 74 | LYS_IN_YIN = 2 /**< YIN schema input format */ |
| 75 | } LYS_INFORMAT; |
| 76 | |
| 77 | /** |
| 78 | * @brief Schema output formats accepted by libyang [printer functions](@ref howtoschemasprinters). |
| 79 | */ |
| 80 | typedef enum { |
| 81 | LYS_OUT_UNKNOWN = 0, /**< unknown format, used as return value in case of error */ |
| 82 | LYS_OUT_YANG = 1, /**< YANG schema output format */ |
| 83 | LYS_OUT_YIN = 2, /**< YIN schema output format */ |
| 84 | LYS_OUT_TREE, /**< Tree schema output format, for more information see the [printers](@ref howtoschemasprinters) page */ |
| 85 | LYS_OUT_INFO, /**< Info schema output format, for more information see the [printers](@ref howtoschemasprinters) page */ |
| 86 | LYS_OUT_JSON, /**< JSON schema output format, reflecting YIN format with conversion of attributes to object's members */ |
| 87 | } LYS_OUTFORMAT; |
| 88 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 89 | #define LY_REV_SIZE 11 /**< revision data string length (including terminating NULL byte) */ |
| 90 | |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 91 | #define LYS_UNKNOWN 0x0000 /**< uninitalized unknown statement node */ |
| 92 | #define LYS_CONTAINER 0x0001 /**< container statement node */ |
| 93 | #define LYS_CHOICE 0x0002 /**< choice statement node */ |
| 94 | #define LYS_LEAF 0x0004 /**< leaf statement node */ |
| 95 | #define LYS_LEAFLIST 0x0008 /**< leaf-list statement node */ |
| 96 | #define LYS_LIST 0x0010 /**< list statement node */ |
| 97 | #define LYS_ANYXML 0x0020 /**< anyxml statement node */ |
| 98 | #define LYS_CASE 0x0040 /**< case statement node */ |
| 99 | #define LYS_USES 0x0080 /**< uses statement node */ |
| 100 | #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] | 101 | |
| 102 | /** |
| 103 | * @brief YANG import-stmt |
| 104 | */ |
| 105 | struct lysp_import { |
Michal Vasko | d5927ca | 2018-09-07 15:05:32 +0200 | [diff] [blame] | 106 | const char *name; /**< name of the module to import (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 107 | const char *prefix; /**< prefix for the data from the imported schema (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 108 | const char *dsc; /**< description */ |
| 109 | const char *ref; /**< reference */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 110 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 111 | char rev[LY_REV_SIZE]; /**< revision-date of the imported module */ |
| 112 | }; |
| 113 | |
| 114 | /** |
| 115 | * @brief YANG include-stmt |
| 116 | */ |
| 117 | struct lysp_include { |
Michal Vasko | d5927ca | 2018-09-07 15:05:32 +0200 | [diff] [blame] | 118 | const char *name; /**< name of the submodule to include (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 119 | const char *dsc; /**< description */ |
| 120 | const char *ref; /**< reference */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 121 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 122 | char rev[LY_REV_SIZE]; /**< revision-date of the included submodule */ |
| 123 | }; |
| 124 | |
| 125 | /** |
| 126 | * @brief YANG extension-stmt |
| 127 | */ |
| 128 | struct lysp_ext { |
| 129 | const char *name; /**< extension name */ |
| 130 | const char *argument; /**< argument name, NULL if not specified */ |
| 131 | const char *dsc; /**< description statement */ |
| 132 | const char *ref; /**< reference statement */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 133 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 134 | uint16_t flags; /**< LYS_STATUS_* and LYS_YINELEM values (@ref snodeflags) */ |
| 135 | }; |
| 136 | |
| 137 | /** |
| 138 | * @brief Helper structure for generic storage of the extension instances content. |
| 139 | */ |
| 140 | struct lysp_stmt { |
| 141 | const char *stmt; /**< identifier of the statement */ |
| 142 | const char *arg; /**< statement's argument */ |
| 143 | struct lysp_stmt *next; /**< link to the next statement */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 144 | struct lysp_stmt *child; /**< list of the statement's substatements (linked list) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 145 | }; |
| 146 | |
| 147 | /** |
Michal Vasko | d92e42a | 2018-09-07 08:35:02 +0200 | [diff] [blame] | 148 | * @brief Enum of substatements in which extension instances can appear. |
| 149 | */ |
| 150 | typedef enum { |
| 151 | LYEXT_SUBSTMT_SELF = 0, /**< extension of the structure itself, not substatement's */ |
| 152 | LYEXT_SUBSTMT_ARGUMENT, /**< extension of the argument statement, can appear in lys_ext */ |
| 153 | LYEXT_SUBSTMT_BASE, /**< extension of the base statement, can appear (repeatedly) in lys_type and lys_ident */ |
| 154 | LYEXT_SUBSTMT_BELONGSTO, /**< extension of the belongs-to statement, can appear in lys_submodule */ |
| 155 | LYEXT_SUBSTMT_CONTACT, /**< extension of the contact statement, can appear in lys_module */ |
| 156 | LYEXT_SUBSTMT_DEFAULT, /**< extension of the default statement, can appear in lys_node_leaf, lys_node_leaflist, |
| 157 | lys_node_choice and lys_deviate */ |
| 158 | LYEXT_SUBSTMT_DESCRIPTION, /**< extension of the description statement, can appear in lys_module, lys_submodule, |
| 159 | lys_node, lys_import, lys_include, lys_ext, lys_feature, lys_tpdf, lys_restr, |
| 160 | lys_ident, lys_deviation, lys_type_enum, lys_type_bit, lys_when and lys_revision */ |
| 161 | LYEXT_SUBSTMT_ERRTAG, /**< extension of the error-app-tag statement, can appear in lys_restr */ |
| 162 | LYEXT_SUBSTMT_ERRMSG, /**< extension of the error-message statement, can appear in lys_restr */ |
| 163 | LYEXT_SUBSTMT_KEY, /**< extension of the key statement, can appear in lys_node_list */ |
| 164 | LYEXT_SUBSTMT_NAMESPACE, /**< extension of the namespace statement, can appear in lys_module */ |
| 165 | LYEXT_SUBSTMT_ORGANIZATION, /**< extension of the organization statement, can appear in lys_module and lys_submodule */ |
| 166 | LYEXT_SUBSTMT_PATH, /**< extension of the path statement, can appear in lys_type */ |
| 167 | LYEXT_SUBSTMT_PREFIX, /**< extension of the prefix statement, can appear in lys_module, lys_submodule (for |
| 168 | belongs-to's prefix) and lys_import */ |
| 169 | LYEXT_SUBSTMT_PRESENCE, /**< extension of the presence statement, can appear in lys_node_container */ |
| 170 | LYEXT_SUBSTMT_REFERENCE, /**< extension of the reference statement, can appear in lys_module, lys_submodule, |
| 171 | lys_node, lys_import, lys_include, lys_revision, lys_tpdf, lys_restr, lys_ident, |
| 172 | lys_ext, lys_feature, lys_deviation, lys_type_enum, lys_type_bit and lys_when */ |
| 173 | LYEXT_SUBSTMT_REVISIONDATE, /**< extension of the revision-date statement, can appear in lys_import and lys_include */ |
| 174 | LYEXT_SUBSTMT_UNITS, /**< extension of the units statement, can appear in lys_tpdf, lys_node_leaf, |
| 175 | lys_node_leaflist and lys_deviate */ |
| 176 | LYEXT_SUBSTMT_VALUE, /**< extension of the value statement, can appear in lys_type_enum */ |
| 177 | LYEXT_SUBSTMT_VERSION, /**< extension of the yang-version statement, can appear in lys_module and lys_submodule */ |
| 178 | LYEXT_SUBSTMT_MODIFIER, /**< extension of the modifier statement, can appear in lys_restr */ |
| 179 | LYEXT_SUBSTMT_REQINSTANCE, /**< extension of the require-instance statement, can appear in lys_type */ |
| 180 | LYEXT_SUBSTMT_YINELEM, /**< extension of the yin-element statement, can appear in lys_ext */ |
| 181 | LYEXT_SUBSTMT_CONFIG, /**< extension of the config statement, can appear in lys_node and lys_deviate */ |
| 182 | LYEXT_SUBSTMT_MANDATORY, /**< extension of the mandatory statement, can appear in lys_node_leaf, lys_node_choice, |
| 183 | lys_node_anydata and lys_deviate */ |
| 184 | LYEXT_SUBSTMT_ORDEREDBY, /**< extension of the ordered-by statement, can appear in lys_node_list and lys_node_leaflist */ |
| 185 | LYEXT_SUBSTMT_STATUS, /**< extension of the status statement, can appear in lys_tpdf, lys_node, lys_ident, |
| 186 | lys_ext, lys_feature, lys_type_enum and lys_type_bit */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 187 | LYEXT_SUBSTMT_FRACDIGITS, /**< extension of the fraction-digits statement, can appear in lys_type */ |
Michal Vasko | d92e42a | 2018-09-07 08:35:02 +0200 | [diff] [blame] | 188 | LYEXT_SUBSTMT_MAX, /**< extension of the max-elements statement, can appear in lys_node_list, |
| 189 | lys_node_leaflist and lys_deviate */ |
| 190 | LYEXT_SUBSTMT_MIN, /**< extension of the min-elements statement, can appear in lys_node_list, |
| 191 | lys_node_leaflist and lys_deviate */ |
| 192 | LYEXT_SUBSTMT_POSITION, /**< extension of the position statement, can appear in lys_type_bit */ |
| 193 | LYEXT_SUBSTMT_UNIQUE, /**< extension of the unique statement, can appear in lys_node_list and lys_deviate */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 194 | LYEXT_SUBSTMT_IFFEATURE, /**< extension of the if-feature statement */ |
Michal Vasko | d92e42a | 2018-09-07 08:35:02 +0200 | [diff] [blame] | 195 | } LYEXT_SUBSTMT; |
| 196 | |
| 197 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 198 | * @brief YANG extension instance |
| 199 | */ |
| 200 | struct lysp_ext_instance { |
| 201 | const char *name; /**< extension identifier, including possible prefix */ |
| 202 | const char *argument; /**< optional value of the extension's argument */ |
Michal Vasko | d92e42a | 2018-09-07 08:35:02 +0200 | [diff] [blame] | 203 | LYEXT_SUBSTMT insubstmt; /**< value identifying placement of the extension instance */ |
| 204 | uint32_t insubstmt_index; /**< in case the instance is in a substatement, this identifies |
| 205 | the index of that substatement */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 206 | struct lysp_stmt *child; /**< list of the extension's substatements (linked list) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 207 | }; |
| 208 | |
| 209 | /** |
| 210 | * @brief YANG feature-stmt |
| 211 | */ |
| 212 | struct lysp_feature { |
| 213 | const char *name; /**< feature name (mandatory) */ |
| 214 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 215 | const char *dsc; /**< description statement */ |
| 216 | const char *ref; /**< reference statement */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 217 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 218 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values allowed */ |
| 219 | }; |
| 220 | |
| 221 | /** |
| 222 | * @brief YANG identity-stmt |
| 223 | */ |
| 224 | struct lysp_ident { |
| 225 | const char *name; /**< identity name (mandatory), including possible prefix */ |
| 226 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 227 | const char **bases; /**< list of base identifiers (NULL-terminated) */ |
| 228 | const char *dsc; /**< description statement */ |
| 229 | const char *ref; /**< reference statement */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 230 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 231 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ values are allowed */ |
| 232 | }; |
| 233 | |
Michal Vasko | 71e64ca | 2018-09-07 16:30:29 +0200 | [diff] [blame] | 234 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 235 | * @brief Covers restrictions: range, length, pattern, must |
| 236 | */ |
| 237 | struct lysp_restr { |
| 238 | const char *arg; /**< The restriction expression/value (mandatory); |
| 239 | in case of pattern restriction, the first byte has a special meaning: |
| 240 | 0x06 (ACK) for regular match and 0x15 (NACK) for invert-match */ |
| 241 | const char *emsg; /**< error-message */ |
| 242 | const char *eapptag; /**< error-app-tag value */ |
| 243 | const char *dsc; /**< description */ |
| 244 | const char *ref; /**< reference */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 245 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 246 | }; |
| 247 | |
| 248 | /** |
Michal Vasko | 71e64ca | 2018-09-07 16:30:29 +0200 | [diff] [blame] | 249 | * @brief YANG revision-stmt |
| 250 | */ |
| 251 | struct lysp_revision { |
| 252 | char rev[LY_REV_SIZE]; /**< revision date (madatory) */ |
| 253 | const char *dsc; /**< description statement */ |
| 254 | const char *ref; /**< reference statement */ |
| 255 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
| 256 | }; |
| 257 | |
| 258 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 259 | * @brief Enumeration/Bit value definition |
| 260 | */ |
| 261 | struct lysp_type_enum { |
| 262 | const char *name; /**< name (mandatory) */ |
| 263 | const char *dsc; /**< description statement */ |
| 264 | const char *ref; /**< reference statement */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 265 | int64_t value; /**< enum's value or bit's position */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 266 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 267 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 268 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ and LYS_SET_VALUE |
| 269 | values are allowed */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 270 | }; |
| 271 | |
| 272 | /** |
| 273 | * @brief YANG type-stmt |
| 274 | * |
| 275 | * Some of the items in the structure may be mandatory, but it is necessary to resolve the type's base type first |
| 276 | */ |
| 277 | struct lysp_type { |
| 278 | const char *name; /**< name of the type (mandatory) */ |
| 279 | struct lysp_restr *range; /**< allowed values range - numerical, decimal64 */ |
| 280 | struct lysp_restr *length; /**< allowed length of the value - string, binary */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 281 | struct lysp_restr *patterns; /**< list of patterns (0-terminated) - string */ |
| 282 | struct lysp_type_enum *enums; /**< list of enum-stmts (0-terminated) - enum */ |
| 283 | struct lysp_type_enum *bits; /**< list of bit-stmts (0-terminated) - bits */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 284 | const char *path; /**< path - leafref */ |
| 285 | const char **bases; /**< list of base identifiers (NULL-terminated) - identityref */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 286 | struct lysp_type *types; /**< list of sub-types (0-terminated) - union */ |
| 287 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 288 | |
| 289 | uint8_t fraction_digits; /**< number of fraction digits - decimal64 */ |
| 290 | uint8_t require_instance; /**< require-instance flag - leafref, instance */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 291 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_SET_REQINST allowed */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 292 | }; |
| 293 | |
| 294 | /** |
| 295 | * @brief YANG typedef-stmt |
| 296 | */ |
| 297 | struct lysp_tpdf { |
| 298 | const char *name; /**< name of the newly defined type (mandatory) */ |
| 299 | const char *units; /**< units of the newly defined type */ |
| 300 | const char *dflt; /**< default value of the newly defined type */ |
| 301 | const char *dsc; /**< description statement */ |
| 302 | const char *ref; /**< reference statement */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 303 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 304 | struct lysp_type type; /**< base type from which the typedef is derived (mandatory) */ |
| 305 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values allowed */ |
| 306 | }; |
| 307 | |
| 308 | /** |
| 309 | * @brief YANG grouping-stmt |
| 310 | */ |
| 311 | struct lysp_grp { |
| 312 | const char *name; /**< grouping name (mandatory) */ |
| 313 | const char *dsc; /**< description statement */ |
| 314 | const char *ref; /**< reference statement */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 315 | struct lysp_tpdf *typedefs; /**< list of typedefs (0-terminated) */ |
| 316 | struct lysp_grp *groupings; /**< list of groupings (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 317 | struct lysp_node *data; /**< list of data nodes (linked list) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 318 | struct lysp_action *actions; /**< list of actions (0-terminated) */ |
| 319 | struct lysp_notif *notifs; /**< list of notifications (0-terminated) */ |
| 320 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 321 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */ |
| 322 | }; |
| 323 | |
| 324 | /** |
| 325 | * @brief YANG when-stmt |
| 326 | */ |
| 327 | struct lysp_when { |
| 328 | const char *cond; /**< specified condition (mandatory) */ |
| 329 | const char *dsc; /**< description statement */ |
| 330 | const char *ref; /**< reference statement */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 331 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 332 | }; |
| 333 | |
| 334 | /** |
| 335 | * @brief YANG refine-stmt |
| 336 | */ |
| 337 | struct lysp_refine { |
| 338 | const char *nodeid; /**< target descendant schema nodeid (mandatory) */ |
| 339 | const char *dsc; /**< description statement */ |
| 340 | const char *ref; /**< reference statement */ |
| 341 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 342 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 343 | const char *presence; /**< presence description */ |
| 344 | const char **dflts; /**< list of default values (NULL-terminated) */ |
| 345 | uint32_t min; /**< min-elements constraint */ |
| 346 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 347 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 348 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 349 | }; |
| 350 | |
| 351 | /** |
| 352 | * @brief YANG uses-augment-stmt and augment-stmt |
| 353 | */ |
| 354 | struct lysp_augment { |
| 355 | const char *nodeid; /**< target schema nodeid (mandatory) - absolute for global augments, descendant for uses's augments */ |
| 356 | const char *dsc; /**< description statement */ |
| 357 | const char *ref; /**< reference statement */ |
| 358 | struct lysp_when *when; /**< when statement */ |
| 359 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 360 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 361 | struct lysp_action *actions; /**< list of actions (0-terminated) */ |
| 362 | struct lysp_notif *notifs; /**< list of notifications (0-terminated) */ |
| 363 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 364 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */ |
| 365 | }; |
| 366 | |
| 367 | /** |
| 368 | * @defgroup deviatetypes Deviate types |
| 369 | * @{ |
| 370 | */ |
| 371 | #define LYS_DEV_NOT_SUPPORTED 1 /**< deviate type not-supported */ |
| 372 | #define LYS_DEV_ADD 2 /**< deviate type add */ |
| 373 | #define LYS_DEV_DELETE 3 /**< deviate type delete */ |
| 374 | #define LYS_DEV_REPLACE 4 /**< deviate type replace */ |
| 375 | /** @} */ |
| 376 | |
| 377 | /** |
| 378 | * @brief Generic deviate structure to get type and cast to lysp_deviate_* structure |
| 379 | */ |
| 380 | struct lysp_deviate { |
| 381 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 382 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 383 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 384 | }; |
| 385 | |
| 386 | struct lysp_deviate_add { |
| 387 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 388 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 389 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
| 390 | const char *units; /**< units of the values */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 391 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 392 | const char **uniques; /**< list of uniques specifications (NULL-terminated) */ |
| 393 | const char **dflts; /**< list of default values (NULL-terminated) */ |
| 394 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 395 | uint32_t min; /**< min-elements constraint */ |
| 396 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 397 | }; |
| 398 | |
| 399 | struct lysp_deviate_del { |
| 400 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 401 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 402 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
| 403 | const char *units; /**< units of the values */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 404 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 405 | const char **uniques; /**< list of uniques specifications (NULL-terminated) */ |
| 406 | const char **dflts; /**< list of default values (NULL-terminated) */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 407 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 408 | }; |
| 409 | |
| 410 | struct lysp_deviate_rpl { |
| 411 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 412 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 413 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
| 414 | struct lysp_type *type; /**< type of the node */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 415 | const char *units; /**< units of the values */ |
| 416 | const char *dflt; /**< default value */ |
| 417 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 418 | uint32_t min; /**< min-elements constraint */ |
| 419 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 420 | }; |
| 421 | |
| 422 | struct lysp_deviation { |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 423 | const char *nodeid; /**< target absolute schema nodeid (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 424 | const char *dsc; /**< description statement */ |
| 425 | const char *ref; /**< reference statement */ |
| 426 | struct lysp_deviate* deviates; /**< list of deviate specifications (linked list) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 427 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 428 | }; |
| 429 | |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 430 | #define LYS_CONFIG_W 0x01 /**< config true; */ |
| 431 | #define LYS_CONFIG_R 0x02 /**< config false; */ |
| 432 | #define LYS_CONFIG_MASK 0x03 /**< mask for config value */ |
| 433 | #define LYS_STATUS_CURR 0x08 /**< status current; */ |
| 434 | #define LYS_STATUS_DEPRC 0x10 /**< status deprecated; */ |
| 435 | #define LYS_STATUS_OBSLT 0x20 /**< status obsolete; */ |
| 436 | #define LYS_STATUS_MASK 0x38 /**< mask for status value */ |
| 437 | #define LYS_MAND_TRUE 0x40 /**< mandatory true; applicable only to |
| 438 | ::lys_node_choice, ::lys_node_leaf and ::lys_node_anydata */ |
| 439 | #define LYS_MAND_FALSE 0x80 /**< mandatory false; applicable only to |
| 440 | ::lys_node_choice, ::lys_node_leaf and ::lys_node_anydata */ |
| 441 | #define LYS_MAND_MASK 0xc0 /**< mask for mandatory values */ |
| 442 | #define LYS_ORDBY_SYSTEM 0x100 /**< ordered-by system lists, applicable only to |
| 443 | ::lys_node_list and ::lys_node_leaflist */ |
| 444 | #define LYS_ORDBY_USER 0x200 /**< ordered-by user lists, applicable only to |
| 445 | ::lys_node_list and ::lys_node_leaflist */ |
| 446 | #define LYS_ORDBY_MASK 0x300 /**< mask for ordered-by flags */ |
| 447 | #define LYS_FENABLED 0x100 /**< feature enabled flag, applicable only to ::lys_feature */ |
| 448 | #define LYS_AUTOASSIGNED 0x01 /**< value was auto-assigned, applicable only to |
| 449 | ::lys_type enum and bits flags */ |
| 450 | #define LYS_YINELEM_TRUE 0x01 /**< yin-element true for extension's argument */ |
| 451 | #define LYS_YINELEM_FALSE 0x02 /**< yin-element false for extension's argument */ |
| 452 | #define LYS_YINELEM_MASK 0x03 /**< mask for yin-element value */ |
| 453 | #define LYS_SET_VALUE 0x01 /**< value attribute is set */ |
| 454 | #define LYS_SET_MAX 0x400 /**< max attribute is set */ |
| 455 | #define LYS_SET_MIN 0x800 /**< min attribute is set */ |
| 456 | #define LYS_SET_REQINST 0x01 /**< require_instance attribute is set */ |
| 457 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 458 | /** |
| 459 | * @brief Generic YANG data node |
| 460 | */ |
| 461 | struct lysp_node { |
| 462 | uint16_t nodetype; /**< type of the node (mandatory) */ |
| 463 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 464 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 465 | const char *name; /**< node name (mandatory) */ |
| 466 | const char *dsc; /**< description statement */ |
| 467 | const char *ref; /**< reference statement */ |
| 468 | struct lysp_when *when; /**< when statement */ |
| 469 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 470 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 471 | }; |
| 472 | |
| 473 | /** |
| 474 | * @brief Extension structure of the lysp_node for YANG container |
| 475 | */ |
| 476 | struct lysp_node_container { |
| 477 | uint16_t nodetype; /**< LYS_CONTAINER */ |
| 478 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 479 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 480 | const char *name; /**< node name (mandatory) */ |
| 481 | const char *dsc; /**< description statement */ |
| 482 | const char *ref; /**< reference statement */ |
| 483 | struct lysp_when *when; /**< when statement */ |
| 484 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 485 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 486 | |
| 487 | /* container */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 488 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 489 | const char *presence; /**< presence description */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 490 | struct lysp_tpdf *typedefs; /**< list of typedefs (0-terminated) */ |
| 491 | struct lysp_grp *groupings; /**< list of groupings (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 492 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 493 | struct lysp_action *actions; /**< list of actions (0-terminated) */ |
| 494 | struct lysp_notif *notifs; /**< list of notifications (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 495 | }; |
| 496 | |
| 497 | struct lysp_node_leaf { |
| 498 | uint16_t nodetype; /**< LYS_LEAF */ |
| 499 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 500 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 501 | const char *name; /**< node name (mandatory) */ |
| 502 | const char *dsc; /**< description statement */ |
| 503 | const char *ref; /**< reference statement */ |
| 504 | struct lysp_when *when; /**< when statement */ |
| 505 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 506 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 507 | |
| 508 | /* leaf */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 509 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 510 | struct lysp_type type; /**< type of the leaf node (mandatory) */ |
| 511 | const char *units; /**< units of the leaf's type */ |
| 512 | const char *dflt; /**< default value */ |
| 513 | }; |
| 514 | |
| 515 | struct lysp_node_leaflist { |
| 516 | uint16_t nodetype; /**< LYS_LEAFLIST */ |
| 517 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 518 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 519 | const char *name; /**< node name (mandatory) */ |
| 520 | const char *dsc; /**< description statement */ |
| 521 | const char *ref; /**< reference statement */ |
| 522 | struct lysp_when *when; /**< when statement */ |
| 523 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 524 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 525 | |
| 526 | /* leaf-list */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 527 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 528 | struct lysp_type type; /**< type of the leaf node (mandatory) */ |
| 529 | const char *units; /**< units of the leaf's type */ |
| 530 | const char **dflts; /**< list of default values (NULL-terminated) */ |
| 531 | uint32_t min; /**< min-elements constraint */ |
| 532 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 533 | }; |
| 534 | |
| 535 | struct lysp_node_list { |
| 536 | uint16_t nodetype; /**< LYS_LIST */ |
| 537 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 538 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 539 | const char *name; /**< node name (mandatory) */ |
| 540 | const char *dsc; /**< description statement */ |
| 541 | const char *ref; /**< reference statement */ |
| 542 | struct lysp_when *when; /**< when statement */ |
| 543 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 544 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 545 | |
| 546 | /* list */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 547 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 548 | const char *key; /**< keys specification */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 549 | struct lysp_tpdf *typedefs; /**< list of typedefs (0-terminated) */ |
| 550 | struct lysp_grp *groupings; /**< list of groupings (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 551 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 552 | struct lysp_action *actions; /**< list of actions (0-terminated) */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 553 | struct lysp_notif *notifs; /**< list of notifications (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 554 | const char **uniques; /**< list of uniques specifications (NULL-terminated) */ |
| 555 | uint32_t min; /**< min-elements constraint */ |
| 556 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 557 | }; |
| 558 | |
| 559 | struct lysp_node_choice { |
| 560 | uint16_t nodetype; /**< LYS_CHOICE */ |
| 561 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 562 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 563 | const char *name; /**< node name (mandatory) */ |
| 564 | const char *dsc; /**< description statement */ |
| 565 | const char *ref; /**< reference statement */ |
| 566 | struct lysp_when *when; /**< when statement */ |
| 567 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 568 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 569 | |
| 570 | /* choice */ |
| 571 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
| 572 | const char* dflt; /**< default case */ |
| 573 | }; |
| 574 | |
| 575 | struct lysp_node_case { |
| 576 | uint16_t nodetype; /**< LYS_CASE */ |
| 577 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 578 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 579 | const char *name; /**< node name (mandatory) */ |
| 580 | const char *dsc; /**< description statement */ |
| 581 | const char *ref; /**< reference statement */ |
| 582 | struct lysp_when *when; /**< when statement */ |
| 583 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 584 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 585 | |
| 586 | /* case */ |
| 587 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
| 588 | }; |
| 589 | |
| 590 | struct lysp_node_anydata { |
| 591 | uint16_t nodetype; /**< LYS_ANYXML || LYS_ANYDATA */ |
| 592 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 593 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 594 | const char *name; /**< node name (mandatory) */ |
| 595 | const char *dsc; /**< description statement */ |
| 596 | const char *ref; /**< reference statement */ |
| 597 | struct lysp_when *when; /**< when statement */ |
| 598 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 599 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 600 | |
| 601 | /* anyxml/anydata */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 602 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 603 | }; |
| 604 | |
| 605 | struct lysp_node_uses { |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 606 | uint16_t nodetype; /**< LYS_USES */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 607 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 608 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 609 | const char *name; /**< grouping name reference (mandatory) */ |
| 610 | const char *dsc; /**< description statement */ |
| 611 | const char *ref; /**< reference statement */ |
| 612 | struct lysp_when *when; /**< when statement */ |
| 613 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 614 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 615 | |
| 616 | /* uses */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 617 | struct lysp_refine *refines; /**< list of uses's refines (0-terminated) */ |
| 618 | struct lysp_augment *augments; /**< list of uses's augment (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 619 | }; |
| 620 | |
| 621 | /** |
| 622 | * @brief YANG input-stmt and output-stmt |
| 623 | */ |
| 624 | struct lysp_action_inout { |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 625 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
| 626 | struct lysp_tpdf *typedefs; /**< list of typedefs (0-terminated) */ |
| 627 | struct lysp_grp *groupings; /**< list of groupings (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 628 | struct lysp_node *data; /**< list of data nodes (linked list) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 629 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 630 | }; |
| 631 | |
| 632 | /** |
| 633 | * @brief YANG rpc-stmt and action-stmt |
| 634 | */ |
| 635 | struct lysp_action { |
| 636 | const char *name; /**< grouping name reference (mandatory) */ |
| 637 | const char *dsc; /**< description statement */ |
| 638 | const char *ref; /**< reference statement */ |
| 639 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 640 | struct lysp_tpdf *typedefs; /**< list of typedefs (0-terminated) */ |
| 641 | struct lysp_grp *groupings; /**< list of groupings (0-terminated) */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 642 | struct lysp_action_inout *input; /**< RPC's/Action's input */ |
| 643 | struct lysp_action_inout *output;/**< RPC's/Action's output */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 644 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 645 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 646 | }; |
| 647 | |
| 648 | /** |
| 649 | * @brief YANG notification-stmt |
| 650 | */ |
| 651 | struct lysp_notif { |
| 652 | const char *name; /**< grouping name reference (mandatory) */ |
| 653 | const char *dsc; /**< description statement */ |
| 654 | const char *ref; /**< reference statement */ |
| 655 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 656 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
| 657 | struct lysp_tpdf *typedefs; /**< list of typedefs (0-terminated) */ |
| 658 | struct lysp_grp *groupings; /**< list of groupings (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 659 | struct lysp_node *data; /**< list of data nodes (linked list) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 660 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 661 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */ |
| 662 | }; |
| 663 | |
| 664 | /** |
Radek Krejci | f0fceb6 | 2018-09-05 14:58:45 +0200 | [diff] [blame] | 665 | * @brief supported YANG schema version values |
| 666 | */ |
| 667 | typedef enum LYS_VERSION { |
| 668 | LYS_VERSION_UNDEF = 0, /**< no specific version, YANG 1.0 as default */ |
| 669 | LYS_VERSION_1_0 = 1, /**< YANG 1.0 */ |
| 670 | LYS_VERSION_1_1 = 2 /**< YANG 1.1 */ |
| 671 | } LYS_VERSION; |
| 672 | |
| 673 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 674 | * @brief Printable YANG schema tree structure representing YANG module. |
| 675 | * |
| 676 | * Simple structure corresponding to the YANG format. The schema is only syntactically validated. |
| 677 | */ |
| 678 | struct lysp_module { |
| 679 | struct ly_ctx *ctx; /**< libyang context of the module (mandatory) */ |
| 680 | const char *name; /**< name of the module (mandatory) */ |
| 681 | const char *filepath; /**< path, if the schema was read from a file, NULL in case of reading from memory */ |
| 682 | union { |
| 683 | /* module */ |
Michal Vasko | d5927ca | 2018-09-07 15:05:32 +0200 | [diff] [blame] | 684 | const char *ns; /**< namespace of the module (module - mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 685 | /* submodule */ |
Michal Vasko | d5927ca | 2018-09-07 15:05:32 +0200 | [diff] [blame] | 686 | const char *belongsto; /**< belongs to parent module (submodule - mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 687 | }; |
Michal Vasko | d5927ca | 2018-09-07 15:05:32 +0200 | [diff] [blame] | 688 | const char *prefix; /**< module prefix or submodule belongsto prefix of main module (mandatory) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 689 | struct lysp_import *imports; /**< list of imported modules (0-terminated) */ |
| 690 | struct lysp_include *includes; /**< list of included submodules (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 691 | const char *org; /**< party/company responsible for the module */ |
| 692 | const char *contact; /**< contact information for the module */ |
| 693 | const char *dsc; /**< description of the module */ |
| 694 | const char *ref; /**< cross-reference for the module */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 695 | struct lysp_revision *revs; /**< list of the module revisions (0-terminated), the first revision |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 696 | in the list is always the last (newest) revision of the module */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 697 | struct lysp_ext *extensions; /**< list of extension statements (0-terminated) */ |
| 698 | struct lysp_feature *features; /**< list of feature definitions (0-terminated) */ |
| 699 | struct lysp_ident *identities; /**< list of identities (0-terminated) */ |
| 700 | struct lysp_tpdf *typedefs; /**< list of typedefs (0-terminated) */ |
| 701 | struct lysp_grp *groupings; /**< list of groupings (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 702 | struct lysp_node *data; /**< list of module's top-level data nodes (linked list) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 703 | struct lysp_augment *augments; /**< list of augments (0-terminated) */ |
| 704 | struct lysp_action *rpcs; /**< list of RPCs (0-terminated) */ |
| 705 | struct lysp_notif *notifs; /**< list of notifications (0-terminated) */ |
| 706 | struct lysp_deviation *deviations; /**< list of deviations (0-terminated) */ |
| 707 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 708 | |
Radek Krejci | f0fceb6 | 2018-09-05 14:58:45 +0200 | [diff] [blame] | 709 | uint8_t submodule:1; /**< flag to distinguish main modules and submodules */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 710 | uint8_t implemented:1; /**< flag if the module is implemented, not just imported */ |
| 711 | uint8_t latest_revision:1; /**< flag if the module was loaded without specific revision and is |
| 712 | the latest revision found */ |
Radek Krejci | f0fceb6 | 2018-09-05 14:58:45 +0200 | [diff] [blame] | 713 | uint8_t version:4; /**< yang-version (LYS_VERSION values) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 714 | }; |
| 715 | |
| 716 | /** |
Radek Krejci | 3f5e3db | 2018-10-11 15:57:47 +0200 | [diff] [blame] | 717 | * @brief Free the printable YANG schema tree structure. |
| 718 | * |
| 719 | * @param[in] module Printable YANG schema tree structure to free. |
| 720 | */ |
| 721 | void lysp_module_free(struct lysp_module *module); |
| 722 | |
| 723 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 724 | * @brief Compiled YANG schema tree structure representing YANG module. |
| 725 | * |
| 726 | * Semantically validated YANG schema tree for data tree parsing. |
| 727 | * Contains only the necessary information for the data validation. |
| 728 | */ |
| 729 | struct lysc_module { |
| 730 | }; |
| 731 | |
| 732 | /** |
Radek Krejci | 0af5f5d | 2018-09-07 15:00:30 +0200 | [diff] [blame] | 733 | * @brief Compiled YANG data node |
| 734 | */ |
| 735 | struct lysc_node { |
| 736 | }; |
| 737 | |
| 738 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 739 | * @brief Available YANG schema tree structures representing YANG module. |
| 740 | */ |
| 741 | struct lys_module { |
| 742 | struct lysp_module *parsed; /**< Simply parsed (unresolved) YANG schema tree */ |
| 743 | struct lysc_module *compiled; /**< Compiled and fully validated YANG schema tree for data parsing */ |
| 744 | }; |
| 745 | |
| 746 | /** @} */ |
| 747 | |
| 748 | #endif /* LY_TREE_SCHEMA_H_ */ |