libyang  2.1.30
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tree_schema.h File Reference

libyang representation of YANG schema trees. More...

#include <pcre2.h>
#include <stdint.h>
#include <stdio.h>
#include "config.h"
#include "log.h"
#include "tree.h"

Go to the source code of this file.

Data Structures

struct  lys_module
 Available YANG schema tree structures representing YANG module. More...
 
struct  lysc_ext
 Compiled YANG extension-stmt. More...
 
struct  lysc_ident
 YANG identity-stmt. More...
 
struct  lysc_iffeature
 Compiled YANG if-feature-stmt. More...
 
struct  lysc_module
 Compiled YANG schema tree structure representing YANG module. More...
 
struct  lysc_must
 
struct  lysc_node
 Compiled YANG data node. More...
 
struct  lysc_node_action
 
union  lysc_node_action.__unnamed__
 
struct  lysc_node_action.__unnamed__.__unnamed__
 
struct  lysc_node_action_inout
 
union  lysc_node_action_inout.__unnamed__
 
struct  lysc_node_action_inout.__unnamed__.__unnamed__
 
struct  lysc_node_anydata
 
union  lysc_node_anydata.__unnamed__
 
struct  lysc_node_anydata.__unnamed__.__unnamed__
 
struct  lysc_node_case
 
union  lysc_node_case.__unnamed__
 
struct  lysc_node_case.__unnamed__.__unnamed__
 
struct  lysc_node_choice
 
union  lysc_node_choice.__unnamed__
 
struct  lysc_node_choice.__unnamed__.__unnamed__
 
struct  lysc_node_container
 
union  lysc_node_container.__unnamed__
 
struct  lysc_node_container.__unnamed__.__unnamed__
 
struct  lysc_node_leaf
 
union  lysc_node_leaf.__unnamed__
 
struct  lysc_node_leaf.__unnamed__.__unnamed__
 
struct  lysc_node_leaflist
 
union  lysc_node_leaflist.__unnamed__
 
struct  lysc_node_leaflist.__unnamed__.__unnamed__
 
struct  lysc_node_list
 
union  lysc_node_list.__unnamed__
 
struct  lysc_node_list.__unnamed__.__unnamed__
 
struct  lysc_node_notif
 
union  lysc_node_notif.__unnamed__
 
struct  lysc_node_notif.__unnamed__.__unnamed__
 
struct  lysc_pattern
 
struct  lysc_prefix
 Compiled prefix data pair mapping of prefixes to modules. In case the format is LY_VALUE_SCHEMA_RESOLVED, the expected prefix data is a sized array of these structures. More...
 
struct  lysc_range
 
struct  lysc_range::lysc_range_part
 
union  lysc_range::lysc_range_part.__unnamed__
 
union  lysc_range::lysc_range_part.__unnamed__
 
struct  lysc_revision
 Compiled YANG revision statement. More...
 
struct  lysc_type
 
struct  lysc_type_bin
 
struct  lysc_type_bitenum_item
 
union  lysc_type_bitenum_item.__unnamed__
 
struct  lysc_type_bits
 
struct  lysc_type_dec
 
struct  lysc_type_enum
 
struct  lysc_type_identityref
 
struct  lysc_type_instanceid
 
struct  lysc_type_leafref
 
struct  lysc_type_num
 
struct  lysc_type_str
 
struct  lysc_type_union
 
struct  lysc_when
 YANG when-stmt. More...
 
struct  lysp_deviate
 Generic deviate structure to get type and cast to lysp_deviate_* structure. More...
 
struct  lysp_deviate_add
 
struct  lysp_deviate_del
 
struct  lysp_deviate_rpl
 
struct  lysp_deviation
 
struct  lysp_ext
 YANG extension-stmt. More...
 
struct  lysp_feature
 YANG feature-stmt. More...
 
struct  lysp_ident
 YANG identity-stmt. More...
 
struct  lysp_import
 YANG import-stmt. More...
 
