libyang  3.6.0
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
plugins_exts.h File Reference

libyang support for YANG extensions implementation. More...

#include "log.h"
#include "parser_data.h"
#include "plugins.h"
#include "tree_data.h"
#include "tree_edit.h"
#include "tree_schema.h"
Include dependency graph for plugins_exts.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lyplg_ext
 Extension plugin implementing various aspects of a YANG extension. More...
 
struct  lyplg_ext_record
 
struct  lysc_ext_instance
 YANG extension compiled instance. More...
 
struct  lysc_ext_substmt
 Structure representing a compiled known YANG substatement in an extension instance. More...
 
struct  lysp_ext_instance
 YANG extension parsed instance. More...
 
struct  lysp_ext_substmt
 Structure representing a parsed known YANG substatement in an extension instance. More...
 
struct  lysp_stmt
 Structure representing a generic parsed YANG substatement in an extension instance. More...
 

Macros

#define LY_STMT_DATA_NODE_MASK
 Mask for a data node statement. More...
 
#define LY_STMT_NODE_MASK   0xFFFF
 Mask for a node statement. More...
 
#define LY_STMT_OP_MASK   (LY_STMT_ACTION | LY_STMT_RPC)
 Mask for an operation statement. More...
 
#define LYPLG_EXT_API_VERSION   8
 Extensions API version. More...
 
#define LYPLG_EXTENSIONS
 Macro to define plugin information in external plugins. More...
 
#define LYS_COMPILE_DISABLED   0x02
 
#define LYS_COMPILE_GROUPING   0x01
 
#define LYS_COMPILE_NO_CONFIG   0x04
 
#define LYS_COMPILE_NO_DISABLED   0x08
 
#define LYS_COMPILE_NOTIFICATION   (LYS_IS_NOTIF | LYS_COMPILE_NO_CONFIG)
 
#define LYS_COMPILE_RPC_INPUT   (LYS_IS_INPUT | LYS_COMPILE_NO_CONFIG)
 
#define LYS_COMPILE_RPC_OUTPUT   (LYS_IS_OUTPUT | LYS_COMPILE_NO_CONFIG)
 

Typedefs

typedef 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). More...
 
typedef 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. More...
 
typedef 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. More...
 
typedef 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. Needed only if the extension instance supports some nested standard YANG data. More...
 
typedef 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. More...
 
typedef LY_ERR(* lyplg_ext_parse_clb )(struct lysp_ctx *pctx, struct lysp_ext_instance *ext)
 Callback for parsing extension instance substatements. More...
 
typedef 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. More...
 
typedef 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. More...
 
typedef 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. More...
 
typedef 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. More...
 
typedef 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. More...
 
typedef 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. More...
 

Enumerations

