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

Modules

 Schema printer flags
 Schema output flags accepted by libyang printer functions.
 
 YANG Extensions
 
 Schema nodes flags
 
 User Types
 

Data Structures

struct  lys_module
 Main schema node structure representing YANG module. More...
 
struct  lys_submodule
 Submodule schema node structure that can be included into a YANG module. More...
 
struct  lys_type_info_binary
 
struct  lys_type_bit
 Single bit value specification for lys_type_info_bits. More...
 
struct  lys_type_info_bits
 Container for information about bits types (LY_TYPE_BINARY), used in lys_type_info. More...
 
struct  lys_type_info_dec64
 Container for information about decimal64 types (LY_TYPE_DEC64), used in lys_type_info. More...
 
struct  lys_type_enum
 Single enumeration value specification for lys_type_info_enums. More...
 
struct  lys_type_info_enums
 Container for information about enumeration types (LY_TYPE_ENUM), used in lys_type_info. More...
 
struct  lys_type_info_ident
 Container for information about identity types (LY_TYPE_IDENT), used in lys_type_info. More...
 
struct  lys_type_info_inst
 Container for information about instance-identifier types (LY_TYPE_INST), used in lys_type_info. More...
 
struct  lys_type_info_num
 Container for information about integer types, used in lys_type_info. More...
 
struct  lys_type_info_lref
 Container for information about leafref types (LY_TYPE_LEAFREF), used in lys_type_info. More...
 
struct  lys_type_info_str
 Container for information about string types (LY_TYPE_STRING), used in lys_type_info. More...
 
struct  lys_type_info_union
 Container for information about union types (LY_TYPE_UNION), used in lys_type_info. More...
 
union  lys_type_info
 Union for holding type-specific information in lys_type. More...
 
struct  lys_type
 YANG type structure providing information from the schema. More...
 
struct  lys_iffeature
 Compiled if-feature expression structure. More...
 
struct  lys_node
 Common structure representing single YANG data statement describing. More...
 
struct  lys_node_container
 Schema container node structure. More...
 
struct  lys_node_choice
 Schema choice node structure. More...
 
struct  lys_node_leaf
 Schema leaf node structure. More...
 
struct  lys_node_leaflist
 Schema leaf-list node structure. More...
 
struct  lys_node_list
 Schema list node structure. More...
 
struct  lys_node_anydata
 Schema anydata (and anyxml) node structure. More...
 
struct  lys_node_uses
 Schema uses node structure. More...
 
struct  lys_node_grp
 Schema grouping node structure. More...
 
struct  lys_node_case
 Schema case node structure. More...
 
struct  lys_node_inout
 RPC input and output node structure. More...
 
struct  lys_node_notif
 Schema notification node structure. More...
 
struct  lys_node_rpc_action
 Schema rpc/action node structure. More...
 
struct  lys_node_augment
 YANG augment structure (covering both possibilities - uses's substatement as well as (sub)module's substatement). More...
 
struct  lys_refine_mod_list
 Container for list modifications in lys_refine_mod. More...
 
union  lys_refine_mod
 Union to hold target modification in lys_refine. More...
 
struct  lys_refine
 YANG uses's refine substatement structure, see RFC 6020 sec. 7.12.2 More...
 
struct  lys_deviate
 YANG deviate statement structure, see RFC 6020 sec. 7.18.3.2 More...
 
struct  lys_deviation
 YANG deviation statement structure, see RFC 6020 sec. 7.18.3 More...
 
struct  lys_import
 YANG import structure used to reference other schemas (modules). More...
 
struct  lys_include
 YANG include structure used to reference submodules. More...
 
struct  lys_revision
 YANG revision statement for (sub)modules. More...
 
struct  lys_tpdf
 YANG typedef structure providing information from the schema. More...
 
struct  lys_unique
 YANG list's unique statement structure, see RFC 6020 sec. 7.8.3 More...
 
struct  lys_feature
 YANG feature definition structure. More...
 
struct  lys_restr
 YANG validity restriction (must, length, etc.) structure providing information from the schema. More...
 
struct  lys_when
 YANG when restriction, see RFC 6020 sec. 7.19.5 More...
 
struct  lys_ident
 Structure to hold information about identity, see RFC 6020 sec. 7.16 More...
 

Macros

#define LY_ARRAY_MAX(var)   (sizeof(var) == 8 ? ULLONG_MAX : ((1ULL << (sizeof(var) * 8)) - 1))
 
#define LY_REV_SIZE   11
 
#define LYS_YANG   1
 
#define LYS_YIN   2
 
#define LYS_NO_RPC_NOTIF_NODE   0x807F
 
#define LYS_ANY   0xFFFF
 
#define LY_DATA_TYPE_COUNT   20
 
#define LYS_IFF_NOT   0x00
 
#define LYS_IFF_AND   0x01
 
#define LYS_IFF_OR   0x02
 
#define LYS_IFF_F   0x03
 
#define LYS_GETNEXT_WITHCHOICE   0x01
 
#define LYS_GETNEXT_WITHCASE   0x02
 
#define LYS_GETNEXT_WITHGROUPING   0x04
 
#define LYS_GETNEXT_WITHINOUT   0x08
 
#define LYS_GETNEXT_WITHUSES   0x10
 
#define LYS_GETNEXT_INTOUSES   0x20
 
#define LYS_GETNEXT_INTONPCONT   0x40
 
#define LYS_GETNEXT_PARENTUSES   0x80
 
#define LYS_GETNEXT_NOSTATECHECK   0x100
 
#define LYXP_MUST   0x01
 
#define LYXP_WHEN   0x02
 
#define LYXP_RECURSIVE   0x01
 
#define LYXP_NO_LOCAL   0x02
 
#define LYS_PATH_FIRST_PREFIX   0x01
 

Typedefs

typedef enum lys_nodetype LYS_NODE
 YANG schema node types. More...
 
typedef enum LYS_VERSION LYS_VERSION
 supported YANG schema version values More...
 
typedef enum lys_deviate_type LYS_DEVIATE_TYPE
 Possible deviation modifications, see RFC 6020 sec. 7.18.3.2 More...
 

Enumerations

enum  LYS_INFORMAT { LYS_IN_UNKNOWN = 0, LYS_IN_YANG = 1, LYS_IN_YIN = 2 }
 Schema input formats accepted by libyang parser functions. More...
 
enum  LYS_OUTFORMAT {
  LYS_OUT_UNKNOWN = 0, LYS_OUT_YANG = 1, LYS_OUT_YIN = 2, LYS_OUT_TREE,
  LYS_OUT_INFO, LYS_OUT_JSON
}
 Schema output formats accepted by libyang printer functions. More...
 
enum  lys_nodetype {
  LYS_UNKNOWN = 0x0000, LYS_CONTAINER = 0x0001, LYS_CHOICE = 0x0002, LYS_LEAF = 0x0004,
  LYS_LEAFLIST = 0x0008, LYS_LIST = 0x0010, LYS_ANYXML = 0x0020, LYS_CASE = 0x0040,
  LYS_NOTIF = 0x0080, LYS_RPC = 0x0100, LYS_INPUT = 0x0200, LYS_OUTPUT = 0x0400,
  LYS_GROUPING = 0x0800, LYS_USES = 0x1000, LYS_AUGMENT = 0x2000, LYS_ACTION = 0x4000,
  LYS_ANYDATA = 0x8020, LYS_EXT = 0x10000
}
 YANG schema node types. More...
 
enum  LYS_VERSION { LYS_VERSION_UNDEF = 0, LYS_VERSION_1 = 1, LYS_VERSION_1_1 = 2 }
 supported YANG schema version values More...
 
enum  LY_DATA_TYPE {
  LY_TYPE_DER = 0, LY_TYPE_BINARY, LY_TYPE_BITS, LY_TYPE_BOOL,
  LY_TYPE_DEC64, LY_TYPE_EMPTY, LY_TYPE_ENUM, LY_TYPE_IDENT,
  LY_TYPE_INST, LY_TYPE_LEAFREF, LY_TYPE_STRING, LY_TYPE_UNION,
  LY_TYPE_INT8, LY_TYPE_UINT8, LY_TYPE_INT16, LY_TYPE_UINT16,
  LY_TYPE_INT32, LY_TYPE_UINT32, LY_TYPE_INT64, LY_TYPE_UINT64,
  LY_TYPE_UNKNOWN
}
 YANG built-in types. More...
 
enum  lys_deviate_type { LY_DEVIATE_NO, LY_DEVIATE_ADD, LY_DEVIATE_RPL, LY_DEVIATE_DEL }
 Possible deviation modifications, see RFC 6020 sec. 7.18.3.2 More...
 
enum  lyxp_node_type {
  LYXP_NODE_ROOT, LYXP_NODE_ROOT_CONFIG, LYXP_NODE_ELEM, LYXP_NODE_TEXT,
  LYXP_NODE_ATTR, LYXP_NODE_NONE
}
 Types of context nodes, LYXP_NODE_ROOT_CONFIG used only in when or must conditions. More...
 

Functions

struct lys_modulelys_parse_mem (struct ly_ctx *ctx, const char *data, LYS_INFORMAT format)
 Load a schema into the specified context. More...
 
struct lys_modulelys_parse_fd (struct ly_ctx *ctx, int fd, LYS_INFORMAT format)
 Read a schema from file descriptor into the specified context. More...
 
struct lys_modulelys_parse_path (struct ly_ctx *ctx, const char *path, LYS_INFORMAT format)
 Load a schema into the specified context from a file. More...
 
int lys_search_localfile (const char *const *searchpaths, int cwd, const char *name, const char *revision, char **localfile, LYS_INFORMAT *format)
 Search for the schema file in the specified searchpaths. More...
 
const char ** lys_features_list (const struct lys_module *module, uint8_t **states)
 Get list of all the defined features in the module and its submodules. More...
 
int lys_features_enable (const struct lys_module *module, const char *feature)
 Enable specified feature in the module. In case its if-feature evaluates to false, return an error. More...
 
int lys_features_disable (const struct lys_module *module, const char *feature)
 Disable specified feature in the module. If it causes some dependant features to be disabled, they are also set to disabled. More...
 
