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