enum  ly_stmt {
  LY_STMT_NONE = 0, LY_STMT_NOTIFICATION = 0x0001, LY_STMT_INPUT = 0x0002, LY_STMT_OUTPUT = 0x0004,
  LY_STMT_ACTION = 0x0008, LY_STMT_RPC = 0x0010, LY_STMT_ANYDATA = 0x0020, LY_STMT_ANYXML = 0x0040,
  LY_STMT_AUGMENT = 0x0080, LY_STMT_CASE = 0x0100, LY_STMT_CHOICE = 0x0200, LY_STMT_CONTAINER = 0x0400,
  LY_STMT_GROUPING = 0x0800, LY_STMT_LEAF = 0x1000, LY_STMT_LEAF_LIST = 0x2000, LY_STMT_LIST = 0x4000,
  LY_STMT_USES = 0x8000, LY_STMT_ARGUMENT = 0x10000, LY_STMT_BASE = 0x20000, LY_STMT_BELONGS_TO = 0x30000,
  LY_STMT_BIT = 0x40000, LY_STMT_CONFIG = 0x50000, LY_STMT_CONTACT = 0x60000, LY_STMT_DEFAULT = 0x70000,
  LY_STMT_DESCRIPTION = 0x80000, LY_STMT_DEVIATE = 0x90000, LY_STMT_DEVIATION = 0xA0000, LY_STMT_ENUM = 0xB0000,
  LY_STMT_ERROR_APP_TAG = 0xC0000, LY_STMT_ERROR_MESSAGE = 0xD0000, LY_STMT_EXTENSION = 0xE0000, LY_STMT_EXTENSION_INSTANCE = 0xF0000,
  LY_STMT_FEATURE = 0x100000, LY_STMT_FRACTION_DIGITS = 0x110000, LY_STMT_IDENTITY = 0x120000, LY_STMT_IF_FEATURE = 0x130000,
  LY_STMT_IMPORT = 0x140000, LY_STMT_INCLUDE = 0x150000, LY_STMT_KEY = 0x160000, LY_STMT_LENGTH = 0x170000,
  LY_STMT_MANDATORY = 0x180000, LY_STMT_MAX_ELEMENTS = 0x190000, LY_STMT_MIN_ELEMENTS = 0x1A0000, LY_STMT_MODIFIER = 0x1B0000,
  LY_STMT_MODULE = 0x1C0000, LY_STMT_MUST = 0x1D0000, LY_STMT_NAMESPACE = 0x1E0000, LY_STMT_ORDERED_BY = 0x1F0000,
  LY_STMT_ORGANIZATION = 0x200000, LY_STMT_PATH = 0x210000, LY_STMT_PATTERN = 0x220000, LY_STMT_POSITION = 0x230000,
  LY_STMT_PREFIX = 0x240000, LY_STMT_PRESENCE = 0x250000, LY_STMT_RANGE = 0x260000, LY_STMT_REFERENCE = 0x270000,
  LY_STMT_REFINE = 0x280000, LY_STMT_REQUIRE_INSTANCE = 0x290000, LY_STMT_REVISION = 0x2A0000, LY_STMT_REVISION_DATE = 0x2B0000,
  LY_STMT_STATUS = 0x2C0000, LY_STMT_SUBMODULE = 0x2D0000, LY_STMT_TYPE = 0x2E0000, LY_STMT_TYPEDEF = 0x2F0000,
  LY_STMT_UNIQUE = 0x300000, LY_STMT_UNITS = 0x310000, LY_STMT_VALUE = 0x320000, LY_STMT_WHEN = 0x330000,
  LY_STMT_YANG_VERSION = 0x340000, LY_STMT_YIN_ELEMENT = 0x350000, LY_STMT_SYNTAX_SEMICOLON, LY_STMT_SYNTAX_LEFT_BRACE,
  LY_STMT_SYNTAX_RIGHT_BRACE, LY_STMT_ARG_TEXT, LY_STMT_ARG_VALUE
}
 List of YANG statements. More...
 

Functions

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(). More...
 
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. More...
 
LIBYANG_API_DECL struct ly_ctxlyplg_ext_compile_get_ctx (const struct lysc_ctx *ctx)
 YANG schema compilation context getter for libyang context. More...
 
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. More...
 
LIBYANG_API_DECL uint32_t * lyplg_ext_compile_get_options (const struct lysc_ctx *ctx)
 YANG schema compilation context getter for compilation options. More...
 
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. More...
 
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. More...
 
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 item. More...
 
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 path. More...
 
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(). More...
 
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. More...
 
LIBYANG_API_DECL LY_ERR lyplg_ext_insert (struct lyd_node *parent, struct lyd_node *first)
 Insert extension instance data into a parent. More...
 
LIBYANG_API_DECL enum ly_stmt lyplg_ext_nodetype2stmt (uint16_t nodetype)
 Convert nodetype to statement identifier. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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(). More...
 
LIBYANG_API_DECL uint16_t * lyplg_ext_print_get_level (const struct lyspr_ctx *ctx)
 YANG printer context getter for printer indentation level. More...
 
LIBYANG_API_DECL uint32_t * lyplg_ext_print_get_options (const struct lyspr_ctx *ctx)
 YANG printer context getter for printer options. More...
 
LIBYANG_API_DECL struct ly_out ** lyplg_ext_print_get_out (const struct lyspr_ctx *ctx)
 YANG printer context getter for output handler. More...
 
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). More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
LIBYANG_API_DECL const char * lyplg_ext_stmt2str (enum ly_stmt stmt)
 Stringify statement identifier. More...
 

Detailed Description

libyang support for YANG extensions implementation.

Author
Radek Krejci rkrej.nosp@m.ci@c.nosp@m.esnet.nosp@m..cz
Michal Vasko mvask.nosp@m.o@ce.nosp@m.snet..nosp@m.cz Copyright (c) 2015 - 2022 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 plugins_exts.h.