Loading...
Searching...
No Matches
Data Tree
Trees
Collaboration diagram for Data Tree:

## Modules

| Data compare options
| Data diff merge options.
| Data diff options.
| Data duplication options
| Data merge options.
| Data node flags
| Data operation type
| Data parser options
| Data printer flags
| Data validation options
| Implicit node creation options
| New value creation options
| Node type format hints
| Value and node type format hints
| Value format hints.

## Macros

#define | LYD_CTX(node) ((node)->schema ? (node)->schema->module->ctx : ((const struct lyd_node_opaq *)(node))->ctx)
| Macro to get context from a data tree node.
#define | LYD_LIST_FOR_INST(START, SCHEMA, ELEM)
| Macro to iterate via all schema node data instances in data siblings.
#define | LYD_LIST_FOR_INST_SAFE(START, SCHEMA, NEXT, ELEM)
| Macro to iterate via all schema node data instances in data siblings allowing to modify the list itself.
#define | LYD_NODE_IS_ALONE(NODE)
| Find out if the node is the only instance, i.e. it has no siblings with the same schema.
#define | LYD_TREE_DFS_BEGIN(START, ELEM)
| Macro to iterate via all elements in a data tree. This is the opening part to the LYD_TREE_DFS_END - they always have to be used together.
#define | LYD_TREE_DFS_END(START, ELEM)
| Macro to iterate via all elements in a tree. This is the closing part to the LYD_TREE_DFS_BEGIN - they always have to be used together.

## Enumerations

enum | LYD_ANYDATA_VALUETYPE { LYD_ANYDATA_DATATREE , LYD_ANYDATA_STRING , LYD_ANYDATA_XML , LYD_ANYDATA_JSON , LYD_ANYDATA_LYB }
| List of possible value types stored in lyd_node_any. More...
enum | LYD_FORMAT { LYD_UNKNOWN = 0 , LYD_XML , LYD_JSON , LYD_LYB }
| Data input/output formats supported by libyang parser and printer functions. More...

## Functions

LIBYANG_API_DECL LY_ERR | lyd_parse_data (const struct ly_ctx *ctx, struct lyd_node *parent, struct ly_in *in, LYD_FORMAT format, uint32_t parse_options, uint32_t validate_options, struct lyd_node **tree)
| Parse (and validate) data from the input handler as a YANG data tree.
LIBYANG_API_DECL LY_ERR | lyd_parse_data_fd (const struct ly_ctx *ctx, int fd, LYD_FORMAT format, uint32_t parse_options, uint32_t validate_options, struct lyd_node **tree)
| Parse (and validate) input data as a YANG data tree.
LIBYANG_API_DECL LY_ERR | lyd_parse_data_mem (const struct ly_ctx *ctx, const char *data, LYD_FORMAT format, uint32_t parse_options, uint32_t validate_options, struct lyd_node **tree)
| Parse (and validate) input data as a YANG data tree.
LIBYANG_API_DECL LY_ERR | lyd_parse_data_path (const struct ly_ctx *ctx, const char *path, LYD_FORMAT format, uint32_t parse_options, uint32_t validate_options, struct lyd_node **tree)
| Parse (and validate) input data as a YANG data tree.
LIBYANG_API_DECL LY_ERR | lyd_parse_ext_data (const struct lysc_ext_instance *ext, struct lyd_node *parent, struct ly_in *in, LYD_FORMAT format, uint32_t parse_options, uint32_t validate_options, struct lyd_node **tree)
| Parse (and validate) data from the input handler as an extension data tree following the schema tree of the given extension instance.
LIBYANG_API_DECL LY_ERR | lyd_parse_ext_op (const struct lysc_ext_instance *ext, struct lyd_node *parent, struct ly_in *in, LYD_FORMAT format, enum lyd_type data_type, struct lyd_node **tree, struct lyd_node **op)
| Parse extension data into an operation data tree following only the specification from the given extension instance.
LIBYANG_API_DECL LY_ERR | lyd_parse_op (const struct ly_ctx *ctx, struct lyd_node *parent, struct ly_in *in, LYD_FORMAT format, enum lyd_type data_type, struct lyd_node **tree, struct lyd_node **op)
| Parse YANG data into an operation data tree. Specific parsing flags LYD_PARSE_ONLY, LYD_PARSE_STRICT and no validation flags are used.
LIBYANG_API_DECL LY_ERR | lyd_validate_all (struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t val_opts, struct lyd_node **diff)
| Fully validate a data tree.
LIBYANG_API_DECL LY_ERR | lyd_validate_module (struct lyd_node **tree, const struct lys_module *module, uint32_t val_opts, struct lyd_node **diff)
| Fully validate a data tree of a module.
LIBYANG_API_DECL LY_ERR | lyd_validate_module_final (struct lyd_node *tree, const struct lys_module *module, uint32_t val_opts)
| Finish validation of a module data that have previously been validated with LYD_VALIDATE_NOT_FINAL flag.
LIBYANG_API_DECL LY_ERR | lyd_validate_op (struct lyd_node *op_tree, const struct lyd_node *dep_tree, enum lyd_type data_type, struct lyd_node **diff)
| Validate an RPC/action request, reply, or notification. Only the operation data tree (input/output/notif) is validate, any parents are ignored.

