libyang  1.0.253
YANG data modeling language library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
YANG Extensions
Collaboration diagram for YANG Extensions:

Modules

 Extension flags
 

Data Structures

struct  lyext_substmt
 Description of the extension instance substatement. More...
 
struct  lys_ext
 YANG extension definition. More...
 
struct  lys_ext_instance
 Generic extension instance structure. More...
 
struct  lys_ext_instance_complex
 Complex extension instance structure. More...
 
struct  lyext_plugin
 
struct  lyext_plugin_complex
 
struct  lyext_plugin_list
 

Macros

#define LYEXT_API_VERSION   1
 Extensions API version. More...
 
#define LYEXT_VERSION_CHECK   int lyext_api_version = LYEXT_API_VERSION;
 Macro to store version of extension plugins API in the plugins. It is matched when the plugin is being loaded by libyang. More...
 
#define LYEXT_LOG(ctx, level, plugin, str, args...)   lyext_log(ctx, level, plugin, __func__, str, ##args); \
 Logging macro for extension plugins. More...
 
#define LYEXT_VLOG(ctx, vecode, plugin, elem_type, elem, str, args...)   lyext_vlog(ctx, vecode, plugin, __func__, elem_type, elem, str, ##args)
 Validation logging macro for extension plugins. More...
 

Typedefs

typedef int(* lyext_check_position_clb )(const void *parent, LYEXT_PAR parent_type, LYEXT_SUBSTMT substmt_type)
 Callback to check that the extension can be instantiated inside the provided node. More...
 
typedef int(* lyext_check_result_clb )(struct lys_ext_instance *ext)
 Callback to check that the extension instance is correct - have the valid argument, cardinality, etc. More...
 
typedef int(* lyext_check_inherit_clb )(struct lys_ext_instance *ext, struct lys_node *node)
 Callback to decide whether the extension will be inherited into the provided schema node. The extension instance is always from some of the node's parents. The inherited extension instances are marked with the LYEXT_OPT_INHERIT flag. More...
 
typedef int(* lyext_valid_data_clb )(struct lys_ext_instance *ext, struct lyd_node *node)
 Callback to decide if data is valid towards to schema. More...
 

Enumerations

enum  LY_STMT {
  LY_STMT_NODE = -1, LY_STMT_UNKNOWN = 0, LY_STMT_ARGUMENT = 1, LY_STMT_BASE,
  LY_STMT_BELONGSTO, LY_STMT_CONTACT, LY_STMT_DEFAULT, LY_STMT_DESCRIPTION,
  LY_STMT_ERRTAG, LY_STMT_ERRMSG, LY_STMT_KEY, LY_STMT_NAMESPACE,
  LY_STMT_ORGANIZATION, LY_STMT_PATH, LY_STMT_PREFIX, LY_STMT_PRESENCE,
  LY_STMT_REFERENCE, LY_STMT_REVISIONDATE, LY_STMT_UNITS, LY_STMT_VALUE,
  LY_STMT_VERSION, LY_STMT_MODIFIER, LY_STMT_REQINSTANCE, LY_STMT_YINELEM,
  LY_STMT_CONFIG, LY_STMT_MANDATORY, LY_STMT_ORDEREDBY, LY_STMT_STATUS,
  LY_STMT_DIGITS, LY_STMT_MAX, LY_STMT_MIN, LY_STMT_POSITION,
  LY_STMT_UNIQUE, LY_STMT_MODULE, LY_STMT_ACTION, LY_STMT_ANYDATA,
  LY_STMT_ANYXML, LY_STMT_CASE, LY_STMT_CHOICE, LY_STMT_CONTAINER,
  LY_STMT_GROUPING, LY_STMT_INPUT, LY_STMT_LEAF, LY_STMT_LEAFLIST,
  LY_STMT_LIST, LY_STMT_NOTIFICATION, LY_STMT_OUTPUT, LY_STMT_USES,
  LY_STMT_TYPEDEF, LY_STMT_TYPE, LY_STMT_IFFEATURE, LY_STMT_LENGTH,
  LY_STMT_MUST, LY_STMT_PATTERN, LY_STMT_RANGE, LY_STMT_WHEN,
  LY_STMT_REVISION, LY_STMT_SUBMODULE, LY_STMT_RPC, LY_STMT_BIT,
  LY_STMT_ENUM, LY_STMT_REFINE, LY_STMT_AUGMENT, LY_STMT_DEVIATE,
  LY_STMT_DEVIATION, LY_STMT_EXTENSION, LY_STMT_FEATURE, LY_STMT_IDENTITY,
  LY_STMT_IMPORT, LY_STMT_INCLUDE
}
 List of YANG statements. More...
 
enum  LY_STMT_CARD { LY_STMT_CARD_OPT, LY_STMT_CARD_MAND, LY_STMT_CARD_SOME, LY_STMT_CARD_ANY }
 Possible cardinalities of the YANG statements. More...
 