struct  lysp_include
 YANG include-stmt. More...
 
struct  lysp_module
 Printable YANG schema tree structure representing YANG module. More...
 
struct  lysp_node
 Generic YANG data node. More...
 
struct  lysp_node_action
 YANG rpc-stmt and action-stmt. More...
 
union  lysp_node_action.__unnamed__
 
struct  lysp_node_action.__unnamed__.__unnamed__
 
struct  lysp_node_action_inout
 YANG input-stmt and output-stmt. More...
 
union  lysp_node_action_inout.__unnamed__
 
struct  lysp_node_action_inout.__unnamed__.__unnamed__
 
struct  lysp_node_anydata
 
union  lysp_node_anydata.__unnamed__
 
struct  lysp_node_anydata.__unnamed__.__unnamed__
 
struct  lysp_node_augment
 YANG uses-augment-stmt and augment-stmt (compatible with struct lysp_node ) More...
 
union  lysp_node_augment.__unnamed__
 
struct  lysp_node_augment.__unnamed__.__unnamed__
 
struct  lysp_node_case
 
union  lysp_node_case.__unnamed__
 
struct  lysp_node_case.__unnamed__.__unnamed__
 
struct  lysp_node_choice
 
union  lysp_node_choice.__unnamed__
 
struct  lysp_node_choice.__unnamed__.__unnamed__
 
struct  lysp_node_container
 Extension structure of the lysp_node for YANG container. More...
 
union  lysp_node_container.__unnamed__
 
struct  lysp_node_container.__unnamed__.__unnamed__
 
struct  lysp_node_grp
 YANG grouping-stmt. More...
 
union  lysp_node_grp.__unnamed__
 
struct  lysp_node_grp.__unnamed__.__unnamed__
 
struct  lysp_node_leaf
 
union  lysp_node_leaf.__unnamed__
 
struct  lysp_node_leaf.__unnamed__.__unnamed__
 
struct  lysp_node_leaflist
 
union  lysp_node_leaflist.__unnamed__
 
struct  lysp_node_leaflist.__unnamed__.__unnamed__
 
struct  lysp_node_list
 
union  lysp_node_list.__unnamed__
 
struct  lysp_node_list.__unnamed__.__unnamed__
 
struct  lysp_node_notif
 YANG notification-stmt. More...
 
union  lysp_node_notif.__unnamed__
 
struct  lysp_node_notif.__unnamed__.__unnamed__
 
struct  lysp_node_uses
 
union  lysp_node_uses.__unnamed__
 
struct  lysp_node_uses.__unnamed__.__unnamed__
 
struct  lysp_qname
 Qualified name (optional prefix followed by an identifier). More...
 
struct  lysp_refine
 YANG refine-stmt. More...
 
struct  lysp_restr
 Covers restrictions: range, length, pattern, must. More...
 
struct  lysp_revision
 YANG revision-stmt. More...
 
struct  lysp_submodule
 
struct  lysp_tpdf
 YANG typedef-stmt. More...
 
struct  lysp_type
 YANG type-stmt. More...
 
struct  lysp_type_enum
 Enumeration/Bit value definition. More...
 
struct  lysp_when
 YANG when-stmt. More...
 

Macros

#define _LYSC_TREE_DFS_NEXT(START, ELEM, NEXT)
 Helper macro for LYSC_TREE_DFS_END, should not be used directly! More...
 
#define LY_REV_SIZE   11
 
#define LYS_ACTION   0x0200
 
#define LYS_ANYDATA   0x0060
 
#define LYS_ANYXML   0x0020
 
#define LYS_AUGMENT   0x8000
 
#define LYS_CASE   0x0080
 
#define LYS_CHOICE   0x0002
 
#define LYS_CONFIG_MASK   0x03
 
#define LYS_CONFIG_R   0x02
 
#define LYS_CONFIG_W   0x01
 
#define LYS_CONTAINER   0x0001
 
#define LYS_DEV_ADD   2
 
#define LYS_DEV_DELETE   3
 