## Detailed Description

Data structures and functions to manipulate and access instance data tree.

## Macro Definition Documentation

## LYD_CTX

#define LYD_CTX | ( |  | node | ) | ((node)->schema ? (node)->schema->module->ctx : ((const struct lyd_node_opaq *)(node))->ctx)

Macro to get context from a data tree node.

Definition at line 522 of file tree_data.h.

## LYD_LIST_FOR_INST

#define LYD_LIST_FOR_INST | ( |  | START,
|  |  | SCHEMA,
|  |  | ELEM
| ) |  |

Value:
for (lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
(ELEM) && ((ELEM)->schema == (SCHEMA)); \
(ELEM) = (ELEM)->next)
lyd_find_sibling_val
LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema, const char *key_or_value, size_t val_len, struct lyd_node **match)
Search in the given siblings for the first schema instance. Uses hashes - should be used whenever pos...

Macro to iterate via all schema node data instances in data siblings.

Parameters

  START | Pointer to the starting sibling. Even if it is not first, all the siblings are searched.
  SCHEMA | Schema node of the searched instances.
  ELEM | Iterator.

Definition at line 499 of file tree_data.h.

## LYD_LIST_FOR_INST_SAFE

#define LYD_LIST_FOR_INST_SAFE | ( |  | START,
|  |  | SCHEMA,
|  |  | NEXT,
|  |  | ELEM
| ) |  |

Value:
for ((NEXT) = (ELEM) = NULL, lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
(ELEM) && ((ELEM)->schema == (SCHEMA)) ? ((NEXT) = (ELEM)->next, 1) : 0; \
(ELEM) = (NEXT))

Macro to iterate via all schema node data instances in data siblings allowing to modify the list itself.

Parameters

  START | Pointer to the starting sibling. Even if it is not first, all the siblings are searched.
  SCHEMA | Schema node of the searched instances.
  NEXT | Temporary storage to allow removing of the current iterator content.
  ELEM | Iterator.

Definition at line 512 of file tree_data.h.

## LYD_NODE_IS_ALONE

#define LYD_NODE_IS_ALONE | ( |  | NODE | ) |

Value:
(((NODE)->prev == NODE) || \
(((NODE)->prev->schema != (NODE)->schema) && (!(NODE)->next || ((NODE)->schema != (NODE)->next->schema))))

Find out if the node is the only instance, i.e. it has no siblings with the same schema.

Parameters

  [in] | NODE | Pointer to the struct lyd_node.

Returns
  1 `NODE` is a single instance (is alone).
  0 `NODE` is not alone.

Definition at line 531 of file tree_data.h.

## LYD_TREE_DFS_BEGIN

#define LYD_TREE_DFS_BEGIN | ( |  | START,
|  |  | ELEM
| ) |  |

