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