#define LYS_DEV_NOT_SUPPORTED   1
 
#define LYS_DEV_REPLACE   4
 
#define LYS_DISABLED   0x0100
 
#define LYS_DOUBLEQUOTED   0x0200
 
#define LYS_FENABLED   0x20
 
#define LYS_FIND_NO_MATCH_ERROR   0x40
 
#define LYS_FIND_XP_OUTPUT   0x10
 
#define LYS_FIND_XP_SCHEMA   0x08
 
#define LYS_FLAGS_COMPILED_MASK   0xff
 
#define LYS_GETNEXT_INTONPCONT   0x08
 
#define LYS_GETNEXT_NOCHOICE   0x02
 
#define LYS_GETNEXT_OUTPUT   0x10
 
#define LYS_GETNEXT_WITHCASE   0x04
 
#define LYS_GETNEXT_WITHCHOICE   0x01
 
#define LYS_GROUPING   0x4000
 
#define LYS_IFF_AND   0x01
 
#define LYS_IFF_F   0x03
 
#define LYS_IFF_NOT   0x00
 
#define LYS_IFF_OR   0x02
 
#define LYS_INPUT   0x1000
 
#define LYS_INTERNAL   0x1000
 
#define LYS_IS_ENUM   0x0200
 
#define LYS_IS_INPUT   0x1000
 
#define LYS_IS_NOTIF   0x4000
 
#define LYS_IS_OUTPUT   0x2000
 
#define LYS_KEY   0x0100
 
#define LYS_KEYLESS   0x0200
 
#define LYS_LEAF   0x0004
 
#define LYS_LEAFLIST   0x0008
 
#define LYS_LIST   0x0010
 
#define LYS_MAND_FALSE   0x40
 
#define LYS_MAND_MASK   0x60
 
#define LYS_MAND_TRUE   0x20
 
#define LYS_MOD_IMPORTED_REV   0x04
 
#define LYS_MOD_LATEST_IMPCLB   0x08
 
#define LYS_MOD_LATEST_REV   0x01
 
#define LYS_MOD_LATEST_SEARCHDIRS   0x02
 
#define LYS_NODE_HASH_COUNT   4
 Maximum number of hashes stored in a schema node. More...
 
#define LYS_NODETYPE_MASK   0xffff
 
#define LYS_NOTIF   0x0400
 
#define LYS_ORDBY_MASK   0x60
 
#define LYS_ORDBY_SYSTEM   0x80
 
#define LYS_ORDBY_USER   0x40
 
#define LYS_OUTPUT   0x2000
 
#define LYS_PRESENCE   0x80
 
#define LYS_RPC   0x0100
 
#define LYS_SET_BASE   0x0001
 
#define LYS_SET_BIT   0x0002
 
#define LYS_SET_CONFIG   0x0800
 
#define LYS_SET_DFLT   0x0200
 
#define LYS_SET_ENUM   0x0004
 
#define LYS_SET_FRDIGITS   0x0008
 
#define LYS_SET_LENGTH   0x0010
 
#define LYS_SET_MAX   0x0400
 
#define LYS_SET_MIN   0x0200
 
#define LYS_SET_PATH   0x0020
 
#define LYS_SET_PATTERN   0x0040
 
#define LYS_SET_RANGE   0x0080
 
#define LYS_SET_REQINST   0x0200
 
#define LYS_SET_TYPE   0x0100
 
#define LYS_SET_UNITS   0x0400
 
#define LYS_SET_VALUE   0x0200
 
#define LYS_SINGLEQUOTED   0x0100
 
#define LYS_STATUS_CURR   0x04
 
#define LYS_STATUS_DEPRC   0x08
 
#define LYS_STATUS_MASK   0x1C
 
#define LYS_STATUS_OBSLT   0x10
 
#define LYS_UNIQUE   0x80
 
#define LYS_UNKNOWN   0x0000
 
#define LYS_USED_GRP   0x0400
 
#define LYS_USES   0x0800
 