enum  LYEXT_TYPE { LYEXT_ERR = -1, LYEXT_FLAG = 0, LYEXT_COMPLEX }
 Extension types. More...
 
enum  LYEXT_PAR {
  LYEXT_PAR_MODULE, LYEXT_PAR_NODE, LYEXT_PAR_TPDF, LYEXT_PAR_TYPE,
  LYEXT_PAR_TYPE_BIT, LYEXT_PAR_TYPE_ENUM, LYEXT_PAR_FEATURE, LYEXT_PAR_RESTR,
  LYEXT_PAR_WHEN, LYEXT_PAR_IDENT, LYEXT_PAR_EXT, LYEXT_PAR_EXTINST,
  LYEXT_PAR_REFINE, LYEXT_PAR_DEVIATION, LYEXT_PAR_DEVIATE, LYEXT_PAR_IMPORT,
  LYEXT_PAR_INCLUDE, LYEXT_PAR_REVISION, LYEXT_PAR_IFFEATURE
}
 Extension instance structure parent enumeration. More...
 
enum  LYEXT_SUBSTMT {
  LYEXT_SUBSTMT_ALL = -1, LYEXT_SUBSTMT_SELF = 0, LYEXT_SUBSTMT_ARGUMENT, LYEXT_SUBSTMT_BASE,
  LYEXT_SUBSTMT_BELONGSTO, LYEXT_SUBSTMT_CONTACT, LYEXT_SUBSTMT_DEFAULT, LYEXT_SUBSTMT_DESCRIPTION,
  LYEXT_SUBSTMT_ERRTAG, LYEXT_SUBSTMT_ERRMSG, LYEXT_SUBSTMT_KEY, LYEXT_SUBSTMT_NAMESPACE,
  LYEXT_SUBSTMT_ORGANIZATION, LYEXT_SUBSTMT_PATH, LYEXT_SUBSTMT_PREFIX, LYEXT_SUBSTMT_PRESENCE,
  LYEXT_SUBSTMT_REFERENCE, LYEXT_SUBSTMT_REVISIONDATE, LYEXT_SUBSTMT_UNITS, LYEXT_SUBSTMT_VALUE,
  LYEXT_SUBSTMT_VERSION, LYEXT_SUBSTMT_MODIFIER, LYEXT_SUBSTMT_REQINSTANCE, LYEXT_SUBSTMT_YINELEM,
  LYEXT_SUBSTMT_CONFIG, LYEXT_SUBSTMT_MANDATORY, LYEXT_SUBSTMT_ORDEREDBY, LYEXT_SUBSTMT_STATUS,
  LYEXT_SUBSTMT_DIGITS, LYEXT_SUBSTMT_MAX, LYEXT_SUBSTMT_MIN, LYEXT_SUBSTMT_POSITION,
  LYEXT_SUBSTMT_UNIQUE
}
 List of substatement without extensions storage. If the module contains extension instances in these substatements, they are stored with the extensions of the parent statement and flag to show to which substatement they belongs to. More...
 
enum  LYEXT_VLOG_ELEM {
  LYEXT_VLOG_NONE = 0, LYEXT_VLOG_XML, LYEXT_VLOG_LYS, LYEXT_VLOG_LYD,
  LYEXT_VLOG_STR, LYEXT_VLOG_PREV
}
 Type of object concerned by a validation error. This is used to determine how to compute the path of the element at issue. More...
 

Functions

const void * lys_ext_instance_substmt (const struct lys_ext_instance *ext)
 Get address of the substatement structure to which the extension instance refers. More...
 
int lys_ext_instance_presence (struct lys_ext *def, struct lys_ext_instance **ext, uint8_t ext_size)
 Get the position of the extension instance in the extensions list. More...
 
void * lys_ext_complex_get_substmt (LY_STMT stmt, struct lys_ext_instance_complex *ext, struct lyext_substmt **info)
 get pointer to the place where the specified extension's substatement is supposed to be stored in the complex extension instance. More...
 
const char *const * ly_get_loaded_plugins (void)
 Get list of all the loaded plugins, both extension and user type ones. More...
 
void ly_load_plugins (void)
 Load the available YANG extension and type plugins from the plugin directory (LIBDIR/libyang/). More...
 
int ly_register_exts (struct lyext_plugin_list *plugin, const char *log_name)
 Directly register a YANG extension by pointer. More...
 
int ly_register_types (struct lytype_plugin_list *plugin, const char *log_name)
 Directly register a YANG type by pointer. More...
 
int ly_clean_plugins (void)
 Unload all the YANG extension and type plugins. More...
 
void lyext_log (const struct ly_ctx *ctx, LY_LOG_LEVEL level, const char *plugin, const char *function, const char *format,...)
 Logging function for extension plugins, use LYEXT_LOG macro instead! More...
 
