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 | |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 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_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] | 60 | |
| 61 | /** |
| 62 | * @brief YANG import-stmt |
| 63 | */ |
| 64 | struct lysp_import { |
Michal Vasko | d5927ca | 2018-09-07 15:05:32 +0200 | [diff] [blame] | 65 | const char *name; /**< name of the module to import (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 66 | const char *prefix; /**< prefix for the data from the imported schema (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 67 | const char *dsc; /**< description */ |
| 68 | const char *ref; /**< reference */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 69 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 70 | char rev[LY_REV_SIZE]; /**< revision-date of the imported module */ |
| 71 | }; |
| 72 | |
| 73 | /** |
| 74 | * @brief YANG include-stmt |
| 75 | */ |
| 76 | struct lysp_include { |
Michal Vasko | d5927ca | 2018-09-07 15:05:32 +0200 | [diff] [blame] | 77 | const char *name; /**< name of the submodule to include (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 78 | const char *dsc; /**< description */ |
| 79 | const char *ref; /**< reference */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 80 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 81 | char rev[LY_REV_SIZE]; /**< revision-date of the included submodule */ |
| 82 | }; |
| 83 | |
| 84 | /** |
| 85 | * @brief YANG extension-stmt |
| 86 | */ |
| 87 | struct lysp_ext { |
| 88 | const char *name; /**< extension name */ |
| 89 | const char *argument; /**< argument name, NULL if not specified */ |
| 90 | const char *dsc; /**< description statement */ |
| 91 | const char *ref; /**< reference statement */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 92 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 93 | uint16_t flags; /**< LYS_STATUS_* and LYS_YINELEM values (@ref snodeflags) */ |
| 94 | }; |
| 95 | |
| 96 | /** |
| 97 | * @brief Helper structure for generic storage of the extension instances content. |
| 98 | */ |
| 99 | struct lysp_stmt { |
| 100 | const char *stmt; /**< identifier of the statement */ |
| 101 | const char *arg; /**< statement's argument */ |
| 102 | struct lysp_stmt *next; /**< link to the next statement */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 103 | struct lysp_stmt *child; /**< list of the statement's substatements (linked list) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | /** |
Michal Vasko | d92e42a | 2018-09-07 08:35:02 +0200 | [diff] [blame] | 107 | * @brief Enum of substatements in which extension instances can appear. |
| 108 | */ |
| 109 | typedef enum { |
| 110 | LYEXT_SUBSTMT_SELF = 0, /**< extension of the structure itself, not substatement's */ |
| 111 | LYEXT_SUBSTMT_ARGUMENT, /**< extension of the argument statement, can appear in lys_ext */ |
| 112 | LYEXT_SUBSTMT_BASE, /**< extension of the base statement, can appear (repeatedly) in lys_type and lys_ident */ |
| 113 | LYEXT_SUBSTMT_BELONGSTO, /**< extension of the belongs-to statement, can appear in lys_submodule */ |
| 114 | LYEXT_SUBSTMT_CONTACT, /**< extension of the contact statement, can appear in lys_module */ |
| 115 | LYEXT_SUBSTMT_DEFAULT, /**< extension of the default statement, can appear in lys_node_leaf, lys_node_leaflist, |
| 116 | lys_node_choice and lys_deviate */ |
| 117 | LYEXT_SUBSTMT_DESCRIPTION, /**< extension of the description statement, can appear in lys_module, lys_submodule, |
| 118 | lys_node, lys_import, lys_include, lys_ext, lys_feature, lys_tpdf, lys_restr, |
| 119 | lys_ident, lys_deviation, lys_type_enum, lys_type_bit, lys_when and lys_revision */ |
| 120 | LYEXT_SUBSTMT_ERRTAG, /**< extension of the error-app-tag statement, can appear in lys_restr */ |
| 121 | LYEXT_SUBSTMT_ERRMSG, /**< extension of the error-message statement, can appear in lys_restr */ |
| 122 | LYEXT_SUBSTMT_KEY, /**< extension of the key statement, can appear in lys_node_list */ |
| 123 | LYEXT_SUBSTMT_NAMESPACE, /**< extension of the namespace statement, can appear in lys_module */ |
| 124 | LYEXT_SUBSTMT_ORGANIZATION, /**< extension of the organization statement, can appear in lys_module and lys_submodule */ |
| 125 | LYEXT_SUBSTMT_PATH, /**< extension of the path statement, can appear in lys_type */ |
| 126 | LYEXT_SUBSTMT_PREFIX, /**< extension of the prefix statement, can appear in lys_module, lys_submodule (for |
| 127 | belongs-to's prefix) and lys_import */ |
| 128 | LYEXT_SUBSTMT_PRESENCE, /**< extension of the presence statement, can appear in lys_node_container */ |
| 129 | LYEXT_SUBSTMT_REFERENCE, /**< extension of the reference statement, can appear in lys_module, lys_submodule, |
| 130 | lys_node, lys_import, lys_include, lys_revision, lys_tpdf, lys_restr, lys_ident, |
| 131 | lys_ext, lys_feature, lys_deviation, lys_type_enum, lys_type_bit and lys_when */ |
| 132 | LYEXT_SUBSTMT_REVISIONDATE, /**< extension of the revision-date statement, can appear in lys_import and lys_include */ |
| 133 | LYEXT_SUBSTMT_UNITS, /**< extension of the units statement, can appear in lys_tpdf, lys_node_leaf, |
| 134 | lys_node_leaflist and lys_deviate */ |
| 135 | LYEXT_SUBSTMT_VALUE, /**< extension of the value statement, can appear in lys_type_enum */ |
| 136 | LYEXT_SUBSTMT_VERSION, /**< extension of the yang-version statement, can appear in lys_module and lys_submodule */ |
| 137 | LYEXT_SUBSTMT_MODIFIER, /**< extension of the modifier statement, can appear in lys_restr */ |
| 138 | LYEXT_SUBSTMT_REQINSTANCE, /**< extension of the require-instance statement, can appear in lys_type */ |
| 139 | LYEXT_SUBSTMT_YINELEM, /**< extension of the yin-element statement, can appear in lys_ext */ |
| 140 | LYEXT_SUBSTMT_CONFIG, /**< extension of the config statement, can appear in lys_node and lys_deviate */ |
| 141 | LYEXT_SUBSTMT_MANDATORY, /**< extension of the mandatory statement, can appear in lys_node_leaf, lys_node_choice, |
| 142 | lys_node_anydata and lys_deviate */ |
| 143 | LYEXT_SUBSTMT_ORDEREDBY, /**< extension of the ordered-by statement, can appear in lys_node_list and lys_node_leaflist */ |
| 144 | LYEXT_SUBSTMT_STATUS, /**< extension of the status statement, can appear in lys_tpdf, lys_node, lys_ident, |
| 145 | lys_ext, lys_feature, lys_type_enum and lys_type_bit */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 146 | 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] | 147 | LYEXT_SUBSTMT_MAX, /**< extension of the max-elements statement, can appear in lys_node_list, |
| 148 | lys_node_leaflist and lys_deviate */ |
| 149 | LYEXT_SUBSTMT_MIN, /**< extension of the min-elements statement, can appear in lys_node_list, |
| 150 | lys_node_leaflist and lys_deviate */ |
| 151 | LYEXT_SUBSTMT_POSITION, /**< extension of the position statement, can appear in lys_type_bit */ |
| 152 | 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] | 153 | LYEXT_SUBSTMT_IFFEATURE, /**< extension of the if-feature statement */ |
Michal Vasko | d92e42a | 2018-09-07 08:35:02 +0200 | [diff] [blame] | 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 */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 224 | int64_t value; /**< enum's value or bit's position */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 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) */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 227 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ and LYS_SET_VALUE |
| 228 | values are allowed */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 229 | }; |
| 230 | |
| 231 | /** |
| 232 | * @brief YANG type-stmt |
| 233 | * |
| 234 | * Some of the items in the structure may be mandatory, but it is necessary to resolve the type's base type first |
| 235 | */ |
| 236 | struct lysp_type { |
| 237 | const char *name; /**< name of the type (mandatory) */ |
| 238 | struct lysp_restr *range; /**< allowed values range - numerical, decimal64 */ |
| 239 | struct lysp_restr *length; /**< allowed length of the value - string, binary */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 240 | struct lysp_restr *patterns; /**< list of patterns (0-terminated) - string */ |
| 241 | struct lysp_type_enum *enums; /**< list of enum-stmts (0-terminated) - enum */ |
| 242 | struct lysp_type_enum *bits; /**< list of bit-stmts (0-terminated) - bits */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 243 | const char *path; /**< path - leafref */ |
| 244 | const char **bases; /**< list of base identifiers (NULL-terminated) - identityref */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 245 | struct lysp_type *types; /**< list of sub-types (0-terminated) - union */ |
| 246 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 247 | |
| 248 | uint8_t fraction_digits; /**< number of fraction digits - decimal64 */ |
| 249 | uint8_t require_instance; /**< require-instance flag - leafref, instance */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 250 | 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] | 251 | }; |
| 252 | |
| 253 | /** |
| 254 | * @brief YANG typedef-stmt |
| 255 | */ |
| 256 | struct lysp_tpdf { |
| 257 | const char *name; /**< name of the newly defined type (mandatory) */ |
| 258 | const char *units; /**< units of the newly defined type */ |
| 259 | const char *dflt; /**< default value of the newly defined type */ |
| 260 | const char *dsc; /**< description statement */ |
| 261 | const char *ref; /**< reference statement */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 262 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 263 | struct lysp_type type; /**< base type from which the typedef is derived (mandatory) */ |
| 264 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values allowed */ |
| 265 | }; |
| 266 | |
| 267 | /** |
| 268 | * @brief YANG grouping-stmt |
| 269 | */ |
| 270 | struct lysp_grp { |
| 271 | const char *name; /**< grouping name (mandatory) */ |
| 272 | const char *dsc; /**< description statement */ |
| 273 | const char *ref; /**< reference statement */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 274 | struct lysp_tpdf *typedefs; /**< list of typedefs (0-terminated) */ |
| 275 | struct lysp_grp *groupings; /**< list of groupings (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 276 | struct lysp_node *data; /**< list of data nodes (linked list) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 277 | struct lysp_action *actions; /**< list of actions (0-terminated) */ |
| 278 | struct lysp_notif *notifs; /**< list of notifications (0-terminated) */ |
| 279 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 280 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */ |
| 281 | }; |
| 282 | |
| 283 | /** |
| 284 | * @brief YANG when-stmt |
| 285 | */ |
| 286 | struct lysp_when { |
| 287 | const char *cond; /**< specified condition (mandatory) */ |
| 288 | const char *dsc; /**< description statement */ |
| 289 | const char *ref; /**< reference statement */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 290 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 291 | }; |
| 292 | |
| 293 | /** |
| 294 | * @brief YANG refine-stmt |
| 295 | */ |
| 296 | struct lysp_refine { |
| 297 | const char *nodeid; /**< target descendant schema nodeid (mandatory) */ |
| 298 | const char *dsc; /**< description statement */ |
| 299 | const char *ref; /**< reference statement */ |
| 300 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 301 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 302 | const char *presence; /**< presence description */ |
| 303 | const char **dflts; /**< list of default values (NULL-terminated) */ |
| 304 | uint32_t min; /**< min-elements constraint */ |
| 305 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 306 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 307 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 308 | }; |
| 309 | |
| 310 | /** |
| 311 | * @brief YANG uses-augment-stmt and augment-stmt |
| 312 | */ |
| 313 | struct lysp_augment { |
| 314 | const char *nodeid; /**< target schema nodeid (mandatory) - absolute for global augments, descendant for uses's augments */ |
| 315 | const char *dsc; /**< description statement */ |
| 316 | const char *ref; /**< reference statement */ |
| 317 | struct lysp_when *when; /**< when statement */ |
| 318 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 319 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 320 | struct lysp_action *actions; /**< list of actions (0-terminated) */ |
| 321 | struct lysp_notif *notifs; /**< list of notifications (0-terminated) */ |
| 322 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 323 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */ |
| 324 | }; |
| 325 | |
| 326 | /** |
| 327 | * @defgroup deviatetypes Deviate types |
| 328 | * @{ |
| 329 | */ |
| 330 | #define LYS_DEV_NOT_SUPPORTED 1 /**< deviate type not-supported */ |
| 331 | #define LYS_DEV_ADD 2 /**< deviate type add */ |
| 332 | #define LYS_DEV_DELETE 3 /**< deviate type delete */ |
| 333 | #define LYS_DEV_REPLACE 4 /**< deviate type replace */ |
| 334 | /** @} */ |
| 335 | |
| 336 | /** |
| 337 | * @brief Generic deviate structure to get type and cast to lysp_deviate_* structure |
| 338 | */ |
| 339 | struct lysp_deviate { |
| 340 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 341 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 342 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 343 | }; |
| 344 | |
| 345 | struct lysp_deviate_add { |
| 346 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 347 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 348 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
| 349 | const char *units; /**< units of the values */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 350 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 351 | const char **uniques; /**< list of uniques specifications (NULL-terminated) */ |
| 352 | const char **dflts; /**< list of default values (NULL-terminated) */ |
| 353 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 354 | uint32_t min; /**< min-elements constraint */ |
| 355 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 356 | }; |
| 357 | |
| 358 | struct lysp_deviate_del { |
| 359 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 360 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 361 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
| 362 | const char *units; /**< units of the values */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 363 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 364 | const char **uniques; /**< list of uniques specifications (NULL-terminated) */ |
| 365 | const char **dflts; /**< list of default values (NULL-terminated) */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 366 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 367 | }; |
| 368 | |
| 369 | struct lysp_deviate_rpl { |
| 370 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 371 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 372 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
| 373 | struct lysp_type *type; /**< type of the node */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 374 | const char *units; /**< units of the values */ |
| 375 | const char *dflt; /**< default value */ |
| 376 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 377 | uint32_t min; /**< min-elements constraint */ |
| 378 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 379 | }; |
| 380 | |
| 381 | struct lysp_deviation { |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 382 | const char *nodeid; /**< target absolute schema nodeid (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 383 | const char *dsc; /**< description statement */ |
| 384 | const char *ref; /**< reference statement */ |
| 385 | struct lysp_deviate* deviates; /**< list of deviate specifications (linked list) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 386 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 387 | }; |
| 388 | |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 389 | #define LYS_CONFIG_W 0x01 /**< config true; */ |
| 390 | #define LYS_CONFIG_R 0x02 /**< config false; */ |
| 391 | #define LYS_CONFIG_MASK 0x03 /**< mask for config value */ |
| 392 | #define LYS_STATUS_CURR 0x08 /**< status current; */ |
| 393 | #define LYS_STATUS_DEPRC 0x10 /**< status deprecated; */ |
| 394 | #define LYS_STATUS_OBSLT 0x20 /**< status obsolete; */ |
| 395 | #define LYS_STATUS_MASK 0x38 /**< mask for status value */ |
| 396 | #define LYS_MAND_TRUE 0x40 /**< mandatory true; applicable only to |
| 397 | ::lys_node_choice, ::lys_node_leaf and ::lys_node_anydata */ |
| 398 | #define LYS_MAND_FALSE 0x80 /**< mandatory false; applicable only to |
| 399 | ::lys_node_choice, ::lys_node_leaf and ::lys_node_anydata */ |
| 400 | #define LYS_MAND_MASK 0xc0 /**< mask for mandatory values */ |
| 401 | #define LYS_ORDBY_SYSTEM 0x100 /**< ordered-by system lists, applicable only to |
| 402 | ::lys_node_list and ::lys_node_leaflist */ |
| 403 | #define LYS_ORDBY_USER 0x200 /**< ordered-by user lists, applicable only to |
| 404 | ::lys_node_list and ::lys_node_leaflist */ |
| 405 | #define LYS_ORDBY_MASK 0x300 /**< mask for ordered-by flags */ |
| 406 | #define LYS_FENABLED 0x100 /**< feature enabled flag, applicable only to ::lys_feature */ |
| 407 | #define LYS_AUTOASSIGNED 0x01 /**< value was auto-assigned, applicable only to |
| 408 | ::lys_type enum and bits flags */ |
| 409 | #define LYS_YINELEM_TRUE 0x01 /**< yin-element true for extension's argument */ |
| 410 | #define LYS_YINELEM_FALSE 0x02 /**< yin-element false for extension's argument */ |
| 411 | #define LYS_YINELEM_MASK 0x03 /**< mask for yin-element value */ |
| 412 | #define LYS_SET_VALUE 0x01 /**< value attribute is set */ |
| 413 | #define LYS_SET_MAX 0x400 /**< max attribute is set */ |
| 414 | #define LYS_SET_MIN 0x800 /**< min attribute is set */ |
| 415 | #define LYS_SET_REQINST 0x01 /**< require_instance attribute is set */ |
| 416 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 417 | /** |
| 418 | * @brief Generic YANG data node |
| 419 | */ |
| 420 | struct lysp_node { |
| 421 | uint16_t nodetype; /**< type of the node (mandatory) */ |
| 422 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 423 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 424 | const char *name; /**< node name (mandatory) */ |
| 425 | const char *dsc; /**< description statement */ |
| 426 | const char *ref; /**< reference statement */ |
| 427 | struct lysp_when *when; /**< when statement */ |
| 428 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 429 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 430 | }; |
| 431 | |
| 432 | /** |
| 433 | * @brief Extension structure of the lysp_node for YANG container |
| 434 | */ |
| 435 | struct lysp_node_container { |
| 436 | uint16_t nodetype; /**< LYS_CONTAINER */ |
| 437 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 438 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 439 | const char *name; /**< node name (mandatory) */ |
| 440 | const char *dsc; /**< description statement */ |
| 441 | const char *ref; /**< reference statement */ |
| 442 | struct lysp_when *when; /**< when statement */ |
| 443 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 444 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 445 | |
| 446 | /* container */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 447 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 448 | const char *presence; /**< presence description */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 449 | struct lysp_tpdf *typedefs; /**< list of typedefs (0-terminated) */ |
| 450 | struct lysp_grp *groupings; /**< list of groupings (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 451 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 452 | struct lysp_action *actions; /**< list of actions (0-terminated) */ |
| 453 | struct lysp_notif *notifs; /**< list of notifications (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 454 | }; |
| 455 | |
| 456 | struct lysp_node_leaf { |
| 457 | uint16_t nodetype; /**< LYS_LEAF */ |
| 458 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 459 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 460 | const char *name; /**< node name (mandatory) */ |
| 461 | const char *dsc; /**< description statement */ |
| 462 | const char *ref; /**< reference statement */ |
| 463 | struct lysp_when *when; /**< when statement */ |
| 464 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 465 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 466 | |
| 467 | /* leaf */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 468 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 469 | struct lysp_type type; /**< type of the leaf node (mandatory) */ |
| 470 | const char *units; /**< units of the leaf's type */ |
| 471 | const char *dflt; /**< default value */ |
| 472 | }; |
| 473 | |
| 474 | struct lysp_node_leaflist { |
| 475 | uint16_t nodetype; /**< LYS_LEAFLIST */ |
| 476 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 477 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 478 | const char *name; /**< node name (mandatory) */ |
| 479 | const char *dsc; /**< description statement */ |
| 480 | const char *ref; /**< reference statement */ |
| 481 | struct lysp_when *when; /**< when statement */ |
| 482 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 483 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 484 | |
| 485 | /* leaf-list */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 486 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 487 | struct lysp_type type; /**< type of the leaf node (mandatory) */ |
| 488 | const char *units; /**< units of the leaf's type */ |
| 489 | const char **dflts; /**< list of default values (NULL-terminated) */ |
| 490 | uint32_t min; /**< min-elements constraint */ |
| 491 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 492 | }; |
| 493 | |
| 494 | struct lysp_node_list { |
| 495 | uint16_t nodetype; /**< LYS_LIST */ |
| 496 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 497 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 498 | const char *name; /**< node name (mandatory) */ |
| 499 | const char *dsc; /**< description statement */ |
| 500 | const char *ref; /**< reference statement */ |
| 501 | struct lysp_when *when; /**< when statement */ |
| 502 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 503 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 504 | |
| 505 | /* list */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 506 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 507 | const char *key; /**< keys specification */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 508 | struct lysp_tpdf *typedefs; /**< list of typedefs (0-terminated) */ |
| 509 | struct lysp_grp *groupings; /**< list of groupings (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 510 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 511 | struct lysp_action *actions; /**< list of actions (0-terminated) */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 512 | struct lysp_notif *notifs; /**< list of notifications (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 513 | const char **uniques; /**< list of uniques specifications (NULL-terminated) */ |
| 514 | uint32_t min; /**< min-elements constraint */ |
| 515 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 516 | }; |
| 517 | |
| 518 | struct lysp_node_choice { |
| 519 | uint16_t nodetype; /**< LYS_CHOICE */ |
| 520 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 521 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 522 | const char *name; /**< node name (mandatory) */ |
| 523 | const char *dsc; /**< description statement */ |
| 524 | const char *ref; /**< reference statement */ |
| 525 | struct lysp_when *when; /**< when statement */ |
| 526 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 527 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 528 | |
| 529 | /* choice */ |
| 530 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
| 531 | const char* dflt; /**< default case */ |
| 532 | }; |
| 533 | |
| 534 | struct lysp_node_case { |
| 535 | uint16_t nodetype; /**< LYS_CASE */ |
| 536 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 537 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 538 | const char *name; /**< node name (mandatory) */ |
| 539 | const char *dsc; /**< description statement */ |
| 540 | const char *ref; /**< reference statement */ |
| 541 | struct lysp_when *when; /**< when statement */ |
| 542 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 543 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 544 | |
| 545 | /* case */ |
| 546 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
| 547 | }; |
| 548 | |
| 549 | struct lysp_node_anydata { |
| 550 | uint16_t nodetype; /**< LYS_ANYXML || LYS_ANYDATA */ |
| 551 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 552 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 553 | const char *name; /**< node name (mandatory) */ |
| 554 | const char *dsc; /**< description statement */ |
| 555 | const char *ref; /**< reference statement */ |
| 556 | struct lysp_when *when; /**< when statement */ |
| 557 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 558 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 559 | |
| 560 | /* anyxml/anydata */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 561 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 562 | }; |
| 563 | |
| 564 | struct lysp_node_uses { |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 565 | uint16_t nodetype; /**< LYS_USES */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 566 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 567 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 568 | const char *name; /**< grouping name reference (mandatory) */ |
| 569 | const char *dsc; /**< description statement */ |
| 570 | const char *ref; /**< reference statement */ |
| 571 | struct lysp_when *when; /**< when statement */ |
| 572 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 573 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 574 | |
| 575 | /* uses */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 576 | struct lysp_refine *refines; /**< list of uses's refines (0-terminated) */ |
| 577 | struct lysp_augment *augments; /**< list of uses's augment (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 578 | }; |
| 579 | |
| 580 | /** |
| 581 | * @brief YANG input-stmt and output-stmt |
| 582 | */ |
| 583 | struct lysp_action_inout { |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 584 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
| 585 | struct lysp_tpdf *typedefs; /**< list of typedefs (0-terminated) */ |
| 586 | struct lysp_grp *groupings; /**< list of groupings (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 587 | struct lysp_node *data; /**< list of data nodes (linked list) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 588 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 589 | }; |
| 590 | |
| 591 | /** |
| 592 | * @brief YANG rpc-stmt and action-stmt |
| 593 | */ |
| 594 | struct lysp_action { |
| 595 | const char *name; /**< grouping name reference (mandatory) */ |
| 596 | const char *dsc; /**< description statement */ |
| 597 | const char *ref; /**< reference 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_tpdf *typedefs; /**< list of typedefs (0-terminated) */ |
| 600 | struct lysp_grp *groupings; /**< list of groupings (0-terminated) */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 601 | struct lysp_action_inout *input; /**< RPC's/Action's input */ |
| 602 | struct lysp_action_inout *output;/**< RPC's/Action's output */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 603 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 604 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 605 | }; |
| 606 | |
| 607 | /** |
| 608 | * @brief YANG notification-stmt |
| 609 | */ |
| 610 | struct lysp_notif { |
| 611 | const char *name; /**< grouping name reference (mandatory) */ |
| 612 | const char *dsc; /**< description statement */ |
| 613 | const char *ref; /**< reference statement */ |
| 614 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 615 | struct lysp_restr *musts; /**< list of must restrictions (0-terminated) */ |
| 616 | struct lysp_tpdf *typedefs; /**< list of typedefs (0-terminated) */ |
| 617 | struct lysp_grp *groupings; /**< list of groupings (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 618 | struct lysp_node *data; /**< list of data nodes (linked list) */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 619 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 620 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */ |
| 621 | }; |
| 622 | |
| 623 | /** |
Radek Krejci | f0fceb6 | 2018-09-05 14:58:45 +0200 | [diff] [blame] | 624 | * @brief supported YANG schema version values |
| 625 | */ |
| 626 | typedef enum LYS_VERSION { |
| 627 | LYS_VERSION_UNDEF = 0, /**< no specific version, YANG 1.0 as default */ |
| 628 | LYS_VERSION_1_0 = 1, /**< YANG 1.0 */ |
| 629 | LYS_VERSION_1_1 = 2 /**< YANG 1.1 */ |
| 630 | } LYS_VERSION; |
| 631 | |
| 632 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 633 | * @brief Printable YANG schema tree structure representing YANG module. |
| 634 | * |
| 635 | * Simple structure corresponding to the YANG format. The schema is only syntactically validated. |
| 636 | */ |
| 637 | struct lysp_module { |
| 638 | struct ly_ctx *ctx; /**< libyang context of the module (mandatory) */ |
| 639 | const char *name; /**< name of the module (mandatory) */ |
| 640 | const char *filepath; /**< path, if the schema was read from a file, NULL in case of reading from memory */ |
| 641 | union { |
| 642 | /* module */ |
Michal Vasko | d5927ca | 2018-09-07 15:05:32 +0200 | [diff] [blame] | 643 | const char *ns; /**< namespace of the module (module - mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 644 | /* submodule */ |
Michal Vasko | d5927ca | 2018-09-07 15:05:32 +0200 | [diff] [blame] | 645 | const char *belongsto; /**< belongs to parent module (submodule - mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 646 | }; |
Michal Vasko | d5927ca | 2018-09-07 15:05:32 +0200 | [diff] [blame] | 647 | 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] | 648 | struct lysp_import *imports; /**< list of imported modules (0-terminated) */ |
| 649 | struct lysp_include *includes; /**< list of included submodules (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 650 | const char *org; /**< party/company responsible for the module */ |
| 651 | const char *contact; /**< contact information for the module */ |
| 652 | const char *dsc; /**< description of the module */ |
| 653 | const char *ref; /**< cross-reference for the module */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 654 | 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] | 655 | in the list is always the last (newest) revision of the module */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 656 | struct lysp_ext *extensions; /**< list of extension statements (0-terminated) */ |
| 657 | struct lysp_feature *features; /**< list of feature definitions (0-terminated) */ |
| 658 | struct lysp_ident *identities; /**< list of identities (0-terminated) */ |
| 659 | struct lysp_tpdf *typedefs; /**< list of typedefs (0-terminated) */ |
| 660 | struct lysp_grp *groupings; /**< list of groupings (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 661 | 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] | 662 | struct lysp_augment *augments; /**< list of augments (0-terminated) */ |
| 663 | struct lysp_action *rpcs; /**< list of RPCs (0-terminated) */ |
| 664 | struct lysp_notif *notifs; /**< list of notifications (0-terminated) */ |
| 665 | struct lysp_deviation *deviations; /**< list of deviations (0-terminated) */ |
| 666 | struct lysp_ext_instance *exts; /**< list of the extension instances (0-terminated) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 667 | |
Radek Krejci | f0fceb6 | 2018-09-05 14:58:45 +0200 | [diff] [blame] | 668 | uint8_t submodule:1; /**< flag to distinguish main modules and submodules */ |
| 669 | 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] | 670 | uint8_t implemented:1; /**< flag if the module is implemented, not just imported */ |
| 671 | uint8_t latest_revision:1; /**< flag if the module was loaded without specific revision and is |
| 672 | the latest revision found */ |
Radek Krejci | f0fceb6 | 2018-09-05 14:58:45 +0200 | [diff] [blame] | 673 | uint8_t version:4; /**< yang-version (LYS_VERSION values) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 674 | }; |
| 675 | |
| 676 | /** |
Radek Krejci | 3f5e3db | 2018-10-11 15:57:47 +0200 | [diff] [blame^] | 677 | * @brief Free the printable YANG schema tree structure. |
| 678 | * |
| 679 | * @param[in] module Printable YANG schema tree structure to free. |
| 680 | */ |
| 681 | void lysp_module_free(struct lysp_module *module); |
| 682 | |
| 683 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 684 | * @brief Compiled YANG schema tree structure representing YANG module. |
| 685 | * |
| 686 | * Semantically validated YANG schema tree for data tree parsing. |
| 687 | * Contains only the necessary information for the data validation. |
| 688 | */ |
| 689 | struct lysc_module { |
| 690 | }; |
| 691 | |
| 692 | /** |
Radek Krejci | 0af5f5d | 2018-09-07 15:00:30 +0200 | [diff] [blame] | 693 | * @brief Compiled YANG data node |
| 694 | */ |
| 695 | struct lysc_node { |
| 696 | }; |
| 697 | |
| 698 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 699 | * @brief Available YANG schema tree structures representing YANG module. |
| 700 | */ |
| 701 | struct lys_module { |
| 702 | struct lysp_module *parsed; /**< Simply parsed (unresolved) YANG schema tree */ |
| 703 | struct lysc_module *compiled; /**< Compiled and fully validated YANG schema tree for data parsing */ |
| 704 | }; |
| 705 | |
| 706 | /** @} */ |
| 707 | |
| 708 | #endif /* LY_TREE_SCHEMA_H_ */ |