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