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