Value:
{ ly_bool LYD_TREE_DFS_continue = 0; struct lyd_node *LYD_TREE_DFS_next; \
for ((ELEM) = (LYD_TREE_DFS_next) = (struct lyd_node *)(START); \
(ELEM); \
(ELEM) = (LYD_TREE_DFS_next), LYD_TREE_DFS_continue = 0)
ly_bool
uint8_t ly_bool
Type to indicate boolean value.
Definition log.h:35
lyd_node
Generic structure for a data node.
Definition tree_data.h:795

Macro to iterate via all elements in a data tree. This is the opening part to the LYD_TREE_DFS_END - they always have to be used together.

The function follows deep-first search algorithm:

        1
       / \
      2   4
     /   / \
    3   5   6

Use the same parameters for LYD_TREE_DFS_BEGIN and LYD_TREE_DFS_END. While START can be any of the lyd_node* types, ELEM variable must be a pointer to the generic struct lyd_node.

To skip a particular subtree, instead of the continue statement, set LYD_TREE_DFS_continue variable to non-zero value.

Use with opening curly bracket '{' after the macro.

Parameters

  START | Pointer to the starting element processed first.
  ELEM | Iterator intended for use in the block.

Definition at line 445 of file tree_data.h.

## LYD_TREE_DFS_END

#define LYD_TREE_DFS_END | ( |  | START,
|  |  | ELEM
| ) |  |

Value:
/* select element for the next run - children first */ \
if (LYD_TREE_DFS_continue) { \
(LYD_TREE_DFS_next) = NULL; \
} else { \
(LYD_TREE_DFS_next) = lyd_child(ELEM); \
}\
if (!(LYD_TREE_DFS_next)) { \
/* no children */ \
if ((ELEM) == (struct lyd_node *)(START)) { \
/* we are done, (START) has no children */ \
break; \
} \
/* try siblings */ \
(LYD_TREE_DFS_next) = (ELEM)->next; \
} \
while (!(LYD_TREE_DFS_next)) { \
/* parent is already processed, go to its sibling */ \
(ELEM) = (struct lyd_node *)(ELEM)->parent; \
/* no siblings, go back through parents */ \
if ((ELEM)->parent == (START)->parent) { \
/* we are done, no next element to process */ \
break; \
} \
(LYD_TREE_DFS_next) = (ELEM)->next; \
} }
lyd_node::next
struct lyd_node * next
Definition tree_data.h:803

Macro to iterate via all elements in a tree. This is the closing part to the LYD_TREE_DFS_BEGIN - they always have to be used together.

Use the same parameters for LYD_TREE_DFS_BEGIN and LYD_TREE_DFS_END. While START can be any of the lyd_node* types, ELEM variable must be a pointer to the generic struct lyd_node.

Use with closing curly bracket '}' after the macro.

Parameters

  START | Pointer to the starting element processed first.
  ELEM | Iterator intended for use in the block.

Definition at line 465 of file tree_data.h.

## Enumeration Type Documentation

## LYD_ANYDATA_VALUETYPE

enum LYD_ANYDATA_VALUETYPE

List of possible value types stored in lyd_node_any.

Enumerator
LYD_ANYDATA_DATATREE | Value is a pointer to lyd_node structure (first sibling). When provided as input parameter, the pointer is directly connected into the anydata node without duplication, caller is supposed to not manipulate with the data after a successful call (including calling lyd_free_all() on the provided data)
LYD_ANYDATA_STRING | Value is a generic string without any knowledge about its format (e.g. anyxml value in JSON encoded as string). XML sensitive characters (such as & or >) are automatically escaped when the anydata is printed in XML format.
LYD_ANYDATA_XML | Value is a string containing the serialized XML data.
LYD_ANYDATA_JSON | Value is a string containing the data modeled by YANG and encoded as I-JSON.
LYD_ANYDATA_LYB | Value is a memory chunk with the serialized data tree in LYB format.

Definition at line 549 of file tree_data.h.

## LYD_FORMAT

enum LYD_FORMAT

Data input/output formats supported by libyang parser and printer functions.

Enumerator
LYD_UNKNOWN | unknown data format, invalid value
LYD_XML | XML instance data format
LYD_JSON | JSON instance data format
LYD_LYB | LYB instance data format

