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 | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 18 | #include <pcre.h> |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 19 | #include <stdint.h> |
| 20 | |
Radek Krejci | ce8c159 | 2018-10-29 15:35:51 +0100 | [diff] [blame] | 21 | #include "extensions.h" |
| 22 | |
Radek Krejci | 70853c5 | 2018-10-15 14:46:16 +0200 | [diff] [blame] | 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 27 | /** |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 28 | * @brief XPath representation. |
| 29 | */ |
| 30 | struct lyxp_expr; |
| 31 | |
| 32 | /** |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 33 | * @brief Macro selector for other LY_ARRAY_* macros, do not use directly! |
| 34 | */ |
| 35 | #define LY_ARRAY_SELECT(_1, _2, NAME, ...) NAME |
| 36 | |
| 37 | /** |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 38 | * @brief Helper macro to go through sized-arrays with a pointer iterator. |
| 39 | * |
| 40 | * Use with opening curly bracket (`{`). |
| 41 | * |
| 42 | * @param[in] ARRAY Array to go through |
| 43 | * @param[in] TYPE Type of the records in the ARRAY |
| 44 | * @param[out] ITER Iterating pointer to the item being processed in each loop |
| 45 | */ |
| 46 | #define LY_ARRAY_FOR_ITER(ARRAY, TYPE, ITER) \ |
Radek Krejci | 2c4e717 | 2018-10-19 15:56:26 +0200 | [diff] [blame] | 47 | for (ITER = ARRAY; \ |
| 48 | (ARRAY) && ((void*)ITER - (void*)ARRAY)/(sizeof(TYPE)) < (*((uint32_t*)(ARRAY) - 1)); \ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 49 | ITER = (void*)((TYPE*)ITER + 1)) |
| 50 | |
| 51 | /** |
| 52 | * @brief Helper macro to go through sized-arrays with a numeric iterator. |
| 53 | * |
| 54 | * Use with opening curly bracket (`{`). |
| 55 | * |
| 56 | * To access an item with the INDEX value, use always LY_ARRAY_INDEX macro! |
| 57 | * |
| 58 | * @param[in] ARRAY Array to go through |
| 59 | * @param[out] INDEX Iterating index of the item being processed in each loop |
| 60 | */ |
| 61 | #define LY_ARRAY_FOR_INDEX(ARRAY, INDEX) \ |
| 62 | for (INDEX = 0; \ |
Radek Krejci | 2c4e717 | 2018-10-19 15:56:26 +0200 | [diff] [blame] | 63 | ARRAY && INDEX < (*((uint32_t*)(ARRAY) - 1)); \ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 64 | ++INDEX) |
| 65 | |
| 66 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 67 | * @defgroup schematree Schema Tree |
| 68 | * @{ |
| 69 | * |
| 70 | * Data structures and functions to manipulate and access schema tree. |
| 71 | */ |
| 72 | |
Radek Krejci | 0af5f5d | 2018-09-07 15:00:30 +0200 | [diff] [blame] | 73 | /** |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 74 | * @brief Get a number of records in the ARRAY. |
Radek Krejci | 86d106e | 2018-10-18 09:53:19 +0200 | [diff] [blame] | 75 | * |
| 76 | * Does not check if array exists! |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 77 | */ |
Radek Krejci | 2c4e717 | 2018-10-19 15:56:26 +0200 | [diff] [blame] | 78 | #define LY_ARRAY_SIZE(ARRAY) (*((uint32_t*)(ARRAY) - 1)) |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 79 | |
| 80 | /** |
| 81 | * @brief Sized-array iterator (for-loop). |
| 82 | * |
| 83 | * Use with opening curly bracket (`{`). |
| 84 | * |
| 85 | * There are 2 variants: |
| 86 | * |
| 87 | * LY_ARRAY_FOR(ARRAY, TYPE, ITER) |
| 88 | * |
| 89 | * Where ARRAY is a sized-array to go through, TYPE is the type of the items in the ARRAY and ITER is a pointer variable |
| 90 | * providing the items of the ARRAY in the loops. This functionality is provided by LY_ARRAY_FOR_ITER macro |
| 91 | * |
| 92 | * LY_ARRAY_FOR(ARRAY, INDEX) |
| 93 | * |
| 94 | * The ARRAY is again a sized-array to go through, the INDEX is a variable (unsigned integer) for storing iterating ARRAY's index |
Radek Krejci | 2c4e717 | 2018-10-19 15:56:26 +0200 | [diff] [blame] | 95 | * to access the items of ARRAY in the loops. This functionality is provided by LY_ARRAY_FOR_INDEX macro. |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 96 | */ |
| 97 | #define LY_ARRAY_FOR(ARRAY, ...) LY_ARRAY_SELECT(__VA_ARGS__, LY_ARRAY_FOR_ITER, LY_ARRAY_FOR_INDEX)(ARRAY, __VA_ARGS__) |
Radek Krejci | 5fac359 | 2018-10-12 15:23:45 +0200 | [diff] [blame] | 98 | |
| 99 | /** |
| 100 | * @brief Macro to iterate via all sibling elements without affecting the list itself |
| 101 | * |
| 102 | * Works for all types of nodes despite it is data or schema tree, but all the |
| 103 | * parameters must be pointers to the same type. |
| 104 | * |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 105 | * Use with opening curly bracket (`{`). All parameters must be of the same type. |
Radek Krejci | 5fac359 | 2018-10-12 15:23:45 +0200 | [diff] [blame] | 106 | * |
| 107 | * @param START Pointer to the starting element. |
| 108 | * @param ELEM Iterator. |
| 109 | */ |
| 110 | #define LY_LIST_FOR(START, ELEM) \ |
| 111 | for ((ELEM) = (START); \ |
| 112 | (ELEM); \ |
| 113 | (ELEM) = (ELEM)->next) |
| 114 | |
| 115 | /** |
Radek Krejci | 5fac359 | 2018-10-12 15:23:45 +0200 | [diff] [blame] | 116 | * @brief Macro to iterate via all sibling elements allowing to modify the list itself (e.g. removing elements) |
| 117 | * |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 118 | * Use with opening curly bracket (`{`). All parameters must be of the same type. |
Radek Krejci | 5fac359 | 2018-10-12 15:23:45 +0200 | [diff] [blame] | 119 | * |
| 120 | * @param START Pointer to the starting element. |
| 121 | * @param NEXT Temporary storage to allow removing of the current iterator content. |
| 122 | * @param ELEM Iterator. |
| 123 | */ |
| 124 | #define LY_LIST_FOR_SAFE(START, NEXT, ELEM) \ |
| 125 | for ((ELEM) = (START); \ |
| 126 | (ELEM) ? (NEXT = (ELEM)->next, 1) : 0; \ |
| 127 | (ELEM) = (NEXT)) |
| 128 | |
| 129 | /** |
Radek Krejci | 0af5f5d | 2018-09-07 15:00:30 +0200 | [diff] [blame] | 130 | * @brief Schema input formats accepted by libyang [parser functions](@ref howtoschemasparsers). |
| 131 | */ |
| 132 | typedef enum { |
| 133 | LYS_IN_UNKNOWN = 0, /**< unknown format, used as return value in case of error */ |
| 134 | LYS_IN_YANG = 1, /**< YANG schema input format */ |
| 135 | LYS_IN_YIN = 2 /**< YIN schema input format */ |
| 136 | } LYS_INFORMAT; |
| 137 | |
| 138 | /** |
| 139 | * @brief Schema output formats accepted by libyang [printer functions](@ref howtoschemasprinters). |
| 140 | */ |
| 141 | typedef enum { |
| 142 | LYS_OUT_UNKNOWN = 0, /**< unknown format, used as return value in case of error */ |
| 143 | LYS_OUT_YANG = 1, /**< YANG schema output format */ |
| 144 | LYS_OUT_YIN = 2, /**< YIN schema output format */ |
| 145 | LYS_OUT_TREE, /**< Tree schema output format, for more information see the [printers](@ref howtoschemasprinters) page */ |
| 146 | LYS_OUT_INFO, /**< Info schema output format, for more information see the [printers](@ref howtoschemasprinters) page */ |
| 147 | LYS_OUT_JSON, /**< JSON schema output format, reflecting YIN format with conversion of attributes to object's members */ |
| 148 | } LYS_OUTFORMAT; |
| 149 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 150 | #define LY_REV_SIZE 11 /**< revision data string length (including terminating NULL byte) */ |
| 151 | |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 152 | #define LYS_UNKNOWN 0x0000 /**< uninitalized unknown statement node */ |
| 153 | #define LYS_CONTAINER 0x0001 /**< container statement node */ |
| 154 | #define LYS_CHOICE 0x0002 /**< choice statement node */ |
| 155 | #define LYS_LEAF 0x0004 /**< leaf statement node */ |
| 156 | #define LYS_LEAFLIST 0x0008 /**< leaf-list statement node */ |
| 157 | #define LYS_LIST 0x0010 /**< list statement node */ |
| 158 | #define LYS_ANYXML 0x0020 /**< anyxml statement node */ |
| 159 | #define LYS_CASE 0x0040 /**< case statement node */ |
| 160 | #define LYS_USES 0x0080 /**< uses statement node */ |
| 161 | #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] | 162 | |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 163 | #define LYS_INOUT 0x200 |
| 164 | #define LYS_ACTION 0x400 |
| 165 | #define LYS_NOTIF 0x800 |
| 166 | #define LYS_GROUPING 0x1000 |
| 167 | #define LYS_AUGMENT 0x2000 |
| 168 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 169 | /** |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 170 | * @brief YANG built-in types |
| 171 | */ |
| 172 | typedef enum { |
| 173 | LY_TYPE_UNKNOWN = 0, /**< Unknown type */ |
| 174 | LY_TYPE_BINARY, /**< Any binary data ([RFC 6020 sec 9.8](http://tools.ietf.org/html/rfc6020#section-9.8)) */ |
| 175 | LY_TYPE_BITS, /**< A set of bits or flags ([RFC 6020 sec 9.7](http://tools.ietf.org/html/rfc6020#section-9.7)) */ |
| 176 | LY_TYPE_BOOL, /**< "true" or "false" ([RFC 6020 sec 9.5](http://tools.ietf.org/html/rfc6020#section-9.5)) */ |
| 177 | LY_TYPE_DEC64, /**< 64-bit signed decimal number ([RFC 6020 sec 9.3](http://tools.ietf.org/html/rfc6020#section-9.3))*/ |
| 178 | LY_TYPE_EMPTY, /**< A leaf that does not have any value ([RFC 6020 sec 9.11](http://tools.ietf.org/html/rfc6020#section-9.11)) */ |
| 179 | LY_TYPE_ENUM, /**< Enumerated strings ([RFC 6020 sec 9.6](http://tools.ietf.org/html/rfc6020#section-9.6)) */ |
| 180 | LY_TYPE_IDENT, /**< A reference to an abstract identity ([RFC 6020 sec 9.10](http://tools.ietf.org/html/rfc6020#section-9.10)) */ |
| 181 | LY_TYPE_INST, /**< References a data tree node ([RFC 6020 sec 9.13](http://tools.ietf.org/html/rfc6020#section-9.13)) */ |
| 182 | LY_TYPE_LEAFREF, /**< A reference to a leaf instance ([RFC 6020 sec 9.9](http://tools.ietf.org/html/rfc6020#section-9.9))*/ |
| 183 | LY_TYPE_STRING, /**< Human-readable string ([RFC 6020 sec 9.4](http://tools.ietf.org/html/rfc6020#section-9.4)) */ |
| 184 | LY_TYPE_UNION, /**< Choice of member types ([RFC 6020 sec 9.12](http://tools.ietf.org/html/rfc6020#section-9.12)) */ |
| 185 | LY_TYPE_INT8, /**< 8-bit signed integer ([RFC 6020 sec 9.2](http://tools.ietf.org/html/rfc6020#section-9.2)) */ |
| 186 | LY_TYPE_UINT8, /**< 8-bit unsigned integer ([RFC 6020 sec 9.2](http://tools.ietf.org/html/rfc6020#section-9.2)) */ |
| 187 | LY_TYPE_INT16, /**< 16-bit signed integer ([RFC 6020 sec 9.2](http://tools.ietf.org/html/rfc6020#section-9.2)) */ |
| 188 | LY_TYPE_UINT16, /**< 16-bit unsigned integer ([RFC 6020 sec 9.2](http://tools.ietf.org/html/rfc6020#section-9.2)) */ |
| 189 | LY_TYPE_INT32, /**< 32-bit signed integer ([RFC 6020 sec 9.2](http://tools.ietf.org/html/rfc6020#section-9.2)) */ |
| 190 | LY_TYPE_UINT32, /**< 32-bit unsigned integer ([RFC 6020 sec 9.2](http://tools.ietf.org/html/rfc6020#section-9.2)) */ |
| 191 | LY_TYPE_INT64, /**< 64-bit signed integer ([RFC 6020 sec 9.2](http://tools.ietf.org/html/rfc6020#section-9.2)) */ |
| 192 | LY_TYPE_UINT64, /**< 64-bit unsigned integer ([RFC 6020 sec 9.2](http://tools.ietf.org/html/rfc6020#section-9.2)) */ |
| 193 | } LY_DATA_TYPE; |
| 194 | #define LY_DATA_TYPE_COUNT 20 /**< Number of different types */ |
| 195 | |
Radek Krejci | d505e3d | 2018-11-13 09:04:17 +0100 | [diff] [blame] | 196 | extern const char* ly_data_type2str[LY_DATA_TYPE_COUNT]; |
| 197 | |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 198 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 199 | * @brief YANG import-stmt |
| 200 | */ |
| 201 | struct lysp_import { |
Radek Krejci | 086c713 | 2018-10-26 15:29:04 +0200 | [diff] [blame] | 202 | struct lys_module *module; /**< pointer to the imported module |
| 203 | (mandatory, but resolved when the referring module is completely parsed) */ |
| 204 | const char *name; /**< name of the imported module (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 205 | const char *prefix; /**< prefix for the data from the imported schema (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 206 | const char *dsc; /**< description */ |
| 207 | const char *ref; /**< reference */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 208 | 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] | 209 | char rev[LY_REV_SIZE]; /**< revision-date of the imported module */ |
| 210 | }; |
| 211 | |
| 212 | /** |
| 213 | * @brief YANG include-stmt |
| 214 | */ |
| 215 | struct lysp_include { |
Radek Krejci | 086c713 | 2018-10-26 15:29:04 +0200 | [diff] [blame] | 216 | struct lysp_module *submodule; /**< pointer to the parsed submodule structure |
| 217 | (mandatory, but resolved when the referring module is completely parsed) */ |
| 218 | const char *name; /**< name of the included submodule (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 219 | const char *dsc; /**< description */ |
| 220 | const char *ref; /**< reference */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 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 | char rev[LY_REV_SIZE]; /**< revision-date of the included submodule */ |
| 223 | }; |
| 224 | |
| 225 | /** |
| 226 | * @brief YANG extension-stmt |
| 227 | */ |
| 228 | struct lysp_ext { |
| 229 | const char *name; /**< extension name */ |
| 230 | const char *argument; /**< argument name, NULL if not specified */ |
| 231 | const char *dsc; /**< description statement */ |
| 232 | const char *ref; /**< reference statement */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 233 | 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] | 234 | uint16_t flags; /**< LYS_STATUS_* and LYS_YINELEM values (@ref snodeflags) */ |
| 235 | }; |
| 236 | |
| 237 | /** |
| 238 | * @brief Helper structure for generic storage of the extension instances content. |
| 239 | */ |
| 240 | struct lysp_stmt { |
| 241 | const char *stmt; /**< identifier of the statement */ |
| 242 | const char *arg; /**< statement's argument */ |
| 243 | struct lysp_stmt *next; /**< link to the next statement */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 244 | struct lysp_stmt *child; /**< list of the statement's substatements (linked list) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 245 | }; |
| 246 | |
| 247 | /** |
| 248 | * @brief YANG extension instance |
| 249 | */ |
| 250 | struct lysp_ext_instance { |
| 251 | const char *name; /**< extension identifier, including possible prefix */ |
| 252 | const char *argument; /**< optional value of the extension's argument */ |
Michal Vasko | d92e42a | 2018-09-07 08:35:02 +0200 | [diff] [blame] | 253 | LYEXT_SUBSTMT insubstmt; /**< value identifying placement of the extension instance */ |
| 254 | uint32_t insubstmt_index; /**< in case the instance is in a substatement, this identifies |
| 255 | the index of that substatement */ |
Michal Vasko | bc2559f | 2018-09-07 10:17:50 +0200 | [diff] [blame] | 256 | struct lysp_stmt *child; /**< list of the extension's substatements (linked list) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 257 | }; |
| 258 | |
| 259 | /** |
| 260 | * @brief YANG feature-stmt |
| 261 | */ |
| 262 | struct lysp_feature { |
| 263 | const char *name; /**< feature name (mandatory) */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 264 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 265 | const char *dsc; /**< description statement */ |
| 266 | const char *ref; /**< reference statement */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 267 | 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] | 268 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* values allowed */ |
| 269 | }; |
| 270 | |
| 271 | /** |
| 272 | * @brief YANG identity-stmt |
| 273 | */ |
| 274 | struct lysp_ident { |
| 275 | const char *name; /**< identity name (mandatory), including possible prefix */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 276 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 277 | const char **bases; /**< list of base identifiers ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 278 | const char *dsc; /**< description statement */ |
| 279 | const char *ref; /**< reference statement */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 280 | 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] | 281 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ values are allowed */ |
| 282 | }; |
| 283 | |
Michal Vasko | 71e64ca | 2018-09-07 16:30:29 +0200 | [diff] [blame] | 284 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 285 | * @brief Covers restrictions: range, length, pattern, must |
| 286 | */ |
| 287 | struct lysp_restr { |
| 288 | const char *arg; /**< The restriction expression/value (mandatory); |
| 289 | in case of pattern restriction, the first byte has a special meaning: |
| 290 | 0x06 (ACK) for regular match and 0x15 (NACK) for invert-match */ |
| 291 | const char *emsg; /**< error-message */ |
| 292 | const char *eapptag; /**< error-app-tag value */ |
| 293 | const char *dsc; /**< description */ |
| 294 | const char *ref; /**< reference */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 295 | 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] | 296 | }; |
| 297 | |
| 298 | /** |
Michal Vasko | 71e64ca | 2018-09-07 16:30:29 +0200 | [diff] [blame] | 299 | * @brief YANG revision-stmt |
| 300 | */ |
| 301 | struct lysp_revision { |
Radek Krejci | b7db73a | 2018-10-24 14:18:40 +0200 | [diff] [blame] | 302 | char date[LY_REV_SIZE]; /**< revision date (madatory) */ |
Michal Vasko | 71e64ca | 2018-09-07 16:30:29 +0200 | [diff] [blame] | 303 | const char *dsc; /**< description statement */ |
| 304 | const char *ref; /**< reference statement */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 305 | 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] | 306 | }; |
| 307 | |
| 308 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 309 | * @brief Enumeration/Bit value definition |
| 310 | */ |
| 311 | struct lysp_type_enum { |
| 312 | const char *name; /**< name (mandatory) */ |
| 313 | const char *dsc; /**< description statement */ |
| 314 | const char *ref; /**< reference statement */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 315 | int64_t value; /**< enum's value or bit's position */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 316 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 317 | 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] | 318 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ and LYS_SET_VALUE |
| 319 | values are allowed */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 320 | }; |
| 321 | |
| 322 | /** |
| 323 | * @brief YANG type-stmt |
| 324 | * |
| 325 | * Some of the items in the structure may be mandatory, but it is necessary to resolve the type's base type first |
| 326 | */ |
| 327 | struct lysp_type { |
| 328 | const char *name; /**< name of the type (mandatory) */ |
| 329 | struct lysp_restr *range; /**< allowed values range - numerical, decimal64 */ |
| 330 | struct lysp_restr *length; /**< allowed length of the value - string, binary */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 331 | struct lysp_restr *patterns; /**< list of patterns ([sized array](@ref sizedarrays)) - string */ |
| 332 | struct lysp_type_enum *enums; /**< list of enum-stmts ([sized array](@ref sizedarrays)) - enum */ |
| 333 | 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] | 334 | const char *path; /**< path - leafref */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 335 | const char **bases; /**< list of base identifiers ([sized array](@ref sizedarrays)) - identityref */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 336 | struct lysp_type *types; /**< list of sub-types ([sized array](@ref sizedarrays)) - union */ |
| 337 | 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] | 338 | |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 339 | struct lysc_type *compiled; /**< pointer to the compiled type */ |
| 340 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 341 | uint8_t fraction_digits; /**< number of fraction digits - decimal64 */ |
| 342 | uint8_t require_instance; /**< require-instance flag - leafref, instance */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 343 | uint16_t flags; /**< [schema node flags](@ref spnodeflags) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 344 | }; |
| 345 | |
| 346 | /** |
| 347 | * @brief YANG typedef-stmt |
| 348 | */ |
| 349 | struct lysp_tpdf { |
| 350 | const char *name; /**< name of the newly defined type (mandatory) */ |
| 351 | const char *units; /**< units of the newly defined type */ |
| 352 | const char *dflt; /**< default value of the newly defined type */ |
| 353 | const char *dsc; /**< description statement */ |
| 354 | const char *ref; /**< reference statement */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 355 | 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] | 356 | 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] | 357 | uint16_t flags; /**< [schema node flags](@ref spnodeflags) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 358 | }; |
| 359 | |
| 360 | /** |
| 361 | * @brief YANG grouping-stmt |
| 362 | */ |
| 363 | struct lysp_grp { |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 364 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level grouping) */ |
| 365 | uint16_t nodetype; /**< LYS_GROUPING */ |
| 366 | 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] | 367 | const char *name; /**< grouping name (mandatory) */ |
| 368 | const char *dsc; /**< description statement */ |
| 369 | const char *ref; /**< reference statement */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 370 | struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */ |
| 371 | struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 372 | struct lysp_node *data; /**< list of data nodes (linked list) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 373 | struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */ |
| 374 | struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */ |
| 375 | 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] | 376 | }; |
| 377 | |
| 378 | /** |
| 379 | * @brief YANG when-stmt |
| 380 | */ |
| 381 | struct lysp_when { |
| 382 | const char *cond; /**< specified condition (mandatory) */ |
| 383 | const char *dsc; /**< description statement */ |
| 384 | const char *ref; /**< reference statement */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 385 | 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] | 386 | }; |
| 387 | |
| 388 | /** |
| 389 | * @brief YANG refine-stmt |
| 390 | */ |
| 391 | struct lysp_refine { |
| 392 | const char *nodeid; /**< target descendant schema nodeid (mandatory) */ |
| 393 | const char *dsc; /**< description statement */ |
| 394 | const char *ref; /**< reference statement */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 395 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 396 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 397 | const char *presence; /**< presence description */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 398 | const char **dflts; /**< list of default values ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 399 | uint32_t min; /**< min-elements constraint */ |
| 400 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 401 | 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] | 402 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 403 | }; |
| 404 | |
| 405 | /** |
| 406 | * @brief YANG uses-augment-stmt and augment-stmt |
| 407 | */ |
| 408 | struct lysp_augment { |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 409 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level augment) */ |
| 410 | uint16_t nodetype; /**< LYS_AUGMENT */ |
| 411 | 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] | 412 | const char *nodeid; /**< target schema nodeid (mandatory) - absolute for global augments, descendant for uses's augments */ |
| 413 | const char *dsc; /**< description statement */ |
| 414 | const char *ref; /**< reference statement */ |
| 415 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 416 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 417 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 418 | struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */ |
| 419 | struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */ |
| 420 | 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] | 421 | }; |
| 422 | |
| 423 | /** |
| 424 | * @defgroup deviatetypes Deviate types |
| 425 | * @{ |
| 426 | */ |
| 427 | #define LYS_DEV_NOT_SUPPORTED 1 /**< deviate type not-supported */ |
| 428 | #define LYS_DEV_ADD 2 /**< deviate type add */ |
| 429 | #define LYS_DEV_DELETE 3 /**< deviate type delete */ |
| 430 | #define LYS_DEV_REPLACE 4 /**< deviate type replace */ |
| 431 | /** @} */ |
| 432 | |
| 433 | /** |
| 434 | * @brief Generic deviate structure to get type and cast to lysp_deviate_* structure |
| 435 | */ |
| 436 | struct lysp_deviate { |
| 437 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 438 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 439 | 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] | 440 | }; |
| 441 | |
| 442 | struct lysp_deviate_add { |
| 443 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 444 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 445 | 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] | 446 | const char *units; /**< units of the values */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 447 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 448 | const char **uniques; /**< list of uniques specifications ([sized array](@ref sizedarrays)) */ |
| 449 | const char **dflts; /**< list of default values ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 450 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 451 | uint32_t min; /**< min-elements constraint */ |
| 452 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 453 | }; |
| 454 | |
| 455 | struct lysp_deviate_del { |
| 456 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 457 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 458 | 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] | 459 | const char *units; /**< units of the values */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 460 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 461 | const char **uniques; /**< list of uniques specifications ([sized array](@ref sizedarrays)) */ |
| 462 | const char **dflts; /**< list of default values ([sized array](@ref sizedarrays)) */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 463 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 464 | }; |
| 465 | |
| 466 | struct lysp_deviate_rpl { |
| 467 | uint8_t mod; /**< [type](@ref deviatetypes) of the deviate modification */ |
| 468 | struct lysp_deviate *next; /**< next deviate structure in the list */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 469 | 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] | 470 | struct lysp_type *type; /**< type of the node */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 471 | const char *units; /**< units of the values */ |
| 472 | const char *dflt; /**< default value */ |
| 473 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 474 | uint32_t min; /**< min-elements constraint */ |
| 475 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 476 | }; |
| 477 | |
| 478 | struct lysp_deviation { |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 479 | const char *nodeid; /**< target absolute schema nodeid (mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 480 | const char *dsc; /**< description statement */ |
| 481 | const char *ref; /**< reference statement */ |
| 482 | struct lysp_deviate* deviates; /**< list of deviate specifications (linked list) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 483 | 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] | 484 | }; |
| 485 | |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 486 | /** |
| 487 | * @defgroup spnodeflags Parsed schema nodes flags |
| 488 | * @ingroup snodeflags |
| 489 | * |
| 490 | * Various flags for parsed schema nodes. |
| 491 | * |
| 492 | * 1 - container 6 - anydata/anyxml 11 - output 16 - grouping 21 - enum |
| 493 | * 2 - choice 7 - case 12 - feature 17 - uses 22 - type |
| 494 | * 3 - leaf 8 - notification 13 - identity 18 - refine |
| 495 | * 4 - leaflist 9 - rpc 14 - extension 19 - augment |
| 496 | * 5 - list 10 - input 15 - typedef 20 - deviate |
| 497 | * |
| 498 | * 1 1 1 1 1 1 1 1 1 1 2 2 2 |
| 499 | * bit name 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 |
| 500 | * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 501 | * 1 LYS_CONFIG_W |x|x|x|x|x|x|x| | | | | | | | | | |x| |x| | | |
Radek Krejci | d505e3d | 2018-11-13 09:04:17 +0100 | [diff] [blame] | 502 | * LYS_SET_BASE | | | | | | | | | | | | | | | | | | | | | |x| |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 503 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 504 | * 2 LYS_CONFIG_R |x|x|x|x|x|x|x| | | | | | | | | | |x| |x| | | |
Radek Krejci | d505e3d | 2018-11-13 09:04:17 +0100 | [diff] [blame] | 505 | * LYS_SET_BIT | | | | | | | | | | | | | | | | | | | | | |x| |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 506 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 507 | * 3 LYS_STATUS_CURR |x|x|x|x|x|x|x|x|x| | |x|x|x|x|x|x| |x|x|x| | |
Radek Krejci | d505e3d | 2018-11-13 09:04:17 +0100 | [diff] [blame] | 508 | * LYS_SET_ENUM | | | | | | | | | | | | | | | | | | | | | |x| |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 509 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 510 | * 4 LYS_STATUS_DEPRC |x|x|x|x|x|x|x|x|x| | |x|x|x|x|x|x| |x|x|x| | |
Radek Krejci | d505e3d | 2018-11-13 09:04:17 +0100 | [diff] [blame] | 511 | * LYS_SET_FRDIGITS | | | | | | | | | | | | | | | | | | | | | |x| |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 512 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 513 | * 5 LYS_STATUS_OBSLT |x|x|x|x|x|x|x|x|x| | |x|x|x|x|x|x| |x|x|x| | |
Radek Krejci | d505e3d | 2018-11-13 09:04:17 +0100 | [diff] [blame] | 514 | * LYS_SET_LENGTH | | | | | | | | | | | | | | | | | | | | | |x| |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 515 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 516 | * 6 LYS_MAND_TRUE | |x|x| | |x| | | | | | | | | | | |x| |x| | | |
| 517 | * LYS_ORDBY_SYSTEM | | | |x|x| | | | | | | | | | | | | | | | | | |
Radek Krejci | d505e3d | 2018-11-13 09:04:17 +0100 | [diff] [blame] | 518 | * LYS_SET_PATH | | | | | | | | | | | | | | | | | | | | | |x| |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 519 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 520 | * 7 LYS_MAND_FALSE | |x|x| | |x| | | | | | | | | | | |x| |x| | | |
| 521 | * LYS_ORDBY_USER | | | |x|x| | | | | | | | | | | | | | | | | | |
Radek Krejci | d505e3d | 2018-11-13 09:04:17 +0100 | [diff] [blame] | 522 | * LYS_SET_PATTERN | | | | | | | | | | | | | | | | | | | | | |x| |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 523 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 524 | * 8 LYS_YINELEM_TRUE | | | | | | | | | | | | | |x| | | | | | | | | |
Radek Krejci | d505e3d | 2018-11-13 09:04:17 +0100 | [diff] [blame] | 525 | * LYS_SET_RANGE | | | | | | | | | | | | | | | | | | | | | |x| |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 526 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 527 | * 9 LYS_YINELEM_FALSE| | | | | | | | | | | | | |x| | | | | | | | | |
Radek Krejci | d505e3d | 2018-11-13 09:04:17 +0100 | [diff] [blame] | 528 | * LYS_SET_TYPE | | | | | | | | | | | | | | | | | | | | | |x| |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 529 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 530 | * 10 LYS_SET_VALUE | | | | | | | | | | | | | | | | | | | | |x| | |
| 531 | * LYS_SET_REQINST | | | | | | | | | | | | | | | | | | | | | |x| |
| 532 | * LYS_SET_MIN | | | |x|x| | | | | | | | | | | | |x| |x| | | |
| 533 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 534 | * 11 LYS_SET_MAX | | | |x|x| | | | | | | | | | | | |x| |x| | | |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 535 | * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 536 | * |
| 537 | */ |
| 538 | |
| 539 | /** |
| 540 | * @defgroup scnodeflags Compiled schema nodes flags |
| 541 | * @ingroup snodeflags |
| 542 | * |
| 543 | * Various flags for compiled schema nodes. |
| 544 | * |
| 545 | * 1 - container 6 - anydata/anyxml 11 - output |
| 546 | * 2 - choice 7 - case 12 - feature |
| 547 | * 3 - leaf 8 - notification 13 - identity |
| 548 | * 4 - leaflist 9 - rpc 14 - extension |
| 549 | * 5 - list 10 - input |
| 550 | * |
| 551 | * 1 1 1 1 1 |
| 552 | * bit name 1 2 3 4 5 6 7 8 9 0 1 2 3 4 |
| 553 | * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 554 | * 1 LYS_CONFIG_W |x|x|x|x|x|x|x| | |x| | | | | |
| 555 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 556 | * 2 LYS_CONFIG_R |x|x|x|x|x|x|x| | | |x| | | | |
| 557 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 558 | * 3 LYS_PRESENCE |x| | | | | | | | | | | | | | |
| 559 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 560 | * 4 LYS_UNIQUE | | |x| | | | | | | | | | | | |
| 561 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 562 | * 5 LYS_FENABLED | | | | | | | | | | | |x| | | |
| 563 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 564 | * 6 LYS_MAND_TRUE | |x|x| | |x| | | | | | | | | |
| 565 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 566 | * 7 LYS_ORDBY_USER | | | |x|x| | | | | | | | | | |
| 567 | * ---------------------+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 568 | * |
| 569 | */ |
| 570 | |
| 571 | /** |
| 572 | * @defgroup snodeflags Schema nodes flags |
| 573 | * @ingroup schematree |
| 574 | * @{ |
| 575 | */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 576 | #define LYS_CONFIG_W 0x01 /**< config true; */ |
| 577 | #define LYS_CONFIG_R 0x02 /**< config false; */ |
| 578 | #define LYS_CONFIG_MASK 0x03 /**< mask for config value */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 579 | #define LYS_STATUS_CURR 0x04 /**< status current; */ |
| 580 | #define LYS_STATUS_DEPRC 0x08 /**< status deprecated; */ |
| 581 | #define LYS_STATUS_OBSLT 0x10 /**< status obsolete; */ |
| 582 | #define LYS_STATUS_MASK 0x1C /**< mask for status value */ |
| 583 | #define LYS_MAND_TRUE 0x20 /**< mandatory true; applicable only to ::lysp_node_choice/::lysc_node_choice, |
| 584 | ::lysp_node_leaf/::lysc_node_leaf and ::lysp_node_anydata/::lysc_node_anydata */ |
| 585 | #define LYS_MAND_FALSE 0x40 /**< mandatory false; applicable only to |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 586 | ::lysp_node_choice/::lysc_node_choice, ::lysp_node_leaf/::lysc_node_leaf |
| 587 | and ::lysp_node_anydata/::lysc_node_anydata */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 588 | #define LYS_MAND_MASK 0x60 /**< mask for mandatory values */ |
| 589 | #define LYS_PRESENCE 0x04 /**< flag for presence property of a container, applicable only to ::lysc_node_container */ |
| 590 | #define LYS_UNIQUE 0x08 /**< flag for leafs being part of a unique set, applicable only to ::lysc_node_leaf */ |
| 591 | #define LYS_FENABLED 0x10 /**< feature enabled flag, applicable only to ::lysc_feature */ |
| 592 | #define LYS_ORDBY_SYSTEM 0x20 /**< ordered-by user lists, applicable only to ::lysc_node_leaflist/::lysp_node_leaflist and |
| 593 | ::lysc_node_list/::lysp_node_list */ |
| 594 | #define LYS_ORDBY_USER 0x40 /**< ordered-by user lists, applicable only to ::lysc_node_leaflist/::lysp_node_leaflist and |
| 595 | ::lysc_node_list/::lysp_node_list */ |
| 596 | #define LYS_ORDBY_MASK 0x60 /**< mask for ordered-by values */ |
| 597 | #define LYS_YINELEM_TRUE 0x80 /**< yin-element true for extension's argument */ |
| 598 | #define LYS_YINELEM_FALSE 0x100 /**< yin-element false for extension's argument */ |
| 599 | #define LYS_YINELEM_MASK 0x180 /**< mask for yin-element value */ |
| 600 | #define LYS_SET_VALUE 0x200 /**< value attribute is set */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 601 | #define LYS_SET_MIN 0x200 /**< min attribute is set */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 602 | #define LYS_SET_MAX 0x400 /**< max attribute is set */ |
Radek Krejci | d505e3d | 2018-11-13 09:04:17 +0100 | [diff] [blame] | 603 | |
| 604 | #define LYS_SET_BASE 0x0001 /**< type's flag for present base substatement */ |
| 605 | #define LYS_SET_BIT 0x0002 /**< type's flag for present bit substatement */ |
| 606 | #define LYS_SET_ENUM 0x0004 /**< type's flag for present enum substatement */ |
| 607 | #define LYS_SET_FRDIGITS 0x0008 /**< type's flag for present fraction-digits substatement */ |
| 608 | #define LYS_SET_LENGTH 0x0010 /**< type's flag for present length substatement */ |
| 609 | #define LYS_SET_PATH 0x0020 /**< type's flag for present path substatement */ |
| 610 | #define LYS_SET_PATTERN 0x0040 /**< type's flag for present pattern substatement */ |
| 611 | #define LYS_SET_RANGE 0x0080 /**< type's flag for present range substatement */ |
| 612 | #define LYS_SET_TYPE 0x0100 /**< type's flag for present type substatement */ |
| 613 | #define LYS_SET_REQINST 0x0200 /**< type's flag for present require-instance substatement */ |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 614 | /** @} */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 615 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 616 | /** |
| 617 | * @brief Generic YANG data node |
| 618 | */ |
| 619 | struct lysp_node { |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 620 | 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] | 621 | uint16_t nodetype; /**< type of the node (mandatory) */ |
| 622 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 623 | 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] | 624 | const char *name; /**< node name (mandatory) */ |
| 625 | const char *dsc; /**< description statement */ |
| 626 | const char *ref; /**< reference statement */ |
| 627 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 628 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 629 | 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] | 630 | }; |
| 631 | |
| 632 | /** |
| 633 | * @brief Extension structure of the lysp_node for YANG container |
| 634 | */ |
| 635 | struct lysp_node_container { |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 636 | 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] | 637 | uint16_t nodetype; /**< LYS_CONTAINER */ |
| 638 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 639 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 640 | const char *name; /**< node name (mandatory) */ |
| 641 | const char *dsc; /**< description statement */ |
| 642 | const char *ref; /**< reference statement */ |
| 643 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 644 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 645 | 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] | 646 | |
| 647 | /* container */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 648 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 649 | const char *presence; /**< presence description */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 650 | struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */ |
| 651 | struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 652 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 653 | struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */ |
| 654 | struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 655 | }; |
| 656 | |
| 657 | struct lysp_node_leaf { |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 658 | 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] | 659 | uint16_t nodetype; /**< LYS_LEAF */ |
| 660 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 661 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 662 | const char *name; /**< node name (mandatory) */ |
| 663 | const char *dsc; /**< description statement */ |
| 664 | const char *ref; /**< reference statement */ |
| 665 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 666 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 667 | 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] | 668 | |
| 669 | /* leaf */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 670 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 671 | struct lysp_type type; /**< type of the leaf node (mandatory) */ |
| 672 | const char *units; /**< units of the leaf's type */ |
| 673 | const char *dflt; /**< default value */ |
| 674 | }; |
| 675 | |
| 676 | struct lysp_node_leaflist { |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 677 | 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] | 678 | uint16_t nodetype; /**< LYS_LEAFLIST */ |
| 679 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 680 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 681 | const char *name; /**< node name (mandatory) */ |
| 682 | const char *dsc; /**< description statement */ |
| 683 | const char *ref; /**< reference statement */ |
| 684 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 685 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 686 | 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] | 687 | |
| 688 | /* leaf-list */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 689 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 690 | struct lysp_type type; /**< type of the leaf node (mandatory) */ |
| 691 | const char *units; /**< units of the leaf's type */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 692 | const char **dflts; /**< list of default values ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 693 | uint32_t min; /**< min-elements constraint */ |
| 694 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 695 | }; |
| 696 | |
| 697 | struct lysp_node_list { |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 698 | 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] | 699 | uint16_t nodetype; /**< LYS_LIST */ |
| 700 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 701 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 702 | const char *name; /**< node name (mandatory) */ |
| 703 | const char *dsc; /**< description statement */ |
| 704 | const char *ref; /**< reference statement */ |
| 705 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 706 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 707 | 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] | 708 | |
| 709 | /* list */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 710 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 711 | const char *key; /**< keys specification */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 712 | struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */ |
| 713 | struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 714 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 715 | struct lysp_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */ |
| 716 | struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 717 | const char **uniques; /**< list of unique specifications ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 718 | uint32_t min; /**< min-elements constraint */ |
| 719 | uint32_t max; /**< max-elements constraint, 0 means unbounded */ |
| 720 | }; |
| 721 | |
| 722 | struct lysp_node_choice { |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 723 | 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] | 724 | uint16_t nodetype; /**< LYS_CHOICE */ |
| 725 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 726 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 727 | const char *name; /**< node name (mandatory) */ |
| 728 | const char *dsc; /**< description statement */ |
| 729 | const char *ref; /**< reference statement */ |
| 730 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 731 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 732 | 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] | 733 | |
| 734 | /* choice */ |
| 735 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
| 736 | const char* dflt; /**< default case */ |
| 737 | }; |
| 738 | |
| 739 | struct lysp_node_case { |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 740 | 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] | 741 | uint16_t nodetype; /**< LYS_CASE */ |
| 742 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 743 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 744 | const char *name; /**< node name (mandatory) */ |
| 745 | const char *dsc; /**< description statement */ |
| 746 | const char *ref; /**< reference statement */ |
| 747 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 748 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 749 | 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] | 750 | |
| 751 | /* case */ |
| 752 | struct lysp_node *child; /**< list of data nodes (linked list) */ |
| 753 | }; |
| 754 | |
| 755 | struct lysp_node_anydata { |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 756 | 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] | 757 | uint16_t nodetype; /**< LYS_ANYXML || LYS_ANYDATA */ |
| 758 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 759 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 760 | const char *name; /**< node name (mandatory) */ |
| 761 | const char *dsc; /**< description statement */ |
| 762 | const char *ref; /**< reference statement */ |
| 763 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 764 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 765 | 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] | 766 | |
| 767 | /* anyxml/anydata */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 768 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 769 | }; |
| 770 | |
| 771 | struct lysp_node_uses { |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 772 | 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] | 773 | uint16_t nodetype; /**< LYS_USES */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 774 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 775 | struct lysp_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 776 | const char *name; /**< grouping name reference (mandatory) */ |
| 777 | const char *dsc; /**< description statement */ |
| 778 | const char *ref; /**< reference statement */ |
| 779 | struct lysp_when *when; /**< when statement */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 780 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 781 | 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] | 782 | |
| 783 | /* uses */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 784 | struct lysp_refine *refines; /**< list of uses's refines ([sized array](@ref sizedarrays)) */ |
| 785 | 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] | 786 | }; |
| 787 | |
| 788 | /** |
| 789 | * @brief YANG input-stmt and output-stmt |
| 790 | */ |
| 791 | struct lysp_action_inout { |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 792 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */ |
| 793 | uint16_t nodetype; /**< LYS_INOUT */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 794 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
| 795 | struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */ |
| 796 | struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 797 | struct lysp_node *data; /**< list of data nodes (linked list) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 798 | 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] | 799 | }; |
| 800 | |
| 801 | /** |
| 802 | * @brief YANG rpc-stmt and action-stmt |
| 803 | */ |
| 804 | struct lysp_action { |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 805 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */ |
| 806 | uint16_t nodetype; /**< LYS_ACTION */ |
| 807 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 808 | const char *name; /**< grouping name reference (mandatory) */ |
| 809 | const char *dsc; /**< description statement */ |
| 810 | const char *ref; /**< reference statement */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 811 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 812 | struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */ |
| 813 | struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */ |
Michal Vasko | b55f6c1 | 2018-09-12 11:13:15 +0200 | [diff] [blame] | 814 | struct lysp_action_inout *input; /**< RPC's/Action's input */ |
| 815 | struct lysp_action_inout *output;/**< RPC's/Action's output */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 816 | 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] | 817 | }; |
| 818 | |
| 819 | /** |
| 820 | * @brief YANG notification-stmt |
| 821 | */ |
| 822 | struct lysp_notif { |
Radek Krejci | 6d9b9b5 | 2018-11-02 12:43:39 +0100 | [diff] [blame] | 823 | struct lysp_node *parent; /**< parent node (NULL if this is a top-level node) */ |
| 824 | uint16_t nodetype; /**< LYS_NOTIF */ |
| 825 | 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] | 826 | const char *name; /**< grouping name reference (mandatory) */ |
| 827 | const char *dsc; /**< description statement */ |
| 828 | const char *ref; /**< reference statement */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 829 | const char **iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 830 | struct lysp_restr *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
| 831 | struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */ |
| 832 | struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 833 | struct lysp_node *data; /**< list of data nodes (linked list) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 834 | 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] | 835 | }; |
| 836 | |
| 837 | /** |
Radek Krejci | f0fceb6 | 2018-09-05 14:58:45 +0200 | [diff] [blame] | 838 | * @brief supported YANG schema version values |
| 839 | */ |
| 840 | typedef enum LYS_VERSION { |
| 841 | LYS_VERSION_UNDEF = 0, /**< no specific version, YANG 1.0 as default */ |
| 842 | LYS_VERSION_1_0 = 1, /**< YANG 1.0 */ |
| 843 | LYS_VERSION_1_1 = 2 /**< YANG 1.1 */ |
| 844 | } LYS_VERSION; |
| 845 | |
| 846 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 847 | * @brief Printable YANG schema tree structure representing YANG module. |
| 848 | * |
| 849 | * Simple structure corresponding to the YANG format. The schema is only syntactically validated. |
| 850 | */ |
| 851 | struct lysp_module { |
| 852 | struct ly_ctx *ctx; /**< libyang context of the module (mandatory) */ |
| 853 | const char *name; /**< name of the module (mandatory) */ |
Radek Krejci | 6d6e4e4 | 2018-10-29 13:28:19 +0100 | [diff] [blame] | 854 | const char *filepath; /**< path, if the schema was read from a file, NULL in case of reading from memory */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 855 | union { |
| 856 | /* module */ |
Michal Vasko | d5927ca | 2018-09-07 15:05:32 +0200 | [diff] [blame] | 857 | const char *ns; /**< namespace of the module (module - mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 858 | /* submodule */ |
Michal Vasko | d5927ca | 2018-09-07 15:05:32 +0200 | [diff] [blame] | 859 | const char *belongsto; /**< belongs to parent module (submodule - mandatory) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 860 | }; |
Michal Vasko | d5927ca | 2018-09-07 15:05:32 +0200 | [diff] [blame] | 861 | const char *prefix; /**< module prefix or submodule belongsto prefix of main module (mandatory) */ |
Radek Krejci | b7db73a | 2018-10-24 14:18:40 +0200 | [diff] [blame] | 862 | struct lysp_revision *revs; /**< list of the module revisions ([sized array](@ref sizedarrays)), the first revision |
| 863 | in the list is always the last (newest) revision of the module */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 864 | struct lysp_import *imports; /**< list of imported modules ([sized array](@ref sizedarrays)) */ |
| 865 | struct lysp_include *includes; /**< list of included submodules ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 866 | const char *org; /**< party/company responsible for the module */ |
| 867 | const char *contact; /**< contact information for the module */ |
| 868 | const char *dsc; /**< description of the module */ |
| 869 | const char *ref; /**< cross-reference for the module */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 870 | struct lysp_ext *extensions; /**< list of extension statements ([sized array](@ref sizedarrays)) */ |
| 871 | struct lysp_feature *features; /**< list of feature definitions ([sized array](@ref sizedarrays)) */ |
| 872 | struct lysp_ident *identities; /**< list of identities ([sized array](@ref sizedarrays)) */ |
| 873 | struct lysp_tpdf *typedefs; /**< list of typedefs ([sized array](@ref sizedarrays)) */ |
| 874 | struct lysp_grp *groupings; /**< list of groupings ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 875 | 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] | 876 | struct lysp_augment *augments; /**< list of augments ([sized array](@ref sizedarrays)) */ |
| 877 | struct lysp_action *rpcs; /**< list of RPCs ([sized array](@ref sizedarrays)) */ |
| 878 | struct lysp_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */ |
| 879 | struct lysp_deviation *deviations; /**< list of deviations ([sized array](@ref sizedarrays)) */ |
| 880 | 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] | 881 | |
Radek Krejci | f0fceb6 | 2018-09-05 14:58:45 +0200 | [diff] [blame] | 882 | uint8_t submodule:1; /**< flag to distinguish main modules and submodules */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 883 | uint8_t implemented:1; /**< flag if the module is implemented, not just imported */ |
Radek Krejci | 086c713 | 2018-10-26 15:29:04 +0200 | [diff] [blame] | 884 | uint8_t latest_revision:2; /**< flag to mark the latest available revision: |
| 885 | 1 - the latest revision in searchdirs was not searched yet and this is the |
| 886 | latest revision in the current context |
| 887 | 2 - searchdirs were searched and this is the latest available revision */ |
| 888 | uint8_t parsing:1; /**< flag for circular check */ |
| 889 | uint8_t version; /**< yang-version (LYS_VERSION values) */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 890 | }; |
| 891 | |
| 892 | /** |
Radek Krejci | 3f5e3db | 2018-10-11 15:57:47 +0200 | [diff] [blame] | 893 | * @brief Free the printable YANG schema tree structure. |
| 894 | * |
| 895 | * @param[in] module Printable YANG schema tree structure to free. |
| 896 | */ |
| 897 | void lysp_module_free(struct lysp_module *module); |
| 898 | |
| 899 | /** |
Radek Krejci | ce8c159 | 2018-10-29 15:35:51 +0100 | [diff] [blame] | 900 | * @brief YANG extension instance |
| 901 | */ |
| 902 | struct lysc_ext_instance { |
| 903 | struct lyext_plugin *plugin; /**< pointer to the plugin implementing the extension (if present) */ |
| 904 | void *parent; /**< pointer to the parent element holding the extension instance(s), use |
| 905 | ::lysc_ext_instance#parent_type to access the schema element */ |
| 906 | const char *argument; /**< optional value of the extension's argument */ |
| 907 | LYEXT_SUBSTMT insubstmt; /**< value identifying placement of the extension instance */ |
| 908 | uint32_t insubstmt_index; /**< in case the instance is in a substatement that can appear multiple times, |
| 909 | this identifies the index of the substatement for this extension instance */ |
Radek Krejci | 2a408df | 2018-10-29 16:32:26 +0100 | [diff] [blame] | 910 | LYEXT_PARENT parent_type; /**< type of the parent structure */ |
Radek Krejci | ce8c159 | 2018-10-29 15:35:51 +0100 | [diff] [blame] | 911 | #if 0 |
Radek Krejci | ce8c159 | 2018-10-29 15:35:51 +0100 | [diff] [blame] | 912 | uint8_t ext_type; /**< extension type (#LYEXT_TYPE) */ |
| 913 | uint8_t padding; /**< 32b padding */ |
Radek Krejci | ce8c159 | 2018-10-29 15:35:51 +0100 | [diff] [blame] | 914 | struct lys_module *module; /**< pointer to the extension instance's module (mandatory) */ |
| 915 | LYS_NODE nodetype; /**< LYS_EXT */ |
| 916 | #endif |
Radek Krejci | 2a408df | 2018-10-29 16:32:26 +0100 | [diff] [blame] | 917 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 918 | void *priv; /**< private caller's data, not used by libyang */ |
Radek Krejci | ce8c159 | 2018-10-29 15:35:51 +0100 | [diff] [blame] | 919 | }; |
| 920 | |
| 921 | /** |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 922 | * @brief Compiled YANG if-feature-stmt |
| 923 | */ |
| 924 | struct lysc_iffeature { |
| 925 | uint8_t *expr; /**< 2bits array describing the if-feature expression in prefix format, see @ref ifftokens */ |
| 926 | struct lysc_feature **features; /**< array of pointers to the features used in expression ([sized array](@ref sizedarrays)) */ |
| 927 | }; |
| 928 | |
| 929 | /** |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 930 | * @brief YANG import-stmt |
| 931 | */ |
| 932 | struct lysc_import { |
Radek Krejci | 6d6e4e4 | 2018-10-29 13:28:19 +0100 | [diff] [blame] | 933 | struct lys_module *module; /**< link to the imported module */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 934 | const char *prefix; /**< prefix for the data from the imported schema (mandatory) */ |
Radek Krejci | ce8c159 | 2018-10-29 15:35:51 +0100 | [diff] [blame] | 935 | 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] | 936 | }; |
| 937 | |
| 938 | /** |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 939 | * @brief YANG when-stmt |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 940 | */ |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 941 | struct lysc_when { |
| 942 | struct lyxp_expr *cond; /**< XPath when condition */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 943 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 944 | }; |
| 945 | |
| 946 | /** |
Radek Krejci | 2a408df | 2018-10-29 16:32:26 +0100 | [diff] [blame] | 947 | * @brief YANG identity-stmt |
| 948 | */ |
| 949 | struct lysc_ident { |
| 950 | const char *name; /**< identity name (mandatory), including possible prefix */ |
| 951 | struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 952 | struct lysc_ident **derived; /**< list of (pointers to the) derived identities ([sized array](@ref sizedarrays)) */ |
| 953 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 954 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_ values are allowed */ |
| 955 | }; |
| 956 | |
| 957 | /** |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 958 | * @brief YANG feature-stmt |
| 959 | */ |
| 960 | struct lysc_feature { |
| 961 | const char *name; /**< feature name (mandatory) */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 962 | struct lysc_feature **depfeatures;/**< list of pointers to other features depending on this one ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 963 | struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | ce8c159 | 2018-10-29 15:35:51 +0100 | [diff] [blame] | 964 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 965 | uint16_t flags; /**< [schema node flags](@ref snodeflags) - only LYS_STATUS_* and |
| 966 | #LYS_FENABLED values allowed */ |
| 967 | }; |
| 968 | |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 969 | /** |
| 970 | * @defgroup ifftokens if-feature expression tokens |
| 971 | * Tokens of if-feature expression used in ::lysc_iffeature#expr |
| 972 | * |
| 973 | * @{ |
| 974 | */ |
| 975 | #define LYS_IFF_NOT 0x00 /**< operand "not" */ |
| 976 | #define LYS_IFF_AND 0x01 /**< operand "and" */ |
| 977 | #define LYS_IFF_OR 0x02 /**< operand "or" */ |
| 978 | #define LYS_IFF_F 0x03 /**< feature */ |
| 979 | /** |
| 980 | * @} |
| 981 | */ |
| 982 | |
| 983 | /** |
Radek Krejci | b7db73a | 2018-10-24 14:18:40 +0200 | [diff] [blame] | 984 | * @brief Compiled YANG revision statement |
| 985 | */ |
| 986 | struct lysc_revision { |
| 987 | char date[LY_REV_SIZE]; /**< revision-date (mandatory) */ |
| 988 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 989 | }; |
| 990 | |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 991 | struct lysc_default { |
| 992 | struct lys_module *module; /**< module where the default was defined */ |
| 993 | const char *value; /**< default value (with possible prefixes from the module where defined) */ |
| 994 | }; |
| 995 | |
| 996 | struct lysc_range { |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 997 | struct lysc_range_part { |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 998 | union { /**< min boundary TODO decimal */ |
| 999 | int64_t min_64; /**< for int8, int16, int32 and int64 */ |
| 1000 | uint64_t min_u64; /**< for uint8, uint16, uint32 and uint64 */ |
| 1001 | }; |
| 1002 | union { /**< max boundary TODO decimal */ |
| 1003 | int64_t max_64; /**< for int8, int16, int32 and int64 */ |
| 1004 | uint64_t max_u64; /**< for uint8, uint16, uint32 and uint64 */ |
| 1005 | }; |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1006 | } *parts; /**< compiled range expression ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1007 | const char *emsg; /**< error-message */ |
| 1008 | const char *eapptag; /**< error-app-tag value */ |
| 1009 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1010 | }; |
| 1011 | |
| 1012 | struct lysc_pattern { |
| 1013 | pcre *expr; /**< compiled regular expression */ |
| 1014 | pcre_extra *expr_extra; /**< additional information to speed up matching */ |
| 1015 | const char *emsg; /**< error-message */ |
| 1016 | const char *eapptag; /**< error-app-tag value */ |
| 1017 | 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] | 1018 | uint32_t inverted:1; /**< invert-match flag */ |
| 1019 | uint32_t refcount:31; /**< reference counter */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1020 | }; |
| 1021 | |
| 1022 | struct lysc_must { |
| 1023 | struct lys_module *module; /**< module where the must was defined */ |
| 1024 | struct lyxp_expr *cond; /**< XPath when condition */ |
| 1025 | const char *emsg; /**< error-message */ |
| 1026 | const char *eapptag; /**< error-app-tag value */ |
| 1027 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1028 | }; |
| 1029 | |
| 1030 | struct lysc_type { |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1031 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1032 | LY_DATA_TYPE basetype; /**< Base type of the type */ |
| 1033 | uint32_t refcount; /**< reference counter for type sharing */ |
| 1034 | }; |
| 1035 | |
| 1036 | struct lysc_type_num { |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1037 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1038 | LY_DATA_TYPE basetype; /**< Base type of the type */ |
| 1039 | uint32_t refcount; /**< reference counter for type sharing */ |
| 1040 | struct lysc_range *range; /**< Optional range limitation */ |
| 1041 | }; |
| 1042 | |
| 1043 | struct lysc_type_dec { |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1044 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1045 | LY_DATA_TYPE basetype; /**< Base type of the type */ |
| 1046 | uint32_t refcount; /**< reference counter for type sharing */ |
| 1047 | uint64_t fraction_digits:1; /**< fraction digits specification */ |
| 1048 | uint64_t div:63; /**< value for moving decimal point (dividing the stored value to get the real value) */ |
| 1049 | struct lysc_range *range; /**< Optional range limitation */ |
| 1050 | }; |
| 1051 | |
| 1052 | struct lysc_type_str { |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1053 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1054 | LY_DATA_TYPE basetype; /**< Base type of the type */ |
| 1055 | uint32_t refcount; /**< reference counter for type sharing */ |
| 1056 | struct lysc_range *length; /**< Optional length limitation */ |
Radek Krejci | 4586a02 | 2018-11-13 11:29:26 +0100 | [diff] [blame] | 1057 | 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] | 1058 | }; |
| 1059 | |
| 1060 | struct lysc_type_enum { |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1061 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1062 | LY_DATA_TYPE basetype; /**< Base type of the type */ |
| 1063 | uint32_t refcount; /**< reference counter for type sharing */ |
Radek Krejci | 8b76466 | 2018-11-14 14:15:13 +0100 | [diff] [blame^] | 1064 | struct lysc_type_enum_item { |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1065 | const char *name; /**< enumeration identifier */ |
| 1066 | struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 8b76466 | 2018-11-14 14:15:13 +0100 | [diff] [blame^] | 1067 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1068 | int32_t value; /**< integer value associated with the enumeration */ |
| 1069 | } *enums; /**< enumerations list ([sized array](@ref sizedarrays)), mandatory (at least 1 item) */ |
| 1070 | }; |
| 1071 | |
| 1072 | struct lysc_type_leafref { |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1073 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1074 | LY_DATA_TYPE basetype; /**< Base type of the type */ |
| 1075 | uint32_t refcount; /**< reference counter for type sharing */ |
| 1076 | struct lysc_node* target; /**< Target schema node */ |
| 1077 | uint8_t require_instance; /**< require-instance flag */ |
| 1078 | }; |
| 1079 | |
| 1080 | struct lysc_type_identityref { |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1081 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1082 | LY_DATA_TYPE basetype; /**< Base type of the type */ |
| 1083 | uint32_t refcount; /**< reference counter for type sharing */ |
| 1084 | struct lysc_ident **base; /**< list of pointers to the base identities ([sized array](@ref sizedarrays)), |
| 1085 | mandatory (at least 1 item) */ |
| 1086 | }; |
| 1087 | |
| 1088 | struct lysc_type_instanceid { |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1089 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1090 | LY_DATA_TYPE basetype; /**< Base type of the type */ |
| 1091 | uint32_t refcount; /**< reference counter for type sharing */ |
| 1092 | uint8_t require_instance; /**< require-instance flag */ |
| 1093 | }; |
| 1094 | |
| 1095 | struct lysc_type_bits { |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1096 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1097 | LY_DATA_TYPE basetype; /**< Base type of the type */ |
| 1098 | uint32_t refcount; /**< reference counter for type sharing */ |
Radek Krejci | 8b76466 | 2018-11-14 14:15:13 +0100 | [diff] [blame^] | 1099 | struct lysc_type_bits_item { |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1100 | const char *name; /**< bit identifier */ |
| 1101 | struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 8b76466 | 2018-11-14 14:15:13 +0100 | [diff] [blame^] | 1102 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1103 | uint32_t position; /**< non-negative integer value associated with the bit */ |
| 1104 | } *bits; /**< bits list ([sized array](@ref sizedarrays)), mandatory (at least 1 item) */ |
| 1105 | }; |
| 1106 | |
| 1107 | struct lysc_type_union { |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1108 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1109 | LY_DATA_TYPE basetype; /**< Base type of the type */ |
| 1110 | uint32_t refcount; /**< reference counter for type sharing */ |
| 1111 | struct lysc_type **types; /**< list of types in the union ([sized array](@ref sizedarrays)), mandatory (at least 1 item) */ |
| 1112 | }; |
| 1113 | |
| 1114 | struct lysc_type_bin { |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1115 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2167ee1 | 2018-11-02 16:09:07 +0100 | [diff] [blame] | 1116 | LY_DATA_TYPE basetype; /**< Base type of the type */ |
| 1117 | uint32_t refcount; /**< reference counter for type sharing */ |
| 1118 | struct lysc_range *length; /**< Optional length limitation */ |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 1119 | }; |
| 1120 | |
| 1121 | /** |
Radek Krejci | 0af5f5d | 2018-09-07 15:00:30 +0200 | [diff] [blame] | 1122 | * @brief Compiled YANG data node |
| 1123 | */ |
| 1124 | struct lysc_node { |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1125 | uint16_t nodetype; /**< type of the node (mandatory) */ |
| 1126 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1127 | struct lys_module *module; /**< module structure */ |
| 1128 | 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. */ |
| 1129 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1130 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1131 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 1132 | never NULL. If there is no sibling node, pointer points to the node |
| 1133 | itself. In case of the first node, this pointer points to the last |
| 1134 | node in the list. */ |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1135 | const char *name; /**< node name (mandatory) */ |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 1136 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1137 | }; |
| 1138 | |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1139 | struct lysc_node_container { |
| 1140 | uint16_t nodetype; /**< LYS_CONTAINER */ |
| 1141 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1142 | struct lys_module *module; /**< module structure */ |
| 1143 | 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. */ |
| 1144 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1145 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1146 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 1147 | never NULL. If there is no sibling node, pointer points to the node |
| 1148 | itself. In case of the first node, this pointer points to the last |
| 1149 | node in the list. */ |
| 1150 | const char *name; /**< node name (mandatory) */ |
| 1151 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1152 | |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1153 | struct lysc_when *when; /**< when statement */ |
| 1154 | struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 1155 | |
| 1156 | struct lysc_node *child; /**< first child node (linked list) */ |
| 1157 | struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
| 1158 | struct lysc_action *actions; /**< list of actions ([sized array](@ref sizedarrays)) */ |
| 1159 | struct lysc_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */ |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1160 | }; |
| 1161 | |
| 1162 | struct lysc_node_choice { |
| 1163 | uint16_t nodetype; /**< LYS_CHOICE */ |
| 1164 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1165 | struct lys_module *module; /**< module structure */ |
| 1166 | 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. */ |
| 1167 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1168 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1169 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 1170 | never NULL. If there is no sibling node, pointer points to the node |
| 1171 | itself. In case of the first node, this pointer points to the last |
| 1172 | node in the list. */ |
| 1173 | const char *name; /**< node name (mandatory) */ |
| 1174 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1175 | |
| 1176 | struct lysc_node *child; |
| 1177 | }; |
| 1178 | |
| 1179 | struct lysc_node_leaf { |
| 1180 | uint16_t nodetype; /**< LYS_LEAF */ |
| 1181 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1182 | struct lys_module *module; /**< module structure */ |
| 1183 | 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. */ |
| 1184 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1185 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1186 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 1187 | never NULL. If there is no sibling node, pointer points to the node |
| 1188 | itself. In case of the first node, this pointer points to the last |
| 1189 | node in the list. */ |
| 1190 | const char *name; /**< node name (mandatory) */ |
| 1191 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1192 | |
Radek Krejci | 4f28eda | 2018-11-12 11:46:16 +0100 | [diff] [blame] | 1193 | struct lysc_when *when; /**< when statement */ |
| 1194 | struct lysc_iffeature *iffeatures; /**< list of if-feature expressions ([sized array](@ref sizedarrays)) */ |
| 1195 | |
| 1196 | struct lysc_must *musts; /**< list of must restrictions ([sized array](@ref sizedarrays)) */ |
| 1197 | struct lysc_type *type; /**< type of the leaf node (mandatory) */ |
| 1198 | const char *units; /**< units of the leaf's type */ |
| 1199 | const char *dflt; /**< default value */ |
Radek Krejci | bd8d9ba | 2018-11-02 16:06:26 +0100 | [diff] [blame] | 1200 | }; |
| 1201 | |
| 1202 | struct lysc_node_leaflist { |
| 1203 | uint16_t nodetype; /**< LYS_LEAFLIST */ |
| 1204 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1205 | struct lys_module *module; /**< module structure */ |
| 1206 | 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. */ |
| 1207 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1208 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1209 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 1210 | never NULL. If there is no sibling node, pointer points to the node |
| 1211 | itself. In case of the first node, this pointer points to the last |
| 1212 | node in the list. */ |
| 1213 | const char *name; /**< node name (mandatory) */ |
| 1214 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1215 | |
| 1216 | }; |
| 1217 | |
| 1218 | struct lysc_node_list { |
| 1219 | uint16_t nodetype; /**< LYS_LIST */ |
| 1220 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1221 | struct lys_module *module; /**< module structure */ |
| 1222 | 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. */ |
| 1223 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1224 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1225 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 1226 | never NULL. If there is no sibling node, pointer points to the node |
| 1227 | itself. In case of the first node, this pointer points to the last |
| 1228 | node in the list. */ |
| 1229 | const char *name; /**< node name (mandatory) */ |
| 1230 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1231 | |
| 1232 | struct lysc_node *child; |
| 1233 | }; |
| 1234 | |
| 1235 | struct lysc_node_anydata { |
| 1236 | uint16_t nodetype; /**< LYS_ANYXML or LYS_ANYDATA */ |
| 1237 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1238 | struct lys_module *module; /**< module structure */ |
| 1239 | 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. */ |
| 1240 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1241 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1242 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 1243 | never NULL. If there is no sibling node, pointer points to the node |
| 1244 | itself. In case of the first node, this pointer points to the last |
| 1245 | node in the list. */ |
| 1246 | const char *name; /**< node name (mandatory) */ |
| 1247 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1248 | |
| 1249 | }; |
| 1250 | |
| 1251 | struct lysc_node_case { |
| 1252 | uint16_t nodetype; /**< LYS_CASE */ |
| 1253 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1254 | struct lys_module *module; /**< module structure */ |
| 1255 | 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. */ |
| 1256 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1257 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1258 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 1259 | never NULL. If there is no sibling node, pointer points to the node |
| 1260 | itself. In case of the first node, this pointer points to the last |
| 1261 | node in the list. */ |
| 1262 | const char *name; /**< node name (mandatory) */ |
| 1263 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1264 | |
| 1265 | struct lysc_node *child; |
| 1266 | }; |
| 1267 | |
| 1268 | struct lysc_node_uses { |
| 1269 | uint16_t nodetype; /**< LYS_CHOICE */ |
| 1270 | uint16_t flags; /**< [schema node flags](@ref snodeflags) */ |
| 1271 | struct lys_module *module; /**< module structure */ |
| 1272 | 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. */ |
| 1273 | struct lysc_node *parent; /**< parent node (NULL in case of top level node) */ |
| 1274 | struct lysc_node *next; /**< next sibling node (NULL if there is no one) */ |
| 1275 | struct lysc_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 1276 | never NULL. If there is no sibling node, pointer points to the node |
| 1277 | itself. In case of the first node, this pointer points to the last |
| 1278 | node in the list. */ |
| 1279 | const char *name; /**< node name (mandatory) */ |
| 1280 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
| 1281 | |
| 1282 | struct lysc_node *child; |
| 1283 | }; |
| 1284 | |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1285 | /** |
| 1286 | * @brief Compiled YANG schema tree structure representing YANG module. |
| 1287 | * |
| 1288 | * Semantically validated YANG schema tree for data tree parsing. |
| 1289 | * Contains only the necessary information for the data validation. |
| 1290 | */ |
| 1291 | struct lysc_module { |
| 1292 | struct ly_ctx *ctx; /**< libyang context of the module (mandatory) */ |
| 1293 | const char *name; /**< name of the module (mandatory) */ |
Radek Krejci | 6d6e4e4 | 2018-10-29 13:28:19 +0100 | [diff] [blame] | 1294 | const char *filepath; /**< path, if the schema was read from a file, NULL in case of reading from memory */ |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1295 | const char *ns; /**< namespace of the module (mandatory) */ |
| 1296 | const char *prefix; /**< module prefix (mandatory) */ |
Radek Krejci | f8f882a | 2018-10-31 14:51:15 +0100 | [diff] [blame] | 1297 | const char *revision; /**< the revision of the module */ |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 1298 | struct lysc_import *imports; /**< list of imported modules ([sized array](@ref sizedarrays)) */ |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1299 | |
Radek Krejci | e53a8dc | 2018-10-17 12:52:40 +0200 | [diff] [blame] | 1300 | struct lysc_feature *features; /**< list of feature definitions ([sized array](@ref sizedarrays)) */ |
Radek Krejci | 2a408df | 2018-10-29 16:32:26 +0100 | [diff] [blame] | 1301 | struct lysc_ident *identities; /**< list of identities ([sized array](@ref sizedarrays)) */ |
| 1302 | struct lysc_node *data; /**< list of module's top-level data nodes (linked list) */ |
| 1303 | struct lysc_action *rpcs; /**< list of RPCs ([sized array](@ref sizedarrays)) */ |
| 1304 | struct lysc_notif *notifs; /**< list of notifications ([sized array](@ref sizedarrays)) */ |
Radek Krejci | ce8c159 | 2018-10-29 15:35:51 +0100 | [diff] [blame] | 1305 | struct lysc_ext_instance *exts; /**< list of the extension instances ([sized array](@ref sizedarrays)) */ |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1306 | |
| 1307 | uint8_t implemented:1; /**< flag if the module is implemented, not just imported */ |
Radek Krejci | faa1eac | 2018-10-30 14:34:55 +0100 | [diff] [blame] | 1308 | uint8_t latest_revision:2; /**< flag to mark the latest available revision: |
| 1309 | 1 - the latest revision in searchdirs was not searched yet and this is the |
| 1310 | latest revision in the current context |
| 1311 | 2 - searchdirs were searched and this is the latest available revision */ |
Radek Krejci | 086c713 | 2018-10-26 15:29:04 +0200 | [diff] [blame] | 1312 | uint8_t version; /**< yang-version (LYS_VERSION values) */ |
Radek Krejci | 0af5f5d | 2018-09-07 15:00:30 +0200 | [diff] [blame] | 1313 | }; |
| 1314 | |
| 1315 | /** |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 1316 | * @brief Get how the if-feature statement currently evaluates. |
| 1317 | * |
| 1318 | * @param[in] iff Compiled if-feature statement to evaluate. |
| 1319 | * @return If the statement evaluates to true, 1 is returned. 0 is returned when the statement evaluates to false. |
| 1320 | */ |
| 1321 | int lysc_iffeature_value(const struct lysc_iffeature *iff); |
| 1322 | |
| 1323 | /** |
| 1324 | * @brief Get the current status of the provided feature. |
| 1325 | * |
| 1326 | * @param[in] feature Compiled feature statement to examine. |
| 1327 | * @return |
| 1328 | * - 1 if feature is enabled, |
| 1329 | * - 0 if feature is disabled, |
| 1330 | * - -1 in case of error (invalid argument) |
| 1331 | */ |
| 1332 | int lysc_feature_value(const struct lysc_feature *feature); |
| 1333 | |
| 1334 | /** |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 1335 | * @brief Available YANG schema tree structures representing YANG module. |
| 1336 | */ |
| 1337 | struct lys_module { |
| 1338 | struct lysp_module *parsed; /**< Simply parsed (unresolved) YANG schema tree */ |
| 1339 | struct lysc_module *compiled; /**< Compiled and fully validated YANG schema tree for data parsing */ |
| 1340 | }; |
| 1341 | |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 1342 | /** |
| 1343 | * @brief Enable specified feature in the module |
| 1344 | * |
| 1345 | * By default, when the module is loaded by libyang parser, all features are disabled. |
| 1346 | * |
Radek Krejci | ca3db00 | 2018-11-01 10:31:01 +0100 | [diff] [blame] | 1347 | * If all features are being enabled, it must be possible respecting their if-feature conditions. For example, |
| 1348 | * enabling all features on the following feature set will fail since it is not possible to enable both features |
| 1349 | * (and it is unclear which of them should be enabled then). In this case the LY_EDENIED is returned and the feature |
| 1350 | * is untouched. |
| 1351 | * |
| 1352 | * feature f1; |
| 1353 | * feature f2 { if-feature 'not f1';} |
| 1354 | * |
Radek Krejci | 151a5b7 | 2018-10-19 14:21:44 +0200 | [diff] [blame] | 1355 | * @param[in] module Module where the feature will be enabled. |
| 1356 | * @param[in] feature Name of the feature to enable. To enable all features at once, use asterisk (`*`) character. |
| 1357 | * @return LY_ERR value. |
| 1358 | */ |
| 1359 | LY_ERR lys_feature_enable(struct lys_module *module, const char *feature); |
| 1360 | |
| 1361 | /** |
| 1362 | * @brief Disable specified feature in the module |
| 1363 | * |
| 1364 | * By default, when the module is loaded by libyang parser, all features are disabled. |
| 1365 | * |
| 1366 | * @param[in] module Module where the feature will be disabled. |
| 1367 | * @param[in] feature Name of the feature to disable. To disable all features at once, use asterisk (`*`) character. |
| 1368 | * @return LY_ERR value |
| 1369 | */ |
| 1370 | LY_ERR lys_feature_disable(struct lys_module *module, const char *feature); |
| 1371 | |
| 1372 | /** |
| 1373 | * @brief Get the current status of the specified feature in the module. |
| 1374 | * |
| 1375 | * @param[in] module Module where the feature is defined. |
| 1376 | * @param[in] feature Name of the feature to inspect. |
| 1377 | * @return |
| 1378 | * - 1 if feature is enabled, |
| 1379 | * - 0 if feature is disabled, |
| 1380 | * - -1 in case of error (e.g. feature is not defined or invalid arguments) |
| 1381 | */ |
| 1382 | int lys_feature_value(const struct lys_module *module, const char *feature); |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1383 | |
| 1384 | /** |
Radek Krejci | 86d106e | 2018-10-18 09:53:19 +0200 | [diff] [blame] | 1385 | * @brief Load a schema into the specified context. |
| 1386 | * |
| 1387 | * @param[in] ctx libyang context where to process the data model. |
| 1388 | * @param[in] data The string containing the dumped data model in the specified |
| 1389 | * format. |
| 1390 | * @param[in] format Format of the input data (YANG or YIN). |
| 1391 | * @return Pointer to the data model structure or NULL on error. |
| 1392 | */ |
Radek Krejci | d14e969 | 2018-11-01 11:00:37 +0100 | [diff] [blame] | 1393 | 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] | 1394 | |
| 1395 | /** |
| 1396 | * @brief Read a schema from file descriptor into the specified context. |
| 1397 | * |
| 1398 | * \note Current implementation supports only reading data from standard (disk) file, not from sockets, pipes, etc. |
| 1399 | * |
| 1400 | * @param[in] ctx libyang context where to process the data model. |
| 1401 | * @param[in] fd File descriptor of a regular file (e.g. sockets are not supported) containing the schema |
| 1402 | * in the specified format. |
| 1403 | * @param[in] format Format of the input data (YANG or YIN). |
| 1404 | * @return Pointer to the data model structure or NULL on error. |
| 1405 | */ |
Radek Krejci | d14e969 | 2018-11-01 11:00:37 +0100 | [diff] [blame] | 1406 | 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] | 1407 | |
| 1408 | /** |
Radek Krejci | d33273d | 2018-10-25 14:55:52 +0200 | [diff] [blame] | 1409 | * @brief Read a schema into the specified context from a file. |
Radek Krejci | 86d106e | 2018-10-18 09:53:19 +0200 | [diff] [blame] | 1410 | * |
| 1411 | * @param[in] ctx libyang context where to process the data model. |
| 1412 | * @param[in] path Path to the file with the model in the specified format. |
| 1413 | * @param[in] format Format of the input data (YANG or YIN). |
| 1414 | * @return Pointer to the data model structure or NULL on error. |
| 1415 | */ |
Radek Krejci | d14e969 | 2018-11-01 11:00:37 +0100 | [diff] [blame] | 1416 | 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] | 1417 | |
| 1418 | /** |
Radek Krejci | d33273d | 2018-10-25 14:55:52 +0200 | [diff] [blame] | 1419 | * @brief Search for the schema file in the specified searchpaths. |
| 1420 | * |
| 1421 | * @param[in] searchpaths NULL-terminated array of paths to be searched (recursively). Current working |
| 1422 | * directory is searched automatically (but non-recursively if not in the provided list). Caller can use |
| 1423 | * result of the ly_ctx_get_searchdirs(). |
| 1424 | * @param[in] cwd Flag to implicitly search also in the current working directory (non-recursively). |
| 1425 | * @param[in] name Name of the schema to find. |
| 1426 | * @param[in] revision Revision of the schema to find. If NULL, the newest found schema filepath is returned. |
| 1427 | * @param[out] localfile Mandatory output variable containing absolute path of the found schema. If no schema |
| 1428 | * complying the provided restriction is found, NULL is set. |
| 1429 | * @param[out] format Optional output variable containing expected format of the schema document according to the |
| 1430 | * file suffix. |
| 1431 | * @return LY_ERR value (LY_SUCCESS is returned even if the file is not found, then the *localfile is NULL). |
| 1432 | */ |
| 1433 | LY_ERR lys_search_localfile(const char * const *searchpaths, int cwd, const char *name, const char *revision, char **localfile, LYS_INFORMAT *format); |
| 1434 | |
| 1435 | /** |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1436 | * @defgroup scflags Schema compile flags |
| 1437 | * @ingroup schematree |
| 1438 | * |
| 1439 | * @{ |
| 1440 | */ |
| 1441 | #define LYSC_OPT_FREE_SP 1 /**< Free the input printable schema */ |
| 1442 | |
| 1443 | /** |
| 1444 | * @} |
| 1445 | */ |
| 1446 | |
| 1447 | /** |
| 1448 | * @brief Compile printable schema into a validated schema linking all the references. |
| 1449 | * |
Radek Krejci | f8f882a | 2018-10-31 14:51:15 +0100 | [diff] [blame] | 1450 | * @param[in, out] mod Schema structure holding pointers to both schema structure types. The ::lys_module#parsed |
| 1451 | * member is used as input and ::lys_module#compiled is used to hold the result of the compilation. |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1452 | * @param[in] options Various options to modify compiler behavior, see [compile flags](@ref scflags). |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1453 | * @return LY_ERR value. |
| 1454 | */ |
Radek Krejci | d14e969 | 2018-11-01 11:00:37 +0100 | [diff] [blame] | 1455 | LY_ERR lys_compile(struct lys_module *mod, int options); |
Radek Krejci | dd4e8d4 | 2018-10-16 14:55:43 +0200 | [diff] [blame] | 1456 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 1457 | /** @} */ |
| 1458 | |
Radek Krejci | 70853c5 | 2018-10-15 14:46:16 +0200 | [diff] [blame] | 1459 | #ifdef __cplusplus |
| 1460 | } |
| 1461 | #endif |
| 1462 | |
Radek Krejci | 5aeea3a | 2018-09-05 13:29:36 +0200 | [diff] [blame] | 1463 | #endif /* LY_TREE_SCHEMA_H_ */ |