blob: e2728d3dee79285953f0d99694bc37fdec53be97 [file] [log] [blame]
Radek Krejcib1c12512015-08-11 11:22:04 +02001/**
2 * @file validation.h
3 * @author Radek Krejci <rkrejci@cesnet.cz>
4 * @brief Data tree validation for libyang
5 *
6 * Copyright (c) 2015 CESNET, z.s.p.o.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of the Company nor the names of its contributors
18 * may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
Radek Krejcib1c12512015-08-11 11:22:04 +020020 */
21
22#ifndef LY_VALIDATION_H_
23#define LY_VALIDATION_H_
24
25#include "libyang.h"
Michal Vaskocf024702015-10-08 15:01:42 +020026#include "resolve.h"
Michal Vasko2d162e12015-09-24 14:33:29 +020027#include "tree_data.h"
Radek Krejcib1c12512015-08-11 11:22:04 +020028
29/**
Radek Krejcieab784a2015-08-27 09:56:53 +020030 * @brief Check, that the data node of the given schema node can even appear in a data tree.
Radek Krejcib1c12512015-08-11 11:22:04 +020031 *
Radek Krejcieab784a2015-08-27 09:56:53 +020032 * Checks included:
33 * - data node is not disabled via if-features
Michal Vaskocf024702015-10-08 15:01:42 +020034 * - data node is not disabled via an unsatisfied when condition
Radek Krejcieab784a2015-08-27 09:56:53 +020035 * - data node is not status in case of edit-config content (options includes LYD_OPT_EDIT)
Radek Krejci4a49bdf2016-01-12 17:17:01 +010036 * - data node is in correct place (options includes LYD_OPT_RPC or LYD_OPT_RPCREPLY), since elements order matters
37 * in RPCs and RPC replies.
Radek Krejcib1c12512015-08-11 11:22:04 +020038 *
Michal Vaskocf024702015-10-08 15:01:42 +020039 * @param[in] node Data tree node to be checked.
Radek Krejcieab784a2015-08-27 09:56:53 +020040 * @param[in] options Parser options, see @ref parseroptions.
Michal Vaskocf024702015-10-08 15:01:42 +020041 * @param[in] line Optional line of the input to be printed in case of an error.
42 * @param[out] unres Structure to store unresolved items into. Can be NULL.
Radek Krejcieab784a2015-08-27 09:56:53 +020043 * @return EXIT_SUCCESS or EXIT_FAILURE with ly_errno set.
Radek Krejcib1c12512015-08-11 11:22:04 +020044 */
Michal Vasko1e62a092015-12-01 12:27:20 +010045int lyv_data_context(const struct lyd_node *node, int options, unsigned int line, struct unres_data *unres);
Radek Krejcieab784a2015-08-27 09:56:53 +020046
47/**
48 * @brief Validate if the node's content is valid in the context it is placed.
49 *
50 * Expects that the node is already interconnected to the target tree and all its children
51 * are already resolved. All currently connected siblings are included to the tests.
52 *
53 * @param[in] node Data tree node to be checked.
Radek Krejcieab784a2015-08-27 09:56:53 +020054 * @param[in] options Parser options, see @ref parseroptions.
Michal Vaskocf024702015-10-08 15:01:42 +020055 * @param[in] line Optional line of the input to be printed in case of an error.
56 * @param[out] unres Structure to store unresolved items into. Can be NULL.
Radek Krejcieab784a2015-08-27 09:56:53 +020057 * @return EXIT_SUCCESS or EXIT_FAILURE with set ly_errno. If EXIT_FAILURE is returned
58 * but ly_errno is not set, the issue was internally resolved and caller is supposed to
59 * unlink and free the node and continue;
60 */
Michal Vaskocf024702015-10-08 15:01:42 +020061int lyv_data_content(struct lyd_node *node, int options, unsigned int line, struct unres_data *unres);
Radek Krejcib1c12512015-08-11 11:22:04 +020062
63#endif /* LY_VALIDATION_H_ */