Definition at line 539 of file tree_data.h.

## Function Documentation

## lyd_parse_data()

LIBYANG_API_DECL LY_ERR lyd_parse_data | ( | const struct ly_ctx * | ctx,
|  | struct lyd_node * | parent,
|  | struct ly_in * | in,
|  | LYD_FORMAT | format,
|  | uint32_t | parse_options,
|  | uint32_t | validate_options,
|  | struct lyd_node ** | tree
| ) |  |

Parse (and validate) data from the input handler as a YANG data tree.

Parameters

  [in] | ctx | Context to connect with the tree being built here.
  [in] | parent | Optional parent to connect the parsed nodes to. If provided, the data are expected to describe a subtree of the YANG module instead of starting at the schema root.
  [in] | in | The input handle to provide the dumped data in the specified `format` to parse (and validate).
  [in] | format | Format of the input data to be parsed. Can be 0 to try to detect format from the input handler.
  [in] | parse_options | Options for parser, see Data parser options.
  [in] | validate_options | Options for the validation phase, see Data validation options.
  [out] | tree | Full parsed data tree, note that NULL can be a valid tree. If `parent` is set, the first parsed child.

Returns
  LY_SUCCESS in case of successful parsing (and validation).
  LY_ERR value in case of error. Additional error information can be obtained from the context using ly_err* functions.

When parsing subtrees (i.e., when `parent` is non-NULL), validation is only performed on the newly parsed data. This might result in allowing invalid datastore content when the schema contains cross-branch constraints, complicated `must` statements, etc. When a full-datastore validation is desirable, parse all subtrees first, and then request validation of the complete datastore content.

## lyd_parse_data_fd()

LIBYANG_API_DECL LY_ERR lyd_parse_data_fd | ( | const struct ly_ctx * | ctx,
|  | int | fd,
|  | LYD_FORMAT | format,
|  | uint32_t | parse_options,
|  | uint32_t | validate_options,
|  | struct lyd_node ** | tree
| ) |  |

Parse (and validate) input data as a YANG data tree.

Wrapper around lyd_parse_data() hiding work with the input handler and some obscure options.

Parameters

  [in] | ctx | Context to connect with the tree being built here.
  [in] | fd | File descriptor of a regular file (e.g. sockets are not supported) containing the input data in the specified `format` to parse.
  [in] | format | Format of the input data to be parsed.
  [in] | parse_options | Options for parser, see Data parser options.
  [in] | validate_options | Options for the validation phase, see Data validation options.
  [out] | tree | Full parsed data tree, note that NULL can be a valid tree

Returns
  LY_SUCCESS in case of successful parsing (and validation).
  LY_ERR value in case of error. Additional error information can be obtained from the context using ly_err* functions.

## lyd_parse_data_mem()

LIBYANG_API_DECL LY_ERR lyd_parse_data_mem | ( | const struct ly_ctx * | ctx,
|  | const char * | data,
|  | LYD_FORMAT | format,
|  | uint32_t | parse_options,
|  | uint32_t | validate_options,
|  | struct lyd_node ** | tree
| ) |  |

Parse (and validate) input data as a YANG data tree.

Wrapper around lyd_parse_data() hiding work with the input handler and some obscure options.

Parameters

  [in] | ctx | Context to connect with the tree being built here.
  [in] | data | The input data in the specified `format` to parse (and validate).
  [in] | format | Format of the input data to be parsed.
  [in] | parse_options | Options for parser, see Data parser options.
  [in] | validate_options | Options for the validation phase, see Data validation options.
  [out] | tree | Full parsed data tree, note that NULL can be a valid tree

Returns
  LY_SUCCESS in case of successful parsing (and validation).
  LY_ERR value in case of error. Additional error information can be obtained from the context using ly_err* functions.

## lyd_parse_data_path()

LIBYANG_API_DECL LY_ERR lyd_parse_data_path | ( | const struct ly_ctx * | ctx,
|  | const char * | path,
|  | LYD_FORMAT | format,
|  | uint32_t | parse_options,
|  | uint32_t | validate_options,
|  | struct lyd_node ** | tree
| ) |  |