#define LYS_YIN_ARGUMENT   0x0800
 
#define LYS_YIN_ATTR   0x0400
 
#define LYS_YINELEM_FALSE   0x0100
 
#define LYS_YINELEM_MASK   0x0180
 
#define LYS_YINELEM_TRUE   0x80
 
#define lysc_data_parent(SCHEMA)   lysc_data_node((SCHEMA) ? (SCHEMA)->parent : NULL)
 Same as lysc_data_node() but never returns the node itself. More...
 
#define lysc_is_dup_inst_list(lysc_node)
 Examine whether a node is a key-less list or a non-configuration leaf-list. More...
 
#define lysc_is_key(lysc_node)   ((!lysc_node || (lysc_node->nodetype != LYS_LEAF) || !(lysc_node->flags & LYS_KEY)) ? 0 : 1)
 Examine whether a node is a list's key. More...
 
#define lysc_is_np_cont(lysc_node)   ((!lysc_node || (lysc_node->nodetype != LYS_CONTAINER) || (lysc_node->flags & LYS_PRESENCE)) ? 0 : 1)
 Examine whether a node is a non-presence container. More...
 
#define lysc_is_userordered(lysc_node)   ((!lysc_node || !(lysc_node->nodetype & (LYS_LEAFLIST | LYS_LIST)) || !(lysc_node->flags & LYS_ORDBY_USER)) ? 0 : 1)
 Examine whether a node is user-ordered list or leaf-list. More...
 
#define LYSC_TREE_DFS_BEGIN(START, ELEM)
 Macro to iterate via all elements in a schema (sub)tree including input and output. Note that actions and notifications of traversed nodes are ignored! To traverse on all the nodes including those, use lysc_tree_dfs_full() instead. More...
 
#define LYSC_TREE_DFS_END(START, ELEM)
 Macro to iterate via all elements in a (sub)tree. This is the closing part to the LYSC_TREE_DFS_BEGIN - they always have to be used together. More...
 
#define LYSP_MODULE_NAME(PMOD)   (PMOD->is_submod ? ((struct lysp_submodule *)PMOD)->name : ((struct lysp_module *)PMOD)->mod->name)
 Get the parsed module or submodule name. More...
 
#define LYSP_RESTR_PATTERN_ACK   0x06
 
#define LYSP_RESTR_PATTERN_NACK   0x15
 
#define PCRE2_CODE_UNIT_WIDTH   8
 

Typedefs

typedef enum LYS_VERSION LYS_VERSION
 supported YANG schema version values More...
 
typedef LY_ERR(* lysc_dfs_clb )(struct lysc_node *node, void *data, ly_bool *dfs_continue)
 Callback to be called for every schema node in a DFS traversal. More...
 

Enumerations

enum  LYS_VERSION { LYS_VERSION_UNDEF = 0, LYS_VERSION_1_0 = 1, LYS_VERSION_1_1 = 2 }
 supported YANG schema version values More...
 
enum  LYSC_PATH_TYPE { LYSC_PATH_LOG, LYSC_PATH_DATA, LYSC_PATH_DATA_PATTERN }
 Types of the different schema paths. More...
 

Functions

LIBYANG_API_DECL LY_ERR lys_feature_value (const struct lys_module *module, const char *feature)
 Get the current real status of the specified feature in the module. More...
 
LIBYANG_API_DECL struct lysc_nodelys_find_child (const struct lysc_node *parent, const struct lys_module *module, const char *name, size_t name_len, uint16_t nodetype, uint32_t options)
 Get child node according to the specified criteria. More...
 
LIBYANG_API_DECL LY_ERR lys_find_expr_atoms (const struct lysc_node *ctx_node, const struct lys_module *cur_mod, const struct lyxp_expr *expr, const struct lysc_prefix *prefixes, uint32_t options, struct ly_set **set)
 Get all the schema nodes that are required for expr to be evaluated (atoms). More...
 
