 |
libyang
1.0.101
YANG data modeling language library
|
Go to the documentation of this file.
15 #ifndef LY_TREE_SCHEMA_H_
16 #define LY_TREE_SCHEMA_H_
19 #include <machine/endian.h>
20 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
21 #include <sys/endian.h>
30 #include <sys/types.h>
48 #define LY_TREE_FOR(START, ELEM) \
49 for ((ELEM) = (START); \
51 (ELEM) = (ELEM)->next)
66 #define LY_TREE_FOR_SAFE(START, NEXT, ELEM) \
67 for ((ELEM) = (START); \
68 (ELEM) ? (NEXT = (ELEM)->next, 1) : 0; \
98 #define LY_TREE_DFS_BEGIN(START, NEXT, ELEM) \
99 for ((ELEM) = (NEXT) = (START); \
123 #define TYPES_COMPATIBLE(type1, type2) typeid(*(type1)) == typeid(type2)
124 #elif defined(__GNUC__) || defined(__clang__)
125 #define TYPES_COMPATIBLE(type1, type2) __builtin_types_compatible_p(__typeof__(*(type1)), type2)
127 #define TYPES_COMPATIBLE(type1, type2) _Generic(*(type1), type2: 1, default: 0)
130 #define LY_TREE_DFS_END(START, NEXT, ELEM) \
132 if (TYPES_COMPATIBLE(ELEM, struct lyd_node)) { \
134 if (((struct lyd_node *)(ELEM))->schema->nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_ANYDATA)) { \
137 (NEXT) = (ELEM)->child; \
139 } else if (TYPES_COMPATIBLE(ELEM, struct lys_node)) { \
141 if (((struct lys_node *)(ELEM))->nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_ANYDATA)) { \
144 (NEXT) = (ELEM)->child; \
147 (NEXT) = (ELEM)->child; \
152 if ((ELEM) == (START)) { \
157 (NEXT) = (ELEM)->next; \
161 if (TYPES_COMPATIBLE(ELEM, struct lys_node) \
162 && (((struct lys_node *)(ELEM)->parent)->nodetype == LYS_AUGMENT)) { \
163 (ELEM) = (ELEM)->parent->prev; \
165 (ELEM) = (ELEM)->parent; \
168 if (TYPES_COMPATIBLE(ELEM, struct lys_node)) { \
170 if (lys_parent((struct lys_node *)(ELEM)) == lys_parent((struct lys_node *)(START))) { \
174 } else if ((ELEM)->parent == (START)->parent) { \
178 (NEXT) = (ELEM)->next; \
188 #define LY_ARRAY_MAX(var) (sizeof(var) == 8 ? ULLONG_MAX : ((1ULL << (sizeof(var) * 8)) - 1))
190 #define LY_REV_SIZE 11
219 #define LYS_OUTOPT_TREE_RFC 0x01
220 #define LYS_OUTOPT_TREE_GROUPING 0x02
221 #define LYS_OUTOPT_TREE_USES 0x04
222 #define LYS_OUTOPT_TREE_NO_LEAFREF 0x08
237 typedef enum lys_nodetype {
259 #define LYS_NO_RPC_NOTIF_NODE 0x807F
261 #define LYS_ANY 0xFFFF
412 #define LYEXT_OPT_INHERIT 0x01
418 #define LYEXT_OPT_YANG 0x02
419 #define LYEXT_OPT_CONTENT 0x04
421 #define LYEXT_OPT_VALID 0x08
422 #define LYEXT_OPT_VALID_SUBTREE 0x10
426 #define LYEXT_OPT_PLUGIN1 0x0100
427 #define LYEXT_OPT_PLUGIN2 0x0200
428 #define LYEXT_OPT_PLUGIN3 0x0400
429 #define LYEXT_OPT_PLUGIN4 0x0800
430 #define LYEXT_OPT_PLUGIN5 0x1000
431 #define LYEXT_OPT_PLUGIN6 0x2000
432 #define LYEXT_OPT_PLUGIN7 0x4000
433 #define LYEXT_OPT_PLUGIN8 0x8000
443 struct lyext_substmt {
815 #define LY_DATA_TYPE_COUNT 20
820 struct lys_type_info_binary {
945 #ifdef LY_ENABLED_CACHE
946 void **patterns_pcre;
1070 #define LYS_IFF_NOT 0x00
1071 #define LYS_IFF_AND 0x01
1072 #define LYS_IFF_OR 0x02
1073 #define LYS_IFF_F 0x03
1143 #define LYS_CONFIG_W 0x01
1144 #define LYS_CONFIG_R 0x02
1145 #define LYS_CONFIG_SET 0x04
1146 #define LYS_CONFIG_MASK 0x03
1147 #define LYS_STATUS_CURR 0x08
1148 #define LYS_STATUS_DEPRC 0x10
1149 #define LYS_STATUS_OBSLT 0x20
1150 #define LYS_STATUS_MASK 0x38
1151 #define LYS_RFN_MAXSET 0x08
1152 #define LYS_RFN_MINSET 0x10
1153 #define LYS_MAND_TRUE 0x40
1155 #define LYS_MAND_FALSE 0x80
1157 #define LYS_INCL_STATUS 0x80
1159 #define LYS_MAND_MASK 0xc0
1160 #define LYS_USERORDERED 0x100
1162 #define LYS_FENABLED 0x100
1163 #define LYS_UNIQUE 0x100
1164 #define LYS_AUTOASSIGNED 0x01
1166 #define LYS_USESGRP 0x01
1167 #define LYS_IMPLICIT 0x40
1168 #define LYS_XPCONF_DEP 0x200
1171 #define LYS_XPSTATE_DEP 0x400
1174 #define LYS_LEAFREF_DEP 0x800
1177 #define LYS_DFLTJSON 0x1000
1181 #define LYS_NOTAPPLIED 0x01
1182 #define LYS_YINELEM 0x01
1183 #define LYS_VALID_EXT 0x2000
1184 #define LYS_VALID_EXT_SUBTREE 0x4000
1191 #ifdef LY_ENABLED_CACHE
1196 #define LYS_NODE_HASH_COUNT 4
1249 #ifdef LY_ENABLED_CACHE
1250 uint8_t hash[LYS_NODE_HASH_COUNT];
1291 #ifdef LY_ENABLED_CACHE
1292 uint8_t hash[LYS_NODE_HASH_COUNT];
1382 #ifdef LY_ENABLED_CACHE
1383 uint8_t hash[LYS_NODE_HASH_COUNT];
1436 #ifdef LY_ENABLED_CACHE
1437 uint8_t hash[LYS_NODE_HASH_COUNT];
1491 #ifdef LY_ENABLED_CACHE
1492 uint8_t hash[LYS_NODE_HASH_COUNT];
1548 #ifdef LY_ENABLED_CACHE
1549 uint8_t hash[LYS_NODE_HASH_COUNT];
1766 #ifdef LY_ENABLED_CACHE
1767 uint8_t hash[LYS_NODE_HASH_COUNT];
1812 #ifdef LY_ENABLED_CACHE
1813 uint8_t hash[LYS_NODE_HASH_COUNT];
2264 #define LYS_GETNEXT_WITHCHOICE 0x01
2265 #define LYS_GETNEXT_WITHCASE 0x02
2266 #define LYS_GETNEXT_WITHGROUPING 0x04
2267 #define LYS_GETNEXT_WITHINOUT 0x08
2269 #define LYS_GETNEXT_WITHUSES 0x10
2270 #define LYS_GETNEXT_INTOUSES 0x20
2272 #define LYS_GETNEXT_INTONPCONT 0x40
2273 #define LYS_GETNEXT_PARENTUSES 0x80
2275 #define LYS_GETNEXT_NOSTATECHECK 0x100
2285 const struct lys_type *lys_getnext_union_type(const struct lys_type *last, const struct lys_type *type);
2330 const char *expr,
int options);
2332 #define LYXP_MUST 0x01
2333 #define LYXP_WHEN 0x02
2342 struct ly_set *lys_node_xpath_atomize(const struct lys_node *node, int options);
2344 #define LYXP_RECURSIVE 0x01
2345 #define LYXP_NO_LOCAL 0x02
2358 char *lys_path(const struct lys_node *node, int options);
2360 #define LYS_PATH_FIRST_PREFIX 0x01
2370 char *lys_data_path(const struct lys_node *node);
2503 int line_length,
int options);
2518 int line_length,
int options);
2533 int line_length,
int options);
2548 int line_length,
int options);
2563 int lys_print_clb(ssize_t (*writeclb)(
void *arg,
const void *buf,
size_t count),
void *arg,
2564 const struct lys_module *module,
LYS_OUTFORMAT format,
const char *target_node,
int line_length,
int options);
LYS_OUTFORMAT
Schema output formats accepted by libyang printer functions.
struct lys_type_info_bits bits
LYS_INFORMAT
Schema input formats accepted by libyang parser functions.
#define _PACKED
Compiler flag for packed data types.
uint8_t has_union_leafref
struct lys_type_bit * bit
Container for information about enumeration types (LY_TYPE_ENUM), used in lys_type_info.
YANG type structure providing information from the schema.
int lys_features_disable(const struct lys_module *module, const char *feature)
Disable specified feature in the module.
lys_deviate_type
Possible deviation modifications, see RFC 6020 sec. 7.18.3.2
struct lys_module * belongsto
YANG deviate statement structure, see RFC 6020 sec. 7.18.3.2
struct lys_deviate * deviate
YANG validity restriction (must, length, etc.) structure providing information from the schema.
Complex extension instance structure.
struct lys_unique * unique
struct lys_module * module
struct lys_ext_instance ** ext
YANG deviation statement structure, see RFC 6020 sec. 7.18.3
Schema rpc/action node structure.
LY_DATA_TYPE _PACKED base
int lys_set_implemented(const struct lys_module *module)
Mark imported module as "implemented".
const char *const * ly_get_loaded_plugins(void)
Get list of all the loaded plugins, both extension and user type ones.
void ly_load_plugins(void)
Load the available YANG extension and type plugins from the plugin directory (LIBDIR/libyang/).
Main schema node structure representing YANG module.
enum lys_nodetype LYS_NODE
YANG schema node types.
struct lys_type_info_union uni
Single bit value specification for lys_type_info_bits.
YANG include structure used to reference submodules.
YANG when restriction, see RFC 6020 sec. 7.19.5
lyxp_node_type
Types of context nodes, LYXP_NODE_ROOT_CONFIG used only in when or must conditions.
Container for information about bits types (LY_TYPE_BINARY), used in lys_type_info.
Description of the extension instance substatement.
int ly_register_types(struct lytype_plugin_list *plugin, const char *log_name)
Directly register a YANG type by pointer.
struct lys_module * lys_node_module(const struct lys_node *node)
Return main module of the schema tree node.
int lys_iffeature_value(const struct lys_iffeature *iff)
Learn how the if-feature statement currently evaluates.
struct lys_restr * length
void * lys_set_private(const struct lys_node *node, void *priv)
Set a schema private pointer to a user pointer.
int lys_features_state(const struct lys_module *module, const char *feature)
Get the current status of the specified feature in the module.
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...
YANG list's unique statement structure, see RFC 6020 sec. 7.8.3
Schema case node structure.
YANG revision statement for (sub)modules.
struct lys_ext_instance ** ext
struct lys_iffeature * iffeature
Container for list modifications in lys_refine_mod.
const struct lys_module * lys_parse_mem(struct ly_ctx *ctx, const char *data, LYS_INFORMAT format)
Load a schema into the specified context.
Union to hold target modification in lys_refine.
const void * lys_ext_instance_substmt(const struct lys_ext_instance *ext)
Get address of the substatement structure to which the extension instance refers.
struct lys_node * lys_parent(const struct lys_node *node)
Return parent node in the schema tree.
Schema leaf node structure.
Schema uses node structure.
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_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...
Single enumeration value specification for lys_type_info_enums.
struct lyext_plugin * plugin
struct lys_submodule * submodule
LYS_VERSION
supported YANG schema version values
struct lys_type_info_enums enums
struct lys_type_info_lref lref
struct lys_type_info_dec64 dec64
YANG augment structure (covering both possibilities - uses's substatement as well as (sub)module's su...
struct lys_deviation * deviation
struct lys_ext * extensions
Structure to hold a set of (not necessary somehow connected) lyd_node or lys_node objects....
Schema container node structure.
Schema grouping node structure.
struct lys_type_enum * enm
struct lys_module * module
struct lys_revision * rev
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).
struct lys_type_info_inst inst
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.
struct lys_node_augment * augment
LY_STMT
List of YANG statements.
YANG feature definition structure.
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.
YANG typedef structure providing information from the schema.
Container for information about identity types (LY_TYPE_IDENT), used in lys_type_info.
struct lys_feature ** features
int lys_set_enabled(const struct lys_module *module)
Enable previously disabled module.
LY_DATA_TYPE
YANG built-in types.
Structure to hold information about identity, see RFC 6020 sec. 7.16
Schema choice node structure.
Submodule schema node structure that can be included into a YANG module.
enum lys_deviate_type LYS_DEVIATE_TYPE
Possible deviation modifications, see RFC 6020 sec. 7.18.3.2
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.
Common structure representing single YANG data statement describing.
Container for information about leafref types (LY_TYPE_LEAFREF), used in lys_type_info.
struct ly_set * backlinks
YANG import structure used to reference other schemas (modules).
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.
struct lys_restr * patterns
struct lys_refine_mod_list list
Container for information about decimal64 types (LY_TYPE_DEC64), used in lys_type_info.
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.
YANG extension definition.
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.
YANG uses's refine substatement structure, see RFC 6020 sec. 7.12.2
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.
Schema anydata (and anyxml) node structure.
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...
Container for information about integer types, used in lys_type_info.
struct lys_node_grp * grp
struct lys_type_info_num num
Container for information about union types (LY_TYPE_UNION), used in lys_type_info.
struct lys_type_info_str str
struct lys_node * orig_node
struct lys_type_info_ident ident
int ly_clean_plugins(void)
Unload all the YANG extension and type plugins.
struct lys_module * lys_implemented_module(const struct lys_module *mod)
Find the implemented revision of the given module in the context.
Compiled if-feature expression structure.
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 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.
struct lyext_substmt * substmt
Schema leaf-list node structure.
struct lys_node_leaf * target
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.
Generic extension instance structure.
Container for information about string types (LY_TYPE_STRING), used in lys_type_info.
struct lys_node_leaf ** keys
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.
Union for holding type-specific information in lys_type.
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_type_info_binary binary
struct ly_set * depfeatures
Container for information about instance-identifier types (LY_TYPE_INST), used in lys_type_info.
Schema notification node structure.
struct lys_refine * refine
struct lys_module * lys_main_module(const struct lys_module *module)
Return main module of the module.
LYEXT_TYPE
Extension types.
int lys_features_enable(const struct lys_module *module, const char *feature)
Enable specified feature in the module.
struct lys_feature * features
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....
RPC input and output node structure.
Schema list node structure.