libyang  1.0.253
YANG data modeling language library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
tree_schema.h File Reference

libyang representation of data model trees. More...

#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>
Include dependency graph for tree_schema.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lyext_substmt
 Description of the extension instance substatement. More...
 
struct  lys_ext
 YANG extension definition. More...
 
struct  lys_ext_instance
 Generic extension instance structure. More...
 
struct  lys_ext_instance_complex
 Complex extension instance structure. More...
 
struct  lys_module
 Main schema node structure representing YANG module. More...
 
struct  lys_submodule
 Submodule schema node structure that can be included into a YANG module. More...
 
struct  lys_type_info_binary
 
struct  lys_type_bit
 Single bit value specification for lys_type_info_bits. More...
 
struct  lys_type_info_bits
 Container for information about bits types (LY_TYPE_BINARY), used in lys_type_info. More...
 
struct  lys_type_info_dec64
 Container for information about decimal64 types (LY_TYPE_DEC64), used in lys_type_info. More...
 
struct  lys_type_enum
 Single enumeration value specification for lys_type_info_enums. More...
 
struct  lys_type_info_enums
 Container for information about enumeration types (LY_TYPE_ENUM), used in lys_type_info. More...
 
struct  lys_type_info_ident
 Container for information about identity types (LY_TYPE_IDENT), used in lys_type_info. More...
 
struct  lys_type_info_inst
 Container for information about instance-identifier types (LY_TYPE_INST), used in lys_type_info. More...
 
struct  lys_type_info_num
 Container for information about integer types, used in lys_type_info. More...
 
struct  lys_type_info_lref
 Container for information about leafref types (LY_TYPE_LEAFREF), used in lys_type_info. More...
 
struct  lys_type_info_str
 Container for information about string types (LY_TYPE_STRING), used in lys_type_info. More...
 
struct  lys_type_info_union
 Container for information about union types (LY_TYPE_UNION), used in lys_type_info. More...
 
union  lys_type_info
 Union for holding type-specific information in lys_type. More...
 
struct  lys_type
 YANG type structure providing information from the schema. More...
 
struct  lys_iffeature
 Compiled if-feature expression structure. More...
 
struct  lys_node
 Common structure representing single YANG data statement describing. More...
 
struct  lys_node_container
 Schema container node structure. More...
 
struct  lys_node_choice
 Schema choice node structure. More...
 
struct  lys_node_leaf
 Schema leaf node structure. More...
 
struct  lys_node_leaflist
 Schema leaf-list node structure. More...
 
struct  lys_node_list
 Schema list node structure. More...
 
struct  lys_node_anydata
 Schema anydata (and anyxml) node structure. More...
 
struct  lys_node_uses
 Schema uses node structure. More...
 
struct  lys_node_grp
 Schema grouping node structure. More...
 
struct  lys_node_case
 Schema case node structure. More...
 
struct  lys_node_inout
 RPC input and output node structure. More...
 
struct  lys_node_notif
 Schema notification node structure. More...
 
struct  lys_node_rpc_action
 Schema rpc/action node structure. More...
 
struct  lys_node_augment
 YANG augment structure (covering both possibilities - uses's substatement as well as (sub)module's substatement). More...
 
struct  lys_refine_mod_list
 Container for list modifications in lys_refine_mod. More...
 
union  lys_refine_mod
 Union to hold target modification in lys_refine. More...
 
struct  lys_refine
 YANG uses's refine substatement structure, see RFC 6020 sec. 7.12.2 More...
 
struct  lys_deviate
 YANG deviate statement structure, see RFC 6020 sec. 7.18.3.2 More...
 
struct  lys_deviation
 YANG deviation statement structure, see RFC 6020 sec. 7.18.3 More...
 
struct  lys_import
 YANG import structure used to reference other schemas (modules). More...
 
struct  lys_include
 YANG include structure used to reference submodules. More...
 
struct  lys_revision
 YANG revision statement for (sub)modules. More...
 
struct  lys_tpdf
 YANG typedef structure providing information from the schema. More...
 
struct  lys_unique
 YANG list's unique statement structure, see RFC 6020 sec. 7.8.3 More...
 
struct  lys_feature
 YANG feature definition structure. More...
 
struct  lys_restr
 YANG validity restriction (must, length, etc.) structure providing information from the schema. More...
 
struct  lys_when
 YANG when restriction, see RFC 6020 sec. 7.19.5 More...
 
struct  lys_ident
 Structure to hold information about identity, see RFC 6020 sec. 7.16 More...
 