LIBYANG_API_DECL LY_ERR lys_find_lypath_atoms (const struct ly_path *path, struct ly_set **set)
 Get all the schema nodes that are required for path to be evaluated (atoms). More...
 
LIBYANG_API_DECL struct lysc_nodelys_find_path (const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *path, ly_bool output)
 Get a schema node based on the given data path (JSON format, see XPath Addressing). More...
 
LIBYANG_API_DECL LY_ERR lys_find_path_atoms (const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *path, ly_bool output, struct ly_set **set)
 Get all the schema nodes that are required for path to be evaluated (atoms). More...
 
LIBYANG_API_DECL LY_ERR lys_find_xpath (const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *xpath, uint32_t options, struct ly_set **set)
 Evaluate an xpath expression on schema nodes. More...
 
LIBYANG_API_DECL LY_ERR lys_find_xpath_atoms (const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const char *xpath, uint32_t options, struct ly_set **set)
 Get all the schema nodes that are required for xpath to be evaluated (atoms). More...
 
LIBYANG_API_DECL struct lysc_nodelys_getnext (const struct lysc_node *last, const struct lysc_node *parent, const struct lysc_module *module, uint32_t options)
 Get next schema (sibling) node element in the schema order that can be instantiated in a data tree. Returned node may be from an augment. More...
 
LIBYANG_API_DECL struct lysc_nodelys_getnext_ext (const struct lysc_node *last, const struct lysc_node *parent, const struct lysc_ext_instance *ext, uint32_t options)
 Get next schema (sibling) node element in the schema order of an extension that can be instantiated in a data tree. More...
 
LIBYANG_API_DECL LY_ERR lys_identity_iffeature_value (const struct lysc_ident *ident)
 Get how the if-feature statement is evaluated for certain identity. More...
 
LIBYANG_API_DECL const char * lys_nodetype2str (uint16_t nodetype)
 Stringify schema nodetype. More...
 
LIBYANG_API_DECL LY_ERR lys_set_implemented (struct lys_module *mod, const char **features)
 Make the specific module implemented. More...
 
LIBYANG_API_DECL struct lysc_nodelysc_data_node (const struct lysc_node *schema)
 Get nearest schema parent (including the node itself) that can be instantiated in data. More...
 
LIBYANG_API_DECL struct lysc_whenlysc_has_when (const struct lysc_node *node)
 Check whether the schema node data instance existence depends on any when conditions. This node and any direct parent choice and case schema nodes are also examined for when conditions. More...
 
LIBYANG_API_DECL LY_ERR lysc_iffeature_value (const struct lysc_iffeature *iff)
 Get how the if-feature statement currently evaluates. More...
 
LIBYANG_API_DECL LY_ERR lysc_module_dfs_full (const struct lys_module *mod, lysc_dfs_clb dfs_clb, void *data)
 DFS traversal of all the schema nodes in a module including RPCs and notifications. More...
 
LIBYANG_API_DECL struct
lysc_node_action
lysc_node_actions (const struct lysc_node *node)
 Get the actions/RPCs linked list of the given (compiled) schema node. Decides the node's type and in case it has a actions/RPCs array, returns it. More...
 
LIBYANG_API_DECL struct lysc_nodelysc_node_child (const struct lysc_node *node)
 Get the children linked list of the given (compiled) schema node. More...
 
LIBYANG_API_DECL struct lysc_mustlysc_node_musts (const struct lysc_node *node)
 Get the must statements list if present in the node. More...
 
LIBYANG_API_DECL struct
lysc_node_notif
lysc_node_notifs (const struct lysc_node *node)
 Get the Notifications linked list of the given (compiled) schema node. Decides the node's type and in case it has a Notifications array, returns it. More...
 
LIBYANG_API_DECL struct
lysc_when ** 
lysc_node_when (const struct lysc_node *node)
 Get the when statements list if present in the node. More...
 
LIBYANG_API_DECL struct
lys_module
lysc_owner_module (const struct lysc_node *node)
 Get the owner module of the schema node. It is the module of the top-level node. Generally, in case of augments it is the target module, recursively, otherwise it is the module where the node is defined. More...
 