int lys_features_enable_force (const struct lys_module *module, const char *feature)
 Enable specified feature in the module disregarding its if-features. More...
 
int lys_features_disable_force (const struct lys_module *module, const char *feature)
 Disable specified feature in the module disregarding dependant features. More...
 
int lys_features_state (const struct lys_module *module, const char *feature)
 Get the current status of the specified feature in the module. Even if the feature is enabled but some of its if-features evaluate to false, it is reported as disabled. More...
 
struct lys_nodelys_is_disabled (const struct lys_node *node, int recursive)
 Check if the schema node is disabled in the schema tree, i.e. there is any disabled if-feature statement affecting the node. More...
 
int lys_iffeature_value (const struct lys_iffeature *iff)
 Learn how the if-feature statement currently evaluates. More...
 
struct lys_node_listlys_is_key (const struct lys_node_leaf *node, uint8_t *index)
 Check if the schema leaf node is used as a key for a list. More...
 
struct lys_nodelys_getnext (const struct lys_node *last, const struct lys_node *parent, const struct lys_module *module, int options)
 Get next schema tree (sibling) node element that can be instantiated in a data tree. Returned node can be from an augment. More...
 
struct lys_typelys_getnext_union_type (const struct lys_type *last, const struct lys_type *type)
 Get next type of a union. More...
 
struct ly_set * lys_find_path (const struct lys_module *cur_module, const struct lys_node *cur_node, const char *path)
 Search for schema nodes matching the provided path. More...
 
struct ly_set * lys_xpath_atomize (const struct lys_node *ctx_node, enum lyxp_node_type ctx_node_type, const char *expr, int options)
 Get all the partial XPath nodes (atoms) that are required for expr to be evaluated. More...
 
struct ly_set * lys_node_xpath_atomize (const struct lys_node *node, int options)
 Call lys_xpath_atomize() on all the when and must expressions of the node. This node must be a descendant of an input, output, or notification node. This subtree then forms the local subtree. More...
 
char * lys_path (const struct lys_node *node, int options)
 Build schema path (usable as path, see howtoxpath) of the schema node. More...
 
char * lys_data_path (const struct lys_node *node)
 Build data path (usable as path, see howtoxpath) of the schema node. More...
 
char * lys_data_path_pattern (const struct lys_node *node, const char *placeholder)
 Build the data path pattern of a schema node. More...
 
struct lys_nodelys_parent (const struct lys_node *node)
 Return parent node in the schema tree. More...
 
struct lys_modulelys_node_module (const struct lys_node *node)
 Return main module of the schema tree node. More...
 
struct lys_modulelys_main_module (const struct lys_module *module)
 Return main module of the module. More...
 
struct lys_modulelys_implemented_module (const struct lys_module *mod)
 Find the implemented revision of the given module in the context. More...
 
int lys_set_implemented (const struct lys_module *module)
 Mark imported module as "implemented". More...
 
int lys_set_disabled (const struct lys_module *module)
 Disable module in its context to avoid its further usage (it will be hidden for module getters). More...
 
int lys_set_enabled (const struct lys_module *module)
 Enable previously disabled module. More...
 
void * lys_set_private (const struct lys_node *node, void *priv)
 Set a schema private pointer to a user pointer. More...
 
int lys_print_mem (char **strp, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node, int line_length, int options)
 Print schema tree in the specified format into a memory block. It is up to caller to free the returned string by free(). More...
 
int lys_print_fd (int fd, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node, int line_length, int options)
 Print schema tree in the specified format into a file descriptor. More...
 
int lys_print_file (FILE *f, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node, int line_length, int options)
 Print schema tree in the specified format into a file stream. More...
 
int lys_print_path (const char *path, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node, int line_length, int options)
 Print schema tree in the specified format into a file. More...
 
int lys_print_clb (ssize_t(*writeclb)(void *arg, const void *buf, size_t count), void *arg, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node, int line_length, int options)
 Print schema tree in the specified format using a provided callback. More...
 

Detailed Description

Data structures and functions to manipulate and access schema tree.


Data Structure Documentation

struct lys_module

Main schema node structure representing YANG module.

Compatible with lys_submodule structure with exception of the last, ns member, which is replaced by lys_submodule::belongsto member. Sometimes, lys_submodule can be provided casted to lys_module. Such a thing can be determined via the type member value.

Definition at line 673 of file tree_schema.h.

Data Fields
struct ly_ctx * ctx

libyang context of the module (mandatory)

const char * name

name of the module (mandatory)

const char * prefix

prefix of the module (mandatory)

const char * dsc

description of the module

const char * ref

cross-reference for the module

const char * org

party/company responsible for the module

const char * contact

contact information for the module

const char * filepath

path, if the schema was read from a file, NULL in case of reading from memory

uint8_t type:1

0 - structure type used to distinguish structure from lys_submodule

uint8_t version:3

yang-version (LYS_VERSION):

  • 0 = not specified, YANG 1.0 as default,
  • 1 = YANG 1.0,
  • 2 = YANG 1.1
uint8_t deviated:2

deviated flag:

  • 0 = not deviated,
  • 1 = the module is deviated by another module,
  • 2 = deviation applied to this module are temporarily off
uint8_t disabled:1

flag if the module is disabled in the context

uint8_t implemented:1

flag if the module is implemented, not just imported

uint8_t latest_revision:1

flag if the module was loaded without specific revision and is the latest revision found

uint8_t padding1:7

padding for 32b alignment

uint8_t padding2[2]
uint8_t rev_size

number of elements in rev array

uint8_t imp_size

number of elements in imp array

uint8_t inc_size

number of elements in inc array

uint16_t ident_size

number of elements in ident array

uint16_t tpdf_size

number of elements in tpdf array

uint8_t features_size

number of elements in features array

uint8_t augment_size

number of elements in augment array

uint8_t deviation_size

number of elements in deviation array

uint8_t extensions_size

number of elements in extensions array

uint8_t ext_size

number of elements in ext array

struct lys_revision * rev

array of the module revisions, revisions[0] is always the last (newest) revision of the module

struct lys_import * imp

array of imported modules

struct lys_include * inc

array of included submodules

struct lys_tpdf * tpdf

array of typedefs

struct lys_ident * ident

array of identities

struct lys_feature * features

array of feature definitions

struct lys_node_augment * augment

array of augments

struct lys_deviation * deviation

array of specified deviations

struct lys_ext * extensions

array of specified extensions

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_node * data

first data statement, includes also RPCs and Notifications

const char * ns

namespace of the module (mandatory)

struct lys_submodule

Submodule schema node structure that can be included into a YANG module.

Compatible with lys_module structure with exception of the last, belongsto member, which is replaced by lys_module::data and lys_module::ns members. Sometimes, lys_submodule can be provided casted to lys_module. Such a thing can be determined via the type member value.

Definition at line 736 of file tree_schema.h.

Data Fields
struct ly_ctx * ctx

libyang context of the submodule (mandatory)

const char * name

name of the submodule (mandatory)

const char * prefix

prefix of the belongs-to module

const char * dsc

description of the submodule

const char * ref

cross-reference for the submodule

const char * org

party responsible for the submodule

const char * contact

contact information for the submodule

const char * filepath

path to the file from which the submodule was read

uint8_t type:1

1 - structure type used to distinguish structure from lys_module

uint8_t version:3

yang-version (LYS_VERSION):

  • 0 = not specified, YANG 1.0 as default,
  • 1 = YANG 1.0,
  • 2 = YANG 1.1
uint8_t deviated:2

deviated flag (same as in main module):

  • 0 = not deviated,
  • 1 = the module is deviated by another module,
  • 2 = deviation applied to this module are temporarily off
uint8_t disabled:1

flag if the module is disabled in the context (same as in main module)

uint8_t implemented:1

flag if the module is implemented, not just imported (same as in main module)

uint8_t padding[3]

padding for 32b alignment

uint8_t rev_size

number of elements in rev array

uint8_t imp_size

number of elements in imp array

uint8_t inc_size

number of elements in inc array

uint16_t ident_size

number of elements in ident array

uint16_t tpdf_size

number of elements in tpdf array

uint8_t features_size

number of elements in features array

uint8_t augment_size

number of elements in augment array

uint8_t deviation_size

number of elements in deviation array

uint8_t extensions_size

number of elements in extensions array

uint8_t ext_size

number of elements in ext array

struct lys_revision * rev

array of the module revisions, revisions[0] is always the last (newest) revision of the submodule

struct lys_import * imp

array of imported modules

struct lys_include * inc

array of included submodules

struct lys_tpdf * tpdf

array of typedefs

struct lys_ident * ident

array if identities

struct lys_feature * features

array of feature definitions

struct lys_node_augment * augment

array of augments

struct lys_deviation * deviation

array of specified deviations

struct lys_ext * extensions

array of specified extensions

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_module * belongsto

belongs-to (parent module)

struct lys_type_info_binary

Definition at line 819 of file tree_schema.h.

Data Fields
struct lys_restr * length

length restriction (optional), see RFC 6020 sec. 9.4.4

struct lys_type_bit

Single bit value specification for lys_type_info_bits.

Definition at line 827 of file tree_schema.h.

Data Fields
const char * name

bit's name (mandatory)

const char * dsc

bit's description (optional)

const char * ref

bit's reference (optional)

uint16_t flags

bit's flags, whether the position was auto-assigned and the status(one of LYS_NODE_STATUS_* values or 0 for default)

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint32_t pos

bit's position (mandatory)

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_type_info_bits

Container for information about bits types (LY_TYPE_BINARY), used in lys_type_info.

Definition at line 846 of file tree_schema.h.

Data Fields
struct lys_type_bit * bit

array of bit definitions

unsigned int count

number of bit definitions in the bit array

struct lys_type_info_dec64

Container for information about decimal64 types (LY_TYPE_DEC64), used in lys_type_info.

Definition at line 854 of file tree_schema.h.

Data Fields
struct lys_restr * range

range restriction (optional), see RFC 6020 sec. 9.2.4

uint8_t dig