Parse (and validate) input data as a YANG data tree.

Wrapper around lyd_parse_data() hiding work with the input handler and some obscure options.

Parameters

  [in] | ctx | Context to connect with the tree being built here.
  [in] | path | Path to the file with the input data in the specified `format` to parse (and validate).
  [in] | format | Format of the input data to be parsed. Can be 0 to try to detect format from `path` extension.
  [in] | parse_options | Options for parser, see Data parser options.
  [in] | validate_options | Options for the validation phase, see Data validation options.
  [out] | tree | Full parsed data tree, note that NULL can be a valid tree

Returns
  LY_SUCCESS in case of successful parsing (and validation).
  LY_ERR value in case of error. Additional error information can be obtained from the context using ly_err* functions.

## lyd_parse_ext_data()

LIBYANG_API_DECL LY_ERR lyd_parse_ext_data | ( | const struct lysc_ext_instance * | ext,
|  | struct lyd_node * | parent,
|  | struct ly_in * | in,
|  | LYD_FORMAT | format,
|  | uint32_t | parse_options,
|  | uint32_t | validate_options,
|  | struct lyd_node ** | tree
| ) |  |

Parse (and validate) data from the input handler as an extension data tree following the schema tree of the given extension instance.

Note that the data being parsed are limited only to the schema tree specified by the given extension, it does not allow to mix them with the standard data from any module.

Directly applicable to data defined as yang-data.

Parameters

  [in] | ext | Extension instance providing the specific schema tree to match with the data being parsed.
  [in] | parent | Optional parent to connect the parsed nodes to.
  [in] | in | The input handle to provide the dumped data in the specified `format` to parse (and validate).
  [in] | format | Format of the input data to be parsed. Can be 0 to try to detect format from the input handler.
  [in] | parse_options | Options for parser, see Data parser options.
  [in] | validate_options | Options for the validation phase, see Data validation options.
  [out] | tree | Full parsed data tree, note that NULL can be a valid tree. If `parent` is set, set to NULL.

Returns
  LY_SUCCESS in case of successful parsing (and validation).
  LY_ERR value in case of error. Additional error information can be obtained from the context using ly_err* functions.

## lyd_parse_ext_op()

LIBYANG_API_DECL LY_ERR lyd_parse_ext_op | ( | const struct lysc_ext_instance * | ext,
|  | struct lyd_node * | parent,
|  | struct ly_in * | in,
|  | LYD_FORMAT | format,
|  | enum lyd_type | data_type,
|  | struct lyd_node ** | tree,
|  | struct lyd_node ** | op
| ) |  |

Parse extension data into an operation data tree following only the specification from the given extension instance.

Directly applicable to data defined as yang-data.

At least one of `parent`, `tree`, or `op` must always be set.

Specific `data_type` values have different parameter meaning as follows:

- LYD_TYPE_RPC_NETCONF:
  - `parent` - must be NULL, the whole RPC is expected;
  - `format` - must be LYD_XML, NETCONF supports only this format;
  - `tree` - must be provided, all the NETCONF-specific XML envelopes will be returned here as a separate opaque data tree, even if the function fails, this may be returned;
  - `op` - must be provided, the RPC/action data tree itself will be returned here, pointing to the operation;
- LYD_TYPE_NOTIF_NETCONF:
  - `parent` - must be NULL, the whole notification is expected;
  - `format` - must be LYD_XML, NETCONF supports only this format;
  - `tree` - must be provided, all the NETCONF-specific XML envelopes will be returned here as a separate opaque data tree, even if the function fails, this may be returned;
  - `op` - must be provided, the notification data tree itself will be returned here, pointing to the operation;
- LYD_TYPE_REPLY_NETCONF:
  - `parent` - must be set, pointing to the invoked RPC operation (RPC or action) node;
  - `format` - must be LYD_XML, NETCONF supports only this format;
  - `tree` - must be provided, all the NETCONF-specific XML envelopes will be returned here as a separate opaque data tree, even if the function fails, this may be returned;
  - `op` - must be NULL, the reply is appended to the RPC; Note that there are 3 kinds of NETCONF replies - ok, error, and data. Only data reply appends any nodes to the RPC.