LIBYANG_API_DECL char * lysc_path (const struct lysc_node *node, LYSC_PATH_TYPE pathtype, char *buffer, size_t buflen)
 Generate path of the given node in the requested format. More...
 
LIBYANG_API_DECL LY_ERR lysc_tree_dfs_full (const struct lysc_node *root, lysc_dfs_clb dfs_clb, void *data)
 DFS traversal of all the schema nodes in a (sub)tree including any actions and nested notifications. More...
 
LIBYANG_API_DECL struct
lysp_feature
lysp_feature_next (const struct lysp_feature *last, const struct lysp_module *pmod, uint32_t *idx)
 Get the next feature in the module or submodules. More...
 
LIBYANG_API_DECL struct
lysp_node_action
lysp_node_actions (const struct lysp_node *node)
 Get the actions/RPCs linked list of the given (parsed) schema node. Decides the node's type and in case it has a actions/RPCs array, returns it. More...
 
LIBYANG_API_DECL struct lysp_nodelysp_node_child (const struct lysp_node *node)
 Get the children linked list of the given (parsed) schema node. Decides the node's type and in case it has a children list, returns it. More...
 
LIBYANG_API_DECL struct
lysp_node_grp
lysp_node_groupings (const struct lysp_node *node)
 Get the groupings linked list of the given (parsed) schema node. Decides the node's type and in case it has a groupings array, returns it. More...
 
LIBYANG_API_DECL struct
lysp_node_notif
lysp_node_notifs (const struct lysp_node *node)
 Get the Notifications linked list of the given (parsed) schema node. Decides the node's type and in case it has a Notifications array, returns it. More...
 
LIBYANG_API_DECL struct lysp_tpdflysp_node_typedefs (const struct lysp_node *node)
 Get the typedefs sized array of the given (parsed) schema node. Decides the node's type and in case it has a typedefs array, returns it. More...
 
LIBYANG_API_DECL const char * lyxp_get_expr (const struct lyxp_expr *path)
 Getter for original XPath expression from a parsed expression. More...
 

Detailed Description

libyang representation of YANG schema trees.

Author
Radek Krejci rkrej.nosp@m.ci@c.nosp@m.esnet.nosp@m..cz
Michal Vasko mvask.nosp@m.o@ce.nosp@m.snet..nosp@m.cz Copyright (c) 2015 - 2022 CESNET, z.s.p.o.

This source code is licensed under BSD 3-Clause License (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at

https://opensource.org/licenses/BSD-3-Clause

Definition in file tree_schema.h.


Data Structure Documentation

struct lysc_range::lysc_range_part

Definition at line 1257 of file tree_schema.h.

Data Fields
union lysc_range_part __unnamed__
union lysc_range_part __unnamed__
union lysc_range::lysc_range_part.__unnamed__

Definition at line 1262 of file tree_schema.h.

Data Fields
int64_t max_64

< max boundary for int8, int16, int32, int64 and decimal64 ( >= LY_TYPE_DEC64)

uint64_t max_u64

for uint8, uint16, uint32, uint64, string and binary ( < LY_TYPE_DEC64)

union lysc_range::lysc_range_part.__unnamed__

Definition at line 1258 of file tree_schema.h.

Data Fields
int64_t min_64

< min boundary for int8, int16, int32, int64 and decimal64 ( >= LY_TYPE_DEC64)

uint64_t min_u64

for uint8, uint16, uint32, uint64, string and binary ( < LY_TYPE_DEC64)

Macro Definition Documentation

#define LYSP_RESTR_PATTERN_ACK   0x06

Definition at line 360 of file tree_schema.h.

#define LYSP_RESTR_PATTERN_NACK   0x15

Definition at line 361 of file tree_schema.h.

#define PCRE2_CODE_UNIT_WIDTH   8

Definition at line 19 of file tree_schema.h.