fraction-digits restriction (mandatory). Note that in case of types not directly derived from built-in decimal64, dig is present even it cannot be specified in schema. That's because the value is inherited for simpler access to the value and easier manipulation with the decimal64 data

uint64_t div

auxiliary value for moving decimal point (dividing the stored value to get the real value)

struct lys_type_enum

Single enumeration value specification for lys_type_info_enums.

Definition at line 867 of file tree_schema.h.

Data Fields
const char * name

enum's name (mandatory)

const char * dsc

enum's description (optional)

const char * ref

enum's reference (optional)

uint16_t flags

enum's flags, whether the value was auto-assigned and the status(one of LYS_NODE_STATUS_* values or 0 for default)

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

int32_t value

enum's value (mandatory)

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_type_info_enums

Container for information about enumeration types (LY_TYPE_ENUM), used in lys_type_info.

Definition at line 886 of file tree_schema.h.

Data Fields
struct lys_type_enum * enm

array of enum definitions

unsigned int count

number of enum definitions in the enm array

struct lys_type_info_ident

Container for information about identity types (LY_TYPE_IDENT), used in lys_type_info.

Definition at line 894 of file tree_schema.h.

Data Fields
struct lys_ident ** ref

array of pointers (reference) to the identity definition (mandatory)

unsigned int count

number of base identity references

struct lys_type_info_inst

Container for information about instance-identifier types (LY_TYPE_INST), used in lys_type_info.

Definition at line 902 of file tree_schema.h.

Data Fields
int8_t req

require-instance restriction, see RFC 6020 sec. 9.13.2:

  • -1 = false,
  • 0 not defined (true),
  • 1 = true
struct lys_type_info_num

Container for information about integer types, used in lys_type_info.

Definition at line 913 of file tree_schema.h.

Data Fields
struct lys_restr * range

range restriction (optional), see RFC 6020 sec. 9.2.4

struct lys_type_info_lref

Container for information about leafref types (LY_TYPE_LEAFREF), used in lys_type_info.

Definition at line 921 of file tree_schema.h.

Data Fields
const char * path

path to the referred leaf or leaf-list node (mandatory), see RFC 6020 sec. 9.9.2

struct lys_node_leaf * target

target schema node according to path

int8_t req

require-instance restriction:

  • -1 = false,
  • 0 not defined (true),
  • 1 = true
struct lys_type_info_str

Container for information about string types (LY_TYPE_STRING), used in lys_type_info.

Definition at line 934 of file tree_schema.h.

Data Fields
struct lys_restr * length

length restriction (optional), see RFC 6020 sec. 9.4.4

struct lys_restr * patterns

array of pattern restrictions (optional), see RFC 6020 sec. 9.4.6 In each pattern, the first byte of expr is modifier:

  • 0x06 (ACK) for match
  • 0x15 (NACK) for invert-match So the expression itself always starts at expr[1]
unsigned int pat_count

number of pattern definitions in the patterns array

struct lys_type_info_union

Container for information about union types (LY_TYPE_UNION), used in lys_type_info.

Definition at line 954 of file tree_schema.h.

Data Fields
struct lys_type * types

array of union's subtypes

unsigned int count

number of subtype definitions in types array

int has_ptr_type

types include an instance-identifier or leafref meaning the union must always be resolved after parsing

union lys_type_info

Union for holding type-specific information in lys_type.

Definition at line 964 of file tree_schema.h.

Data Fields
struct lys_type_info_binary binary

part for LY_TYPE_BINARY

struct lys_type_info_bits bits

part for LY_TYPE_BITS

struct lys_type_info_dec64 dec64

part for LY_TYPE_DEC64

struct lys_type_info_enums enums

part for LY_TYPE_ENUM

struct lys_type_info_ident ident

part for LY_TYPE_IDENT

struct lys_type_info_inst inst

part for LY_TYPE_INST

struct lys_type_info_num num

part for integer types

struct lys_type_info_lref lref

part for LY_TYPE_LEAFREF

struct lys_type_info_str str

part for LY_TYPE_STRING

struct lys_type_info_union uni

part for LY_TYPE_UNION

struct lys_type

YANG type structure providing information from the schema.

Definition at line 980 of file tree_schema.h.

Data Fields
LY_DATA_TYPE _PACKED base

base type

uint8_t value_flags

value type flags

uint8_t ext_size

number of elements in ext array

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_tpdf * der

pointer to the superior typedef. If NULL, structure provides information about one of the built-in types

struct lys_tpdf * parent

except lys_tpdf, it can points also to lys_node_leaf or lys_node_leaflist so access only the compatible members!

union lys_type_info info

detailed type-specific information

struct lys_iffeature

Compiled if-feature expression structure.

Definition at line 1077 of file tree_schema.h.

Data Fields
uint8_t * expr

2bits array describing the if-feature expression in prefix format

uint8_t ext_size

number of elements in ext array

struct lys_feature ** features

array of pointers to the features used in expression

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_node

Common structure representing single YANG data statement describing.

This is a common structure to allow having a homogeneous tree of nodes despite the nodes are actually heterogeneous. It allow one to go through the tree in a simple way. However, if you want to work with the node in some way or get more appropriate information, you are supposed to cast it to the appropriate lys_node_* structure according to the nodetype value.

To traverse through all the child elements, use LY_TREE_FOR or LY_TREE_FOR_SAFE macro. To traverse the whole subtree, use LY_TREE_DFS_BEGIN macro.

To cover all possible schema nodes, the lys_node type is used in lyd_node::schema for referencing schema definition for a specific data node instance.

The priv member is completely out of libyang control. It is just a pointer to allow libyang caller to store some proprietary data (e.g. callbacks) connected with the specific schema tree node.

Definition at line 1231 of file tree_schema.h.

Data Fields
const char * name