Macros

#define LY_TREE_FOR(START, ELEM)
 Macro to iterate via all sibling elements without affecting the list itself. More...
 
#define LY_TREE_FOR_SAFE(START, NEXT, ELEM)
 Macro to iterate via all sibling elements allowing to modify the list itself (e.g. removing elements) More...
 
#define LY_TREE_DFS_BEGIN(START, NEXT, ELEM)
 Macro to iterate via all elements in a tree. This is the opening part to the LY_TREE_DFS_END - they always have to be used together. More...
 
#define TYPES_COMPATIBLE(type1, type2)   _Generic(*(type1), type2: 1, default: 0)
 Macro to iterate via all elements in a tree. This is the closing part to the LY_TREE_DFS_BEGIN - they always have to be used together. More...
 
#define LY_TREE_DFS_END(START, NEXT, ELEM)
 
#define LY_ARRAY_MAX(var)   (sizeof(var) == 8 ? ULLONG_MAX : ((1ULL << (sizeof(var) * 8)) - 1))
 
#define LY_REV_SIZE   11
 
#define LYS_OUTOPT_TREE_RFC   0x01
 
#define LYS_OUTOPT_TREE_GROUPING   0x02
 
#define LYS_OUTOPT_TREE_USES   0x04
 
#define LYS_OUTOPT_TREE_NO_LEAFREF   0x08
 
#define LYS_YANG   1
 
#define LYS_YIN   2
 
#define LYS_NO_RPC_NOTIF_NODE   0x807F
 
#define LYS_ANY   0xFFFF
 
#define LYEXT_OPT_INHERIT   0x01
 
#define LYEXT_OPT_VALID   0x08
 
#define LYEXT_OPT_VALID_SUBTREE   0x10
 
#define LYEXT_OPT_PLUGIN1   0x0100
 
#define LYEXT_OPT_PLUGIN2   0x0200
 
#define LYEXT_OPT_PLUGIN3   0x0400
 
#define LYEXT_OPT_PLUGIN4   0x0800
 
#define LYEXT_OPT_PLUGIN5   0x1000
 
#define LYEXT_OPT_PLUGIN6   0x2000
 
#define LYEXT_OPT_PLUGIN7   0x4000
 
#define LYEXT_OPT_PLUGIN8   0x8000
 
#define LY_DATA_TYPE_COUNT   20
 
#define LYS_IFF_NOT   0x00
 
#define LYS_IFF_AND   0x01
 
#define LYS_IFF_OR   0x02
 
#define LYS_IFF_F   0x03
 
#define LYS_CONFIG_W   0x01
 
#define LYS_CONFIG_R   0x02
 
#define LYS_CONFIG_SET   0x04
 
#define LYS_CONFIG_MASK   0x03
 
#define LYS_STATUS_CURR   0x08
 
#define LYS_STATUS_DEPRC   0x10
 
#define LYS_STATUS_OBSLT   0x20
 
#define LYS_STATUS_MASK   0x38
 
#define LYS_RFN_MAXSET   0x08
 
#define LYS_RFN_MINSET   0x10
 
#define LYS_MAND_TRUE   0x40
 
#define LYS_MAND_FALSE   0x80
 
#define LYS_INCL_STATUS   0x80
 
#define LYS_MAND_MASK   0xc0
 
#define LYS_USERORDERED   0x100
 
#define LYS_FENABLED   0x100
 
#define LYS_UNIQUE   0x100
 
#define LYS_AUTOASSIGNED   0x01
 
#define LYS_USESGRP   0x01
 
#define LYS_IMPLICIT   0x40
 
#define LYS_XPCONF_DEP   0x200
 
#define LYS_XPSTATE_DEP   0x400
 
#define LYS_LEAFREF_DEP   0x800
 
#define LYS_DFLTJSON   0x1000
 
#define LYS_NOTAPPLIED   0x01
 
#define LYS_YINELEM   0x01
 
#define LYS_VALID_EXT   0x2000
 
#define LYS_VALID_EXT_SUBTREE   0x4000
 
#define LYS_GETNEXT_WITHCHOICE   0x01
 
#define LYS_GETNEXT_WITHCASE   0x02
 
#define LYS_GETNEXT_WITHGROUPING   0x04
 
#define LYS_GETNEXT_WITHINOUT   0x08
 
#define LYS_GETNEXT_WITHUSES   0x10
 
#define LYS_GETNEXT_INTOUSES   0x20
 
