Loading...
Searching...
No Matches
Plugins: Extensions compilation support
Plugins: Extensions
Collaboration diagram for Plugins: Extensions compilation support:

## Topics

| Schema compile flags

## 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).

## Functions

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.
LIBYANG_API_DECL struct ly_ctx * | lyplg_ext_compile_get_ctx (const struct lysc_ctx *ctx)
| YANG schema compilation context getter for libyang context.
LIBYANG_API_DECL const 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 uint32_t * | lyplg_ext_compile_get_options (const struct lysc_ctx *ctx)
| YANG schema compilation context getter for compilation options.
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.
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.
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.
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.

## Detailed Description

Implementing extension plugin compile callback.

## Typedef Documentation

## lyplg_ext_compile_clb

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).

The parsed generic statements can be processed by the callback on its own or the lyplg_ext_compile_extension_instance() function can be used to let the compilation to libyang following the standard rules for processing the YANG statements.

Parameters

  [in] | cctx | Current compile context.
  [in] | extp | Parsed extension instance data.
  [in,out] | ext | Prepared compiled extension instance structure where an addition, extension-specific, data are supposed to be placed for later use (data validation or use of external tool).

Returns
  LY_SUCCESS in case of success.
  LY_ENOT in case the extension instance is not supported and should be removed.
  LY_ERR error on error.

Definition at line 570 of file plugins_exts.h.

## Function Documentation

## lyplg_ext_compile_extension_instance()

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.

Uses standard libyang schema compiler to transform YANG statements into the compiled schema structures. The plugins are supposed to use this function when the extension instance's substatements are supposed to be compiled in a standard way (or if just the Schema compile flags are enough to modify the compilation process).

Parameters

  [in] | ctx | Compile context.
  [in] | extp | Parsed representation of the extension instance being processed.
  [in,out] | ext | Compiled extension instance with the prepared lysc_ext_instance.substmts array, which will be updated by storing the compiled data.

Returns
  LY_SUCCESS on success.
  LY_EVALID if compilation of the substatements fails.
  LY_ENOT if the extension is disabled (by if-feature) and should be ignored.

## lyplg_ext_compile_get_ctx()

LIBYANG_API_DECL struct ly_ctx * lyplg_ext_compile_get_ctx | ( | const struct lysc_ctx * | ctx | ) |

YANG schema compilation context getter for libyang context.

Parameters

  [in] | ctx | YANG schema compilation context.

Returns
  libyang context connected with the compilation context.

## lyplg_ext_compile_get_cur_mod()

LIBYANG_API_DECL const struct lys_module * lyplg_ext_compile_get_cur_mod | ( | const struct lysc_ctx * | ctx | ) |

YANG schema compilation context getter for current module.

Parameters

  [in] | ctx | YANG schema compilation context.

Returns
  current module.

## lyplg_ext_compile_get_options()

LIBYANG_API_DECL uint32_t * lyplg_ext_compile_get_options | ( | const struct lysc_ctx * | ctx | ) |

YANG schema compilation context getter for compilation options.

Parameters

  [in] | ctx | YANG schema compilation context.

Returns
  pointer to the compilation options to allow modifying them with Schema compile flags values.

## lyplg_ext_compile_get_pmod()

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.

Parameters

  [in] | ctx | YANG schema compilation context.

Returns
  Currently processed module.

## lyplg_ext_compile_log()

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.

Parameters

  [in] | cctx | Optional compile context to generate the path from.
  [in] | ext | Compiled extension instance.
  [in] | level | Log message level (error, warning, etc.)
  [in] | err | Error type code.
  [in] | format | Format string to print.

## lyplg_ext_compile_log_err()

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.

Parameters

  [in] | eitem | Error item to log.
  [in] | ext | Compiled extension instance.

## lyplg_ext_compile_log_path()

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.

Parameters

  [in] | path | Log error schema path to use.
  [in] | ext | Compiled extension instance.
  [in] | level | Log message level (error, warning, etc.)
  [in] | err | Error type code.
  [in] | format | Format string to print.