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