#define LYS_GETNEXT_INTONPCONT   0x40
 
#define LYS_GETNEXT_PARENTUSES   0x80
 
#define LYS_GETNEXT_NOSTATECHECK   0x100
 
#define LYXP_MUST   0x01
 
#define LYXP_WHEN   0x02
 
#define LYXP_RECURSIVE   0x01
 
#define LYXP_NO_LOCAL   0x02
 
#define LYS_PATH_FIRST_PREFIX   0x01
 

Typedefs

typedef enum lys_nodetype LYS_NODE
 YANG schema node types. More...
 
typedef enum LYS_VERSION LYS_VERSION
 supported YANG schema version values More...
 
typedef enum lys_deviate_type LYS_DEVIATE_TYPE
 Possible deviation modifications, see RFC 6020 sec. 7.18.3.2 More...
 

Enumerations

enum  LYS_INFORMAT { LYS_IN_UNKNOWN = 0, LYS_IN_YANG = 1, LYS_IN_YIN = 2 }
 Schema input formats accepted by libyang parser functions. More...
 
enum  LYS_OUTFORMAT {
  LYS_OUT_UNKNOWN = 0, LYS_OUT_YANG = 1, LYS_OUT_YIN = 2, LYS_OUT_TREE,
  LYS_OUT_INFO, LYS_OUT_JSON
}
 Schema output formats accepted by libyang printer functions. More...
 
enum  lys_nodetype {
  LYS_UNKNOWN = 0x0000, LYS_CONTAINER = 0x0001, LYS_CHOICE = 0x0002, LYS_LEAF = 0x0004,
  LYS_LEAFLIST = 0x0008, LYS_LIST = 0x0010, LYS_ANYXML = 0x0020, LYS_CASE = 0x0040,
  LYS_NOTIF = 0x0080, LYS_RPC = 0x0100, LYS_INPUT = 0x0200, LYS_OUTPUT = 0x0400,
  LYS_GROUPING = 0x0800, LYS_USES = 0x1000, LYS_AUGMENT = 0x2000, LYS_ACTION = 0x4000,
  LYS_ANYDATA = 0x8020, LYS_EXT = 0x10000
}
 YANG schema node types. More...
 
enum  LY_STMT {
  LY_STMT_NODE = -1, LY_STMT_UNKNOWN = 0, LY_STMT_ARGUMENT = 1, LY_STMT_BASE,
  LY_STMT_BELONGSTO, LY_STMT_CONTACT, LY_STMT_DEFAULT, LY_STMT_DESCRIPTION,
  LY_STMT_ERRTAG, LY_STMT_ERRMSG, LY_STMT_KEY, LY_STMT_NAMESPACE,
  LY_STMT_ORGANIZATION, LY_STMT_PATH, LY_STMT_PREFIX, LY_STMT_PRESENCE,
  LY_STMT_REFERENCE, LY_STMT_REVISIONDATE, LY_STMT_UNITS, LY_STMT_VALUE,
  LY_STMT_VERSION, LY_STMT_MODIFIER, LY_STMT_REQINSTANCE, LY_STMT_YINELEM,
  LY_STMT_CONFIG, LY_STMT_MANDATORY, LY_STMT_ORDEREDBY, LY_STMT_STATUS,
  LY_STMT_DIGITS, LY_STMT_MAX, LY_STMT_MIN, LY_STMT_POSITION,
  LY_STMT_UNIQUE, LY_STMT_MODULE, LY_STMT_ACTION, LY_STMT_ANYDATA,
  LY_STMT_ANYXML, LY_STMT_CASE, LY_STMT_CHOICE, LY_STMT_CONTAINER,
  LY_STMT_GROUPING, LY_STMT_INPUT, LY_STMT_LEAF, LY_STMT_LEAFLIST,
  LY_STMT_LIST, LY_STMT_NOTIFICATION, LY_STMT_OUTPUT, LY_STMT_USES,
  LY_STMT_TYPEDEF, LY_STMT_TYPE, LY_STMT_IFFEATURE, LY_STMT_LENGTH,
  LY_STMT_MUST, LY_STMT_PATTERN, LY_STMT_RANGE, LY_STMT_WHEN,
  LY_STMT_REVISION, LY_STMT_SUBMODULE, LY_STMT_RPC, LY_STMT_BIT,
  LY_STMT_ENUM, LY_STMT_REFINE, LY_STMT_AUGMENT, LY_STMT_DEVIATE,
  LY_STMT_DEVIATION, LY_STMT_EXTENSION, LY_STMT_FEATURE, LY_STMT_IDENTITY,
  LY_STMT_IMPORT, LY_STMT_INCLUDE
}
 List of YANG statements. More...
 
