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 | |
| 27 | #define LY_REV_SIZE 11 /**< revision data string length (including terminating NULL byte) */ |
| 28 | |
| 29 | #define LYS_UNKNOWN 0x0000, /**< uninitalized unknown statement node */ |
| 30 | #define LYS_CONTAINER 0x0001, /**< container statement node */ |
| 31 | #define LYS_CHOICE 0x0002, /**< choice statement node */ |
| 32 | #define LYS_LEAF 0x0004, /**< leaf statement node */ |
| 33 | #define LYS_LEAFLIST 0x0008, /**< leaf-list statement node */ |
| 34 | #define LYS_LIST 0x0010, /**< list statement node */ |
| 35 | #define LYS_ANYXML 0x0020, /**< anyxml statement node */ |
| 36 | #define LYS_CASE 0x0040, /**< case statement node */ |
| 37 | #define LYS_USES 0x0080, /**< uses statement node */ |
| 38 | #define LYS_AUGMENT 0x0100, /**< augment statement node */ |
| 39 | #define LYS_ANYDATA 0x0220, /**< anydata statement node, in tests it can be used for both #LYS_ANYXML and #LYS_ANYDATA */ |
| 40 | |
| 41 | /** |
| 42 | * @brief YANG import-stmt |
| 43 | */ |
| 44 | struct lysp_import { |
| 45 | const char *prefix; /**< prefix for the data from the imported schema (mandatory) */ |
| 46 | struct lysp_module *module; /**< link to the imported module (mandatory) */ |
| 47 | const char *dsc; /**< description */ |
| 48 | const char *ref; /**< reference */ |
| 49 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 50 | char rev[LY_REV_SIZE]; /**< revision-date of the imported module */ |
| 51 | }; |
| 52 | |
| 53 | /** |
| 54 | * @brief YANG include-stmt |
| 55 | */ |
| 56 | struct lysp_include { |
| 57 | struct lysp_module *submodule; /**< link to the included submodule (mandatory) */ |
| 58 | const char *dsc; /**< description */ |
| 59 | const char *ref; /**< reference */ |
| 60 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 61 | char rev[LY_REV_SIZE]; /**< revision-date of the included submodule */ |
| 62 | }; |
| 63 | |
| 64 | /** |
| 65 | * @brief YANG extension-stmt |
| 66 | */ |
| 67 | struct lysp_ext { |
| 68 | const char *name; /**< extension name */ |
| 69 | const char *argument; /**< argument name, NULL if not specified */ |
| 70 | const char *dsc; /**< description statement */ |
| 71 | const char *ref; /**< reference statement */ |
| 72 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 73 | uint16_t flags; /**< LYS_STATUS_* and LYS_YINELEM values (@ref snodeflags) */ |
| 74 | }; |
| 75 | |
| 76 | /** |
| 77 | * @brief Helper structure for generic storage of the extension instances content. |
| 78 | */ |
| 79 | struct lysp_stmt { |
| 80 | const char *stmt; /**< identifier of the statement */ |
| 81 | const char *arg; /**< statement's argument */ |
| 82 | struct lysp_stmt *next; /**< link to the next statement */ |
| 83 | struct lysp_stmt *children; /**< list of the statement's substatements (linked list) */ |
| 84 | }; |
| 85 | |
| 86 | /** |
| 87 | * @brief YANG extension instance |
| 88 | */ |
| 89 | struct lysp_ext_instance { |
| 90 | const char *name; /**< extension identifier, including possible prefix */ |
| 91 | const char *argument; /**< optional value of the extension's argument */ |
| 92 | struct lysp_stmt *children; /**< list of the extension's substatements (linked list) */ |
| 93 | }; |
| 94 | |
| 95 | /** |
| 96 | * @brief YANG feature-stmt |
| 97 | */ |
| 98 | struct lysp_feature { |
| 99 | const char *name; /**< feature name (mandatory) */ |
| 100 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 101 | const char *dsc; /**< description statement */ |
| 102 | const char *ref; /**< reference statement */ |
| 103 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 104 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values allowed */ |
| 105 | }; |
| 106 | |
| 107 | /** |
| 108 | * @brief YANG identity-stmt |
| 109 | */ |
| 110 | struct lysp_ident { |
| 111 | const char *name; /**< identity name (mandatory), including possible prefix */ |
| 112 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 113 | const char **bases; /**< list of base identifiers (NULL-terminated) */ |
| 114 | const char *dsc; /**< description statement */ |
| 115 | const char *ref; /**< reference statement */ |
| 116 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 117 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ values are allowed */ |
| 118 | }; |
| 119 | |
| 120 | /* |
| 121 | * @brief Covers restrictions: range, length, pattern, must |
| 122 | */ |
| 123 | struct lysp_restr { |
| 124 | const char *arg; /**< The restriction expression/value (mandatory); |
| 125 | in case of pattern restriction, the first byte has a special meaning: |
| 126 | 0x06 (ACK) for regular match and 0x15 (NACK) for invert-match */ |
| 127 | const char *emsg; /**< error-message */ |
| 128 | const char *eapptag; /**< error-app-tag value */ |
| 129 | const char *dsc; /**< description */ |
| 130 | const char *ref; /**< reference */ |
| 131 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 132 | }; |
| 133 | |
| 134 | /** |
| 135 | * @brief Enumeration/Bit value definition |
| 136 | */ |
| 137 | struct lysp_type_enum { |
| 138 | const char *name; /**< name (mandatory) */ |
| 139 | const char *dsc; /**< description statement */ |
| 140 | const char *ref; /**< reference statement */ |
| 141 | const char *value; /**< enum's value or bit's position */ |
| 142 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 143 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 144 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ values are allowed */ |
| 145 | }; |
| 146 | |
| 147 | /** |
| 148 | * @brief YANG type-stmt |
| 149 | * |
| 150 | * Some of the items in the structure may be mandatory, but it is necessary to resolve the type's base type first |
| 151 | */ |
| 152 | struct lysp_type { |
| 153 | const char *name; /**< name of the type (mandatory) */ |
| 154 | struct lysp_restr *range; /**< allowed values range - numerical, decimal64 */ |
| 155 | struct lysp_restr *length; /**< allowed length of the value - string, binary */ |
| 156 | struct lysp_restr **patterns; /**< list of patterns (NULL-terminated) - string */ |
| 157 | struct lysp_type_enum **enumerations; /**< list of enum-stmts (NULL-terminated) - enum */ |
| 158 | struct lysp_type_enum **bits; /**< list of bit-stmts (NULL-terminated) - bits */ |
| 159 | const char *path; /**< path - leafref */ |
| 160 | const char **bases; /**< list of base identifiers (NULL-terminated) - identityref */ |
| 161 | struct lysp_type *types; /**< list of sub-types (NULL-terminated) - union */ |
| 162 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 163 | |
| 164 | uint8_t fraction_digits; /**< number of fraction digits - decimal64 */ |
| 165 | uint8_t require_instance; /**< require-instance flag - leafref, instance */ |
| 166 | }; |
| 167 | |
| 168 | /** |
| 169 | * @brief YANG typedef-stmt |
| 170 | */ |
| 171 | struct lysp_tpdf { |
| 172 | const char *name; /**< name of the newly defined type (mandatory) */ |
| 173 | const char *units; /**< units of the newly defined type */ |
| 174 | const char *dflt; /**< default value of the newly defined type */ |
| 175 | const char *dsc; /**< description statement */ |
| 176 | const char *ref; /**< reference statement */ |
| 177 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 178 | struct lysp_type type; /**< base type from which the typedef is derived (mandatory) */ |
| 179 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values allowed */ |
| 180 | }; |
| 181 | |
| 182 | /** |
| 183 | * @brief YANG grouping-stmt |
| 184 | */ |
| 185 | struct lysp_grp { |
| 186 | const char *name; /**< grouping name (mandatory) */ |
| 187 | const char *dsc; /**< description statement */ |
| 188 | const char *ref; /**< reference statement */ |
| 189 | struct lysp_tpdf *typedefs; /**< list of typedefs (NULL-terminated) */ |
| 190 | struct lysp_grp *groupings; /**< list of groupings (NULL-terminated) */ |
| 191 | struct lysp_node *data; /**< list of data nodes (linked list) */ |
| 192 | struct lysp_action *actions; /**< list of actions (NULL-terminated) */ |
| 193 | struct lysp_notif *notifications;/**< list of notifications (NULL-terminated) */ |
| 194 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 195 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */ |
| 196 | }; |
| 197 | |
| 198 | /** |
| 199 | * @brief YANG when-stmt |
| 200 | */ |
| 201 | struct lysp_when { |
| 202 | const char *cond; /**< specified condition (mandatory) */ |
| 203 | const char *dsc; /**< description statement */ |
| 204 | const char *ref; /**< reference statement */ |
| 205 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 206 | }; |
| 207 | |
| 208 | /** |
| 209 | * @brief YANG refine-stmt |
| 210 | */ |
| 211 | struct lysp_refine { |
| 212 | const char *nodeid; /**< target descendant schema nodeid (mandatory) */ |
| 213 | const char *dsc; /**< description statement */ |
| 214 | const char *ref; /**< reference statement */ |
| 215 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 216 | struct lysp_restr *musts; /**< list of must restrictions (NULL-terminated) */ |
| 217 | const char *presence; /**< presence description */ |
| 218 | const char **dflts; /**< list of default values (NULL-terminated) */ |
| 219 | uint32_t min; /**< min-elements constraint */ |
| 220 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 221 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 222 | }; |
| 223 | |
| 224 | /** |
| 225 | * @brief YANG uses-augment-stmt and augment-stmt |
| 226 | */ |
| 227 | struct lysp_augment { |
| 228 | const char *nodeid; /**< target schema nodeid (mandatory) - absolute for global augments, descendant for uses's augments */ |
| 229 | const char *dsc; /**< description statement */ |
| 230 | const char *ref; /**< reference statement */ |
| 231 | struct lysp_when *when; /**< when statement */ |
| 232 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 233 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
| 234 | struct lysp_action *actions; /**< list of actions (NULL-terminated) */ |
| 235 | struct lysp_notif *notifications;/**< list of notifications (NULL-terminated) */ |
| 236 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 237 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */ |
| 238 | }; |
| 239 | |
| 240 | /** |
| 241 | * @defgroup deviatetypes Deviate types |
| 242 | * @{ |
| 243 | */ |
| 244 | #define LYS_DEV_NOT_SUPPORTED 1 /**< deviate type not-supported */ |
| 245 | #define LYS_DEV_ADD 2 /**< deviate type add */ |
| 246 | #define LYS_DEV_DELETE 3 /**< deviate type delete */ |
| 247 | #define LYS_DEV_REPLACE 4 /**< deviate type replace */ |
| 248 | /** @} */ |
| 249 | |
| 250 | /** |
| 251 | * @brief Generic deviate structure to get type and cast to lysp_deviate_* structure |
| 252 | */ |
| 253 | struct lysp_deviate { |
| 254 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 255 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
| 256 | }; |
| 257 | |
| 258 | struct lysp_deviate_add { |
| 259 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 260 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
| 261 | const char *units; /**< units of the leaf's type */ |
| 262 | struct lysp_restr *musts; /**< list of must restrictions (NULL-terminated) */ |
| 263 | const char **uniques; /**< list of uniques specifications (NULL-terminated) */ |
| 264 | const char **dflts; /**< list of default values (NULL-terminated) */ |
| 265 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 266 | uint32_t min; /**< min-elements constraint */ |
| 267 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 268 | }; |
| 269 | |
| 270 | struct lysp_deviate_del { |
| 271 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 272 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
| 273 | const char *units; /**< units of the leaf's type */ |
| 274 | struct lysp_restr *musts; /**< list of must restrictions (NULL-terminated) */ |
| 275 | const char **uniques; /**< list of uniques specifications (NULL-terminated) */ |
| 276 | const char **dflts; /**< list of default values (NULL-terminated) */ |
| 277 | }; |
| 278 | |
| 279 | struct lysp_deviate_rpl { |
| 280 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 281 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
| 282 | struct lysp_type *type; /**< type of the node (mandatory) */ |
| 283 | const char *units; /**< units of the values */ |
| 284 | const char *dflt; /**< default value */ |
| 285 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 286 | uint32_t min; /**< min-elements constraint */ |
| 287 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 288 | }; |
| 289 | |
| 290 | struct lysp_deviation { |
| 291 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 292 | const char *dsc; /**< description statement */ |
| 293 | const char *ref; /**< reference statement */ |
| 294 | struct lysp_deviate* deviates; /**< list of deviate specifications (linked list) */ |
| 295 | }; |
| 296 | |
| 297 | /** |
| 298 | * @brief Generic YANG data node |
| 299 | */ |
| 300 | struct lysp_node { |
| 301 | uint16_t nodetype; /**< type of the node (mandatory) */ |
| 302 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 303 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 304 | const char *name; /**< node name (mandatory) */ |
| 305 | const char *dsc; /**< description statement */ |
| 306 | const char *ref; /**< reference statement */ |
| 307 | struct lysp_when *when; /**< when statement */ |
| 308 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 309 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 310 | }; |
| 311 | |
| 312 | /** |
| 313 | * @brief Extension structure of the lysp_node for YANG container |
| 314 | */ |
| 315 | struct lysp_node_container { |
| 316 | uint16_t nodetype; /**< LYS_CONTAINER */ |
| 317 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 318 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 319 | const char *name; /**< node name (mandatory) */ |
| 320 | const char *dsc; /**< description statement */ |
| 321 | const char *ref; /**< reference statement */ |
| 322 | struct lysp_when *when; /**< when statement */ |
| 323 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 324 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 325 | |
| 326 | /* container */ |
| 327 | struct lysp_restr *musts; /**< list of must restrictions (NULL-terminated) */ |
| 328 | const char *presence; /**< presence description */ |
| 329 | struct lysp_tpdf *typedefs; /**< list of typedefs (NULL-terminated) */ |
| 330 | struct lysp_grp *groupings; /**< list of groupings (NULL-terminated) */ |
| 331 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
| 332 | struct lysp_action *actions; /**< list of actions (NULL-terminated) */ |
| 333 | struct lysp_notif *notifications;/**< list of notifications (NULL-terminated) */ |
| 334 | }; |
| 335 | |
| 336 | struct lysp_node_leaf { |
| 337 | uint16_t nodetype; /**< LYS_LEAF */ |
| 338 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 339 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 340 | const char *name; /**< node name (mandatory) */ |
| 341 | const char *dsc; /**< description statement */ |
| 342 | const char *ref; /**< reference statement */ |
| 343 | struct lysp_when *when; /**< when statement */ |
| 344 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 345 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 346 | |
| 347 | /* leaf */ |
| 348 | struct lysp_restr *musts; /**< list of must restrictions (NULL-terminated) */ |
| 349 | struct lysp_type type; /**< type of the leaf node (mandatory) */ |
| 350 | const char *units; /**< units of the leaf's type */ |
| 351 | const char *dflt; /**< default value */ |
| 352 | }; |
| 353 | |
| 354 | struct lysp_node_leaflist { |
| 355 | uint16_t nodetype; /**< LYS_LEAFLIST */ |
| 356 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 357 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 358 | const char *name; /**< node name (mandatory) */ |
| 359 | const char *dsc; /**< description statement */ |
| 360 | const char *ref; /**< reference statement */ |
| 361 | struct lysp_when *when; /**< when statement */ |
| 362 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 363 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 364 | |
| 365 | /* leaf-list */ |
| 366 | struct lysp_restr *musts; /**< list of must restrictions (NULL-terminated) */ |
| 367 | struct lysp_type type; /**< type of the leaf node (mandatory) */ |
| 368 | const char *units; /**< units of the leaf's type */ |
| 369 | const char **dflts; /**< list of default values (NULL-terminated) */ |
| 370 | uint32_t min; /**< min-elements constraint */ |
| 371 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 372 | }; |
| 373 | |
| 374 | struct lysp_node_list { |
| 375 | uint16_t nodetype; /**< LYS_LIST */ |
| 376 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 377 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 378 | const char *name; /**< node name (mandatory) */ |
| 379 | const char *dsc; /**< description statement */ |
| 380 | const char *ref; /**< reference statement */ |
| 381 | struct lysp_when *when; /**< when statement */ |
| 382 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 383 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 384 | |
| 385 | /* list */ |
| 386 | struct lysp_restr *musts; /**< list of must restrictions (NULL-terminated) */ |
| 387 | const char *key; /**< keys specification */ |
| 388 | struct lysp_tpdf *typedefs; /**< list of typedefs (NULL-terminated) */ |
| 389 | struct lysp_grp *groupings; /**< list of groupings (NULL-terminated) */ |
| 390 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
| 391 | struct lysp_action *actions; /**< list of actions (NULL-terminated) */ |
| 392 | struct lysp_notif *notifications;/**< list of notifications (NULL-terminated) */ |
| 393 | const char **uniques; /**< list of uniques specifications (NULL-terminated) */ |
| 394 | uint32_t min; /**< min-elements constraint */ |
| 395 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 396 | }; |
| 397 | |
| 398 | struct lysp_node_choice { |
| 399 | uint16_t nodetype; /**< LYS_CHOICE */ |
| 400 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 401 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 402 | const char *name; /**< node name (mandatory) */ |
| 403 | const char *dsc; /**< description statement */ |
| 404 | const char *ref; /**< reference statement */ |
| 405 | struct lysp_when *when; /**< when statement */ |
| 406 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 407 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 408 | |
| 409 | /* choice */ |
| 410 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
| 411 | const char* dflt; /**< default case */ |
| 412 | }; |
| 413 | |
| 414 | struct lysp_node_case { |
| 415 | uint16_t nodetype; /**< LYS_CASE */ |
| 416 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 417 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 418 | const char *name; /**< node name (mandatory) */ |
| 419 | const char *dsc; /**< description statement */ |
| 420 | const char *ref; /**< reference statement */ |
| 421 | struct lysp_when *when; /**< when statement */ |
| 422 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 423 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 424 | |
| 425 | /* case */ |
| 426 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
| 427 | }; |
| 428 | |
| 429 | struct lysp_node_anydata { |
| 430 | uint16_t nodetype; /**< LYS_ANYXML || LYS_ANYDATA */ |
| 431 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 432 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 433 | const char *name; /**< node name (mandatory) */ |
| 434 | const char *dsc; /**< description statement */ |
| 435 | const char *ref; /**< reference statement */ |
| 436 | struct lysp_when *when; /**< when statement */ |
| 437 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 438 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 439 | |
| 440 | /* anyxml/anydata */ |
| 441 | struct lysp_restr *musts; /**< list of must restrictions (NULL-terminated) */ |
| 442 | }; |
| 443 | |
| 444 | struct lysp_node_uses { |
| 445 | uint16_t nodetype; /**< LYS_ANYXML || LYS_ANYDATA */ |
| 446 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 447 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 448 | const char *name; /**< grouping name reference (mandatory) */ |
| 449 | const char *dsc; /**< description statement */ |
| 450 | const char *ref; /**< reference statement */ |
| 451 | struct lysp_when *when; /**< when statement */ |
| 452 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 453 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 454 | |
| 455 | /* uses */ |
| 456 | struct lysp_refine *refines; /**< list of uses's refines (NULL-terminated) */ |
| 457 | struct lysp_augment *augments; /**< list of uses's augment (NULL-terminated) */ |
| 458 | }; |
| 459 | |
| 460 | /** |
| 461 | * @brief YANG input-stmt and output-stmt |
| 462 | */ |
| 463 | struct lysp_action_inout { |
| 464 | struct lysp_restr *musts; /**< list of must restrictions (NULL-terminated) */ |
| 465 | struct lysp_tpdf *typedefs; /**< list of typedefs (NULL-terminated) */ |
| 466 | struct lysp_grp *groupings; /**< list of groupings (NULL-terminated) */ |
| 467 | struct lysp_node *data; /**< list of data nodes (linked list) */ |
| 468 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 469 | }; |
| 470 | |
| 471 | /** |
| 472 | * @brief YANG rpc-stmt and action-stmt |
| 473 | */ |
| 474 | struct lysp_action { |
| 475 | const char *name; /**< grouping name reference (mandatory) */ |
| 476 | const char *dsc; /**< description statement */ |
| 477 | const char *ref; /**< reference statement */ |
| 478 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 479 | struct lysp_tpdf *typedefs; /**< list of typedefs (NULL-terminated) */ |
| 480 | struct lysp_grp *groupings; /**< list of groupings (NULL-terminated) */ |
| 481 | struct lysp_action_inout input; /**< RPC's/Action's input */ |
| 482 | struct lysp_action_inout output; /**< RPC's/Action's output */ |
| 483 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 484 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 485 | }; |
| 486 | |
| 487 | /** |
| 488 | * @brief YANG notification-stmt |
| 489 | */ |
| 490 | struct lysp_notif { |
| 491 | const char *name; /**< grouping name reference (mandatory) */ |
| 492 | const char *dsc; /**< description statement */ |
| 493 | const char *ref; /**< reference statement */ |
| 494 | const char **iffeatures; /**< list of if-feature expressions (NULL-terminated) */ |
| 495 | struct lysp_restr *musts; /**< list of must restrictions (NULL-terminated) */ |
| 496 | struct lysp_tpdf *typedefs; /**< list of typedefs (NULL-terminated) */ |
| 497 | struct lysp_grp *groupings; /**< list of groupings (NULL-terminated) */ |
| 498 | struct lysp_node *data; /**< list of data nodes (linked list) */ |
| 499 | struct lysp_ext_instance **ext; /**< list of the extension instances (NULL-terminated) */ |
| 500 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values are allowed */ |
| 501 | }; |
| 502 | |
| 503 | /** |
Radek Krejci | f0fceb6 | 2018-09-05 14:58:45 +0200 | [diff] [blame] | 504 | * @brief supported YANG schema version values |
| 505 | */ |
| 506 | typedef enum LYS_VERSION { |
| 507 | LYS_VERSION_UNDEF = 0, /**< no specific version, YANG 1.0 as default */ |
| 508 | LYS_VERSION_1_0 = 1, /**< YANG 1.0 */ |
| 509 | LYS_VERSION_1_1 = 2 /**< YANG 1.1 */ |
| 510 | } LYS_VERSION; |
| 511 | |
| 512 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 513 | * @brief Printable YANG schema tree structure representing YANG module. |
| 514 | * |
| 515 | * Simple structure corresponding to the YANG format. The schema is only syntactically validated. |
| 516 | */ |
| 517 | struct lysp_module { |
| 518 | struct ly_ctx *ctx; /**< libyang context of the module (mandatory) */ |
| 519 | const char *name; /**< name of the module (mandatory) */ |
| 520 | const char *filepath; /**< path, if the schema was read from a file, NULL in case of reading from memory */ |
| 521 | union { |
| 522 | /* module */ |
| 523 | const char *ns; /**< namespace of the module (module - type 0, mandatory) */ |
| 524 | /* submodule */ |
| 525 | struct lysp_module *belongsto; /**< belongs to parent module (submodule - type 1, mandatory) */ |
| 526 | }; |
| 527 | const char *prefix; /**< prefix of the module (module - type 0, mandatory) */ |
| 528 | struct lysp_import *imports; /**< list of imported modules (NULL-terminated) */ |
| 529 | struct lysp_include *includes; /**< list of included submodules (NULL-terminated) */ |
| 530 | const char *org; /**< party/company responsible for the module */ |
| 531 | const char *contact; /**< contact information for the module */ |
| 532 | const char *dsc; /**< description of the module */ |
| 533 | const char *ref; /**< cross-reference for the module */ |
| 534 | struct lysp_revision *rev; /**< list of the module revisions (NULL-terminated), the first revision |
| 535 | in the list is always the last (newest) revision of the module */ |
| 536 | struct lysp_ext *extensions; /**< list of extension statements (NULL-terminated) */ |
| 537 | struct lysp_feature *features; /**< list of feature definitions (NULL-terminated) */ |
| 538 | struct lysp_ident *identities; /**< list of identities (NULL-terminated) */ |
| 539 | struct lysp_tpdf *typedefs; /**< list of typedefs (NULL-terminated) */ |
| 540 | struct lysp_grp *groupings; /**< list of groupings (NULL-terminated) */ |
| 541 | struct lysp_node *data; /**< list of module's top-level data nodes (linked list) */ |
| 542 | struct lysp_augment *augments; /**< list of augments (NULL-terminated) */ |
| 543 | struct lysp_action *rpcs; /**< list of RPCs (NULL-terminated) */ |
| 544 | struct lysp_notif *notifications; /**< list of notifications (NULL-terminated) */ |
| 545 | struct lysp_deviation *deviations; /**< list of deviations (NULL-terminated) */ |
| 546 | struct lysp_ext_instance **exts; /**< list of the extension instances (NULL-terminated) */ |
| 547 | |
Radek Krejci | f0fceb6 | 2018-09-05 14:58:45 +0200 | [diff] [blame] | 548 | uint8_t submodule:1; /**< flag to distinguish main modules and submodules */ |
| 549 | 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] | 550 | uint8_t implemented:1; /**< flag if the module is implemented, not just imported */ |
| 551 | uint8_t latest_revision:1; /**< flag if the module was loaded without specific revision and is |
| 552 | the latest revision found */ |
Radek Krejci | f0fceb6 | 2018-09-05 14:58:45 +0200 | [diff] [blame] | 553 | uint8_t version:4; /**< yang-version (LYS_VERSION values) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 554 | }; |
| 555 | |
| 556 | /** |
| 557 | * @brief Compiled YANG schema tree structure representing YANG module. |
| 558 | * |
| 559 | * Semantically validated YANG schema tree for data tree parsing. |
| 560 | * Contains only the necessary information for the data validation. |
| 561 | */ |
| 562 | struct lysc_module { |
| 563 | }; |
| 564 | |
| 565 | /** |
| 566 | * @brief Available YANG schema tree structures representing YANG module. |
| 567 | */ |
| 568 | struct lys_module { |
| 569 | struct lysp_module *parsed; /**< Simply parsed (unresolved) YANG schema tree */ |
| 570 | struct lysc_module *compiled; /**< Compiled and fully validated YANG schema tree for data parsing */ |
| 571 | }; |
| 572 | |
| 573 | /** @} */ |
| 574 | |
| 575 | #endif /* LY_TREE_SCHEMA_H_ */ |