node name (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint8_t padding[4]

32b padding - on 64b it just fills the already required data making the space for type-specific values used by the structures derived from lys_node, on 32b it adds one word to lys_node, but this space is anyway required by the (really used) derived structures, so there is no wasting (except lys_node_choice, lys_node_case and lys_node_augment)

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_module * module

pointer to the node's module (mandatory)

LYS_NODE nodetype

type of the node (mandatory)

struct lys_node * parent

pointer to the parent node, NULL in case of a top level node

struct lys_node * child

pointer to the first child node

Note
Since other lys_node_* structures represent end nodes, this member is replaced in those structures. Therefore, be careful with accessing this member without having information about the lys_node::nodetype.
struct lys_node * next

pointer to the next sibling node (NULL if there is no one)

struct lys_node * prev

pointer to the previous sibling node

Note
Note that this pointer is never NULL. If there is no sibling node, pointer points to the node itself. In case of the first node, this pointer points to the last node in the list.
void * priv

private caller's data, not used by libyang

struct lys_node_container

Schema container node structure.

Beginning of the structure is completely compatible with lys_node structure extending it by the when, must, tpdf, and presence members.

The container schema node can be instantiated in the data tree, so the lys_node_container can be directly referenced from lyd_node::schema.

Definition at line 1277 of file tree_schema.h.

Data Fields
const char * name

node name (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint8_t padding[1]

padding for 32b alignment

uint8_t must_size

number of elements in the must array

uint16_t tpdf_size

number of elements in the tpdf array

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_module * module

pointer to the node's module (mandatory)

LYS_NODE nodetype

type of the node (mandatory) - LYS_CONTAINER

struct lys_node * parent

pointer to the parent node, NULL in case of a top level node

struct lys_node * child

pointer to the first child node

struct lys_node * next

pointer to the next sibling node (NULL if there is no one)

struct lys_node * prev

pointer to the previous sibling node

Note
Note that this pointer is never NULL. If there is no sibling node, pointer points to the node itself. In case of the first node, this pointer points to the last node in the list.
void * priv

private caller's data, not used by libyang

struct lys_when * when

when statement (optional)

struct lys_restr * must

array of must constraints

struct lys_tpdf * tpdf

array of typedefs

const char * presence

presence description, used also as a presence flag (optional)

struct lys_node_choice

Schema choice node structure.

Beginning of the structure is completely compatible with lys_node structure extending it by the when and dflt members.

The choice schema node has no instance in the data tree, so the lys_node_choice cannot be directly referenced from lyd_node::schema.

Definition at line 1325 of file tree_schema.h.

Data Fields
const char * name

node name (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint8_t padding[4]

padding for 32b alignment

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_module * module

pointer to the node's module (mandatory)

LYS_NODE nodetype

type of the node (mandatory) - LYS_CHOICE

struct lys_node * parent

pointer to the parent node, NULL in case of a top level node

struct lys_node * child

pointer to the first child node

struct lys_node * next

pointer to the next sibling node (NULL if there is no one)

struct lys_node * prev

pointer to the previous sibling node

Note
Note that this pointer is never NULL. If there is no sibling node, pointer points to the node itself. In case of the first node, this pointer points to the last node in the list.
void * priv

private caller's data, not used by libyang

struct lys_when * when

when statement (optional)

struct lys_node * dflt

default case of the choice (optional)

struct lys_node_leaf

Schema leaf node structure.

Beginning of the structure is completely compatible with lys_node structure extending it by the when, type, units, must_size, must and dflt members. In addition, the structure is compatible with the lys_node_leaflist structure except the last dflt member, which is replaced by lys_node_leaflist::min and lys_node_leaflist::max members.

The leaf schema node can be instantiated in the data tree, so the lys_node_leaf can be directly referenced from lyd_node::schema.

Definition at line 1367 of file tree_schema.h.

Data Fields
const char * name

node name (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint8_t padding[3]

padding for 32b alignment

uint8_t must_size

number of elements in the must array

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_module * module

pointer to the node's module (mandatory)

LYS_NODE nodetype

type of the node (mandatory) - LYS_LEAF

struct lys_node * parent

pointer to the parent node, NULL in case of a top level node

void * child

dummy attribute as a replacement for lys_node's child member

struct lys_node * next

pointer to the next sibling node (NULL if there is no one)

struct lys_node * prev

pointer to the previous sibling node

Note
Note that this pointer is never NULL. If there is no sibling node, pointer points to the node itself. In case of the first node, this pointer points to the last node in the list.
void * priv

private caller's data, not used by libyang

struct lys_when * when

when statement (optional)

struct lys_restr * must

array of must constraints

struct lys_type type

YANG data type definition of the leaf (mandatory)

const char * units

units of the data type (optional)

const char * dflt

default value of the leaf

struct lys_node_leaflist

Schema leaf-list node structure.

Beginning of the structure is completely compatible with lys_node structure extending it by the when, type, units, must_size, must, min and max members. In addition, the structure is compatible with the lys_node_leaf structure except the last min and max members, which are replaced by lys_node_leaf::dflt member.

The leaf-list schema node can be instantiated in the data tree, so the lys_node_leaflist can be directly referenced from lyd_node::schema.

Definition at line 1418 of file tree_schema.h.

Data Fields
const char * name

node name (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint8_t padding[2]

padding for 32b alignment

uint8_t dflt_size

number of elements in the dflt array

uint8_t must_size

number of elements in the must array

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_module * module

pointer to the node's module (mandatory)

LYS_NODE nodetype

type of the node (mandatory) - LYS_LEAFLIST

struct lys_node * parent

pointer to the parent node, NULL in case of a top level node

struct ly_set * backlinks

replacement for lys_node's child member, it is NULL except the leaf/leaflist is target of a leafref. In that case the set stores lys_node leafref objects with path referencing the current lys_node_leaf

struct lys_node * next

pointer to the next sibling node (NULL if there is no one)

struct lys_node * prev

pointer to the previous sibling node

Note
Note that this pointer is never NULL. If there is no sibling node, pointer points to the node itself. In case of the first node, this pointer points to the last node in the list.
void * priv

private caller's data, not used by libyang

struct lys_when * when

when statement (optional)

struct lys_restr * must

array of must constraints

struct lys_type type

YANG data type definition of the leaf (mandatory)

const char * units

units of the data type (optional)

const char ** dflt

array of default value(s) of the leaflist

uint32_t min

min-elements constraint (optional)

uint32_t max

max-elements constraint, 0 means unbounded (optional)

struct lys_node_list

Schema list node structure.

Beginning of the structure is completely compatible with lys_node structure extending it by the when, min, max, must_size, tpdf_size, keys_size, unique_size, must, tpdf, keys and unique members.

The list schema node can be instantiated in the data tree, so the lys_node_list can be directly referenced from lyd_node::schema.

Definition at line 1474 of file tree_schema.h.

Data Fields
const char * name

node name (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint8_t must_size

number of elements in the must array

uint8_t tpdf_size

number of elements in the tpdf array

uint8_t keys_size

number of elements in the keys array

uint8_t unique_size

number of elements in the unique array (number of unique statements)

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_module * module

pointer to the node's module (mandatory)

LYS_NODE nodetype

type of the node (mandatory) - LYS_LIST

struct lys_node * parent

pointer to the parent node, NULL in case of a top level node

struct lys_node * child

pointer to the first child node

struct lys_node * next

pointer to the next sibling node (NULL if there is no one)

struct lys_node * prev

pointer to the previous sibling node

Note
Note that this pointer is never NULL. If there is no sibling node, pointer points to the node itself. In case of the first node, this pointer points to the last node in the list.
void * priv

private caller's data, not used by libyang

struct lys_when * when

when statement (optional)

struct lys_restr * must

array of must constraints

struct lys_tpdf * tpdf

array of typedefs

struct lys_node_leaf ** keys

array of pointers to the key nodes

struct lys_unique * unique

array of unique statement structures

uint32_t min

min-elements constraint

uint32_t max

max-elements constraint, 0 means unbounded

const char * keys_str

string defining the keys, must be stored besides the keys array since the keys may not be present in case the list is inside grouping

struct lys_node_anydata

Schema anydata (and anyxml) node structure.

Beginning of the structure is completely compatible with lys_node structure extending it by the when, must_size and must members.

lys_node_anydata is terminating node in the schema tree, so the child member value is always NULL.

The anydata and anyxml schema nodes can be instantiated in the data tree, so the lys_node_anydata can be directly referenced from lyd_node::schema.

Definition at line 1533 of file tree_schema.h.

Data Fields
const char * name

node name (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint8_t padding[3]

padding for 32b alignment

uint8_t must_size

number of elements in the must array

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_module * module

pointer to the node's module (mandatory)

LYS_NODE nodetype

type of the node (mandatory) - LYS_ANYDATA or LYS_ANYXML

struct lys_node * parent

pointer to the parent node, NULL in case of a top level node

struct lys_node * child

always NULL

struct lys_node * next

pointer to the next sibling node (NULL if there is no one)

struct lys_node * prev

pointer to the previous sibling node

Note
Note that this pointer is never NULL. If there is no sibling node, pointer points to the node itself. In case of the first node, this pointer points to the last node in the list.
void * priv

private caller's data, not used by libyang

struct lys_when * when

when statement (optional)

struct lys_restr * must

array of must constraints

struct lys_node_uses

Schema uses node structure.

Beginning of the structure is completely compatible with lys_node structure extending it by the when, grp, refine_size, augment_size, refine and augment members.

lys_node_uses is terminating node in the schema tree. However, it references data from a specific grouping so the child pointer points to the copy of grouping data applying specified refine and augment statements.

The uses schema node has no instance in the data tree, so the lys_node_uses cannot be directly referenced from lyd_node::schema.

Definition at line 1581 of file tree_schema.h.

Data Fields
const char * name

node name (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags - only LYS_STATUS_* and LYS_USESGRP values are allowed

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint8_t padding[2]

padding for 32b alignment

uint8_t refine_size

number of elements in the refine array

uint8_t augment_size

number of elements in the augment array

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_module * module

pointer to the node's module (mandatory)

LYS_NODE nodetype

type of the node (mandatory) - LYS_USES

struct lys_node * parent

pointer to the parent node, NULL in case of a top level node

struct lys_node * child

pointer to the first child node imported from the referenced grouping

struct lys_node * next

pointer to the next sibling node (NULL if there is no one)

struct lys_node * prev

pointer to the previous sibling node

Note
Note that this pointer is never NULL. If there is no sibling node, pointer points to the node itself. In case of the first node, this pointer points to the last node in the list.
void * priv

private caller's data, not used by libyang

struct lys_when * when

when statement (optional)

struct lys_refine * refine

array of refine changes to the referred grouping

struct lys_node_augment * augment

array of local augments to the referred grouping

struct lys_node_grp * grp

referred grouping definition (mandatory)

struct lys_node_grp

Schema grouping node structure.

Beginning of the structure is completely compatible with lys_node structure extending it by the tpdf_size and tpdf members.

lys_node_grp contains data specifications in the schema tree. However, the data does not directly form the schema data tree. Instead, they are referenced via uses (lys_node_uses) statement and copies of the grouping data are actually placed into the uses nodes. Therefore, the nodes you can find under the lys_node_grp are not referenced from lyd_node::schema.

Definition at line 1628 of file tree_schema.h.

Data Fields
const char * name

node name (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags - only LYS_STATUS_* values are allowed

uint8_t ext_size

number of elements in ext array

uint8_t padding_iffsize

padding byte for the lys_node's iffeature_size

uint16_t unres_count

internal counter for unresolved uses, should be always 0 when the module is parsed

uint16_t tpdf_size

number of elements in tpdf array

struct lys_ext_instance ** ext

array of pointers to the extension instances

void * padding_iff

padding pointer for the lys_node's iffeature pointer

struct lys_module * module

pointer to the node's module (mandatory)

LYS_NODE nodetype

type of the node (mandatory) - LYS_GROUPING

struct lys_node * parent

pointer to the parent node, NULL in case of a top level node

struct lys_node * child

pointer to the first child node

struct lys_node * next

pointer to the next sibling node (NULL if there is no one)

struct lys_node * prev

pointer to the previous sibling node

Note
Note that this pointer is never NULL. If there is no sibling node, pointer points to the node itself. In case of the first node, this pointer points to the last node in the list.
void * priv

private caller's data, not used by libyang

struct lys_tpdf * tpdf

array of typedefs

struct lys_node_case

Schema case node structure.

Beginning of the structure is completely compatible with lys_node structure extending it by the when member.

The case schema node has no instance in the data tree, so the lys_node_case cannot be directly referenced from lyd_node::schema.

Definition at line 1667 of file tree_schema.h.

Data Fields
const char * name

node name (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint8_t padding[4]

padding for 32b alignment

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_module * module

pointer to the node's module (mandatory)

LYS_NODE nodetype

type of the node (mandatory) - LYS_CASE

struct lys_node * parent

pointer to the parent node, NULL in case of a top level node

struct lys_node * child

pointer to the first child node

struct lys_node * next

pointer to the next sibling node (NULL if there is no one)

struct lys_node * prev

pointer to the previous sibling node

Note
Note that this pointer is never NULL. If there is no sibling node, pointer points to the node itself. In case of the first node, this pointer points to the last node in the list.
void * priv

private caller's data, not used by libyang

struct lys_when * when

when statement (optional)

struct lys_node_inout

RPC input and output node structure.

The structure is compatible with lys_node, but the most parts are not usable. Therefore the lys_node::name, lys_node::dsc, lys_node::ref and lys_node::flags were replaced by empty bytes in fill arrays. The reason to keep these useless bytes in the structure is to keep the nodetype, parent, child, next and prev members accessible when functions are using the object via a generic lyd_node structure. But note that the lys_node::iffeature_size is replaced by the tpdf_size member and lys_node::iffeature is replaced by the tpdf member.

Note, that the inout nodes are always present in lys_node_rpc_action node as its input and output children nodes. If they are not specified explicitely in the schema, they are implicitly added to serve as possible target of augments. These implicit elements can be recognised via LYS_IMPLICIT bit in flags member of the input/output node.

Definition at line 1712 of file tree_schema.h.

Data Fields
const char * name
void * fill1[2]

padding for compatibility with lys_node - dsc and ref

uint16_t flags

schema node flags - only LYS_IMPLICIT is applicable

uint8_t ext_size

number of elements in ext array

uint8_t padding_iffsize

padding byte for the lys_node's iffeature_size

uint8_t padding[1]

padding for 32b alignment

uint8_t must_size

number of elements in the must array

uint16_t tpdf_size

number of elements in the tpdf array

struct lys_ext_instance ** ext

array of pointers to the extension instances

void * padding_iff

padding pointer for the lys_node's iffeature pointer

struct lys_module * module

link to the node's data model

LYS_NODE nodetype

type of the node (mandatory) - LYS_INPUT or LYS_OUTPUT

struct lys_node * parent

pointer to the parent rpc node

struct lys_node * child

pointer to the first child node

struct lys_node * next

pointer to the next sibling node (NULL if there is no one)

struct lys_node * prev

pointer to the previous sibling node

Note
Note that this pointer is never NULL. If there is no sibling node, pointer points to the node itself. In case of the first node, this pointer points to the last node in the list.
void * priv

private caller's data, not used by libyang

struct lys_tpdf * tpdf

array of typedefs

struct lys_restr * must

array of must constraints

struct lys_node_notif

Schema notification node structure.

Beginning of the structure is completely compatible with lys_node structure extending it by the tpdf_size and tpdf members.

Definition at line 1750 of file tree_schema.h.

Data Fields
const char * name

node name (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint8_t padding[1]

padding for 32b alignment

uint8_t must_size

number of elements in the must array

uint16_t tpdf_size

number of elements in the tpdf array

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_module * module

pointer to the node's module (mandatory)

LYS_NODE nodetype

type of the node (mandatory) - LYS_NOTIF

struct lys_node * parent

pointer to the parent node, NULL in case of a top level node

struct lys_node * child

pointer to the first child node

struct lys_node * next

pointer to the next sibling node (NULL if there is no one)

struct lys_node * prev

pointer to the previous sibling node

Note
Note that this pointer is never NULL. If there is no sibling node, pointer points to the node itself. In case of the first node, this pointer points to the last node in the list.
void * priv

private caller's data, not used by libyang

struct lys_tpdf * tpdf

array of typedefs

struct lys_restr * must

array of must constraints

struct lys_node_rpc_action

Schema rpc/action node structure.

Beginning of the structure is completely compatible with lys_node structure extending it by the tpdf_size and tpdf members.

Note, that the rpc/action node has always input and output children nodes. If they are not specified explicitly in the schema, they are implicitly added to server as possible target of augments. These implicit elements can be recognized via LYS_IMPLICIT bit in flags member of the input/output node.

Definition at line 1797 of file tree_schema.h.

Data Fields
const char * name

node name (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint8_t padding[2]

padding for 32b alignment

uint16_t tpdf_size

number of elements in the tpdf array

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_module * module

pointer to the node's module (mandatory)

LYS_NODE nodetype

type of the node (mandatory) - LYS_RPC or LYS_ACTION

struct lys_node * parent

pointer to the parent node, NULL in case of a top level node

struct lys_node * child

pointer to the first child node

struct lys_node * next

pointer to the next sibling node (NULL if there is no one)

struct lys_node * prev

pointer to the previous sibling node

Note
Note that this pointer is never NULL. If there is no sibling node, pointer points to the node itself. In case of the first node, this pointer points to the last node in the list.
void * priv

private caller's data, not used by libyang

struct lys_tpdf * tpdf

array of typedefs

struct lys_node_augment

YANG augment structure (covering both possibilities - uses's substatement as well as (sub)module's substatement).

This structure is partially interchangeable with lys_node structure with the following exceptions:

lys_node_augment is not placed between all other nodes defining data node. However, it must be compatible with lys_node structure since its children actually keeps the parent pointer to point to the original augment node instead of the target node they augments (the target node is accessible via the lys_node_augment::target pointer). The fact that a schema node comes from augment can be get via testing the nodetype of its parent - the value in lys_node_augment is LYS_AUGMENT.

Definition at line 1845 of file tree_schema.h.

Data Fields
const char * target_name

schema node identifier of the node where the augment content is supposed to be placed (mandatory).

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint8_t padding[4]

padding for 32b alignment

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_module * module

pointer to the node's module (mandatory)

LYS_NODE nodetype

LYS_AUGMENT

struct lys_node * parent

uses node or NULL in case of module's top level augment

struct lys_node * child

augmenting data

Note
The child here points to the data which are also placed as children in the target node. Children are connected within the child list of the target, but their parent member still points to the augment node (this way they can be distinguished from the original target's children). It is necessary to check this carefully.
struct lys_when * when

when statement (optional)

struct lys_node * target

pointer to the target node

void * priv

private caller's data, not used by libyang

struct lys_refine_mod_list

Container for list modifications in lys_refine_mod.

Definition at line 1880 of file tree_schema.h.

Data Fields
uint32_t min

new min-elements value. Applicable to LYS_LIST and LYS_LEAFLIST target nodes

uint32_t max

new max-elements value. Applicable to LYS_LIST and LYS_LEAFLIST target nodes

union lys_refine_mod

Union to hold target modification in lys_refine.

Definition at line 1888 of file tree_schema.h.

Data Fields
const char * presence

presence description. Applicable to LYS_CONTAINER target node

struct lys_refine_mod_list list

container for list's attributes, applicable to LYS_LIST and LYS_LEAFLIST target nodes

struct lys_refine

YANG uses's refine substatement structure, see RFC 6020 sec. 7.12.2

Definition at line 1897 of file tree_schema.h.

Data Fields
const char * target_name

descendant schema node identifier of the target node to be refined (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags - only config and mandatory flags apply

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint16_t target_type

limitations (get from specified refinements) for target node type:

  • 0 = no limitations,
  • ORed LYS_NODE values if there are some limitations
uint8_t must_size

number of elements in the must array

uint8_t dflt_size

number of elements in the dflt array

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_module * module

pointer to the node's module (mandatory)

struct lys_restr * must

array of additional must restrictions to be added to the target

const char ** dflt

array of new default values. Applicable to LYS_LEAF, LYS_LEAFLIST and LYS_CHOICE target nodes, but multiple defaults are valid only in case of LYS_LEAFLIST.

union lys_refine_mod mod

mutually exclusive target modifications according to the possible target_type

struct lys_deviate

YANG deviate statement structure, see RFC 6020 sec. 7.18.3.2

Definition at line 1938 of file tree_schema.h.

Data Fields
LYS_DEVIATE_TYPE mod

type of deviation modification

uint8_t flags

Properties: config, mandatory

uint8_t dflt_size

Properties: default - number of elements in the dflt array

uint8_t ext_size

number of elements in ext array

uint8_t min_set

Since min can be 0, this flag says if it is default value or 0 was set

uint8_t max_set

Since max can be 0, this flag says if it is default value or 0 (unbounded) was set

uint8_t must_size

Properties: must - number of elements in the must array

uint8_t unique_size

Properties: unique - number of elements in the unique array

uint32_t min

Properties: min-elements

uint32_t max

Properties: max-elements

struct lys_restr * must

Properties: must - array of must constraints

struct lys_unique * unique

Properties: unique - array of unique statement structures

struct lys_type * type

Properties: type - pointer to type in target, type cannot be deleted or added

const char * units

Properties: units

const char ** dflt

Properties: default (both type and choice represented as string value; for deviating leaf-list we need it as an array

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_deviation

YANG deviation statement structure, see RFC 6020 sec. 7.18.3

Definition at line 1965 of file tree_schema.h.

Data Fields
const char * target_name

schema node identifier of the node where the deviation is supposed to be applied (mandatory).

const char * dsc

description (optional)

const char * ref

reference (optional)

struct lys_node * orig_node

original (non-deviated) node (mandatory)

uint8_t deviate_size

number of elements in the deviate array

uint8_t ext_size

number of elements in ext array

struct lys_deviate * deviate

deviate information

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_import

YANG import structure used to reference other schemas (modules).

Definition at line 1981 of file tree_schema.h.

Data Fields
struct lys_module * module

link to the imported module (mandatory)

const char * prefix

prefix for the data from the imported schema (mandatory)

char rev[11]

revision-date of the imported module (optional)

uint8_t ext_size

number of elements in ext array

struct lys_ext_instance ** ext

array of pointers to the extension instances

const char * dsc

description (optional)

const char * ref

reference (optional)

struct lys_include

YANG include structure used to reference submodules.

Definition at line 1994 of file tree_schema.h.

Data Fields
struct lys_submodule * submodule

link to the included submodule (mandatory)

char rev[11]

revision-date of the included submodule (optional)

uint8_t ext_size

number of elements in ext array

struct lys_ext_instance ** ext

array of pointers to the extension instances

const char * dsc

description (optional)

const char * ref

reference (optional)

struct lys_revision

YANG revision statement for (sub)modules.

Definition at line 2006 of file tree_schema.h.

Data Fields
char date[11]

revision-date (mandatory)

uint8_t ext_size

number of elements in ext array

struct lys_ext_instance ** ext

array of pointers to the extension instances

const char * dsc

revision's dsc (optional)

const char * ref

revision's reference (optional)

struct lys_tpdf

YANG typedef structure providing information from the schema.

Definition at line 2017 of file tree_schema.h.

Data Fields
const char * name

name of the newly defined type (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags - only LYS_STATUS_ and LYS_DFLTJSON values (or 0) are allowed

uint8_t ext_size

number of elements in ext array

uint8_t padding_iffsize

padding byte for the lys_node's iffeature_size

uint8_t has_union_leafref

flag to mark typedefs with a leafref inside a union

uint8_t padding[3]

padding for 32b alignment

struct lys_ext_instance ** ext

array of pointers to the extension instances

const char * units

units of the newly defined type (optional)

struct lys_module * module

pointer to the module where the data type is defined (mandatory), NULL in case of built-in typedefs

struct lys_type type

base type from which the typedef is derived (mandatory). In case of a special built-in typedef (from yang_types.c), only the base member is filled

const char * dflt

default value of the newly defined type (optional)

struct lys_unique

YANG list's unique statement structure, see RFC 6020 sec. 7.8.3

Definition at line 2042 of file tree_schema.h.

Data Fields
const char ** expr

array of unique expressions specifying target leafs to be unique

uint8_t expr_size

size of the expr array

uint8_t trg_type

config of the targets: 0 - not specified; 1 - config true; 2 - config false

struct lys_feature

YANG feature definition structure.

Definition at line 2051 of file tree_schema.h.

Data Fields
const char * name

feature name (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags - only LYS_STATUS_* values and LYS_FENABLED value are allowed

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint8_t padding[4]

padding for 32b alignment

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_module * module

link to the features's data model (mandatory)

struct ly_set * depfeatures

set of other features depending on this one

struct lys_restr

YANG validity restriction (must, length, etc.) structure providing information from the schema.

Definition at line 2072 of file tree_schema.h.

Data Fields
const char * expr

The restriction expression/value (mandatory); in case of pattern restriction, the first byte has a special meaning: 0x06 (ACK) for regular match and 0x15 (NACK) for invert-match

const char * dsc

description (optional)

const char * ref

reference (optional)

const char * eapptag

error-app-tag value (optional)

const char * emsg

error-message (optional)

struct lys_ext_instance ** ext

array of pointers to the extension instances

uint8_t ext_size

number of elements in ext array

uint16_t flags

only flags LYS_XPCONF_DEP and LYS_XPSTATE_DEP can be specified

struct lys_when

YANG when restriction, see RFC 6020 sec. 7.19.5

Definition at line 2088 of file tree_schema.h.

Data Fields
const char * cond

specified condition (mandatory)

const char * dsc

description (optional)

const char * ref

reference (optional)

struct lys_ext_instance ** ext

array of pointers to the extension instances

uint8_t ext_size

number of elements in ext array

uint16_t flags

only flags LYS_XPCONF_DEP and LYS_XPSTATE_DEP can be specified

struct lys_ident

Structure to hold information about identity, see RFC 6020 sec. 7.16

First 5 members maps to lys_node.

Definition at line 2102 of file tree_schema.h.

Data Fields
const char * name

identity name (mandatory)

const char * dsc

description statement (optional)

const char * ref

reference statement (optional)

uint16_t flags

schema node flags - only LYS_STATUS_ values are allowed

uint8_t ext_size

number of elements in ext array

uint8_t iffeature_size

number of elements in the iffeature array

uint8_t padding[3]

padding for 32b alignment

uint8_t base_size

number of elements in the base array

struct lys_ext_instance ** ext

array of pointers to the extension instances

struct lys_iffeature * iffeature

array of if-feature expressions

struct lys_module * module

pointer to the module where the identity is defined

struct lys_ident ** base

array of pointers to the base identities

struct ly_set * der

set of backlinks to the derived identities

Macro Definition Documentation

#define LY_ARRAY_MAX (   var)    (sizeof(var) == 8 ? ULLONG_MAX : ((1ULL << (sizeof(var) * 8)) - 1))

maximal index the size_var is able to hold

Definition at line 180 of file tree_schema.h.

#define LY_REV_SIZE   11

revision data string length (including terminating NULL byte)

Definition at line 182 of file tree_schema.h.

#define LYS_YANG   1

YANG schema format, used for LYS_INFORMAT and LYS_OUTFORMAT

Definition at line 221 of file tree_schema.h.

#define LYS_YIN   2

YIN schema format, used for LYS_INFORMAT and LYS_OUTFORMAT

Definition at line 222 of file tree_schema.h.

#define LYS_NO_RPC_NOTIF_NODE   0x807F

Definition at line 251 of file tree_schema.h.

#define LYS_ANY   0xFFFF

Definition at line 253 of file tree_schema.h.

#define LY_DATA_TYPE_COUNT   20

Number of different types

Definition at line 814 of file tree_schema.h.

#define LYS_IFF_NOT   0x00

Definition at line 1069 of file tree_schema.h.

#define LYS_IFF_AND   0x01

Definition at line 1070 of file tree_schema.h.

#define LYS_IFF_OR   0x02

Definition at line 1071 of file tree_schema.h.

#define LYS_IFF_F   0x03

Definition at line 1072 of file tree_schema.h.

#define LYS_GETNEXT_WITHCHOICE   0x01

lys_getnext() option to allow returning LYS_CHOICE nodes instead of looking into them

Definition at line 2300 of file tree_schema.h.

#define LYS_GETNEXT_WITHCASE   0x02

lys_getnext() option to allow returning LYS_CASE nodes instead of looking into them

Definition at line 2301 of file tree_schema.h.

#define LYS_GETNEXT_WITHGROUPING   0x04

lys_getnext() option to allow returning LYS_GROUPING nodes instead of skipping them

Definition at line 2302 of file tree_schema.h.

#define LYS_GETNEXT_WITHINOUT   0x08

lys_getnext() option to allow returning LYS_INPUT and LYS_OUTPUT nodes instead of looking into them

Definition at line 2303 of file tree_schema.h.

#define LYS_GETNEXT_WITHUSES   0x10

lys_getnext() option to allow returning LYS_USES nodes instead of looking into them

Definition at line 2306 of file tree_schema.h.

#define LYS_GETNEXT_INTOUSES   0x20

lys_getnext() option to allow to go into uses, takes effect only with LYS_GETNEXT_WITHUSES, otherwise it goes into uses automatically

Definition at line 2307 of file tree_schema.h.

#define LYS_GETNEXT_INTONPCONT   0x40

lys_getnext() option to look into non-presence container, instead of returning container itself

Definition at line 2310 of file tree_schema.h.

#define LYS_GETNEXT_PARENTUSES   0x80

lys_getnext() option to allow parent to be LYS_USES, in which case only the direct children are traversed

Definition at line 2311 of file tree_schema.h.

#define LYS_GETNEXT_NOSTATECHECK   0x100

lys_getnext() option to skip checking module validity (import-only, disabled) and relevant if-feature conditions state

Definition at line 2314 of file tree_schema.h.

#define LYXP_MUST   0x01

lys_xpath_atomize() option to apply must statement data tree access restrictions

Definition at line 2372 of file tree_schema.h.

#define LYXP_WHEN   0x02

lys_xpath_atomize() option to apply when statement data tree access restrictions

Definition at line 2373 of file tree_schema.h.

#define LYXP_RECURSIVE   0x01

lys_node_xpath_atomize() option to return schema node dependencies of all the expressions in the subtree

Definition at line 2384 of file tree_schema.h.

#define LYXP_NO_LOCAL   0x02

lys_node_xpath_atomize() option to discard schema node dependencies from the local subtree

Definition at line 2385 of file tree_schema.h.

#define LYS_PATH_FIRST_PREFIX   0x01

lys_path() option for the path not to include prefixes of all the nodes, but only for the first one that will be interpreted as the current module (more at howtoxpath). This path is less suitable for further processing but better for displaying as it is shorter.

Definition at line 2400 of file tree_schema.h.

Typedef Documentation

typedef enum lys_nodetype LYS_NODE

YANG schema node types.

Values are defined as separated bit values to allow checking using bitwise operations for multiple nodes.

typedef enum LYS_VERSION LYS_VERSION

supported YANG schema version values

Possible deviation modifications, see RFC 6020 sec. 7.18.3.2

Enumeration Type Documentation

Schema input formats accepted by libyang parser functions.

Enumerator
LYS_IN_UNKNOWN 

unknown format, used as return value in case of error

LYS_IN_YANG 

YANG schema input format

LYS_IN_YIN 

YIN schema input format

Definition at line 187 of file tree_schema.h.

Schema output formats accepted by libyang printer functions.

Enumerator
LYS_OUT_UNKNOWN 

unknown format, used as return value in case of error

LYS_OUT_YANG 

YANG schema output format

LYS_OUT_YIN 

YIN schema output format

LYS_OUT_TREE 

Tree schema output format, for more information see the printers page

LYS_OUT_INFO 

Info schema output format, for more information see the printers page

LYS_OUT_JSON 

JSON schema output format, reflecting YIN format with conversion of attributes to object's members

Definition at line 196 of file tree_schema.h.

YANG schema node types.

Values are defined as separated bit values to allow checking using bitwise operations for multiple nodes.

Enumerator
LYS_UNKNOWN 

uninitialized unknown statement node

LYS_CONTAINER 

container statement node

LYS_CHOICE 

choice statement node

LYS_LEAF 

leaf statement node

LYS_LEAFLIST 

leaf-list statement node

LYS_LIST 

list statement node

LYS_ANYXML 

anyxml statement node

LYS_CASE 

case statement node

LYS_NOTIF 

notification statement node

LYS_RPC 

rpc statement node

LYS_INPUT 

input statement node

LYS_OUTPUT 

output statement node

LYS_GROUPING 

grouping statement node

LYS_USES 

uses statement node

LYS_AUGMENT 

augment statement node

LYS_ACTION 

action statement node

LYS_ANYDATA 

anydata statement node, in tests it can be used for both LYS_ANYXML and LYS_ANYDATA

LYS_EXT 

complex extension instance, lys_ext_instance_complex

Definition at line 229 of file tree_schema.h.

supported YANG schema version values

Enumerator
LYS_VERSION_UNDEF 

no specific version, YANG 1.0 as default

LYS_VERSION_1 

YANG 1.0

LYS_VERSION_1_1 

YANG 1.1

Definition at line 660 of file tree_schema.h.

YANG built-in types.

Enumerator
LY_TYPE_DER 

Derived type

LY_TYPE_BINARY 

Any binary data (RFC 6020 sec 9.8)

LY_TYPE_BITS 

A set of bits or flags (RFC 6020 sec 9.7)

LY_TYPE_BOOL 

"true" or "false" (RFC 6020 sec 9.5)

LY_TYPE_DEC64 

64-bit signed decimal number (RFC 6020 sec 9.3)

LY_TYPE_EMPTY 

A leaf that does not have any value (RFC 6020 sec 9.11)

LY_TYPE_ENUM 

Enumerated strings (RFC 6020 sec 9.6)

LY_TYPE_IDENT 

A reference to an abstract identity (RFC 6020 sec 9.10)

LY_TYPE_INST 

References a data tree node (RFC 6020 sec 9.13)

LY_TYPE_LEAFREF 

A reference to a leaf instance (RFC 6020 sec 9.9)

LY_TYPE_STRING 

Human-readable string (RFC 6020 sec 9.4)

LY_TYPE_UNION 

Choice of member types (RFC 6020 sec 9.12)

LY_TYPE_INT8 

8-bit signed integer (RFC 6020 sec 9.2)

LY_TYPE_UINT8 

8-bit unsigned integer (RFC 6020 sec 9.2)

LY_TYPE_INT16 

16-bit signed integer (RFC 6020 sec 9.2)

LY_TYPE_UINT16 

16-bit unsigned integer (RFC 6020 sec 9.2)

LY_TYPE_INT32 

32-bit signed integer (RFC 6020 sec 9.2)

LY_TYPE_UINT32 

32-bit unsigned integer (RFC 6020 sec 9.2)

LY_TYPE_INT64 

64-bit signed integer (RFC 6020 sec 9.2)

LY_TYPE_UINT64 

64-bit unsigned integer (RFC 6020 sec 9.2)

LY_TYPE_UNKNOWN 

Unknown type (used in edit-config leaves)

Definition at line 791 of file tree_schema.h.

Possible deviation modifications, see RFC 6020 sec. 7.18.3.2

Enumerator
LY_DEVIATE_NO 

not-supported

LY_DEVIATE_ADD 

add

LY_DEVIATE_RPL 

replace

LY_DEVIATE_DEL 

delete

Definition at line 1928 of file tree_schema.h.

Types of context nodes, LYXP_NODE_ROOT_CONFIG used only in when or must conditions.

Enumerator
LYXP_NODE_ROOT 
LYXP_NODE_ROOT_CONFIG 
LYXP_NODE_ELEM 
LYXP_NODE_TEXT 
LYXP_NODE_ATTR 
LYXP_NODE_NONE 

Definition at line 2343 of file tree_schema.h.

Function Documentation

struct lys_module* lys_parse_mem ( struct ly_ctx *  ctx,
const char *  data,
LYS_INFORMAT  format 
)

Load a schema into the specified context.

Parameters
[in]ctxlibyang context where to process the data model.
[in]dataThe string containing the dumped data model in the specified format.
[in]formatFormat of the input data (YANG or YIN).
Returns
Pointer to the data model structure or NULL on error.
struct lys_module* lys_parse_fd ( struct ly_ctx *  ctx,
int  fd,
LYS_INFORMAT  format 
)

Read a schema from file descriptor into the specified context.

Note
Current implementation supports only reading data from standard (disk) file, not from sockets, pipes, etc.
Parameters
[in]ctxlibyang context where to process the data model.
[in]fdFile descriptor of a regular file (e.g. sockets are not supported) containing the schema in the specified format.
[in]formatFormat of the input data (YANG or YIN).
Returns
Pointer to the data model structure or NULL on error.
struct lys_module* lys_parse_path ( struct ly_ctx *  ctx,
const char *  path,
LYS_INFORMAT  format 
)

Load a schema into the specified context from a file.

Parameters
[in]ctxlibyang context where to process the data model.
[in]pathPath to the file with the model in the specified format.
[in]formatFormat of the input data (YANG or YIN).
Returns
Pointer to the data model structure or NULL on error.
int lys_search_localfile ( const char *const *  searchpaths,
int  cwd,
const char *  name,
const char *  revision,
char **  localfile,
LYS_INFORMAT format 
)

Search for the schema file in the specified searchpaths.

Parameters
[in]searchpathsNULL-terminated array of paths to be searched (recursively). Current working directory is searched automatically (but non-recursively if not in the provided list). Caller can use result of the ly_ctx_get_searchdirs().
[in]cwdFlag to implicitly search also in the current working directory (non-recursively).
[in]nameName of the schema to find.
[in]revisionRevision of the schema to find. If NULL, the newest found schema filepath is returned.
[out]localfileMandatory output variable containing absolute path of the found schema. If no schema complying the provided restriction is found, NULL is set.
[out]formatOptional output variable containing expected format of the schema document according to the file suffix.
Returns
EXIT_FAILURE on error, EXIT_SUCCESS otherwise (even if the file is not found, then the *localfile is NULL).
const char** lys_features_list ( const struct lys_module module,
uint8_t **  states 
)

Get list of all the defined features in the module and its submodules.

Parameters
[in]moduleModule to explore.
[out]statesOptional output parameter providing states of all features returned by function in the resulting array. Indexes in both arrays corresponds each other. Similarly to lys_feature_state(), possible values in the state array are 1 (enabled) and 0 (disabled). Caller is supposed to free the array when it is no more needed.
Returns
NULL-terminated array of all the defined features. The returned array must be freed by the caller, do not free names in the array. Also remember that the names will be freed with freeing the context of the module.
int lys_features_enable ( const struct lys_module module,
const char *  feature 
)

Enable specified feature in the module. In case its if-feature evaluates to false, return an error.

By default, when the module is loaded by libyang parser, all features are disabled.

Parameters
[in]moduleModule where the feature will be enabled.
[in]featureName of the feature to enable. To enable all features at once, use asterisk character.
Returns
0 on success, 1 when the feature is not defined in the specified module
int lys_features_disable ( const struct lys_module module,
const char *  feature 
)

Disable specified feature in the module. If it causes some dependant features to be disabled, they are also set to disabled.

By default, when the module is loaded by libyang parser, all features are disabled.

Parameters
[in]moduleModule where the feature will be disabled.
[in]featureName of the feature to disable. To disable all features at once, use asterisk character.
Returns
0 on success, 1 when the feature is not defined in the specified module
int lys_features_enable_force ( const struct lys_module module,
const char *  feature 
)

Enable specified feature in the module disregarding its if-features.

Parameters
[in]moduleModule where the feature will be enabled.
[in]featureName of the feature to enable. To enable all features at once, use asterisk character.
Returns
0 on success, 1 when the feature is not defined in the specified module
int lys_features_disable_force ( const struct lys_module module,
const char *  feature 
)

Disable specified feature in the module disregarding dependant features.

By default, when the module is loaded by libyang parser, all features are disabled.

Parameters
[in]moduleModule where the feature will be disabled.
[in]featureName of the feature to disable. To disable all features at once, use asterisk character.
Returns
0 on success, 1 when the feature is not defined in the specified module
int lys_features_state ( const struct lys_module module,
const char *  feature 
)

Get the current status of the specified feature in the module. Even if the feature is enabled but some of its if-features evaluate to false, it is reported as disabled.

Parameters
[in]moduleModule where the feature is defined.
[in]featureName of the feature to inspect.
Returns
  • 1 if feature is enabled,
  • 0 if feature is disabled,
  • -1 in case of error (e.g. feature is not defined)
struct lys_node* lys_is_disabled ( const struct lys_node node,
int  recursive 
)

Check if the schema node is disabled in the schema tree, i.e. there is any disabled if-feature statement affecting the node.

Parameters
[in]nodeSchema node to check.
[in]recursive- 0 to check if-feature only in the node schema node,
  • 1 to check if-feature in all ascendant schema nodes
  • 2 to check if-feature in all ascendant schema nodes until there is a node possibly having an instance in a data tree
Returns
- NULL if enabled,
  • pointer to the node with the unsatisfied (disabling) if-feature expression.
int lys_iffeature_value ( const struct lys_iffeature iff)

Learn how the if-feature statement currently evaluates.

Parameters
[in]iffif-feature statement to evaluate.
Returns
If the statement evaluates to true, 1 is returned. 0 is returned when the statement evaluates to false.
struct lys_node_list* lys_is_key ( const struct lys_node_leaf node,
uint8_t *  index 
)

Check if the schema leaf node is used as a key for a list.

Parameters
[in]nodeSchema leaf node to check
[out]indexOptional parameter to return position in the list's keys array.
Returns
NULL if the node is not a key, pointer to the list if the node is the key of this list
struct lys_node* lys_getnext ( const struct lys_node last,
const struct lys_node parent,
const struct lys_module module,
int  options 
)

Get next schema tree (sibling) node element that can be instantiated in a data tree. Returned node can be from an augment.

lys_getnext() is supposed to be called sequentially. In the first call, the last parameter is usually NULL and function starts returning i) the first parent child or ii) the first top level element of the module. Consequent calls suppose to provide the previously returned node as the last parameter and still the same parent and module parameters.

Without options, the function is used to traverse only the schema nodes that can be paired with corresponding data nodes in a data tree. By setting some options the behaviour can be modified to the extent that all the schema nodes are iteratively returned.

Parameters
[in]lastPreviously returned schema tree node, or NULL in case of the first call.
[in]parentParent of the subtree where the function starts processing (cannot be LYS_USES, use its parent). If it is LYS_AUGMENT, only the children of that augment are returned.
[in]moduleIn case of iterating on top level elements, the parent is NULL and module must be specified (cannot be submodule).
[in]optionsORed options LYS_GETNEXT_*.
Returns
Next schema tree node that can be instanciated in a data tree, NULL in case there is no such element.
struct lys_type* lys_getnext_union_type ( const struct lys_type last,
const struct lys_type type 
)

Get next type of a union.

Parameters
[in]lastLast returned type. NULL on first call.
[in]typeUnion type structure.
Returns
Next union type in order, NULL if all were returned or on error.
struct ly_set* lys_find_path ( const struct lys_module cur_module,
const struct lys_node cur_node,
const char *  path 
)

Search for schema nodes matching the provided path.

Learn more about the path format at page howtoxpath. Either cur_module or cur_node must be set.

Parameters
[in]cur_moduleCurrent module name.
[in]cur_nodeCurrent (context) schema node.
[in]pathSchema path expression filtering the matching nodes.
Returns
Set of found schema nodes. In case of an error, NULL is returned.
struct ly_set* lys_xpath_atomize ( const struct lys_node ctx_node,
enum lyxp_node_type  ctx_node_type,
const char *  expr,
int  options 
)

Get all the partial XPath nodes (atoms) that are required for expr to be evaluated.

Parameters
[in]ctx_nodeContext (current) schema node. Fake roots are distinguished using ctx_node_type and then this node can be any node from the module (so, for example, do not put node added by an augment from another module).
[in]ctx_node_typeContext (current) schema node type. Most commonly is LYXP_NODE_ELEM, but if your context node is supposed to be the root, you can specify what kind of root it is.
[in]exprXPath expression to be evaluated. Must be in JSON data format (prefixes are model names). Otherwise follows full must or when YANG expression syntax (see schema path howtoxpath, but is not limited to that).
[in]optionsWhether to apply some evaluation restrictions LYXP_MUST or LYXP_WHEN.
Returns
Set of atoms (schema nodes), NULL on error.
struct ly_set* lys_node_xpath_atomize ( const struct lys_node node,
int  options 
)

Call lys_xpath_atomize() on all the when and must expressions of the node. This node must be a descendant of an input, output, or notification node. This subtree then forms the local subtree.

Parameters
[in]nodeNode to examine.
[in]optionsBitmask of LYXP_RECURSIVE and LYXP_NO_LOCAL.
char* lys_path ( const struct lys_node node,
int  options 
)

Build schema path (usable as path, see howtoxpath) of the schema node.

The path includes prefixes of all the nodes and is hence unequivocal in any context. Options can be specified to use a different format of the path.

Parameters
[in]nodeSchema node to be processed.
[in]optionsAdditional path modification options (LYS_PATH_FIRST_PREFIX).
Returns
NULL on error, on success the buffer for the resulting path is allocated and caller is supposed to free it with free().
char* lys_data_path ( const struct lys_node node)

Build data path (usable as path, see howtoxpath) of the schema node.

Parameters
[in]nodeSchema node to be processed.
Returns
NULL on error, on success the buffer for the resulting path is allocated and caller is supposed to free it with free().
char* lys_data_path_pattern ( const struct lys_node node,
const char *  placeholder 
)

Build the data path pattern of a schema node.

For example, when node is a leaf in a list with key1 and key2, in a container and `'s'is set as @p placeholder, the result would be/model:container/list[key1='s'][key2='s']/leaf. That can be used asprintf(3)` format string, for example.

Parameters
[in]nodeSchema node to be processed.
[in]placeholderPlaceholder to insert in the returned path when list key values are encountered.
Returns
NULL on error, on success the buffer for the resulting path is allocated and caller is supposed to free it with free().
struct lys_node* lys_parent ( const struct lys_node node)

Return parent node in the schema tree.

In case of augmenting node, it returns the target tree node where the augmenting node was placed, not the augment definition node. Function just wraps usage of the lys_node::parent pointer in this special case.

Parameters
[in]nodeChild node to the returned parent node.
Returns
The parent node from the schema tree, NULL in case of top level nodes.
struct lys_module* lys_node_module ( const struct lys_node node)

Return main module of the schema tree node.

In case of regular YANG module, it returns lys_node::module pointer, but in case of submodule, it returns pointer to the main module.

Parameters
[in]nodeSchema tree node to be examined
Returns
pointer to the main module (schema structure), NULL in case of error.
struct lys_module* lys_main_module ( const struct lys_module module)

Return main module of the module.

In case of regular YANG module, it returns itself, but in case of submodule, it returns pointer to the main module.

Parameters
[in]moduleModule to be examined
Returns
pointer to the main module (schema structure).
struct lys_module* lys_implemented_module ( const struct lys_module mod)

Find the implemented revision of the given module in the context.

If there is no revision of the module implemented, the given module is returned without any change. It is up to the caller to set the module implemented via lys_set_implemented() when needed.

Also note that the result can be a disabled module and the caller is supposed to decide if it should by enabled via lys_set_enabled(). This is to avoid to try to set another revision of the module implemented that would fail due to the disabled, but the implemented module.

Parameters
[in]modModule to be searched.
Returns
The implemented revision of the module if any, the given module otherwise.
int lys_set_implemented ( const struct lys_module module)

Mark imported module as "implemented".

All the modules explicitly loaded are marked as "implemented", but in case of loading module automatically as an import of another module, it is marked as imported and in that case it is not allowed to load data of this module. On the other hand, the mandatory data nodes of such a module are not required nor the (top-level) default nodes defined in this module are created in the data trees.

When a module is marked as "implemented" it is not allowed to set it back to "imported".

Note that it is not possible to mark "implemented" multiple revisions of a same module within a single context. In such a case the function fails.

If the module is currently disabled, this function enables the module implicitly.

Parameters
[in]moduleThe module to be set implemented.
Returns
EXIT_SUCCESS or EXIT_FAILURE
int lys_set_disabled ( const struct lys_module module)

Disable module in its context to avoid its further usage (it will be hidden for module getters).

The function also disables all the modules in the context that depends on the provided module to disable. If the imported modules are not used by any other module in the context, they are also disabled. The result of this function can be reverted by lys_set_enabled() function.

Since the disabled modules are hidden from the common module getters, there is a special ly_ctx_get_disabled_module_iter() to go through the disabled modules in the context.

libyang internal modules (those present when the context is created) cannot be disabled. Any module loaded into the context is, by default, enabled.

Parameters
[in]moduleModule to be enabled.
Returns
EXIT_SUCCESS or EXIT_FAILURE (in case of invalid parameter).
int lys_set_enabled ( const struct lys_module module)

Enable previously disabled module.

The function tries to revert previous call of the lys_set_disabled() so it checks other disabled modules in the context depending on the specified module and if it is possible, also the other modules are going to be enabled. Similarly, all the imported modules that were previously supposed as useless are enabled.

libyang internal modules (those present when the context is created) are always enabled. Any other module loaded into the context is, by default, enabled.

Parameters
[in]moduleModule to be enabled.
Returns
EXIT_SUCCESS or EXIT_FAILURE (in case of invalid parameter).
void* lys_set_private ( const struct lys_node node,
void *  priv 
)

Set a schema private pointer to a user pointer.

Parameters
[in]nodeNode, whose private field will be assigned.
[in]privArbitrary user-specified pointer.
Returns
previous private object of the node (NULL if this is the first call on the node). Note, that the caller is in this case responsible (if it is necessary) for freeing the replaced private object. In case of invalid (NULL) node, NULL is returned and #ly_errno is set to #LY_EINVAL.
int lys_print_mem ( char **  strp,
const struct lys_module module,
LYS_OUTFORMAT  format,
const char *  target_node,
int  line_length,
int  options 
)

Print schema tree in the specified format into a memory block. It is up to caller to free the returned string by free().

Parameters
[out]strpPointer to store the resulting dump.
[in]moduleSchema tree to print.
[in]formatSchema output format.
[in]target_nodeOptional parameter. It specifies which particular node/subtree in the module will be printed. Only for LYS_OUT_INFO and LYS_OUT_TREE formats. Use fully qualified schema path (howtoxpath).
[in]line_lengthMaximum characters to be printed on a line, 0 for unlimited. Only for LYS_OUT_TREE printer.
[in]optionsSchema output options (see Schema printer flags).
Returns
0 on success, 1 on failure (#ly_errno is set).
int lys_print_fd ( int  fd,
const struct lys_module module,
LYS_OUTFORMAT  format,
const char *  target_node,
int  line_length,
int  options 
)

Print schema tree in the specified format into a file descriptor.

Parameters
[in]moduleSchema tree to print.
[in]fdFile descriptor where to print the data.
[in]formatSchema output format.
[in]target_nodeOptional parameter. It specifies which particular node/subtree in the module will be printed. Only for LYS_OUT_INFO and LYS_OUT_TREE formats. Use fully qualified schema path (howtoxpath).
[in]line_lengthMaximum characters to be printed on a line, 0 for unlimited. Only for LYS_OUT_TREE format.
[in]optionsSchema output options (see Schema printer flags).
Returns
0 on success, 1 on failure (#ly_errno is set).
int lys_print_file ( FILE *  f,
const struct lys_module module,
LYS_OUTFORMAT  format,
const char *  target_node,
int  line_length,
int  options 
)

Print schema tree in the specified format into a file stream.

Parameters
[in]moduleSchema tree to print.
[in]fFile stream where to print the schema.
[in]formatSchema output format.
[in]target_nodeOptional parameter. It specifies which particular node/subtree in the module will be printed. Only for LYS_OUT_INFO and LYS_OUT_TREE formats. Use fully qualified schema path (howtoxpath).
[in]line_lengthMaximum characters to be printed on a line, 0 for unlimited. Only for LYS_OUT_TREE printer.
[in]optionsSchema output options (see Schema printer flags).
Returns
0 on success, 1 on failure (#ly_errno is set).
int lys_print_path ( const char *  path,
const struct lys_module module,
LYS_OUTFORMAT  format,
const char *  target_node,
int  line_length,
int  options 
)

Print schema tree in the specified format into a file.

Parameters
[in]pathFile where to print the schema.
[in]moduleSchema tree to print.
[in]formatSchema output format.
[in]target_nodeOptional parameter. It specifies which particular node/subtree in the module will be printed. Only for LYS_OUT_INFO and LYS_OUT_TREE formats. Use fully qualified schema path (howtoxpath).
[in]line_lengthMaximum characters to be printed on a line, 0 for unlimited. Only for LYS_OUT_TREE printer.
[in]optionsSchema output options (see Schema printer flags).
Returns
0 on success, 1 on failure (#ly_errno is set).
int lys_print_clb ( ssize_t(*)(void *arg, const void *buf, size_t count)  writeclb,
void *  arg,
const struct lys_module module,
LYS_OUTFORMAT  format,
const char *  target_node,
int  line_length,
int  options 
)

Print schema tree in the specified format using a provided callback.

Parameters
[in]moduleSchema tree to print.
[in]writeclbCallback function to write the data (see write(1)).
[in]argOptional caller-specific argument to be passed to the writeclb callback.
[in]formatSchema output format.
[in]target_nodeOptional parameter. It specifies which particular node/subtree in the module will be printed. Only for LYS_OUT_INFO and LYS_OUT_TREE formats. Use fully qualified schema path (howtoxpath).
[in]line_lengthMaximum characters to be printed on a line, 0 for unlimited. Only for LYS_OUT_TREE printer.
[in]optionsSchema output options (see Schema printer flags).
Returns
0 on success, 1 on failure (#ly_errno is set).