libyang  2.0.164
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
Go to the documentation of this file.
1 
15 #ifndef LY_PLUGINS_EXTS_H_
16 #define LY_PLUGINS_EXTS_H_
17 
18 #include "log.h"
19 #include "plugins.h"
20 #include "tree_data.h"
21 #include "tree_edit.h"
22 #include "tree_schema.h"
23 
24 #include "plugins_exts_compile.h"
25 #include "plugins_exts_print.h"
26 
27 struct ly_ctx;
28 struct ly_in;
29 struct lyd_node;
30 struct lysc_ext_substmt;
31 struct lysp_ext_instance;
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
103 #define LYPLG_EXT_API_VERSION 2
104 
111 #define LYPLG_EXTENSIONS \
112  uint32_t plugins_extensions_apiver__ = LYPLG_EXT_API_VERSION; \
113  const struct lyplg_ext_record plugins_extensions__[]
114 
122 LIBYANG_API_DECL void lyplg_ext_instance_substatements_free(struct ly_ctx *ctx, struct lysc_ext_substmt *substmts);
123 
139 typedef LY_ERR (*lyplg_ext_compile_clb)(struct lysc_ctx *cctx, const struct lysp_ext_instance *p_ext,
140  struct lysc_ext_instance *c_ext);
141 
151 typedef LY_ERR (*lyplg_ext_schema_printer_clb)(struct lyspr_ctx *ctx, struct lysc_ext_instance *ext, ly_bool *flag);
152 
159 typedef void (*lyplg_ext_free_clb)(struct ly_ctx *ctx, struct lysc_ext_instance *ext);
160 
176 typedef LY_ERR (*lyplg_ext_data_parse_clb)(struct ly_in *in, LYD_FORMAT format, struct lysc_ext_instance *ext,
177  struct lyd_node *parent, uint32_t parse_opts);
178 
190 typedef LY_ERR (*lyplg_ext_data_validate_clb)(struct lysc_ext_instance *ext, struct lyd_node *sibling, uint32_t val_opts);
191 
195 struct lyplg_ext {
196  const char *id;
206 };
207 
209  /* plugin identification */
210  const char *module;
211  const char *revision;
216  const char *name;
218  /* runtime data */
219  struct lyplg_ext plugin;
220 };
221 
232 LIBYANG_API_DECL LY_ERR lyplg_ext_get_data(const struct ly_ctx *ctx, const struct lysc_ext_instance *ext, void **ext_data,
233  ly_bool *ext_data_free);
234 
243 LIBYANG_API_DECL LY_ERR lyd_insert_ext(struct lyd_node *parent, struct lyd_node *first);
244 
254 LIBYANG_API_DECL void lyplg_ext_log(const struct lysc_ext_instance *ext, LY_LOG_LEVEL level, LY_ERR err_no, const char *path,
255  const char *format, ...);
256 
259 #ifdef __cplusplus
260 }
261 #endif
262 
263 #endif /* LY_PLUGINS_EXTS_H_ */
YANG extension instance.
Definition: tree_schema.h:525
const char * module
Definition: plugins_exts.h:210
LIBYANG_API_DECL void lyplg_ext_log(const struct lysc_ext_instance *ext, LY_LOG_LEVEL level, LY_ERR err_no, const char *path, const char *format,...)
Provide a log message from an extension plugin.
const char * name
Definition: plugins_exts.h:216
const char * revision
Definition: plugins_exts.h:211
Extension plugin implementing various aspects of a YANG extension.
Definition: plugins_exts.h:195
Generic structure for a data node.
Definition: tree_data.h:786
lyplg_ext_schema_printer_clb sprinter
Definition: plugins_exts.h:199
YANG extension instance.
Definition: tree_schema.h:1445
uint8_t ly_bool
Type to indicate boolean value.
Definition: log.h:27
libyang representation of YANG schema trees.
LIBYANG_API_DECL void lyplg_ext_instance_substatements_free(struct ly_ctx *ctx, struct lysc_ext_substmt *substmts)
Free the extension instance's data compiled with lys_compile_extension_instance().
lyplg_ext_free_clb free
Definition: plugins_exts.h:201
lyplg_ext_data_validate_clb validate
Definition: plugins_exts.h:204
LY_ERR(* lyplg_ext_schema_printer_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.
Definition: plugins_exts.h:151
LY_ERR(* lyplg_ext_data_validate_clb)(struct lysc_ext_instance *ext, struct lyd_node *sibling, uint32_t val_opts)
Callback for validating parsed YANG instance data described by an extension instance.
Definition: plugins_exts.h:190
struct lyd_node_inner * parent
Definition: tree_data.h:793
LY_ERR(* lyplg_ext_compile_clb)(struct lysc_ctx *cctx, const struct lysp_ext_instance *p_ext, struct lysc_ext_instance *c_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).
Definition: plugins_exts.h:139
const char * id
Definition: plugins_exts.h:196
LY_ERR(* lyplg_ext_data_parse_clb)(struct ly_in *in, LYD_FORMAT format, struct lysc_ext_instance *ext, struct lyd_node *parent, uint32_t parse_opts)
Callback for parsing YANG instance data described by an extension instance.
Definition: plugins_exts.h:176
libyang representation of YANG data trees.
lyplg_ext_data_parse_clb parse
Definition: plugins_exts.h:203
Parser input structure specifying where the data are read.
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
Definition: tree_data.h:521
LIBYANG_API_DECL LY_ERR lyd_insert_ext(struct lyd_node *parent, struct lyd_node *first)
Insert extension instance data into a parent.
libyang support for YANG extensions implementation - schema print related items.
LY_LOG_LEVEL
Verbosity levels of the libyang logger.
Definition: log.h:87
struct lyplg_ext plugin
Definition: plugins_exts.h:219
lyplg_ext_compile_clb compile
Definition: plugins_exts.h:198
Description of the extension instance substatements.
Definition: tree_schema.h:1435
void(* lyplg_ext_free_clb)(struct ly_ctx *ctx, struct lysc_ext_instance *ext)
Callback to free the extension-specific data created by its compilation.
Definition: plugins_exts.h:159
libyang support for YANG extensions implementation - schema compilation related items.
libyang generic macros and functions to modify YANG schema or data trees. Intended for internal use a...
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().
Plugins manipulation.
LY_ERR
libyang's error codes returned by the libyang functions.
Definition: log.h:247
Logger manipulation routines and error definitions.
libyang context handler.