15 #ifndef LY_TREE_SCHEMA_H_
16 #define LY_TREE_SCHEMA_H_
18 #define PCRE2_CODE_UNIT_WIDTH 8
183 #define LYSC_TREE_DFS_BEGIN(START, ELEM) \
184 { ly_bool LYSC_TREE_DFS_continue = 0; struct lysc_node *LYSC_TREE_DFS_next; \
185 for ((ELEM) = (LYSC_TREE_DFS_next) = (struct lysc_node *)(START); \
187 (ELEM) = (LYSC_TREE_DFS_next), LYSC_TREE_DFS_continue = 0)
202 #define LYSC_TREE_DFS_END(START, ELEM) \
204 if (LYSC_TREE_DFS_continue) { \
205 (LYSC_TREE_DFS_next) = NULL; \
207 (LYSC_TREE_DFS_next) = (struct lysc_node *)lysc_node_child(ELEM); \
209 if (!(LYSC_TREE_DFS_next)) { \
211 _LYSC_TREE_DFS_NEXT(START, ELEM, LYSC_TREE_DFS_next); \
213 while (!(LYSC_TREE_DFS_next)) { \
215 (ELEM) = (ELEM)->parent; \
216 _LYSC_TREE_DFS_NEXT(START, ELEM, LYSC_TREE_DFS_next); \
222 #define _LYSC_TREE_DFS_NEXT(START, ELEM, NEXT) \
223 if ((ELEM) == (struct lysc_node *)(START)) { \
227 (NEXT) = (ELEM)->next;
231 #define LY_REV_SIZE 11
238 #define LYS_UNKNOWN 0x0000
239 #define LYS_CONTAINER 0x0001
240 #define LYS_CHOICE 0x0002
241 #define LYS_LEAF 0x0004
242 #define LYS_LEAFLIST 0x0008
243 #define LYS_LIST 0x0010
244 #define LYS_ANYXML 0x0020
245 #define LYS_ANYDATA 0x0060
246 #define LYS_CASE 0x0080
248 #define LYS_RPC 0x0100
249 #define LYS_ACTION 0x0200
250 #define LYS_NOTIF 0x0400
252 #define LYS_USES 0x0800
253 #define LYS_INPUT 0x1000
254 #define LYS_OUTPUT 0x2000
255 #define LYS_GROUPING 0x4000
256 #define LYS_AUGMENT 0x8000
258 #define LYS_NODETYPE_MASK 0xffff
269 #define LY_STMT_IS_OP(STMT) (((STMT) == LY_STMT_ACTION) || ((STMT) == LY_STMT_RPC))
280 #define LY_STMT_IS_DATA_NODE(STMT) (((STMT) >= LY_STMT_ANYDATA) && ((STMT) <= LY_STMT_LIST))
292 #define LY_STMT_IS_NODE(STMT) (((STMT) >= LY_STMT_NOTIFICATION) && ((STMT) <= LY_STMT_LIST))
594 #define LYSP_RESTR_PATTERN_ACK 0x06
595 #define LYSP_RESTR_PATTERN_NACK 0x15
704 #define LYS_DEV_NOT_SUPPORTED 1
705 #define LYS_DEV_ADD 2
706 #define LYS_DEV_DELETE 3
707 #define LYS_DEV_REPLACE 4
885 #define LYS_CONFIG_W 0x01
886 #define LYS_CONFIG_R 0x02
887 #define LYS_CONFIG_MASK 0x03
888 #define LYS_STATUS_CURR 0x04
889 #define LYS_STATUS_DEPRC 0x08
890 #define LYS_STATUS_OBSLT 0x10
891 #define LYS_STATUS_MASK 0x1C
892 #define LYS_MAND_TRUE 0x20
897 #define LYS_MAND_FALSE 0x40
900 #define LYS_MAND_MASK 0x60
901 #define LYS_PRESENCE 0x80
904 #define LYS_UNIQUE 0x80
905 #define LYS_KEY 0x0100
906 #define LYS_KEYLESS 0x0200
907 #define LYS_DISABLED 0x0100
908 #define LYS_FENABLED 0x20
909 #define LYS_ORDBY_SYSTEM 0x80
911 #define LYS_ORDBY_USER 0x40
914 #define LYS_ORDBY_MASK 0x60
915 #define LYS_YINELEM_TRUE 0x80
916 #define LYS_YINELEM_FALSE 0x0100
917 #define LYS_YINELEM_MASK 0x0180
918 #define LYS_USED_GRP 0x0400
920 #define LYS_SET_VALUE 0x0200
921 #define LYS_SET_MIN 0x0200
922 #define LYS_SET_MAX 0x0400
924 #define LYS_SET_BASE 0x0001
925 #define LYS_SET_BIT 0x0002
926 #define LYS_SET_ENUM 0x0004
927 #define LYS_SET_FRDIGITS 0x0008
928 #define LYS_SET_LENGTH 0x0010
929 #define LYS_SET_PATH 0x0020
930 #define LYS_SET_PATTERN 0x0040
931 #define LYS_SET_RANGE 0x0080
932 #define LYS_SET_TYPE 0x0100
933 #define LYS_SET_REQINST 0x0200
934 #define LYS_SET_DFLT 0x0200
939 #define LYS_SET_UNITS 0x0400
940 #define LYS_SET_CONFIG 0x0800
942 #define LYS_SINGLEQUOTED 0x0100
943 #define LYS_DOUBLEQUOTED 0x0200
945 #define LYS_YIN_ATTR 0x0400
946 #define LYS_YIN_ARGUMENT 0x0800
948 #define LYS_INTERNAL 0x1000
950 #define LYS_IS_ENUM 0x0200
952 #define LYS_IS_INPUT 0x1000
954 #define LYS_IS_OUTPUT 0x2000
956 #define LYS_IS_NOTIF 0x4000
958 #define LYS_FLAGS_COMPILED_MASK 0xff
1385 #define LYSP_MODULE_NAME(PMOD) (PMOD->is_submod ? ((struct lysp_submodule *)PMOD)->name : ((struct lysp_module *)PMOD)->mod->name)
1479 #define LYS_IFF_NOT 0x00
1480 #define LYS_IFF_AND 0x01
1481 #define LYS_IFF_OR 0x02
1482 #define LYS_IFF_F 0x03
1645 #define LYS_NODE_HASH_COUNT 4
1980 #define lysc_is_userordered(lysc_node) \
1981 ((!lysc_node || !(lysc_node->nodetype & (LYS_LEAFLIST | LYS_LIST)) || !(lysc_node->flags & LYS_ORDBY_USER)) ? 0 : 1)
1989 #define lysc_is_key(lysc_node) \
1990 ((!lysc_node || (lysc_node->nodetype != LYS_LEAF) || !(lysc_node->flags & LYS_KEY)) ? 0 : 1)
1998 #define lysc_is_np_cont(lysc_node) \
1999 ((!lysc_node || (lysc_node->nodetype != LYS_CONTAINER) || (lysc_node->flags & LYS_PRESENCE)) ? 0 : 1)
2007 #define lysc_is_dup_inst_list(lysc_node) \
2008 ((lysc_node && (((lysc_node->nodetype == LYS_LIST) && (lysc_node->flags & LYS_KEYLESS)) || \
2009 ((lysc_node->nodetype == LYS_LEAFLIST) && !(lysc_node->flags & LYS_CONFIG_W)))) ? 1 : 0)
2022 #define lysc_data_parent(SCHEMA) lysc_data_node((SCHEMA) ? (SCHEMA)->parent : NULL)
2231 #define LYS_FIND_XP_SCHEMA 0x08
2232 #define LYS_FIND_XP_OUTPUT 0x10
2233 #define LYS_FIND_NO_MATCH_ERROR 0x40
2249 uint32_t options,
struct ly_set **set);
2264 const struct lyxp_expr *expr,
const struct lysc_prefix *prefixes, uint32_t options,
struct ly_set **set);
2278 uint32_t options,
struct ly_set **set);
2313 const char *path,
ly_bool output);
2381 #define LYS_MOD_LATEST_REV 0x01
2382 #define LYS_MOD_LATEST_SEARCHDIRS 0x02
2383 #define LYS_MOD_IMPORTED_REV 0x04
2386 #define LYS_MOD_LATEST_IMPCLB 0x08
2447 #define LYS_GETNEXT_WITHCHOICE 0x01
2448 #define LYS_GETNEXT_NOCHOICE 0x02
2449 #define LYS_GETNEXT_WITHCASE 0x04
2450 #define LYS_GETNEXT_INTONPCONT 0x08
2451 #define LYS_GETNEXT_OUTPUT 0x10
2468 const char *
name,
size_t name_len, uint16_t
nodetype, uint32_t options);
LY_ERR
libyang's error codes returned by the libyang functions.
Structure to hold a set of (not necessary somehow connected) objects. Usually used for lyd_node,...
Extension plugin implementing various aspects of a YANG extension.
Hold type-specific functions for various operations with the data values.
struct lysp_ext_instance * exts
struct lyplg_type * plugin
struct lysp_node_grp * groupings
struct lysp_restr * musts
struct lysp_tpdf * typedefs
struct lysp_ext_instance * exts
struct lysp_node_notif * notifs
struct lysp_tpdf * typedefs
struct lyd_value ** dflts
struct lysp_node_action * actions
struct lysc_ext_instance * exts
struct lysp_feature * features
struct lysc_node_action * rpcs
struct lysc_ext_instance * exts
uint64_t parent_stmt_index
struct lysp_restr * musts
struct lysc_node_action_inout output
struct lysp_restr * musts
struct lysc_range * range
struct lysp_include * includes
struct lysc_range * range
struct lysc_ext * compiled
struct lysp_node_grp * groupings
struct lysp_ext_instance * exts
struct lysp_revision * revs
struct lysp_qname * dflts
struct lys_module ** augmented_by
struct lyplg_type * plugin
struct lysp_node_notif * notifs
struct lysp_restr * range
struct lysp_qname * dflts
struct lysc_ext_instance * exts
struct lysp_deviate * next
struct lysc_node_action * actions
struct lysp_deviate * next
struct lysp_import * imports
struct lysp_ext_instance * exts
struct lys_module ** deviated_by
struct lysp_ext_instance * exts
struct lysp_node_notif * notifs
struct lyplg_type * plugin
struct lysc_node_notif * notifs
struct lysp_qname * uniques
enum ly_stmt_cardinality cardinality
struct lysc_node_notif * notifs
struct lysp_node_notif * notifs
struct lysc_ext_instance * exts
struct lysc_module * compiled
struct lys_module * module
struct lysp_tpdf * typedefs
struct lysp_restr * patterns
struct lysp_ext_instance * exts
struct lysp_tpdf * typedefs
struct lysc_ident * identities
struct lysc_ext_instance * exts
struct lysp_qname * iffeatures
struct lysp_node_action * actions
struct lysp_ext_instance * exts
struct lysp_node_augment * augments
struct lysp_node * parent
struct lysp_ext_instance * exts
struct lysp_node_action * rpcs
struct lysp_node_action * actions
struct lysp_node_grp * groupings
struct lysp_qname * iffeatures
struct lysp_node_grp * groupings
struct lysc_ext_instance * exts
struct lysp_feature ** depfeatures
struct lysc_type_bitenum_item * bits
struct lysp_ext * extensions
struct lyplg_type * plugin
struct lysp_ext_instance * exts
struct lysc_node * parent
struct lyplg_type * plugin
struct lys_module * module
const struct lys_module * cur_mod
struct lysp_type_enum * bits
struct lysc_pattern ** patterns
struct lysp_node_action_inout output
struct lysp_ident * identities
struct lysp_ext_instance * exts
struct lysp_ext_instance * exts
struct lysp_deviation * deviations
struct lysc_iffeature * iffeatures_c
const struct lysp_module * pmod
struct lysp_qname * uniques
struct lysp_ext_instance * exts
struct lysp_node_augment * augments
struct lysc_node_case * cases
struct lysp_restr * musts
struct lysp_ext_instance * exts
struct lysc_node_notif * notifs
struct lysc_ext_substmt * substmts
struct lysp_include * includes
struct lysp_deviate * deviates
struct lysc_ext_instance * exts
struct lyplg_type * plugin
struct lysc_node_action * actions
struct lysp_tpdf * typedefs
struct lysp_qname * uniques
struct lysc_range * length
struct lysp_restr * length
struct lysp_ext_instance * exts
struct lysp_restr * musts
struct lysp_restr * musts
struct lysp_ident * identities
struct lyplg_type * plugin
struct lysp_qname * dflts
struct lysc_ext_instance * exts
struct lysp_restr * musts
struct lysp_qname * iffeatures
struct lysp_ext_instance * exts
struct lysc_ext_instance * exts
struct lysp_revision * revs
struct lysp_node * parsed
struct lysc_type * compiled
struct lys_module * module
struct lysc_ext_instance * exts
struct lysc_node_leaf *** uniques
struct lysp_qname * iffeatures
struct lysp_submodule * submodule
struct lysp_ext_instance * exts
struct lysp_feature * features
struct lysp_qname * dflts
struct lysp_restr * musts
struct lysp_node_action * rpcs
struct lysp_ext_instance * exts
struct lysc_node_action_inout input
struct lysp_node_action * actions
struct lyplg_ext * plugin
struct lysp_deviation * deviations
struct lysc_ident ** derived
struct lysc_prefix * prefixes
struct lysc_ext_instance * exts
uint64_t parent_stmt_index
struct lysc_type_bitenum_item * enums
struct lysp_node_action_inout input
struct lysc_ext_instance * exts
struct lysp_tpdf * typedefs
struct lyplg_type * plugin
struct lysp_node_grp * groupings
struct lysc_range * length
struct lysc_prefix * prefixes
struct lysp_tpdf * typedefs
struct lyplg_type * plugin
struct lysp_node_augment * augments
struct lysp_tpdf * typedefs
struct lysc_ext_instance * exts
struct lysp_type_enum * enums
struct lysc_type * realtype
struct lysc_ext_instance * exts
struct lysp_node_grp * groupings
struct lysp_deviate * next
struct lysc_ext_instance * exts
struct lyplg_type * plugin
struct lysp_module * parsed
struct lysc_ext_instance * exts
struct lyplg_type * plugin
struct lysp_node_notif * notifs
struct lysc_ext_instance * exts
struct lysp_qname * iffeatures
struct lysc_node_case * dflt
struct lysc_ext_instance * exts
struct lys_module * module
struct lysc_type ** types
struct lysc_ext_instance * exts
struct lysc_ext_instance * exts
struct lys_module * module
struct lysp_ext * extensions
struct lysp_node_notif * notifs
struct lysc_node * context
struct lysp_ext_instance * exts
struct lysc_ext_instance * exts
struct lysc_ext_instance * exts
struct lysp_restr * musts
struct lysp_import * imports
struct lysp_ext_instance * exts
const struct lysp_module * mod
struct lysp_restr * musts
struct lysc_ident ** bases
struct lysp_feature ** features
struct lysp_ext_instance * exts
struct lysc_range::lysc_range_part * parts
struct lysc_prefix * prefixes
struct lysp_node_grp * groupings
struct lysp_deviate * next
const struct lys_module * mod
struct lysp_node_grp * groupings
struct lysp_refine * refines
LIBYANG_API_DECL const struct lysp_tpdf * lysp_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 i...
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.
LIBYANG_API_DECL enum ly_stmt lys_nodetype2stmt(uint16_t nodetype)
Convert nodetype to statement identifier.
LIBYANG_API_DECL const struct lysc_node * lysc_node_child(const struct lysc_node *node)
Get the children linked list of the given (compiled) schema node.
LIBYANG_API_DECL struct lysc_must * lysc_node_musts(const struct lysc_node *node)
Get the must statements list if present in the node.
LIBYANG_API_DECL const struct lysc_node * lys_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 i...
LIBYANG_API_DECL const struct lysc_node * lysc_data_node(const struct lysc_node *schema)
Get nearest schema parent (including the node itself) that can be instantiated in data.
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.
LIBYANG_API_DECL LY_ERR lysc_iffeature_value(const struct lysc_iffeature *iff)
Get how the if-feature statement currently evaluates.
LIBYANG_API_DECL const 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...
LIBYANG_API_DECL const 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 ca...
LIBYANG_API_DECL const struct lysc_node * lys_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).
LIBYANG_API_DECL LY_ERR lysc_ext_substmt(const struct lysc_ext_instance *ext, enum ly_stmt substmt, void **instance_p, enum ly_stmt_cardinality *cardinality_p)
Get pointer to the storage of the specified substatement in the given extension instance.
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).
LIBYANG_API_DECL const char * ly_stmt2str(enum ly_stmt stmt)
Stringify statement identifier.
LIBYANG_API_DECL const struct lysc_when * lysc_has_when(const struct lysc_node *node)
Check whether the schema node data instance existence depends on any when conditions....
LIBYANG_API_DECL const struct lysc_node * lys_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....
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).
ly_stmt
List of YANG statements.
LIBYANG_API_DECL const char * lyxp_get_expr(const struct lyxp_expr *path)
Getter for original XPath expression from a parsed expression.
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.
LIBYANG_API_DECL const struct lysp_node * lysp_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 i...
LIBYANG_API_DECL const struct lysc_node * lys_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.
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.
LIBYANG_API_DECL struct lysc_when ** lysc_node_when(const struct lysc_node *node)
Get the when statements list if present in the node.
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).
LIBYANG_API_DECL LY_ERR lys_set_implemented(struct lys_module *mod, const char **features)
Make the specific module implemented.
ly_stmt_cardinality
Possible cardinalities of the YANG statements.
LIBYANG_API_DECL const 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 ...
LYSC_PATH_TYPE
Types of the different schema paths.
#define LYS_NODE_HASH_COUNT
Maximum number of hashes stored in a schema node.
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.
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).
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.
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.
LIBYANG_API_DECL const 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 ...
LIBYANG_API_DECL const char * lys_nodetype2str(uint16_t nodetype)
Stringify schema nodetype.
LIBYANG_API_DECL const 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,...
LYS_VERSION
supported YANG schema version values
LIBYANG_API_DECL const 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 c...
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.
@ LY_STMT_SYNTAX_LEFT_BRACE
@ LY_STMT_REQUIRE_INSTANCE
@ LY_STMT_SYNTAX_RIGHT_BRACE
@ LY_STMT_SYNTAX_SEMICOLON
@ LY_STMT_EXTENSION_INSTANCE
@ LY_STMT_FRACTION_DIGITS
Available YANG schema tree structures representing YANG module.
Compiled YANG extension-stmt.
Description of the extension instance substatements.
Compiled YANG if-feature-stmt.
Compiled YANG schema tree structure representing YANG module.
Compiled prefix data pair mapping of prefixes to modules. In case the format is LY_VALUE_SCHEMA_RESOL...
Compiled YANG revision statement.
Generic deviate structure to get type and cast to lysp_deviate_* structure.
Printable YANG schema tree structure representing YANG module.
YANG rpc-stmt and action-stmt.
YANG input-stmt and output-stmt.
YANG uses-augment-stmt and augment-stmt (compatible with struct lysp_node )
Extension structure of the lysp_node for YANG container.
Qualified name (optional prefix followed by an identifier).
Covers restrictions: range, length, pattern, must.
Helper structure for generic storage of the extension instances content.
Enumeration/Bit value definition.
LY_DATA_TYPE
YANG built-in types.
LY_VALUE_FORMAT
All kinds of supported value formats and prefix mappings to modules.
#define LY_ARRAY_COUNT_TYPE
Type (i.e. size) of the sized array's size counter.
Logger manipulation routines and error definitions.
uint8_t ly_bool
Type to indicate boolean value.
libyang generic macros and functions to work with YANG schema or data trees.
YANG data representation.