void lyext_vlog (const struct ly_ctx *ctx, LY_VECODE vecode, const char *plugin, const char *function, LYEXT_VLOG_ELEM elem_type, const void *elem, const char *format,...)
 Validation logging function for extension plugins, use LYEXT_VLOG macro instead! More...
 
void lys_iffeature_free (struct ly_ctx *ctx, struct lys_iffeature *iffeature, uint8_t iffeature_size, int shallow, void(*private_destructor)(const struct lys_node *node, void *priv))
 Free iffeature structure. In API only for plugins that want to handle if-feature statements similarly to libyang. More...
 

Detailed Description


Data Structure Documentation

struct lyext_substmt

Description of the extension instance substatement.

Provided by extensions plugins to libyang to be able to parse the content of extension instances.

Definition at line 442 of file tree_schema.h.

Data Fields
LY_STMT stmt

allowed substatement

size_t offset

offset in the lys_ext_instance_complex::content

LY_STMT_CARD cardinality

cardinality of the substatement

struct lys_ext

YANG extension definition.

Definition at line 451 of file tree_schema.h.

Data Fields
const char * name

extension name

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

LYS_STATUS_* and LYS_YINELEM values (Schema nodes flags)

uint8_t ext_size

number of elements in ext array

uint8_t padding[5]

padding for compatibility with lys_node

struct lys_ext_instance ** ext

array of pointers to the extension instances

const char * argument

argument name, NULL if not specified, replacement for lys_node's iffeature

struct lys_module * module

link to the extension's data model

struct lyext_plugin * plugin

pointer to the plugin's data if any

struct lys_ext_instance

Generic extension instance structure.

The structure can be cast to another lys_ext_instance_* structure according to the extension type that can be get via lys_ext_type() function. Check the LYEXT_TYPE values to get know the specific mapping between the extension type and lys_ext_instance_* structures.

Definition at line 471 of file tree_schema.h.

Data Fields
struct lys_ext * def

definition of the instantiated extension, according to the type in the extension's plugin structure, the structure can be cast to the more specific structure

void * parent

pointer to the parent element holding the extension instance(s), use lys_ext_instance::parent_type to access the schema element

const char * arg_value

value of the instance's argument, if defined

uint16_t flags

extension flags

uint8_t ext_size

number of elements in ext array

uint8_t insubstmt_index

since some of the statements can appear multiple times, it is needed to keep the position of the specific statement instance which contains this extension instance. Order of both, the extension and the statement, instances is the same. The index is filled only for LYEXT_SUBSTMT_BASE, LYEXT_SUBSTMT_DEFAULT and LYEXT_SUBSTMT_UNIQUE values of the lys_ext_instance::insubstmt member. To get the correct pointer to the data connected with the index, use lys_ext_instance_substmt()

uint8_t insubstmt

LYEXT_SUBSTMT - id for the case the extension instance is actually inside some of the node's members (substatements). libyang does not store extension instances for all possible statements to save some, commonly unused, space.

uint8_t parent_type

LYEXT_PAR - type of the parent structure

uint8_t ext_type

extension type (LYEXT_TYPE)

uint8_t padding

32b padding

struct lys_ext_instance ** ext

array of pointers to the extension instances

void * priv

private caller's data, not used by libyang

struct lys_module * module

pointer to the extension instance's module (mandatory)

LYS_NODE nodetype

LYS_EXT

struct lys_ext_instance_complex

Complex extension instance structure.

The structure extends the generic lys_ext_instance structure to be able to hold substatements as defined by the plugin.

Definition at line 505 of file tree_schema.h.

Data Fields
struct lys_ext * def

definition of the instantiated extension, the plugin's type is LYEXT_COMPLEX

void * parent

pointer to the parent element holding the extension instance(s), use lys_ext_instance::parent_type to access the schema element

const char * arg_value

value of the instance's argument, if defined

uint16_t flags

extension flags

uint8_t ext_size

number of elements in ext array

uint8_t insubstmt_index

since some of the statements can appear multiple times, it is needed to keep the position of the specific statement instance which contains this extension instance. Order of both, the extension and the statement, instances is the same. The index is filled only for LYEXT_SUBSTMT_BASE, LYEXT_SUBSTMT_DEFAULT and LYEXT_SUBSTMT_UNIQUE values of the lys_ext_instance::insubstmt member. To get the correct pointer to the data connected with the index, use lys_ext_instance_substmt()

uint8_t insubstmt

LYEXT_SUBSTMT - id for the case the extension instance is actually inside some of the node's members (substatements). libyang does not store extension instances for all possible statements to save some, commonly unused, space.

uint8_t parent_type

LYEXT_PAR - type of the parent structure

uint8_t ext_type

extension type (LYEXT_TYPE)

uint8_t padding

32b padding

struct lys_ext_instance ** ext

array of pointers to the extension instances

void * priv

private caller's data, not used by libyang

struct lys_module * module

