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