enum  LY_STMT_CARD { LY_STMT_CARD_OPT, LY_STMT_CARD_MAND, LY_STMT_CARD_SOME, LY_STMT_CARD_ANY }
 Possible cardinalities of the YANG statements. More...
 
enum  LYEXT_TYPE { LYEXT_ERR = -1, LYEXT_FLAG = 0, LYEXT_COMPLEX }
 Extension types. More...
 
enum  LYS_VERSION { LYS_VERSION_UNDEF = 0, LYS_VERSION_1 = 1, LYS_VERSION_1_1 = 2 }
 supported YANG schema version values More...
 
enum  LY_DATA_TYPE {
  LY_TYPE_DER = 0, LY_TYPE_BINARY, LY_TYPE_BITS, LY_TYPE_BOOL,
  LY_TYPE_DEC64, LY_TYPE_EMPTY, LY_TYPE_ENUM, LY_TYPE_IDENT,
  LY_TYPE_INST, LY_TYPE_LEAFREF, LY_TYPE_STRING, LY_TYPE_UNION,
  LY_TYPE_INT8, LY_TYPE_UINT8, LY_TYPE_INT16, LY_TYPE_UINT16,
  LY_TYPE_INT32, LY_TYPE_UINT32, LY_TYPE_INT64, LY_TYPE_UINT64,
  LY_TYPE_UNKNOWN
}
 YANG built-in types. More...
 
enum  lys_deviate_type { LY_DEVIATE_NO, LY_DEVIATE_ADD, LY_DEVIATE_RPL, LY_DEVIATE_DEL }
 Possible deviation modifications, see RFC 6020 sec. 7.18.3.2 More...
 
enum  lyxp_node_type {
  LYXP_NODE_ROOT, LYXP_NODE_ROOT_CONFIG, LYXP_NODE_ELEM, LYXP_NODE_TEXT,
  LYXP_NODE_ATTR, LYXP_NODE_NONE
}
 Types of context nodes, LYXP_NODE_ROOT_CONFIG used only in when or must conditions. More...
 

Functions

const void * lys_ext_instance_substmt (const struct lys_ext_instance *ext)
 Get address of the substatement structure to which the extension instance refers. More...
 
int lys_ext_instance_presence (struct lys_ext *def, struct lys_ext_instance **ext, uint8_t ext_size)
 Get the position of the extension instance in the extensions list. More...
 
void * lys_ext_complex_get_substmt (LY_STMT stmt, struct lys_ext_instance_complex *ext, struct lyext_substmt **info)
 get pointer to the place where the specified extension's substatement is supposed to be stored in the complex extension instance. More...
 
const char *const * ly_get_loaded_plugins (void)
 Get list of all the loaded plugins, both extension and user type ones. More...
 
void ly_load_plugins (void)
 Load the available YANG extension and type plugins from the plugin directory (LIBDIR/libyang/). More...
 
int ly_register_exts (struct lyext_plugin_list *plugin, const char *log_name)
 Directly register a YANG extension by pointer. More...
 
int ly_register_types (struct lytype_plugin_list *plugin, const char *log_name)
 Directly register a YANG type by pointer. More...
 
int ly_clean_plugins (void)
 Unload all the YANG extension and type plugins. More...
 
struct lys_modulelys_parse_mem (struct ly_ctx *ctx, const char *data, LYS_INFORMAT format)
 Load a schema into the specified context. More...
 
struct lys_modulelys_parse_fd (struct ly_ctx *ctx, int fd, LYS_INFORMAT format)
 Read a schema from file descriptor into the specified context. More...
 
struct lys_modulelys_parse_path (struct ly_ctx *ctx, const char *path, LYS_INFORMAT format)
 Load a schema into the specified context from a file. More...
 
int lys_search_localfile (const char *const *searchpaths, int cwd, const char *name, const char *revision, char **localfile, LYS_INFORMAT *format)
 Search for the schema file in the specified searchpaths. More...
 
const char ** lys_features_list (const struct lys_module *module, uint8_t **states)
 Get list of all the defined features in the module and its submodules. More...
 
int lys_features_enable (const struct lys_module *module, const char *feature)
 Enable specified feature in the module. In case its if-feature evaluates to false, return an error. More...
 
