Michal Vasko | cde73ac | 2019-11-14 16:10:27 +0100 | [diff] [blame] | 1 | /** |
| 2 | * @file validation.h |
| 3 | * @author Michal Vasko <mvasko@cesnet.cz> |
| 4 | * @brief Validation routines. |
| 5 | * |
| 6 | * Copyright (c) 2019 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_VALIDATION_H_ |
| 16 | #define LY_VALIDATION_H_ |
| 17 | |
| 18 | #include "log.h" |
| 19 | #include "tree_data.h" |
| 20 | |
| 21 | /** |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 22 | * @brief Finish validation of nodes and attributes. Specifically, when (is processed first) and type validation. |
Michal Vasko | cde73ac | 2019-11-14 16:10:27 +0100 | [diff] [blame] | 23 | * |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 24 | * !! It is assumed autodeleted nodes cannot be in the unresolved node type set !! |
| 25 | * |
| 26 | * @param[in,out] tree Data tree, is updated if some nodes are autodeleted. |
| 27 | * @param[in] node_when Set with nodes with "when" conditions, can be NULL. |
Michal Vasko | cde73ac | 2019-11-14 16:10:27 +0100 | [diff] [blame] | 28 | * @param[in] node_types Set with nodes with unresolved types, can be NULL |
Michal Vasko | 9f96a05 | 2020-03-10 09:41:45 +0100 | [diff] [blame] | 29 | * @param[in] meta_types Set with metdata with unresolved types, can be NULL. |
Michal Vasko | cde73ac | 2019-11-14 16:10:27 +0100 | [diff] [blame] | 30 | * @param[in] format Format of the unresolved data. |
| 31 | * @param[in] get_prefix_clb Format-specific getter to resolve prefixes. |
| 32 | * @param[in] parser_data Parser's data for @p get_prefix_clb. |
Michal Vasko | cde73ac | 2019-11-14 16:10:27 +0100 | [diff] [blame] | 33 | * @return LY_ERR value. |
| 34 | */ |
Michal Vasko | 9f96a05 | 2020-03-10 09:41:45 +0100 | [diff] [blame] | 35 | LY_ERR lyd_validate_unres(struct lyd_node **tree, struct ly_set *node_when, struct ly_set *node_types, struct ly_set *meta_types, |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 36 | LYD_FORMAT format, ly_clb_resolve_prefix get_prefix_clb, void *parser_data); |
Michal Vasko | cde73ac | 2019-11-14 16:10:27 +0100 | [diff] [blame] | 37 | |
| 38 | /** |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 39 | * @brief Validate new siblings. Specifically, check duplicated instances, autodelete default values and cases. |
Michal Vasko | cde73ac | 2019-11-14 16:10:27 +0100 | [diff] [blame] | 40 | * |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 41 | * !! It is assumed autodeleted nodes cannot yet be in the unresolved node type set !! |
| 42 | * |
| 43 | * @param[in,out] first First sibling. |
| 44 | * @param[in] sparent Schema parent of the siblings, NULL for top-level siblings. |
| 45 | * @param[in] mod Module of the siblings, NULL for nested siblings. |
| 46 | * @return LY_ERR value. |
| 47 | */ |
| 48 | LY_ERR lyd_validate_new(struct lyd_node **first, const struct lysc_node *sparent, const struct lys_module *mod); |
| 49 | |
| 50 | /** |
| 51 | * @brief Perform all remaining validation tasks, the data tree must be final when calling this function. |
| 52 | * |
| 53 | * @param[in] first First sibling. |
| 54 | * @param[in] sparent Schema parent of the siblings, NULL for top-level siblings. |
| 55 | * @param[in] mod Module of the siblings, NULL for nested siblings. |
Michal Vasko | f03ed03 | 2020-03-04 13:31:44 +0100 | [diff] [blame] | 56 | * @param[in] val_opts Validation options (@ref datavalidationoptions). |
Michal Vasko | cde73ac | 2019-11-14 16:10:27 +0100 | [diff] [blame] | 57 | * @return LY_ERR value. |
| 58 | */ |
Michal Vasko | fea12c6 | 2020-03-30 11:00:15 +0200 | [diff] [blame] | 59 | LY_ERR lyd_validate_final_r(struct lyd_node *first, const struct lysc_node *sparent, const struct lys_module *mod, |
| 60 | int val_opts); |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * @brief Check the existence and create any non-existing default siblings, recursively for the created nodes. |
| 64 | * |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 65 | * @param[in] parent Parent of the potential default values, NULL for top-level siblings. |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 66 | * @param[in,out] first First sibling. |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 67 | * @param[in] sparent Schema parent of the siblings, NULL if schema of @p parent can be used. |
| 68 | * @param[in] mod Module of the default values, NULL for nested siblings. |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 69 | * @param[in] node_types Set to add nodes with unresolved types into. |
| 70 | * @param[in] node_when Set to add nodes with "when" conditions into. |
Michal Vasko | e75ecfd | 2020-03-06 14:12:28 +0100 | [diff] [blame] | 71 | * @param[in] val_opts Validation options (@ref datavalidationoptions). |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 72 | * @return LY_ERR value. |
| 73 | */ |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 74 | LY_ERR lyd_validate_defaults_r(struct lyd_node_inner *parent, struct lyd_node **first, const struct lysc_node *sparent, |
Michal Vasko | e75ecfd | 2020-03-06 14:12:28 +0100 | [diff] [blame] | 75 | const struct lys_module *mod, struct ly_set *node_types, struct ly_set *node_when, int val_opts); |
Michal Vasko | cde73ac | 2019-11-14 16:10:27 +0100 | [diff] [blame] | 76 | |
| 77 | #endif /* LY_VALIDATION_H_ */ |