pointer to the extension instance's module (mandatory)

LYS_NODE nodetype

LYS_EXT

struct lyext_substmt * substmt

pointer to the plugin's list of substatements' information

char content[1]

content of the extension instance

struct lyext_plugin

Definition at line 178 of file extensions.h.

Data Fields
LYEXT_TYPE type

type of the extension, according to it the structure will be casted

uint16_t flags

extension flags

lyext_check_position_clb check_position

callbcak for testing that the extension can be instantiated under the provided parent. Mandatory callback.

lyext_check_result_clb check_result

callback for testing if the argument value of the extension instance is valid. Mandatory if the extension has the argument.

lyext_check_inherit_clb check_inherit

callback to decide if the extension is supposed to be inherited into the provided node, the callback is used only if the flags contains LYEXT_OPT_INHERIT flag

lyext_valid_data_clb valid_data

callback to valid if data is valid toward to schema

struct lyext_plugin_complex

Definition at line 192 of file extensions.h.

Data Fields
LYEXT_TYPE type

type of the extension, according to it the structure will be casted

uint16_t flags

extension flags

lyext_check_position_clb check_position

callbcak for testing that the extension can be instantiated under the provided parent. Mandatory callback.

lyext_check_result_clb check_result

callback for testing if the argument value of the extension instance is valid. Mandatory if the extension has the argument.

lyext_check_inherit_clb check_inherit

callback to decide if the extension is supposed to be inherited into the provided node, the callback is used only if the flags contains LYEXT_OPT_INHERIT flag

lyext_valid_data_clb valid_data

callback to valid if data is valid toward to schema

struct lyext_substmt * substmt

NULL-terminated array of allowed substatements and restrictions to their instantiation inside the extension instance

size_t instance_size

size of the instance structure to allocate, the structure is is provided as lys_ext_instance_complex, but the content array is accessed according to the substmt specification provided by plugin

struct lyext_plugin_list

Definition at line 212 of file extensions.h.

Data Fields
const char * module

name of the module where the extension is defined

const char * revision

optional module revision - if not specified, the plugin applies to any revision, which is not an optional approach due to a possible future revisions of the module. Instead, there should be defined multiple items in the plugins list, each with the different revision, but all with the same pointer to the plugin extension. The only valid use case for the NULL revision is the case the module has no revision.

const char * name

name of the extension

struct lyext_plugin * plugin

plugin for the extension

Macro Definition Documentation

#define LYEXT_API_VERSION   1

Extensions API version.

Definition at line 32 of file extensions.h.

#define LYEXT_VERSION_CHECK   int lyext_api_version = LYEXT_API_VERSION;

Macro to store version of extension plugins API in the plugins. It is matched when the plugin is being loaded by libyang.

Definition at line 41 of file extensions.h.