int lys_features_disable (const struct lys_module *module, const char *feature)
 Disable specified feature in the module. If it causes some dependant features to be disabled, they are also set to disabled. More...
 
int lys_features_enable_force (const struct lys_module *module, const char *feature)
 Enable specified feature in the module disregarding its if-features. More...
 
int lys_features_disable_force (const struct lys_module *module, const char *feature)
 Disable specified feature in the module disregarding dependant features. More...
 
int lys_features_state (const struct lys_module *module, const char *feature)
 Get the current status of the specified feature in the module. Even if the feature is enabled but some of its if-features evaluate to false, it is reported as disabled. More...
 
struct lys_nodelys_is_disabled (const struct lys_node *node, int recursive)
 Check if the schema node is disabled in the schema tree, i.e. there is any disabled if-feature statement affecting the node. More...
 
int lys_iffeature_value (const struct lys_iffeature *iff)
 Learn how the if-feature statement currently evaluates. More...
 
struct lys_node_listlys_is_key (const struct lys_node_leaf *node, uint8_t *index)
 Check if the schema leaf node is used as a key for a list. More...
 
struct lys_nodelys_getnext (const struct lys_node *last, const struct lys_node *parent, const struct lys_module *module, int options)
 Get next schema tree (sibling) node element that can be instantiated in a data tree. Returned node can be from an augment. More...
 
struct lys_typelys_getnext_union_type (const struct lys_type *last, const struct lys_type *type)
 Get next type of a union. More...
 
struct ly_set * lys_find_path (const struct lys_module *cur_module, const struct lys_node *cur_node, const char *path)
 Search for schema nodes matching the provided path. More...
 
struct ly_set * lys_xpath_atomize (const struct lys_node *ctx_node, enum lyxp_node_type ctx_node_type, const char *expr, int options)
 Get all the partial XPath nodes (atoms) that are required for expr to be evaluated. More...
 
struct ly_set * lys_node_xpath_atomize (const struct lys_node *node, int options)
 Call lys_xpath_atomize() on all the when and must expressions of the node. This node must be a descendant of an input, output, or notification node. This subtree then forms the local subtree. More...
 
char * lys_path (const struct lys_node *node, int options)
 Build schema path (usable as path, see howtoxpath) of the schema node. More...
 
char * lys_data_path (const struct lys_node *node)
 Build data path (usable as path, see howtoxpath) of the schema node. More...
 
char * lys_data_path_pattern (const struct lys_node *node, const char *placeholder)
 Build the data path pattern of a schema node. More...
 
struct lys_nodelys_parent (const struct lys_node *node)
 Return parent node in the schema tree. More...
 
struct lys_modulelys_node_module (const struct lys_node *node)
 Return main module of the schema tree node. More...
 
struct lys_modulelys_main_module (const struct lys_module *module)
 Return main module of the module. More...
 
struct lys_modulelys_implemented_module (const struct lys_module *mod)
 Find the implemented revision of the given module in the context. More...
 
int lys_set_implemented (const struct lys_module *module)
 Mark imported module as "implemented". More...
 
int lys_set_disabled (const struct lys_module *module)
 Disable module in its context to avoid its further usage (it will be hidden for module getters). More...
 
int lys_set_enabled (const struct lys_module *module)
 Enable previously disabled module. More...
 
void * lys_set_private (const struct lys_node *node, void *priv)
 Set a schema private pointer to a user pointer. More...
 
int lys_print_mem (char **strp, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node, int line_length, int options)
 Print schema tree in the specified format into a memory block. It is up to caller to free the returned string by free(). More...
 
int lys_print_fd (int fd, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node, int line_length, int options)
 Print schema tree in the specified format into a file descriptor. More...
 
int lys_print_file (FILE *f, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node, int line_length, int options)
 Print schema tree in the specified format into a file stream. More...
 
int lys_print_path (const char *path, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node, int line_length, int options)
 Print schema tree in the specified format into a file. More...
 
int lys_print_clb (ssize_t(*writeclb)(void *arg, const void *buf, size_t count), void *arg, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node, int line_length, int options)
 Print schema tree in the specified format using a provided callback. More...
 

Detailed Description

libyang representation of data model trees.

Author
Radek Krejci rkrej.nosp@m.ci@c.nosp@m.esnet.nosp@m..cz Copyright (c) 2015 - 2018 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.

Macro Definition Documentation

#define LY_TREE_DFS_END (   START,
  NEXT,
  ELEM 
)

Definition at line 122 of file tree_schema.h.