Parameters

  [in] | ext | Extension instance providing the specific schema tree to match with the data being parsed.
  [in] | parent | Optional parent to connect the parsed nodes to.
  [in] | in | Input handle to read the input from.
  [in] | format | Expected format of the data in `in`.
  [in] | data_type | Expected operation to parse (Data operation type).
  [out] | tree | Optional full parsed data tree. If `parent` is set, set to NULL.
  [out] | op | Optional pointer to the operation (action/RPC) node.

Returns
  LY_ERR value.
  LY_ENOT if `data_type` is a NETCONF message and the root XML element is not the expected one.

## lyd_parse_op()

LIBYANG_API_DECL LY_ERR lyd_parse_op | ( | const struct ly_ctx * | ctx,
|  | struct lyd_node * | parent,
|  | struct ly_in * | in,
|  | LYD_FORMAT | format,
|  | enum lyd_type | data_type,
|  | struct lyd_node ** | tree,
|  | struct lyd_node ** | op
| ) |  |

Parse YANG data into an operation data tree. Specific parsing flags LYD_PARSE_ONLY, LYD_PARSE_STRICT and no validation flags are used.

At least one of `parent`, `tree`, or `op` must always be set.

Specific `data_type` values have different parameter meaning as follows:

- LYD_TYPE_RPC_NETCONF:
  - `parent` - must be NULL, the whole RPC is expected;
  - `format` - must be LYD_XML, NETCONF supports only this format;
  - `tree` - must be provided, all the NETCONF-specific XML envelopes will be returned here as a separate opaque data tree, even if the function fails, this may be returned;
  - `op` - must be provided, the RPC/action data tree itself will be returned here, pointing to the operation;
- LYD_TYPE_NOTIF_NETCONF:
  - `parent` - must be NULL, the whole notification is expected;
  - `format` - must be LYD_XML, NETCONF supports only this format;
  - `tree` - must be provided, all the NETCONF-specific XML envelopes will be returned here as a separate opaque data tree, even if the function fails, this may be returned;
  - `op` - must be provided, the notification data tree itself will be returned here, pointing to the operation;
- LYD_TYPE_REPLY_NETCONF:
  - `parent` - must be set, pointing to the invoked RPC operation (RPC or action) node;
  - `format` - must be LYD_XML, NETCONF supports only this format;
  - `tree` - must be provided, all the NETCONF-specific XML envelopes will be returned here as a separate opaque data tree, even if the function fails, this may be returned;
  - `op` - must be NULL, the reply is appended to the RPC; Note that there are 3 kinds of NETCONF replies - ok, error, and data. Only data reply appends any nodes to the RPC.
- LYD_TYPE_RPC_RESTCONF:
  - `parent` - must be set, pointing to the invoked RPC operation (RPC or action) node;
  - `format` - can be both LYD_JSON and LYD_XML;
  - `tree` - must be provided, all the RESTCONF-specific JSON objects will be returned here as a separate opaque data tree, even if the function fails, this may be returned;
  - `op` - must be NULL, `parent` points to the operation;
- LYD_TYPE_NOTIF_RESTCONF:
  - `parent` - must be NULL, the whole notification is expected;
  - `format` - must be LYD_JSON, XML-formatted notifications are parsed using LYD_TYPE_NOTIF_NETCONF;
  - `tree` - must be provided, all the RESTCONF-specific JSON objects will be returned here as a separate opaque data tree, even if the function fails, this may be returned;
  - `op` - must be provided, the notification data tree itself will be returned here, pointing to the operation;
- LYD_TYPE_REPLY_RESTCONF:
  - `parent` - must be set, pointing to the invoked RPC operation (RPC or action) node;
  - `format` - can be both LYD_JSON and LYD_XML;
  - `tree` - must be provided, all the RESTCONF-specific JSON objects will be returned here as a separate opaque data tree, even if the function fails, this may be returned;
  - `op` - must be NULL, `parent` points to the operation; Note that error reply should be parsed as 'yang-data' extension data.