#define LYEXT_LOG (   ctx,
  level,
  plugin,
  str,
  args... 
)    lyext_log(ctx, level, plugin, __func__, str, ##args); \

Logging macro for extension plugins.

Parameters
[in]ctxContext to store the error in.
[in]level#LY_LOG_LEVEL value with the message importance.
[in]pluginPlugin name.
[in]strFormat string as in case of printf function.
[in]argsParameters to expand in format string.

Definition at line 237 of file extensions.h.

#define LYEXT_VLOG (   ctx,
  vecode,
  plugin,
  elem_type,
  elem,
  str,
  args... 
)    lyext_vlog(ctx, vecode, plugin, __func__, elem_type, elem, str, ##args)

Validation logging macro for extension plugins.

Parameters
[in]ctxContext to store the error in.
[in]vecode#LY_VECODE validation error code.
[in]pluginPlugin name.
[in]elem_typeLYEXT_VLOG_ELEM what to expect in elem.
[in]elemThe element at issue.
[in]strFormat string as in case of printf function.
[in]argsParameters to expand in format string.

Definition at line 270 of file extensions.h.

Typedef Documentation

typedef int(* lyext_check_position_clb)(const void *parent, LYEXT_PAR parent_type, LYEXT_SUBSTMT substmt_type)

Callback to check that the extension can be instantiated inside the provided node.

Parameters
[in]parentThe parent of the instantiated extension.
[in]parent_typeThe type of the structure provided as parent.
[in]substmt_typelibyang does not store all the extension instances in the structures where they are instantiated in the module. In some cases (see LYEXT_SUBSTMT) they are stored in parent structure and marked with flag to know in which substatement of the parent the extension was originally instantiated.
Returns
0 - yes 1 - no 2 - ignore / skip without an error

Definition at line 142 of file extensions.h.

typedef int(* lyext_check_result_clb)(struct lys_ext_instance *ext)

Callback to check that the extension instance is correct - have the valid argument, cardinality, etc.

Parameters
[in]extExtension instance to be checked.
Returns
0 - ok 1 - error

Definition at line 152 of file extensions.h.

typedef int(* lyext_check_inherit_clb)(struct lys_ext_instance *ext, struct lys_node *node)

Callback to decide whether the extension will be inherited into the provided schema node. The extension instance is always from some of the node's parents. The inherited extension instances are marked with the LYEXT_OPT_INHERIT flag.

Parameters
[in]extExtension instance to be inherited.
[in]nodeSchema node where the node is supposed to be inherited.
Returns
0 - yes 1 - no (do not process the node's children) 2 - no, but continue with children

Definition at line 165 of file extensions.h.

typedef int(* lyext_valid_data_clb)(struct lys_ext_instance *ext, struct lyd_node *node)

Callback to decide if data is valid towards to schema.

Parameters
[in]extExtension instance to be checked.
[in]nodeData node, which try to valid.
Returns
0 - valid 1 - invalid

Definition at line 176 of file extensions.h.

Enumeration Type Documentation

enum LY_STMT

List of YANG statements.

The description of each statement contains the storage type for the case the statement is specified by extension plugin to appear as a substatement to the extension instance. Note that the storage type/structure are used in case of LY_STMT_CARD_OPT or LY_STMT_CARD_MAND. In other cases, the data are stored as a pointer to the NULL-terminated array of base types:

char*     -> char**
lys_type* -> lys_type**
uint8_t   -> uint8_t*

There are some items, that are not, in case of multiple instances, stored as an array of pointers.

  1. The value is ORed with the previous value in the storage. Initial value is 0. This is the case of e.g. LY_STMT_STATUS. These items actually does not allow to have multiple instances (it does not make sense).
  2. The lys_node_* data types are stored as a data tree, so in case of multiple instances, they are stored as siblings to the first node.

The values <= LY_STMT_UNIQUE are compatible with LYEXT_SUBSTMT values which defines the subset of YANG statements that does not store extension instances directly.

Enumerator
LY_STMT_NODE 

mask for values LY_STMT_ACTION - LY_STMT_USES

LY_STMT_UNKNOWN 

error return value

LY_STMT_ARGUMENT 

stored as const char* + uint8_t, the second item contains yin element interpreted as follows: 1 - true; 2 - false/default, in case of multiple instances, the argument's values and yin elements are stored in two arrays (const char ** + uint8_t *)

LY_STMT_BASE 

stored as const char*

LY_STMT_BELONGSTO 

belongs-to, stored as const char*[2], the second item contains belongs-to's prefix, in case of multiple instances, the belongs-to's module values and prefixes are stored in two arrays (const char **[2])

LY_STMT_CONTACT 

stored as const char*

LY_STMT_DEFAULT 

stored as const char*

LY_STMT_DESCRIPTION 

stored as const char*

LY_STMT_ERRTAG 

error-app-tag, stored as const char*

LY_STMT_ERRMSG 

error-message, stored as const char*

LY_STMT_KEY 

stored as const char*

LY_STMT_NAMESPACE 

stored as const char*

LY_STMT_ORGANIZATION 

organization, stored as const char*

LY_STMT_PATH 

stored as const char*

LY_STMT_PREFIX 

stored as const char*

LY_STMT_PRESENCE 

stored as const char*

LY_STMT_REFERENCE 

stored as const char*

LY_STMT_REVISIONDATE 

revision-date, stored as const char*

LY_STMT_UNITS 

stored as const char*

LY_STMT_VALUE 

stored as int32_t*

LY_STMT_VERSION 

not supported in extension instances

LY_STMT_MODIFIER 

stored as uint8_t interpreted as follows: 0 - not set/default; 1 - invert-match does not allow multiple instances

LY_STMT_REQINSTANCE 

require-instance, stored as uint8_t interpreted as follows: 0 - not set/default; 1 - true; 2 - false, does not allow multiple instances

LY_STMT_YINELEM 

not supported in extension instances

LY_STMT_CONFIG 

stored as uint16_t value (ORed with the previous value(s)), possible values are LYS_CONFIG_R and LYS_CONFIG_W (both ORed with LYS_CONFIG_SET), does not allow multiple instances

LY_STMT_MANDATORY 

stored as uint16_t value (ORed with the previous value(s)), possible values are LYS_MAND_TRUE and LYS_MAND_FALSE, does not allow multiple instances

LY_STMT_ORDEREDBY 

ordered-by, stored as uint16_t value (ORed with the previous value(s)), possible value is LYS_USERORDERED, does not allow multiple instances

LY_STMT_STATUS 

stored as uint16_t value (ORed with the previous value(s)), possible values are LYS_STATUS_CURR, LYS_STATUS_DEPRC and LYS_STATUS_OBSLT, does not allow multiple instances

LY_STMT_DIGITS 

fraction-digits, stored as uint8_t

LY_STMT_MAX 

max-elements, stored as uint32_t*

LY_STMT_MIN 

min-elements, stored as uint32_t*

LY_STMT_POSITION 

stored as uint32_t*

LY_STMT_UNIQUE 

stored as lys_unique*

LY_STMT_MODULE 

stored as lys_module*

LY_STMT_ACTION 

stored as lys_node_rpc_action*, part of the data tree

LY_STMT_ANYDATA 

stored as lys_node_anydata*, part of the data tree

LY_STMT_ANYXML 

stored as lys_node_anydata*, part of the data tree

LY_STMT_CASE 

stored as lys_node_case*, part of the data tree

LY_STMT_CHOICE 

stored as lys_node_choice*, part of the data tree

LY_STMT_CONTAINER 

stored as lys_node_container*, part of the data tree

LY_STMT_GROUPING 

stored as lys_node_grp*, part of the data tree

LY_STMT_INPUT 

stored as lys_node_inout*, part of the data tree, but it cannot appear multiple times

LY_STMT_LEAF 

stored as lys_node_leaf*, part of the data tree

LY_STMT_LEAFLIST 

leaf-list, stored as lys_node_leaflist*, part of the data tree

LY_STMT_LIST 

stored as lys_node_list*, part of the data tree

LY_STMT_NOTIFICATION 

stored as lys_node_notif*, part of the data tree

LY_STMT_OUTPUT 

stored as lys_node_anydata*, part of the data tree, but it cannot apper multiple times

LY_STMT_USES 

stored as lys_node_uses*, part of the data tree

LY_STMT_TYPEDEF 

stored as lys_tpdf*

LY_STMT_TYPE 

stored as lys_type*

LY_STMT_IFFEATURE 

if-feature, stored as lys_iffeature*

LY_STMT_LENGTH 

stored as lys_restr*

LY_STMT_MUST 

stored as lys_restr*

LY_STMT_PATTERN 

stored as lys_restr*

LY_STMT_RANGE 

stored as lys_restr*

LY_STMT_WHEN 

stored as lys_when*

LY_STMT_REVISION 

stored as lys_revision

LY_STMT_SUBMODULE 

not supported - submodules are tightly connected with their modules so it does not make any sense to have them instantiated under an extension instance

LY_STMT_RPC 

not supported, use actions instead

LY_STMT_BIT 

not supported in extension instances

LY_STMT_ENUM 

not supported in extension instances

LY_STMT_REFINE 

not supported in extension instances

LY_STMT_AUGMENT 

not supported in extension instances

LY_STMT_DEVIATE 

not supported in extension instances

LY_STMT_DEVIATION 

not supported in extension instances

LY_STMT_EXTENSION 

not supported in extension instances

LY_STMT_FEATURE 

not supported in extension instances

LY_STMT_IDENTITY 

not supported in extension instances

LY_STMT_IMPORT 

not supported in extension instances

LY_STMT_INCLUDE 

not supported in extension instances

Definition at line 282 of file tree_schema.h.

Possible cardinalities of the YANG statements.

Used in extensions plugins to define cardinalities of the extension instance substatements.

Enumerator
LY_STMT_CARD_OPT 
LY_STMT_CARD_MAND 
LY_STMT_CARD_SOME 
LY_STMT_CARD_ANY 

Definition at line 374 of file tree_schema.h.

enum LYEXT_TYPE

Extension types.

Enumerator
LYEXT_ERR 

error value when LYEXT_TYPE is expected as return value of a function

LYEXT_FLAG 

simple extension with no substatements; instance is stored directly as lys_ext_instance and no cast is needed; plugin is expected directly as lyext_plugin and no cast is done

LYEXT_COMPLEX 

complex extension with YANG substatement(s); instance is stored as lys_ext_instance_complex to which it can be cast from lys_ext_instance; plugin is expected as lyext_plugin_complex to which it can be cast from lyext_plugin

Definition at line 384 of file tree_schema.h.

enum LYEXT_PAR

Extension instance structure parent enumeration.

Enumerator
LYEXT_PAR_MODULE 

lys_module or lys_submodule

LYEXT_PAR_NODE 

lys_node (and the derived structures)

LYEXT_PAR_TPDF 

lys_tpdf

LYEXT_PAR_TYPE 

lys_type

LYEXT_PAR_TYPE_BIT 

lys_type_bit

LYEXT_PAR_TYPE_ENUM 

lys_type_enum

LYEXT_PAR_FEATURE 

lys_feature

LYEXT_PAR_RESTR 

lys_restr - YANG's must, range, length and pattern statements

LYEXT_PAR_WHEN 

lys_when

LYEXT_PAR_IDENT 

lys_ident

LYEXT_PAR_EXT 

lys_ext

LYEXT_PAR_EXTINST 

lys_ext_instance

LYEXT_PAR_REFINE 

lys_refine

LYEXT_PAR_DEVIATION 

lys_deviation

LYEXT_PAR_DEVIATE 

lys_deviate

LYEXT_PAR_IMPORT 

lys_import

LYEXT_PAR_INCLUDE 

lys_include

LYEXT_PAR_REVISION 

lys_revision

LYEXT_PAR_IFFEATURE 

lys_iffeature

Definition at line 47 of file extensions.h.

List of substatement without extensions storage. If the module contains extension instances in these substatements, they are stored with the extensions of the parent statement and flag to show to which substatement they belongs to.

For example, if the extension is supposed to be instantiated as a child to the description statement, libyang stores the description just as its value. So, for example in case of the module's description, the description's extension instance is actually stored in the lys_module's extensions list with the lys_ext_instance::insubstmt set to LYEXT_SUBSTMT_DESCRIPTION, lys_ext_instance::parent_type is LYEXT_PAR_MODULE and the lys_ext_instance::parent points to the lys_module structure.

The values are (convertible) subset of LY_STMT

Enumerator
LYEXT_SUBSTMT_ALL 

special value for the lys_ext_iter()

LYEXT_SUBSTMT_SELF 

extension of the structure itself, not substatement's

LYEXT_SUBSTMT_ARGUMENT 

extension of the argument statement, can appear in lys_ext

LYEXT_SUBSTMT_BASE 

extension of the base statement, can appear (repeatedly) in lys_type and lys_ident

LYEXT_SUBSTMT_BELONGSTO 

extension of the belongs-to statement, can appear in lys_submodule

LYEXT_SUBSTMT_CONTACT 

extension of the contact statement, can appear in lys_module

LYEXT_SUBSTMT_DEFAULT 

extension of the default statement, can appear in lys_node_leaf, lys_node_leaflist, lys_node_choice and lys_deviate

LYEXT_SUBSTMT_DESCRIPTION 

extension of the description statement, can appear in lys_module, lys_submodule, lys_node, lys_import, lys_include, lys_ext, lys_feature, lys_tpdf, lys_restr, lys_ident, lys_deviation, lys_type_enum, lys_type_bit, lys_when and lys_revision

LYEXT_SUBSTMT_ERRTAG 

extension of the error-app-tag statement, can appear in lys_restr

LYEXT_SUBSTMT_ERRMSG 

extension of the error-message statement, can appear in lys_restr

LYEXT_SUBSTMT_KEY 

extension of the key statement, can appear in lys_node_list

LYEXT_SUBSTMT_NAMESPACE 

extension of the namespace statement, can appear in lys_module

LYEXT_SUBSTMT_ORGANIZATION 

extension of the organization statement, can appear in lys_module and lys_submodule

LYEXT_SUBSTMT_PATH 

extension of the path statement, can appear in lys_type

LYEXT_SUBSTMT_PREFIX 

extension of the prefix statement, can appear in lys_module, lys_submodule (for belongs-to's prefix) and lys_import

LYEXT_SUBSTMT_PRESENCE 

extension of the presence statement, can appear in lys_node_container

LYEXT_SUBSTMT_REFERENCE 

extension of the reference statement, can appear in lys_module, lys_submodule, lys_node, lys_import, lys_include, lys_revision, lys_tpdf, lys_restr, lys_ident, lys_ext, lys_feature, lys_deviation, lys_type_enum, lys_type_bit and lys_when

LYEXT_SUBSTMT_REVISIONDATE 

extension of the revision-date statement, can appear in lys_import and lys_include

LYEXT_SUBSTMT_UNITS 

extension of the units statement, can appear in lys_tpdf, lys_node_leaf, lys_node_leaflist and lys_deviate

LYEXT_SUBSTMT_VALUE 

extension of the value statement, can appear in lys_type_enum

LYEXT_SUBSTMT_VERSION 

extension of the yang-version statement, can appear in lys_module and lys_submodule

LYEXT_SUBSTMT_MODIFIER 

extension of the modifier statement, can appear in lys_restr

LYEXT_SUBSTMT_REQINSTANCE 

extension of the require-instance statement, can appear in lys_type

LYEXT_SUBSTMT_YINELEM 

extension of the yin-element statement, can appear in lys_ext

LYEXT_SUBSTMT_CONFIG 

extension of the config statement, can appear in lys_node and lys_deviate

LYEXT_SUBSTMT_MANDATORY 

extension of the mandatory statement, can appear in lys_node_leaf, lys_node_choice, lys_node_anydata and lys_deviate

LYEXT_SUBSTMT_ORDEREDBY 

extension of the ordered-by statement, can appear in lys_node_list and lys_node_leaflist

LYEXT_SUBSTMT_STATUS 

extension of the status statement, can appear in lys_tpdf, lys_node, lys_ident, lys_ext, lys_feature, lys_type_enum and lys_type_bit

LYEXT_SUBSTMT_DIGITS 

extension of the fraction-digits statement, can appear in lys_type

LYEXT_SUBSTMT_MAX 

extension of the max-elements statement, can appear in lys_node_list, lys_node_leaflist and lys_deviate

LYEXT_SUBSTMT_MIN 

extension of the min-elements statement, can appear in lys_node_list, lys_node_leaflist and lys_deviate

LYEXT_SUBSTMT_POSITION 

extension of the position statement, can appear in lys_type_bit

LYEXT_SUBSTMT_UNIQUE 

extension of the unique statement, can appear in lys_node_list and lys_deviate

Definition at line 82 of file extensions.h.

Type of object concerned by a validation error. This is used to determine how to compute the path of the element at issue.

Enumerator
LYEXT_VLOG_NONE 
LYEXT_VLOG_XML 

const struct lyxml_elem*

LYEXT_VLOG_LYS 

const struct lys_node*

LYEXT_VLOG_LYD 

const struct lyd_node*

LYEXT_VLOG_STR 

const char*

LYEXT_VLOG_PREV 

Use the same path as the previous validation error

Definition at line 244 of file extensions.h.

Function Documentation

const void* lys_ext_instance_substmt ( const struct lys_ext_instance ext)

Get address of the substatement structure to which the extension instance refers.

If the extension instance's substmt value is 0, NULL is returned (extension instance refers to the parent, not to any of the parent's substatements).

Returned pointer is supposed to be cast according to the extension instance's substmt value:

Parameters
[in]extThe extension instance to explore
Returns
Pointer to the data connected with the statement where the extension was instantiated. Details about casting the returned pointer are described above.
int lys_ext_instance_presence ( struct lys_ext def,
struct lys_ext_instance **  ext,
uint8_t  ext_size 
)

Get the position of the extension instance in the extensions list.

Parameters
[in]defDefinition of the extension to search
[in]extExtensions list as they are stored in the schema tree nodes
[in]ext_sizeNumber of items in the extensions list
Returns
-1 in case the extension is not present in the list, index of the extension in the provided list otherwise
void* lys_ext_complex_get_substmt ( LY_STMT  stmt,
struct lys_ext_instance_complex ext,
struct lyext_substmt **  info 
)

get pointer to the place where the specified extension's substatement is supposed to be stored in the complex extension instance.

Parameters
[in]stmtSubstatement to get
[in]extComplex extension instance to be explored.
[out]infoOptional output parameter providing information about the stmt from the plugin.
Returns
Address of the storage in the ext, NULL if the substatement is not allowed in this extension or any other error (e.g. invalid input data).
const char* const* ly_get_loaded_plugins ( void  )

Get list of all the loaded plugins, both extension and user type ones.

Returns
Const list of all the plugin names finished with NULL.
void ly_load_plugins ( void  )

Load the available YANG extension and type plugins from the plugin directory (LIBDIR/libyang/).

This function is automatically called whenever a new context is created. Note that the removed plugins are kept in use until all the created contexts are destroyed via ly_ctx_destroy(), so only the newly added plugins are usually loaded by this function.

int ly_register_exts ( struct lyext_plugin_list plugin,
const char *  log_name 
)

Directly register a YANG extension by pointer.

This is intended to be called by executables or libraries using libyang, while bringing along their own application-specific extensions. Instead of loading them from separate module files through dlopen (which can introduce additional problems like mismatching or incorrectly installed modules), they can be directly added by reference.

int ly_register_types ( struct lytype_plugin_list plugin,
const char *  log_name 
)

Directly register a YANG type by pointer.

This is the analog of ly_register_exts(), for types instead of extensions.

int ly_clean_plugins ( void  )

Unload all the YANG extension and type plugins.

This function is automatically called whenever the context is destroyed. Note, that in case there is still a libyang context in use, the function does nothing since unloading the plugins would break the context's modules which may refer/use the plugins.

Since the function is called with ly_ctx_destroy(), there is usually no need to call this function manually.

void lyext_log ( const struct ly_ctx *  ctx,
LY_LOG_LEVEL  level,
const char *  plugin,
const char *  function,
const char *  format,
  ... 
)

Logging function for extension plugins, use LYEXT_LOG macro instead!

void lyext_vlog ( const struct ly_ctx *  ctx,
LY_VECODE  vecode,
const char *  plugin,
const char *  function,
LYEXT_VLOG_ELEM  elem_type,
const void *  elem,
const char *  format,
  ... 
)

Validation logging function for extension plugins, use LYEXT_VLOG macro instead!

void lys_iffeature_free ( struct ly_ctx *  ctx,
struct lys_iffeature iffeature,
uint8_t  iffeature_size,
int  shallow,
void(*)(const struct lys_node *node, void *priv)  private_destructor 
)

Free iffeature structure. In API only for plugins that want to handle if-feature statements similarly to libyang.

Parameters
[in]ctxlibyang context.
[in]iffeatureiffeature array to free.
[in]iffeature_sizesize of array iffeature.
[in]shallowWhether to make only shallow free.
[in]private_destructorCustom destructor for freeing any extension instances.