15#ifndef LY_TREE_SCHEMA_H_
16#define LY_TREE_SCHEMA_H_
40#define LY_TREE_FOR(START, ELEM) \
41 for ((ELEM) = (START); \
43 (ELEM) = (ELEM)->next)
58#define LY_TREE_FOR_SAFE(START, NEXT, ELEM) \
59 for ((ELEM) = (START); \
60 (ELEM) ? (NEXT = (ELEM)->next, 1) : 0; \
90#define LY_TREE_DFS_BEGIN(START, NEXT, ELEM) \
91 for ((ELEM) = (NEXT) = (START); \
115#define TYPES_COMPATIBLE(type1, type2) typeid(*(type1)) == typeid(type2)
116#elif defined(__GNUC__) || defined(__clang__)
117#define TYPES_COMPATIBLE(type1, type2) __builtin_types_compatible_p(__typeof__(*(type1)), type2)
119#define TYPES_COMPATIBLE(type1, type2) _Generic(*(type1), type2: 1, default: 0)
122#define LY_TREE_DFS_END(START, NEXT, ELEM) \
124 if (TYPES_COMPATIBLE(ELEM, struct lyd_node)) { \
126 if (((struct lyd_node *)(ELEM))->schema->nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_ANYDATA)) { \
129 (NEXT) = (ELEM)->child; \
131 } else if (TYPES_COMPATIBLE(ELEM, struct lys_node)) { \
133 if (((struct lys_node *)(ELEM))->nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_ANYDATA)) { \
136 (NEXT) = (ELEM)->child; \
139 (NEXT) = (ELEM)->child; \
144 if ((ELEM) == (START)) { \
149 (NEXT) = (ELEM)->next; \
153 if (TYPES_COMPATIBLE(ELEM, struct lys_node) \
154 && (((struct lys_node *)(ELEM)->parent)->nodetype == LYS_AUGMENT)) { \
155 (ELEM) = (ELEM)->parent->prev; \
157 (ELEM) = (ELEM)->parent; \
160 if (TYPES_COMPATIBLE(ELEM, struct lys_node)) { \
162 if (lys_parent((struct lys_node *)(ELEM)) == lys_parent((struct lys_node *)(START))) { \
166 } else if ((ELEM)->parent == (START)->parent) { \
170 (NEXT) = (ELEM)->next; \
180#define LY_ARRAY_MAX(var) (sizeof(var) == 8 ? ULLONG_MAX : ((1ULL << (sizeof(var) * 8)) - 1))
182#define LY_REV_SIZE 11
211#define LYS_OUTOPT_TREE_RFC 0x01
212#define LYS_OUTOPT_TREE_GROUPING 0x02
213#define LYS_OUTOPT_TREE_USES 0x04
214#define LYS_OUTOPT_TREE_NO_LEAFREF 0x08
251#define LYS_NO_RPC_NOTIF_NODE 0x807F
253#define LYS_ANY 0xFFFF
404#define LYEXT_OPT_INHERIT 0x01
410#define LYEXT_OPT_YANG 0x02
411#define LYEXT_OPT_CONTENT 0x04
413#define LYEXT_OPT_VALID 0x08
414#define LYEXT_OPT_VALID_SUBTREE 0x10
418#define LYEXT_OPT_PLUGIN1 0x0100
419#define LYEXT_OPT_PLUGIN2 0x0200
420#define LYEXT_OPT_PLUGIN3 0x0400
421#define LYEXT_OPT_PLUGIN4 0x0800
422#define LYEXT_OPT_PLUGIN5 0x1000
423#define LYEXT_OPT_PLUGIN6 0x2000
424#define LYEXT_OPT_PLUGIN7 0x4000
425#define LYEXT_OPT_PLUGIN8 0x8000
807#define LY_DATA_TYPE_COUNT 20
937#ifdef LY_ENABLED_CACHE
938 void **patterns_pcre;
1062#define LYS_IFF_NOT 0x00
1063#define LYS_IFF_AND 0x01
1064#define LYS_IFF_OR 0x02
1065#define LYS_IFF_F 0x03
1135#define LYS_CONFIG_W 0x01
1136#define LYS_CONFIG_R 0x02
1137#define LYS_CONFIG_SET 0x04
1138#define LYS_CONFIG_MASK 0x03
1139#define LYS_STATUS_CURR 0x08
1140#define LYS_STATUS_DEPRC 0x10
1141#define LYS_STATUS_OBSLT 0x20
1142#define LYS_STATUS_MASK 0x38
1143#define LYS_RFN_MAXSET 0x08
1144#define LYS_RFN_MINSET 0x10
1145#define LYS_MAND_TRUE 0x40
1147#define LYS_MAND_FALSE 0x80
1149#define LYS_INCL_STATUS 0x80
1151#define LYS_MAND_MASK 0xc0
1152#define LYS_USERORDERED 0x100
1154#define LYS_FENABLED 0x100
1155#define LYS_UNIQUE 0x100
1156#define LYS_AUTOASSIGNED 0x01
1158#define LYS_USESGRP 0x01
1159#define LYS_IMPLICIT 0x40
1160#define LYS_XPCONF_DEP 0x200
1163#define LYS_XPSTATE_DEP 0x400
1166#define LYS_LEAFREF_DEP 0x800
1169#define LYS_DFLTJSON 0x1000
1173#define LYS_NOTAPPLIED 0x01
1174#define LYS_YINELEM 0x01
1175#define LYS_VALID_EXT 0x2000
1176#define LYS_VALID_EXT_SUBTREE 0x4000
1183#ifdef LY_ENABLED_CACHE
1188#define LYS_NODE_HASH_COUNT 4
1241#ifdef LY_ENABLED_CACHE
1242 uint8_t hash[LYS_NODE_HASH_COUNT];
1283#ifdef LY_ENABLED_CACHE
1284 uint8_t hash[LYS_NODE_HASH_COUNT];
1372#ifdef LY_ENABLED_CACHE
1373 uint8_t hash[LYS_NODE_HASH_COUNT];
1426#ifdef LY_ENABLED_CACHE
1427 uint8_t hash[LYS_NODE_HASH_COUNT];
1481#ifdef LY_ENABLED_CACHE
1482 uint8_t hash[LYS_NODE_HASH_COUNT];
1538#ifdef LY_ENABLED_CACHE
1539 uint8_t hash[LYS_NODE_HASH_COUNT];
1756#ifdef LY_ENABLED_CACHE
1757 uint8_t hash[LYS_NODE_HASH_COUNT];
1802#ifdef LY_ENABLED_CACHE
1803 uint8_t hash[LYS_NODE_HASH_COUNT];
2278#define LYS_GETNEXT_WITHCHOICE 0x01
2279#define LYS_GETNEXT_WITHCASE 0x02
2280#define LYS_GETNEXT_WITHGROUPING 0x04
2281#define LYS_GETNEXT_WITHINOUT 0x08
2283#define LYS_GETNEXT_WITHUSES 0x10
2284#define LYS_GETNEXT_INTOUSES 0x20
2286#define LYS_GETNEXT_INTONPCONT 0x40
2287#define LYS_GETNEXT_PARENTUSES 0x80
2289#define LYS_GETNEXT_NOSTATECHECK 0x100
2344 const char *expr,
int options);
2346#define LYXP_MUST 0x01
2347#define LYXP_WHEN 0x02
2358#define LYXP_RECURSIVE 0x01
2359#define LYXP_NO_LOCAL 0x02
2374#define LYS_PATH_FIRST_PREFIX 0x01
2532 int line_length,
int options);
2547 int line_length,
int options);
2562 int line_length,
int options);
2577 int line_length,
int options);
2592int lys_print_clb(ssize_t (*writeclb)(
void *arg,
const void *buf,
size_t count),
void *arg,
2593 const struct lys_module *module,
LYS_OUTFORMAT format,
const char *target_node,
int line_length,
int options);
struct lys_module * module
struct lyext_plugin * plugin
struct lys_ext_instance ** ext
struct lyext_substmt * substmt
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.
int ly_register_types(struct lytype_plugin_list *plugin, const char *log_name)
Directly register a YANG type by pointer.
const char *const * ly_get_loaded_plugins(void)
Get list of all the loaded plugins, both extension and user type ones.
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...
void ly_load_plugins(void)
Load the available YANG extension and type plugins from the plugin directory (LIBDIR/libyang/).
const void * lys_ext_instance_substmt(const struct lys_ext_instance *ext)
Get address of the substatement structure to which the extension instance refers.
int ly_register_exts(struct lyext_plugin_list *plugin, const char *log_name)
Directly register a YANG extension by pointer.
LY_STMT_CARD
Possible cardinalities of the YANG statements.
LY_STMT
List of YANG statements.
int ly_clean_plugins(void)
Unload all the YANG extension and type plugins.
LYEXT_TYPE
Extension types.
Description of the extension instance substatement.
YANG extension definition.
Generic extension instance structure.
Complex extension instance structure.
Structure to hold a set of (not necessary somehow connected) lyd_node or lys_node objects....
struct lys_module * module
struct ly_set * depfeatures
struct lys_node_leaf ** keys
struct lys_feature * features
struct lys_type_info_lref lref
struct lys_type_info_union uni
struct lys_type_info_num num
struct lys_type_info_ident ident
struct lys_refine_mod_list list
struct lys_submodule * submodule
struct lys_ext * extensions
struct lys_node_augment * augment
struct lys_type_info_dec64 dec64
struct lys_revision * rev
struct lys_type_bit * bit
struct lys_ext_instance ** ext
struct lys_node_leaf * target
struct lys_refine * refine
struct lys_type_info_str str
struct lys_restr * patterns
struct lys_restr * length
struct lys_node_grp * grp
struct lys_unique * unique
uint8_t has_union_leafref
struct lys_type_info_enums enums
struct lys_deviate * deviate
struct lys_node * orig_node
struct lys_iffeature * iffeature
struct lys_feature ** features
struct lys_type_info_inst inst
LY_DATA_TYPE _PACKED base
struct ly_set * backlinks
struct lys_deviation * deviation
struct lys_type_info_binary binary
struct lys_type_enum * enm
struct lys_module * belongsto
struct lys_type_info_bits bits
struct lys_module * lys_main_module(const struct lys_module *module)
Return main module of the module.
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.
LY_DATA_TYPE
YANG built-in types.
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.
char * lys_path(const struct lys_node *node, int options)
Build schema path (usable as path, see XPath Addressing) of the schema node.
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 descen...
lyxp_node_type
Types of context nodes, LYXP_NODE_ROOT_CONFIG used only in when or must conditions.
int lys_features_disable_force(const struct lys_module *module, const char *feature)
Disable specified feature in the module disregarding dependant features.
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).
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,...
const struct lys_type * lys_getnext_union_type(const struct lys_type *last, const struct lys_type *type)
Get next type of a union.
const struct lys_module * lys_parse_fd(struct ly_ctx *ctx, int fd, LYS_INFORMAT format)
Read a schema from file descriptor into the specified context.
const struct lys_module * lys_parse_path(struct ly_ctx *ctx, const char *path, LYS_INFORMAT format)
Load a schema into the specified context from a file.
char * lys_data_path(const struct lys_node *node)
Build data path (usable as path, see XPath Addressing) of the schema node.
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.
void * lys_set_private(const struct lys_node *node, void *priv)
Set a schema private pointer to a user pointer.
int lys_set_enabled(const struct lys_module *module)
Enable previously disabled module.
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,...
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.
char * lys_data_path_pattern(const struct lys_node *node, const char *placeholder)
Build the data path pattern of a schema node.
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 returne...
struct lys_node * lys_parent(const struct lys_node *node)
Return parent node in the schema tree.
const struct lys_node * lys_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 statem...
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.
LYS_OUTFORMAT
Schema output formats accepted by libyang printer functions.
enum lys_deviate_type LYS_DEVIATE_TYPE
Possible deviation modifications, see RFC 6020 sec. 7.18.3.2
LYS_INFORMAT
Schema input formats accepted by libyang parser functions.
lys_nodetype
YANG schema node types.
lys_deviate_type
Possible deviation modifications, see RFC 6020 sec. 7.18.3.2
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.
struct lys_module * lys_node_module(const struct lys_node *node)
Return main module of the schema tree node.
const struct lys_node * lys_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....
int lys_iffeature_value(const struct lys_iffeature *iff)
Learn how the if-feature statement currently evaluates.
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.
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.
int lys_set_implemented(const struct lys_module *module)
Mark imported module as "implemented".
int lys_features_enable_force(const struct lys_module *module, const char *feature)
Enable specified feature in the module disregarding its if-features.
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 som...
const struct lys_node_list * lys_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.
const struct lys_module * lys_parse_mem(struct ly_ctx *ctx, const char *data, LYS_INFORMAT format)
Load a schema into the specified context.
LYS_VERSION
supported YANG schema version values
struct lys_module * lys_implemented_module(const struct lys_module *mod)
Find the implemented revision of the given module in the context.
enum lys_nodetype LYS_NODE
YANG schema node types.
YANG deviate statement structure, see RFC 6020 sec. 7.18.3.2
YANG deviation statement structure, see RFC 6020 sec. 7.18.3
YANG feature definition structure.
Structure to hold information about identity, see RFC 6020 sec. 7.16
Compiled if-feature expression structure.
YANG import structure used to reference other schemas (modules).
YANG include structure used to reference submodules.
Main schema node structure representing YANG module.
Common structure representing single YANG data statement describing.
Schema anydata (and anyxml) node structure.
YANG augment structure (covering both possibilities - uses's substatement as well as (sub)module's su...
Schema case node structure.
Schema choice node structure.
Schema container node structure.
Schema grouping node structure.
RPC input and output node structure.
Schema leaf node structure.
Schema leaf-list node structure.
Schema list node structure.
Schema notification node structure.
Schema rpc/action node structure.
Schema uses node structure.
YANG uses's refine substatement structure, see RFC 6020 sec. 7.12.2
Container for list modifications in lys_refine_mod.
YANG validity restriction (must, length, etc.) structure providing information from the schema.
YANG revision statement for (sub)modules.
Submodule schema node structure that can be included into a YANG module.
YANG typedef structure providing information from the schema.
YANG type structure providing information from the schema.
Single bit value specification for lys_type_info_bits.
Single enumeration value specification for lys_type_info_enums.
Container for information about bits types (LY_TYPE_BINARY), used in lys_type_info.
Container for information about decimal64 types (LY_TYPE_DEC64), used in lys_type_info.
Container for information about enumeration types (LY_TYPE_ENUM), used in lys_type_info.
Container for information about identity types (LY_TYPE_IDENT), used in lys_type_info.
Container for information about instance-identifier types (LY_TYPE_INST), used in lys_type_info.
Container for information about leafref types (LY_TYPE_LEAFREF), used in lys_type_info.
Container for information about integer types, used in lys_type_info.
Container for information about string types (LY_TYPE_STRING), used in lys_type_info.
Container for information about union types (LY_TYPE_UNION), used in lys_type_info.
YANG list's unique statement structure, see RFC 6020 sec. 7.8.3
YANG when restriction, see RFC 6020 sec. 7.19.5
Union to hold target modification in lys_refine.
Union for holding type-specific information in lys_type.
#define _PACKED
Compiler flag for packed data types.