- LYD_TYPE_RPC_YANG:
- LYD_TYPE_NOTIF_YANG:
- LYD_TYPE_REPLY_YANG:
  - all the parameters have their default meaning.
- :: LYD_TYPE_DATA_YANG:
  - not accepted by the function.

Parameters

  [in] | ctx | libyang context.
  [in] | parent | Optional parent to connect the parsed nodes to.
  [in] | in | Input handle to read the input from.
  [in] | format | Expected format of the data in `in`.
  [in] | data_type | Expected operation to parse (Data operation type).
  [out] | tree | Optional full parsed data tree. If `parent` is set, set to NULL.
  [out] | op | Optional pointer to the operation (action/RPC/notification) node.

Returns
  LY_ERR value.
  LY_ENOT if `data_type` is a NETCONF message and the root XML element is not the expected one.

## lyd_validate_all()

LIBYANG_API_DECL LY_ERR lyd_validate_all | ( | struct lyd_node ** | tree,
|  | const struct ly_ctx * | ctx,
|  | uint32_t | val_opts,
|  | struct lyd_node ** | diff
| ) |  |

Fully validate a data tree.

The data tree is modified in-place. As a result of the validation, some data might be removed from the tree. In that case, the removed items are freed, not just unlinked.

Parameters

  [in,out] | tree | Data tree to recursively validate. May be changed by validation, might become NULL.
  [in] | ctx | libyang context. Can be NULL if `tree` is set.
  [in] | val_opts | Validation options (Data validation options).
  [out] | diff | Optional diff with any changes made by the validation.

Returns
  LY_SUCCESS on success.
  LY_ERR error on error.

## lyd_validate_module()

LIBYANG_API_DECL LY_ERR lyd_validate_module | ( | struct lyd_node ** | tree,
|  | const struct lys_module * | module,
|  | uint32_t | val_opts,
|  | struct lyd_node ** | diff
| ) |  |

Fully validate a data tree of a module.

The data tree is modified in-place. As a result of the validation, some data might be removed from the tree. In that case, the removed items are freed, not just unlinked.

If several modules need to be validated, the flag LYD_VALIDATE_NOT_FINAL should be used first for validation of each module and then lyd_validate_module_final() should be called also for each module. Otherwise, false-positive validation errors for foreign dependencies may occur.

Parameters

  [in,out] | tree | Data tree to recursively validate. May be changed by validation, might become NULL.
  [in] | module | Module whose data (and schema restrictions) to validate.
  [in] | val_opts | Validation options (Data validation options).
  [out] | diff | Optional diff with any changes made by the validation.

Returns
  LY_SUCCESS on success.
  LY_ERR error on error.

## lyd_validate_module_final()

LIBYANG_API_DECL LY_ERR lyd_validate_module_final | ( | struct lyd_node * | tree,
|  | const struct lys_module * | module,
|  | uint32_t | val_opts
| ) |  |

Finish validation of a module data that have previously been validated with LYD_VALIDATE_NOT_FINAL flag.

This final validation will not add or remove any nodes.

Parameters

  [in] | tree | Data tree to recursively validate.
  [in] | module | Module whose data (and schema restrictions) to validate.
  [in] | val_opts | Validation options (Data validation options).

Returns
  LY_SUCCESS on success.
  LY_ERR error on error.

## lyd_validate_op()

LIBYANG_API_DECL LY_ERR lyd_validate_op | ( | struct lyd_node * | op_tree,
|  | const struct lyd_node * | dep_tree,
|  | enum lyd_type | data_type,
|  | struct lyd_node ** | diff
| ) |  |

Validate an RPC/action request, reply, or notification. Only the operation data tree (input/output/notif) is validate, any parents are ignored.

Parameters

  [in,out] | op_tree | Operation tree with any parents. It can point to the operation itself or any of its parents, only the operation subtree is actually validated.
  [in] | dep_tree | Tree to be used for validating references from the operation subtree.
  [in] | data_type | Operation type to validate (only YANG operations are accepted, Data operation type).
  [out] | diff | Optional diff with any changes made by the validation.

Returns
  LY_SUCCESS on success.
  LY_ERR error on error.