16 #ifndef LY_PLUGINS_EXTS_H_
17 #define LY_PLUGINS_EXTS_H_
33 struct lyspr_tree_ctx;
112 #define LYPLG_EXT_API_VERSION 8
119 #define LY_STMT_OP_MASK (LY_STMT_ACTION | LY_STMT_RPC)
126 #define LY_STMT_DATA_NODE_MASK (LY_STMT_ANYDATA | LY_STMT_ANYXML | LY_STMT_CASE | LY_STMT_CHOICE | LY_STMT_CONTAINER |\
127 LY_STMT_LEAF | LY_STMT_LEAF_LIST | LY_STMT_LIST)
135 #define LY_STMT_NODE_MASK 0xFFFF
460 #define LYPLG_EXTENSIONS \
461 uint32_t plugins_extensions_apiver__ = LYPLG_EXT_API_VERSION; \
462 const struct lyplg_ext_record plugins_extensions__[]
538 #define LYS_COMPILE_GROUPING 0x01
543 #define LYS_COMPILE_DISABLED 0x02
546 #define LYS_COMPILE_NO_CONFIG 0x04
547 #define LYS_COMPILE_NO_DISABLED 0x08
549 #define LYS_COMPILE_RPC_INPUT (LYS_IS_INPUT | LYS_COMPILE_NO_CONFIG)
550 #define LYS_COMPILE_RPC_OUTPUT (LYS_IS_OUTPUT | LYS_COMPILE_NO_CONFIG)
551 #define LYS_COMPILE_NOTIFICATION (LYS_IS_NOTIF | LYS_COMPILE_NO_CONFIG)
570 typedef LY_ERR (*lyplg_ext_compile_clb)(struct lysc_ctx *cctx, const struct lysp_ext_instance *extp,
744 const char **flags,
const char **add_opts);
759 ly_bool *skip,
const char **
flags,
const char **add_opts);
792 void (*free_clb)(
void *plugin_priv));
798 const char **flags,
const char **add_opts);
804 ly_bool *skip,
const char **
flags,
const char **add_opts);
862 const char *
name,
size_t name_len,
const struct lysc_node **snode);
995 const void **storage);
1009 uint32_t storage_size,
const void **storage);
LIBYANG_API_DECL LY_ERR lyplg_ext_sprinter_tree_set_priv(const struct lyspr_tree_ctx *ctx, void *plugin_priv, void(*free_clb)(void *plugin_priv))
Registration of plugin-private data defined by the plugin that is shared between override_clb calls...
Printer output structure specifying where the data are printed.
LIBYANG_API_DECL void lyplg_ext_pfree_instance_substatements(const struct ly_ctx *ctx, struct lysp_ext_substmt *substmts)
Free the extension instance's data parsed with lyplg_ext_parse_extension_instance().
LY_ERR(* lyplg_ext_data_node_clb)(struct lysc_ext_instance *ext, struct lyd_node *node, uint32_t validate_options)
Callback called for all data nodes connected to the extension instance.
LY_ERR(* lyplg_ext_sprinter_info_clb)(struct lyspr_ctx *ctx, struct lysc_ext_instance *ext, ly_bool *flag)
Callback to print the compiled extension instance's private data in the INFO format.
LIBYANG_API_DECL LY_ERR lyplg_ext_sprinter_ctree_add_nodes(const struct lyspr_tree_ctx *ctx, struct lysc_node *nodes, lyplg_ext_sprinter_ctree_override_clb clb)
Registration of printing the group of nodes which were defined in the plugin.
lyplg_ext_sprinter_info_clb printer_info
LIBYANG_API_DECL struct lysp_module * lyplg_ext_compile_get_pmod(const struct lysc_ctx *ctx)
YANG schema compilation context getter for currently processed module.
LY_ERR(* lyplg_ext_sprinter_ctree_override_clb)(const struct lysc_node *node, const void *plugin_priv, ly_bool *skip, const char **flags, const char **add_opts)
Callback for rewriting the tree-diagram form of a specific node.
Extension plugin implementing various aspects of a YANG extension.
Generic structure for a data node.
Structure representing a compiled known YANG substatement in an extension instance.
LIBYANG_API_DECL struct ly_ctx * lyplg_ext_compile_get_ctx(const struct lysc_ctx *ctx)
YANG schema compilation context getter for libyang context.
YANG extension compiled instance.
LIBYANG_API_DECL LY_ERR lyplg_ext_sprinter_ptree_add_ext_nodes(const struct lyspr_tree_ctx *ctx, struct lysp_ext_instance *ext, lyplg_ext_sprinter_ptree_override_clb clb)
Registration of printing a group of nodes, which is already in the extension.
void(* lyplg_ext_parse_free_clb)(const struct ly_ctx *ctx, struct lysp_ext_instance *ext)
Callback to free the extension-specific data created by its parsing.
LY_ERR(* lyplg_ext_sprinter_ptree_override_clb)(const struct lysp_node *node, const void *plugin_priv, ly_bool *skip, const char **flags, const char **add_opts)
Callback for rewriting the tree-diagram form of a specific node.
uint64_t parent_stmt_index
lyplg_ext_parse_clb parse
uint8_t ly_bool
Type to indicate boolean value.
Compiled YANG extension-stmt.
struct lysp_ext_instance * exts
ly_stmt
List of YANG statements.
Structure representing a parsed known YANG substatement in an extension instance. ...
struct lysp_ext_substmt * substmts
LY_ERR(* lyplg_ext_parse_clb)(struct lysp_ctx *pctx, struct lysp_ext_instance *ext)
Callback for parsing extension instance substatements.
LIBYANG_API_DECL LY_ERR lyplg_ext_parse_extension_instance(struct lysp_ctx *pctx, struct lysp_ext_instance *ext)
Parse substatements of an extension instance.
libyang representation of YANG schema trees.
struct lysc_ext_instance * exts
lyplg_ext_sprinter_ptree_clb printer_ptree
uint64_t parent_stmt_index
LIBYANG_API_DECL struct lys_module * lyplg_ext_compile_get_cur_mod(const struct lysc_ctx *ctx)
YANG schema compilation context getter for current module.
LIBYANG_API_DECL uint16_t * lyplg_ext_print_get_level(const struct lyspr_ctx *ctx)
YANG printer context getter for printer indentation level.
LIBYANG_API_DECL void lyplg_ext_compile_log(const struct lysc_ctx *cctx, const struct lysc_ext_instance *ext, LY_LOG_LEVEL level, LY_ERR err, const char *format,...)
Log a message from an extension plugin using the compiled extension instance.
struct lysc_ext_substmt * substmts
lyplg_ext_data_validate_clb validate
LIBYANG_API_DECL LY_ERR lyplg_ext_get_storage(const struct lysc_ext_instance *ext, int stmt, uint32_t storage_size, const void **storage)
Get compiled ext instance storage for a specific statement.
LY_ERR(* lyplg_ext_data_validate_clb)(struct lysc_ext_instance *ext, struct lyd_node *sibling, const struct lyd_node *dep_tree, enum lyd_type data_type, uint32_t val_opts, struct lyd_node **diff)
Callback for validating parsed YANG instance data described by an extension instance.
struct lyd_node_inner * parent
LIBYANG_API_DECL void lyplg_ext_print_info_extension_instance(struct lyspr_ctx *ctx, const struct lysc_ext_instance *ext, ly_bool *flag)
Print substatements of an extension instance in info format (compiled YANG).
struct lyplg_ext_record * record
Data parsers for libyang.
LY_ERR(* lyplg_ext_compile_clb)(struct lysc_ctx *cctx, const struct lysp_ext_instance *extp, struct lysc_ext_instance *ext)
Callback to compile extension from the lysp_ext_instance to the lysc_ext_instance. The later structure is generally prepared and only the extension specific data are supposed to be added (if any).
libyang representation of YANG data trees.
LIBYANG_API_DECL LY_ERR lyplg_ext_schema_mount_create_context(const struct lysc_ext_instance *ext, struct ly_ctx **ctx)
Allocate a new context for a particular instance of the yangmnt:mount-point extension. Caller is responsible for freeing the created context.
LIBYANG_API_DECL void lyplg_ext_parse_log(const struct lysp_ctx *pctx, const struct lysp_ext_instance *ext, LY_LOG_LEVEL level, LY_ERR err, const char *format,...)
Log a message from an extension plugin using the parsed extension instance.
LY_ERR(* lyplg_ext_sprinter_ptree_clb)(struct lysp_ext_instance *ext, const struct lyspr_tree_ctx *ctx, const char **flags, const char **add_opts)
Callback to print parent node of ext or to print the contents of the extension.
Parser input structure specifying where the data are read.
LY_ERR(* lyplg_ext_data_snode_clb)(struct lysc_ext_instance *ext, const struct lyd_node *parent, const struct lysc_node *sparent, const char *prefix, size_t prefix_len, LY_VALUE_FORMAT format, void *prefix_data, const char *name, size_t name_len, const struct lysc_node **snode)
Callback for getting a schema node for a new YANG instance data described by an extension instance...
LIBYANG_API_DECL LY_ERR lyplg_ext_insert(struct lyd_node *parent, struct lyd_node *first)
Insert extension instance data into a parent.
Libyang full error structure.
LY_LOG_LEVEL
Verbosity levels of the libyang logger.
lyplg_ext_compile_clb compile
LIBYANG_API_DECL enum ly_stmt lyplg_ext_nodetype2stmt(uint16_t nodetype)
Convert nodetype to statement identifier.
lyplg_ext_data_node_clb node
LIBYANG_API_DECL LY_ERR lyplg_ext_compile_extension_instance(struct lysc_ctx *ctx, const struct lysp_ext_instance *extp, struct lysc_ext_instance *ext)
Compile substatements of an extension instance.
LY_ERR(* lyplg_ext_sprinter_ctree_clb)(struct lysc_ext_instance *ext, const struct lyspr_tree_ctx *ctx, const char **flags, const char **add_opts)
Callback to print parent node of ext or to print the contents of the extension.
LIBYANG_API_DECL LY_ERR lyplg_ext_schema_mount_get_parent_ref(const struct lysc_ext_instance *ext, struct ly_set **refs)
Expand parent-reference xpath expressions.
struct lys_module * module
LIBYANG_API_DECL LY_ERR lyplg_ext_parsed_get_storage(const struct lysc_ext_instance *ext, int stmt, uint32_t storage_size, const void **storage)
Get parsed ext instance storage for a specific statement.
LIBYANG_API_DECL void lyplg_ext_cfree_instance_substatements(const struct ly_ctx *ctx, struct lysc_ext_substmt *substmts)
Free the extension instance's data compiled with lyplg_ext_compile_extension_instance().
lyplg_ext_compile_free_clb cfree
LIBYANG_API_DECL LY_ERR lyplg_ext_sprinter_ptree_add_nodes(const struct lyspr_tree_ctx *ctx, struct lysp_node *nodes, lyplg_ext_sprinter_ptree_override_clb clb)
Registration of printing the group of nodes which were defined in the plugin.
Structure to hold a set of (not necessary somehow connected) objects. Usually used for lyd_node...
Printable YANG schema tree structure representing YANG module.
Available YANG schema tree structures representing YANG module.
LIBYANG_API_DECL struct ly_out ** lyplg_ext_print_get_out(const struct lyspr_ctx *ctx)
YANG printer context getter for output handler.
LIBYANG_API_DECL struct lysp_module * lyplg_ext_parse_get_cur_pmod(const struct lysp_ctx *pctx)
Get current parsed module from a parse context.
LIBYANG_API_DEF void lyplg_ext_compile_log_err(const struct ly_err_item *eitem, const struct lysc_ext_instance *ext)
Log a message from an extension plugin using the compiled extension instance and a generated error it...
LIBYANG_API_DECL uint32_t * lyplg_ext_print_get_options(const struct lyspr_ctx *ctx)
YANG printer context getter for printer options.
lyplg_ext_data_snode_clb snode
#define LY_ARRAY_COUNT_TYPE
Type (i.e. size) of the sized array's size counter.
libyang generic macros and functions to modify YANG schema or data trees. Intended for internal use a...
lyplg_ext_parse_free_clb pfree
void(* lyplg_ext_compile_free_clb)(const struct ly_ctx *ctx, struct lysc_ext_instance *ext)
Callback to free the extension-specific data created by its compilation.
LY_VALUE_FORMAT
All kinds of supported value formats and prefix mappings to modules.
LIBYANG_API_DECL LY_ERR lyplg_ext_get_data(const struct ly_ctx *ctx, const struct lysc_ext_instance *ext, void **ext_data, ly_bool *ext_data_free)
Get specific run-time extension instance data from a callback set by ly_ctx_set_ext_data_clb().
LIBYANG_API_DECL const char * lyplg_ext_stmt2str(enum ly_stmt stmt)
Stringify statement identifier.
Structure representing a generic parsed YANG substatement in an extension instance.
LIBYANG_API_DECL LY_ERR lyplg_ext_sprinter_ctree_add_ext_nodes(const struct lyspr_tree_ctx *ctx, struct lysc_ext_instance *ext, lyplg_ext_sprinter_ctree_override_clb clb)
Registration of printing a group of nodes, which is already in the extension.
LIBYANG_API_DECL uint32_t * lyplg_ext_compile_get_options(const struct lysc_ctx *ctx)
YANG schema compilation context getter for compilation options.
Logger manipulation routines and error definitions.
lyplg_ext_sprinter_ctree_clb printer_ctree
LY_ERR
libyang's error codes returned by the libyang functions.
LIBYANG_API_DECL void lyplg_ext_compile_log_path(const char *path, const struct lysc_ext_instance *ext, LY_LOG_LEVEL level, LY_ERR err, const char *format,...)
Log a message from an extension plugin using the compiled extension instance with an explicit error p...
YANG extension parsed instance.