libyang  1.0.101
YANG data modeling language library
tree_schema.h
Go to the documentation of this file.
1 
15 #ifndef LY_TREE_SCHEMA_H_
16 #define LY_TREE_SCHEMA_H_
17 
18 #ifdef __APPLE__
19  #include <machine/endian.h>
20 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
21  #include <sys/endian.h>
22 #else
23  #include <endian.h>
24 #endif
25 
26 #include <limits.h>
27 #include <stddef.h>
28 #include <stdint.h>
29 #include <stdio.h>
30 #include <sys/types.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
48 #define LY_TREE_FOR(START, ELEM) \
49  for ((ELEM) = (START); \
50  (ELEM); \
51  (ELEM) = (ELEM)->next)
52 
66 #define LY_TREE_FOR_SAFE(START, NEXT, ELEM) \
67  for ((ELEM) = (START); \
68  (ELEM) ? (NEXT = (ELEM)->next, 1) : 0; \
69  (ELEM) = (NEXT))
70 
98 #define LY_TREE_DFS_BEGIN(START, NEXT, ELEM) \
99  for ((ELEM) = (NEXT) = (START); \
100  (ELEM); \
101  (ELEM) = (NEXT))
102 
122 #ifdef __cplusplus
123 #define TYPES_COMPATIBLE(type1, type2) typeid(*(type1)) == typeid(type2)
124 #elif defined(__GNUC__) || defined(__clang__)
125 #define TYPES_COMPATIBLE(type1, type2) __builtin_types_compatible_p(__typeof__(*(type1)), type2)
126 #else
127 #define TYPES_COMPATIBLE(type1, type2) _Generic(*(type1), type2: 1, default: 0)
128 #endif
129 
130 #define LY_TREE_DFS_END(START, NEXT, ELEM) \
131  /* select element for the next run - children first */ \
132  if (TYPES_COMPATIBLE(ELEM, struct lyd_node)) { \
133  /* child exception for leafs, leaflists and anyxml without children */\
134  if (((struct lyd_node *)(ELEM))->schema->nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_ANYDATA)) { \
135  (NEXT) = NULL; \
136  } else { \
137  (NEXT) = (ELEM)->child; \
138  } \
139  } else if (TYPES_COMPATIBLE(ELEM, struct lys_node)) { \
140  /* child exception for leafs, leaflists and anyxml without children */\
141  if (((struct lys_node *)(ELEM))->nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_ANYDATA)) { \
142  (NEXT) = NULL; \
143  } else { \
144  (NEXT) = (ELEM)->child; \
145  } \
146  } else { \
147  (NEXT) = (ELEM)->child; \
148  } \
149  \
150  if (!(NEXT)) { \
151  /* no children */ \
152  if ((ELEM) == (START)) { \
153  /* we are done, (START) has no children */ \
154  break; \
155  } \
156  /* try siblings */ \
157  (NEXT) = (ELEM)->next; \
158  } \
159  while (!(NEXT)) { \
160  /* parent is already processed, go to its sibling */ \
161  if (TYPES_COMPATIBLE(ELEM, struct lys_node) \
162  && (((struct lys_node *)(ELEM)->parent)->nodetype == LYS_AUGMENT)) { \
163  (ELEM) = (ELEM)->parent->prev; \
164  } else { \
165  (ELEM) = (ELEM)->parent; \
166  } \
167  /* no siblings, go back through parents */ \
168  if (TYPES_COMPATIBLE(ELEM, struct lys_node)) { \
169  /* due to possible augments */ \
170  if (lys_parent((struct lys_node *)(ELEM)) == lys_parent((struct lys_node *)(START))) { \
171  /* we are done, no next element to process */ \
172  break; \
173  } \
174  } else if ((ELEM)->parent == (START)->parent) { \
175  /* we are done, no next element to process */ \
176  break; \
177  } \
178  (NEXT) = (ELEM)->next; \
179  }
180 
188 #define LY_ARRAY_MAX(var) (sizeof(var) == 8 ? ULLONG_MAX : ((1ULL << (sizeof(var) * 8)) - 1))
190 #define LY_REV_SIZE 11
195 typedef enum {
199 } LYS_INFORMAT;
200 
204 typedef enum {
211 } LYS_OUTFORMAT;
212 
219 #define LYS_OUTOPT_TREE_RFC 0x01
220 #define LYS_OUTOPT_TREE_GROUPING 0x02
221 #define LYS_OUTOPT_TREE_USES 0x04
222 #define LYS_OUTOPT_TREE_NO_LEAFREF 0x08
228 /* shortcuts for common in and out formats */
229 #define LYS_YANG 1
230 #define LYS_YIN 2
237 typedef enum lys_nodetype {
238  LYS_UNKNOWN = 0x0000,
239  LYS_CONTAINER = 0x0001,
240  LYS_CHOICE = 0x0002,
241  LYS_LEAF = 0x0004,
242  LYS_LEAFLIST = 0x0008,
243  LYS_LIST = 0x0010,
244  LYS_ANYXML = 0x0020,
245  LYS_CASE = 0x0040,
246  LYS_NOTIF = 0x0080,
247  LYS_RPC = 0x0100,
248  LYS_INPUT = 0x0200,
249  LYS_OUTPUT = 0x0400,
250  LYS_GROUPING = 0x0800,
251  LYS_USES = 0x1000,
252  LYS_AUGMENT = 0x2000,
253  LYS_ACTION = 0x4000,
254  LYS_ANYDATA = 0x8020,
255  LYS_EXT = 0x10000
256 } LYS_NODE;
257 
258 /* all nodes sharing the node namespace except RPCs and notifications */
259 #define LYS_NO_RPC_NOTIF_NODE 0x807F
260 
261 #define LYS_ANY 0xFFFF
262 
290 typedef enum {
375 } LY_STMT;
376 
382 typedef enum {
383  LY_STMT_CARD_OPT, /* 0..1 */
385  LY_STMT_CARD_SOME, /* 1..n */
386  LY_STMT_CARD_ANY /* 0..n */
387 } LY_STMT_CARD;
388 
392 typedef enum {
393  LYEXT_ERR = -1,
402 } LYEXT_TYPE;
403 
412 #define LYEXT_OPT_INHERIT 0x01
418 #define LYEXT_OPT_YANG 0x02
419 #define LYEXT_OPT_CONTENT 0x04
421 #define LYEXT_OPT_VALID 0x08
422 #define LYEXT_OPT_VALID_SUBTREE 0x10
426 #define LYEXT_OPT_PLUGIN1 0x0100
427 #define LYEXT_OPT_PLUGIN2 0x0200
428 #define LYEXT_OPT_PLUGIN3 0x0400
429 #define LYEXT_OPT_PLUGIN4 0x0800
430 #define LYEXT_OPT_PLUGIN5 0x1000
431 #define LYEXT_OPT_PLUGIN6 0x2000
432 #define LYEXT_OPT_PLUGIN7 0x4000
433 #define LYEXT_OPT_PLUGIN8 0x8000
443 struct lyext_substmt {
444  LY_STMT stmt;
445  size_t offset;
446  LY_STMT_CARD cardinality;
447 };
448 
452 struct lys_ext {
453  const char *name;
454  const char *dsc;
455  const char *ref;
456  uint16_t flags;
457  uint8_t ext_size;
458  uint8_t padding[5];
460  const char *argument;
461  struct lys_module *module;
463 };
472 struct lys_ext_instance {
473  struct lys_ext *def;
476  void *parent;
478  const char *arg_value;
479  uint16_t flags;
480  uint8_t ext_size;
481  uint8_t insubstmt_index;
488  uint8_t insubstmt;
491  uint8_t parent_type;
492  uint8_t ext_type;
493  uint8_t padding;
494  struct lys_ext_instance **ext;
495  void *priv;
496  struct lys_module *module;
498 };
507  struct lys_ext *def;
508  void *parent;
510  const char *arg_value;
511  uint16_t flags;
512  uint8_t ext_size;
513  uint8_t insubstmt_index;
520  uint8_t insubstmt;
523  uint8_t parent_type;
524  uint8_t ext_type;
525  uint8_t padding;
526  struct lys_ext_instance **ext;
527  void *priv;
528  struct lys_module *module;
531  /* to this point the structure is compatible with the generic ::lys_ext_instance structure */
533  char content[1];
534 };
582 const void *lys_ext_instance_substmt(const struct lys_ext_instance *ext);
583 
592 int lys_ext_instance_presence(struct lys_ext *def, struct lys_ext_instance **ext, uint8_t ext_size);
593 
605 
611 const char * const *ly_get_loaded_plugins(void);
612 
620 void ly_load_plugins(void);
621 
622 /* don't need the contents of these types, just forward-declare them for the next 2 functions. */
623 struct lyext_plugin_list;
624 struct lytype_plugin_list;
625 
634 int ly_register_exts(struct lyext_plugin_list *plugin, const char *log_name);
635 
641 int ly_register_types(struct lytype_plugin_list *plugin, const char *log_name);
642 
652 int ly_clean_plugins(void);
653 
661 typedef enum LYS_VERSION {
662  LYS_VERSION_UNDEF = 0,
663  LYS_VERSION_1 = 1,
664  LYS_VERSION_1_1 = 2
665 } LYS_VERSION;
666 
674 struct lys_module {
675  struct ly_ctx *ctx;
676  const char *name;
677  const char *prefix;
678  const char *dsc;
679  const char *ref;
680  const char *org;
681  const char *contact;
682  const char *filepath;
683  uint8_t type:1;
684  uint8_t version:3;
688  uint8_t deviated:2;
692  uint8_t disabled:1;
693  uint8_t implemented:1;
694  uint8_t latest_revision:1;
696  uint8_t padding1:7;
697  uint8_t padding2[2];
698 
699  /* array sizes */
700  uint8_t rev_size;
701  uint8_t imp_size;
702  uint8_t inc_size;
704  uint16_t ident_size;
705  uint16_t tpdf_size;
707  uint8_t features_size;
708  uint8_t augment_size;
709  uint8_t deviation_size;
710  uint8_t extensions_size;
711  uint8_t ext_size;
713  struct lys_revision *rev;
715  struct lys_import *imp;
716  struct lys_include *inc;
717  struct lys_tpdf *tpdf;
718  struct lys_ident *ident;
719  struct lys_feature *features;
721  struct lys_deviation *deviation;
722  struct lys_ext *extensions;
725  /* specific module's items in comparison to submodules */
726  struct lys_node *data;
727  const char *ns;
728 };
737 struct lys_submodule {
738  struct ly_ctx *ctx;
739  const char *name;
740  const char *prefix;
741  const char *dsc;
742  const char *ref;
743  const char *org;
744  const char *contact;
745  const char *filepath;
746  uint8_t type:1;
747  uint8_t version:3;
751  uint8_t deviated:2;
755  uint8_t disabled:1;
756  uint8_t implemented:1;
757  uint8_t padding[3];
759  /* array sizes */
760  uint8_t rev_size;
761  uint8_t imp_size;
762  uint8_t inc_size;
764  uint16_t ident_size;
765  uint16_t tpdf_size;
767  uint8_t features_size;
768  uint8_t augment_size;
769  uint8_t deviation_size;
770  uint8_t extensions_size;
771  uint8_t ext_size;
773  struct lys_revision *rev;
775  struct lys_import *imp;
776  struct lys_include *inc;
777  struct lys_tpdf *tpdf;
778  struct lys_ident *ident;
779  struct lys_feature *features;
781  struct lys_deviation *deviation;
782  struct lys_ext *extensions;
785  /* specific submodule's items in comparison to modules */
787 };
792 typedef enum {
795  LY_TYPE_BITS,
796  LY_TYPE_BOOL,
797  LY_TYPE_DEC64,
798  LY_TYPE_EMPTY,
815 #define LY_DATA_TYPE_COUNT 20
820 struct lys_type_info_binary {
821  struct lys_restr *length;
823 };
824 
828 struct lys_type_bit {
829  const char *name;
830  const char *dsc;
831  const char *ref;
832  uint16_t flags;
834  uint8_t ext_size;
835  uint8_t iffeature_size;
837  /* 32b padding for compatibility with ::lys_node */
838  uint32_t pos;
840  struct lys_ext_instance **ext;
842 };
843 
848  struct lys_type_bit *bit;
849  unsigned int count;
850 };
851 
856  struct lys_restr *range;
858  uint8_t dig;
862  uint64_t div;
863 };
864 
868 struct lys_type_enum {
869  const char *name;
870  const char *dsc;
871  const char *ref;
872  uint16_t flags;
874  uint8_t ext_size;
875  uint8_t iffeature_size;
877  /* 32b padding for compatibility with ::lys_node */
878  int32_t value;
880  struct lys_ext_instance **ext;
882 };
883 
889  unsigned int count;
890 };
891 
896  struct lys_ident **ref;
897  unsigned int count;
898 };
899 
904  int8_t req;
909 };
914 struct lys_type_info_num {
915  struct lys_restr *range;
917 };
918 
923  const char *path;
925  struct lys_node_leaf* target;
926  int8_t req;
930 };
931 
935 struct lys_type_info_str {
936  struct lys_restr *length;
938  struct lys_restr *patterns;
944  unsigned int pat_count;
945 #ifdef LY_ENABLED_CACHE
946  void **patterns_pcre;
949 #endif
950 };
955 struct lys_type_info_union {
956  struct lys_type *types;
957  unsigned int count;
958  int has_ptr_type;
960 };
961 
967  struct lys_type_info_bits bits;
968  struct lys_type_info_dec64 dec64;
969  struct lys_type_info_enums enums;
970  struct lys_type_info_ident ident;
971  struct lys_type_info_inst inst;
976 };
981 struct lys_type {
983  uint8_t value_flags;
984  uint8_t ext_size;
985  struct lys_ext_instance **ext;
986  struct lys_tpdf *der;
988  struct lys_tpdf *parent;
991  /*
992  * here is an overview of the info union:
993  * LY_TYPE_BINARY (binary)
994  * struct lys_restr *binary.length; length restriction (optional), see
995  * [RFC 6020 sec. 9.4.4](http://tools.ietf.org/html/rfc6020#section-9.4.4)
996  * -----------------------------------------------------------------------------------------------------------------
997  * LY_TYPE_BITS (bits)
998  * struct lys_type_bit *bits.bit; array of bit definitions
999  * const char *bits.bit[i].name; bit's name (mandatory)
1000  * const char *bits.bit[i].dsc; bit's description (optional)
1001  * const char *bits.bit[i].ref; bit's reference (optional)
1002  * uint8_t bits.bit[i].flags; bit's flags, whether the position was auto-assigned
1003  * and the status(one of LYS_NODE_STATUS_* values or 0 for default)
1004  * uint8_t bits.bit[i].iffeature_size; number of elements in the bit's #iffeature array
1005  * uint8_t bits.bit[i].ext_size; number of elements in the bit's #ext array
1006  * uint32_t bits.bit[i].pos; bit's position (mandatory)
1007  * struct lys_iffeature *bits.bit[i].iffeature; array of bit's if-feature expressions
1008  * struct lys_ext_instance **bits.bit[i].ext; array of pointers to the bit's extension instances (optional)
1009  * unsigned int bits.count; number of bit definitions in the bit array
1010  * -----------------------------------------------------------------------------------------------------------------
1011  * LY_TYPE_DEC64 (dec64)
1012  * struct lys_restr *dec64.range; range restriction (optional), see
1013  * [RFC 6020 sec. 9.2.4](http://tools.ietf.org/html/rfc6020#section-9.2.4)
1014  * struct lys_ext_instance **dec64.ext; array of pointers to the bit's extension instances (optional)
1015  * uint8_t dec64.ext_size; number of elements in the bit's #ext array
1016  * uint8_t dec64.dig; fraction-digits restriction (mandatory)
1017  * uint64_t dec64.div; auxiliary value for moving decimal point (dividing the stored value to get
1018  * the real value) (mandatory, corresponds to the fraction-digits)
1019  * -----------------------------------------------------------------------------------------------------------------
1020  * LY_TYPE_ENUM (enums)
1021  * struct lys_type_enum *enums.enm; array of enum definitions
1022  * const char *enums.enm[i].name; enum's name (mandatory)
1023  * const char *enums.enm[i].dsc; enum's description (optional)
1024  * const char *enums.enm[i].ref; enum's reference (optional)
1025  * uint8_t enums.enm[i].flags; enum's flags, whether the value was auto-assigned
1026  * and the status(one of LYS_NODE_STATUS_* values or 0 for default)
1027  * uint8_t enums.enum[i].iffeature_size; number of elements in the bit's #iffeature array
1028  * uint8_t enums.enum[i].ext_size; number of elements in the bit's #ext array
1029  * int32_t enums.enm[i].value; enum's value (mandatory)
1030  * struct lys_iffeature *enums.enum[i].iffeature; array of bit's if-feature expressions
1031  * struct lys_ext_instance **enums.enum[i].ext; array of pointers to the bit's extension instances (optional)
1032  * unsigned int enums.count; number of enum definitions in the enm array
1033  * -----------------------------------------------------------------------------------------------------------------
1034  * LY_TYPE_IDENT (ident)
1035  * struct lys_ident **ident.ref; array of pointers (reference) to the identity definition (mandatory)
1036  * unsigned int ident.count; number of base identity references
1037  * -----------------------------------------------------------------------------------------------------------------
1038  * LY_TYPE_INST (inst)
1039  * int8_t inst.req; require-identifier restriction, see
1040  * [RFC 6020 sec. 9.13.2](http://tools.ietf.org/html/rfc6020#section-9.13.2):
1041  * - -1 = false,
1042  * - 0 not defined,
1043  * - 1 = true
1044  * -----------------------------------------------------------------------------------------------------------------
1045  * LY_TYPE_*INT* (num)
1046  * struct lys_restr *num.range; range restriction (optional), see
1047  * [RFC 6020 sec. 9.2.4](http://tools.ietf.org/html/rfc6020#section-9.2.4)
1048  * -----------------------------------------------------------------------------------------------------------------
1049  * LY_TYPE_LEAFREF (lref)
1050  * const char *lref.path; path to the referred leaf or leaf-list node (mandatory), see
1051  * [RFC 6020 sec. 9.9.2](http://tools.ietf.org/html/rfc6020#section-9.9.2)
1052  * struct lys_node_leaf *lref.target; target schema node according to path
1053  * int8_t lref.req; require-instance restriction: -1 = false; 0 not defined (true); 1 = true
1054  * -----------------------------------------------------------------------------------------------------------------
1055  * LY_TYPE_STRING (str)
1056  * struct lys_restr *str.length; length restriction (optional), see
1057  * [RFC 6020 sec. 9.4.4](http://tools.ietf.org/html/rfc6020#section-9.4.4)
1058  * struct lys_restr *str.patterns; array of pattern restrictions (optional), see
1059  * [RFC 6020 sec. 9.4.6](http://tools.ietf.org/html/rfc6020#section-9.4.6)
1060  * unsigned int str.pat_count; number of pattern definitions in the patterns array
1061  * -----------------------------------------------------------------------------------------------------------------
1062  * LY_TYPE_UNION (uni)
1063  * struct lys_type *uni.types; array of union's subtypes
1064  * unsigned int uni.count; number of subtype definitions in types array
1065  * int uni.has_ptr_type; types recursively include an instance-identifier or leafref (union must always
1066  * be resolved after it is parsed)
1067  */
1068 };
1069 
1070 #define LYS_IFF_NOT 0x00
1071 #define LYS_IFF_AND 0x01
1072 #define LYS_IFF_OR 0x02
1073 #define LYS_IFF_F 0x03
1074 
1079  uint8_t *expr;
1080  uint8_t ext_size;
1081  struct lys_feature **features;
1082  struct lys_ext_instance **ext;
1083 };
1084 
1143 #define LYS_CONFIG_W 0x01
1144 #define LYS_CONFIG_R 0x02
1145 #define LYS_CONFIG_SET 0x04
1146 #define LYS_CONFIG_MASK 0x03
1147 #define LYS_STATUS_CURR 0x08
1148 #define LYS_STATUS_DEPRC 0x10
1149 #define LYS_STATUS_OBSLT 0x20
1150 #define LYS_STATUS_MASK 0x38
1151 #define LYS_RFN_MAXSET 0x08
1152 #define LYS_RFN_MINSET 0x10
1153 #define LYS_MAND_TRUE 0x40
1155 #define LYS_MAND_FALSE 0x80
1157 #define LYS_INCL_STATUS 0x80
1159 #define LYS_MAND_MASK 0xc0
1160 #define LYS_USERORDERED 0x100
1162 #define LYS_FENABLED 0x100
1163 #define LYS_UNIQUE 0x100
1164 #define LYS_AUTOASSIGNED 0x01
1166 #define LYS_USESGRP 0x01
1167 #define LYS_IMPLICIT 0x40
1168 #define LYS_XPCONF_DEP 0x200
1171 #define LYS_XPSTATE_DEP 0x400
1174 #define LYS_LEAFREF_DEP 0x800
1177 #define LYS_DFLTJSON 0x1000
1181 #define LYS_NOTAPPLIED 0x01
1182 #define LYS_YINELEM 0x01
1183 #define LYS_VALID_EXT 0x2000
1184 #define LYS_VALID_EXT_SUBTREE 0x4000
1191 #ifdef LY_ENABLED_CACHE
1192 
1196 #define LYS_NODE_HASH_COUNT 4
1197 
1198 #endif
1199 
1217 struct lys_node {
1218  const char *name;
1219  const char *dsc;
1220  const char *ref;
1221  uint16_t flags;
1222  uint8_t ext_size;
1223  uint8_t iffeature_size;
1225  uint8_t padding[4];
1231  struct lys_ext_instance **ext;
1232  struct lys_iffeature *iffeature;
1233  struct lys_module *module;
1235  LYS_NODE nodetype;
1236  struct lys_node *parent;
1237  struct lys_node *child;
1241  struct lys_node *next;
1242  struct lys_node *prev;
1247  void *priv;
1249 #ifdef LY_ENABLED_CACHE
1250  uint8_t hash[LYS_NODE_HASH_COUNT];
1251 #endif
1252 };
1264  const char *name;
1265  const char *dsc;
1266  const char *ref;
1267  uint16_t flags;
1268  uint8_t ext_size;
1269  uint8_t iffeature_size;
1271  /* non compatible 32b with ::lys_node */
1272  uint8_t padding[1];
1273  uint8_t must_size;
1274  uint16_t tpdf_size;
1276  struct lys_ext_instance **ext;
1277  struct lys_iffeature *iffeature;
1278  struct lys_module *module;
1280  LYS_NODE nodetype;
1281  struct lys_node *parent;
1282  struct lys_node *child;
1283  struct lys_node *next;
1284  struct lys_node *prev;
1289  void *priv;
1291 #ifdef LY_ENABLED_CACHE
1292  uint8_t hash[LYS_NODE_HASH_COUNT];
1293 #endif
1295  /* specific container's data */
1296  struct lys_when *when;
1297  struct lys_restr *must;
1298  struct lys_tpdf *tpdf;
1299  const char *presence;
1300 };
1301 
1312  const char *name;
1313  const char *dsc;
1314  const char *ref;
1315  uint16_t flags;
1316  uint8_t ext_size;
1317  uint8_t iffeature_size;
1319  /* non compatible 32b with ::lys_node */
1320  uint8_t padding[4];
1322  struct lys_ext_instance **ext;
1323  struct lys_iffeature *iffeature;
1324  struct lys_module *module;
1326  LYS_NODE nodetype;
1327  struct lys_node *parent;
1328  struct lys_node *child;
1329  struct lys_node *next;
1330  struct lys_node *prev;
1335  void *priv;
1337  /* specific choice's data */
1338  struct lys_when *when;
1339  struct lys_node *dflt;
1340 };
1341 
1353 struct lys_node_leaf {
1354  const char *name;
1355  const char *dsc;
1356  const char *ref;
1357  uint16_t flags;
1358  uint8_t ext_size;
1359  uint8_t iffeature_size;
1361  /* non compatible 32b with ::lys_node */
1362  uint8_t padding[3];
1363  uint8_t must_size;
1365  struct lys_ext_instance **ext;
1366  struct lys_iffeature *iffeature;
1367  struct lys_module *module;
1369  LYS_NODE nodetype;
1370  struct lys_node *parent;
1371  struct ly_set *backlinks;
1374  struct lys_node *next;
1375  struct lys_node *prev;
1380  void *priv;
1382 #ifdef LY_ENABLED_CACHE
1383  uint8_t hash[LYS_NODE_HASH_COUNT];
1384 #endif
1386  /* specific leaf's data */
1387  struct lys_when *when;
1388  struct lys_restr *must;
1389  struct lys_type type;
1390  const char *units;
1392  /* to this point, struct lys_node_leaf is compatible with struct lys_node_leaflist */
1393  const char *dflt;
1394 };
1395 
1406 struct lys_node_leaflist {
1407  const char *name;
1408  const char *dsc;
1409  const char *ref;
1410  uint16_t flags;
1411  uint8_t ext_size;
1412  uint8_t iffeature_size;
1414  /* non compatible 32b with ::lys_node */
1415  uint8_t padding[2];
1416  uint8_t dflt_size;
1417  uint8_t must_size;
1419  struct lys_ext_instance **ext;
1420  struct lys_iffeature *iffeature;
1421  struct lys_module *module;
1423  LYS_NODE nodetype;
1424  struct lys_node *parent;
1425  struct ly_set *backlinks;
1428  struct lys_node *next;
1429  struct lys_node *prev;
1434  void *priv;
1436 #ifdef LY_ENABLED_CACHE
1437  uint8_t hash[LYS_NODE_HASH_COUNT];
1438 #endif
1440  /* specific leaf-list's data */
1441  struct lys_when *when;
1442  struct lys_restr *must;
1443  struct lys_type type;
1444  const char *units;
1446  /* to this point, struct lys_node_leaflist is compatible with struct lys_node_leaf
1447  * on the other hand, the min and max are compatible with struct lys_node_list */
1448  const char **dflt;
1449  uint32_t min;
1450  uint32_t max;
1451 };
1452 
1462 struct lys_node_list {
1463  const char *name;
1464  const char *dsc;
1465  const char *ref;
1466  uint16_t flags;
1467  uint8_t ext_size;
1468  uint8_t iffeature_size;
1470  /* non compatible 32b with ::lys_node */
1471  uint8_t must_size;
1472  uint8_t tpdf_size;
1473  uint8_t keys_size;
1474  uint8_t unique_size;
1476  struct lys_ext_instance **ext;
1477  struct lys_iffeature *iffeature;
1478  struct lys_module *module;
1480  LYS_NODE nodetype;
1481  struct lys_node *parent;
1482  struct lys_node *child;
1483  struct lys_node *next;
1484  struct lys_node *prev;
1489  void *priv;
1491 #ifdef LY_ENABLED_CACHE
1492  uint8_t hash[LYS_NODE_HASH_COUNT];
1493 #endif
1495  /* specific list's data */
1496  struct lys_when *when;
1497  struct lys_restr *must;
1498  struct lys_tpdf *tpdf;
1499  struct lys_node_leaf **keys;
1500  struct lys_unique *unique;
1502  uint32_t min;
1503  uint32_t max;
1505  const char *keys_str;
1508 };
1509 
1522  const char *name;
1523  const char *dsc;
1524  const char *ref;
1525  uint16_t flags;
1526  uint8_t ext_size;
1527  uint8_t iffeature_size;
1529  /* non compatible 32b with ::lys_node */
1530  uint8_t padding[3];
1531  uint8_t must_size;
1533  struct lys_ext_instance **ext;
1534  struct lys_iffeature *iffeature;
1535  struct lys_module *module;
1537  LYS_NODE nodetype;
1538  struct lys_node *parent;
1539  struct lys_node *child;
1540  struct lys_node *next;
1541  struct lys_node *prev;
1546  void *priv;
1548 #ifdef LY_ENABLED_CACHE
1549  uint8_t hash[LYS_NODE_HASH_COUNT];
1550 #endif
1551 
1552  /* specific anyxml's data */
1553  struct lys_when *when;
1554  struct lys_restr *must;
1555 };
1569 struct lys_node_uses {
1570  const char *name;
1571  const char *dsc;
1572  const char *ref;
1573  uint16_t flags;
1575  uint8_t ext_size;
1576  uint8_t iffeature_size;
1578  /* non compatible 32b with ::lys_node */
1579  uint8_t padding[2];
1580  uint8_t refine_size;
1581  uint8_t augment_size;
1583  struct lys_ext_instance **ext;
1584  struct lys_iffeature *iffeature;
1585  struct lys_module *module;
1587  LYS_NODE nodetype;
1588  struct lys_node *parent;
1589  struct lys_node *child;
1590  struct lys_node *next;
1591  struct lys_node *prev;
1596  void *priv;
1598  /* specific uses's data */
1599  struct lys_when *when;
1600  struct lys_refine *refine;
1602  struct lys_node_grp *grp;
1603 };
1604 
1616 struct lys_node_grp {
1617  const char *name;
1618  const char *dsc;
1619  const char *ref;
1620  uint16_t flags;
1621  uint8_t ext_size;
1624  /* non compatible 32b with ::lys_node */
1625  uint16_t unres_count;
1626  uint16_t tpdf_size;
1628  struct lys_ext_instance **ext;
1629  void *padding_iff;
1630  struct lys_module *module;
1632  LYS_NODE nodetype;
1633  struct lys_node *parent;
1634  struct lys_node *child;
1635  struct lys_node *next;
1636  struct lys_node *prev;
1641  void *priv;
1643  /* specific grouping's data */
1644  struct lys_tpdf *tpdf;
1645 };
1646 
1656  const char *name;
1657  const char *dsc;
1658  const char *ref;
1659  uint16_t flags;
1660  uint8_t ext_size;
1661  uint8_t iffeature_size;
1663  /* non compatible 32b with ::lys_node */
1664  uint8_t padding[4];
1667  struct lys_iffeature *iffeature;
1668  struct lys_module *module;
1670  LYS_NODE nodetype;
1671  struct lys_node *parent;
1672  struct lys_node *child;
1673  struct lys_node *next;
1674  struct lys_node *prev;
1679  void *priv;
1681  /* specific case's data */
1682  struct lys_when *when;
1683 };
1684 
1700 struct lys_node_inout {
1701  const char *name;
1702  void *fill1[2];
1703  uint16_t flags;
1704  uint8_t ext_size;
1705  uint8_t padding_iffsize;
1707  /* non compatible 32b with ::lys_node */
1708  uint8_t padding[1];
1709  uint8_t must_size;
1710  uint16_t tpdf_size;
1712  struct lys_ext_instance **ext;
1713  void *padding_iff;
1714  struct lys_module *module;
1716  LYS_NODE nodetype;
1717  struct lys_node *parent;
1718  struct lys_node *child;
1719  struct lys_node *next;
1720  struct lys_node *prev;
1725  void *priv;
1727  /* specific inout's data */
1728  struct lys_tpdf *tpdf;
1729  struct lys_restr *must;
1730 };
1739  const char *name;
1740  const char *dsc;
1741  const char *ref;
1742  uint16_t flags;
1743  uint8_t ext_size;
1744  uint8_t iffeature_size;
1746  /* non compatible 32b with ::lys_node */
1747  uint8_t padding[1];
1748  uint8_t must_size;
1749  uint16_t tpdf_size;
1752  struct lys_iffeature *iffeature;
1753  struct lys_module *module;
1755  LYS_NODE nodetype;
1756  struct lys_node *parent;
1757  struct lys_node *child;
1758  struct lys_node *next;
1759  struct lys_node *prev;
1764  void *priv;
1766 #ifdef LY_ENABLED_CACHE
1767  uint8_t hash[LYS_NODE_HASH_COUNT];
1768 #endif
1770  /* specific rpc's data */
1771  struct lys_tpdf *tpdf;
1772  struct lys_restr *must;
1773 };
1785 struct lys_node_rpc_action {
1786  const char *name;
1787  const char *dsc;
1788  const char *ref;
1789  uint16_t flags;
1790  uint8_t ext_size;
1791  uint8_t iffeature_size;
1793  /* non compatible 32b with ::lys_node */
1794  uint8_t padding[2];
1795  uint16_t tpdf_size;
1797  struct lys_ext_instance **ext;
1798  struct lys_iffeature *iffeature;
1799  struct lys_module *module;
1801  LYS_NODE nodetype;
1802  struct lys_node *parent;
1803  struct lys_node *child;
1804  struct lys_node *next;
1805  struct lys_node *prev;
1810  void *priv;
1812 #ifdef LY_ENABLED_CACHE
1813  uint8_t hash[LYS_NODE_HASH_COUNT];
1814 #endif
1815 
1816  /* specific rpc's data */
1817  struct lys_tpdf *tpdf;
1818 };
1833 struct lys_node_augment {
1834  const char *target_name;
1836  const char *dsc;
1837  const char *ref;
1838  uint16_t flags;
1839  uint8_t ext_size;
1840  uint8_t iffeature_size;
1842  /* non compatible 32b with ::lys_node */
1843  uint8_t padding[4];
1845  struct lys_ext_instance **ext;
1846  struct lys_iffeature *iffeature;
1847  struct lys_module *module;
1849  LYS_NODE nodetype;
1850  struct lys_node *parent;
1851  struct lys_node *child;
1857  /* replaces #next and #prev members of ::lys_node */
1858  struct lys_when *when;
1859  struct lys_node *target;
1861  /* again compatible members with ::lys_node */
1862  void *priv;
1863 };
1864 
1869  uint32_t min;
1870  uint32_t max;
1871 };
1876 union lys_refine_mod {
1877  const char *presence;
1878  struct lys_refine_mod_list list;
1880 };
1885 struct lys_refine {
1886  const char *target_name;
1887  const char *dsc;
1888  const char *ref;
1889  uint16_t flags;
1890  uint8_t ext_size;
1891  uint8_t iffeature_size;
1893  /* 32b padding for compatibility with ::lys_node */
1894  uint16_t target_type;
1897  uint8_t must_size;
1898  uint8_t dflt_size;
1901  struct lys_iffeature *iffeature;
1902  struct lys_module *module;
1904  struct lys_restr *must;
1905  const char **dflt;
1910 };
1916 typedef enum lys_deviate_type {
1917  LY_DEVIATE_NO,
1918  LY_DEVIATE_ADD,
1926 struct lys_deviate {
1929  uint8_t flags;
1930  uint8_t dflt_size;
1931  uint8_t ext_size;
1933  uint8_t min_set;
1934  uint8_t max_set;
1935  uint8_t must_size;
1936  uint8_t unique_size;
1938  uint32_t min;
1939  uint32_t max;
1941  struct lys_restr *must;
1942  struct lys_unique *unique;
1943  struct lys_type *type;
1944  const char *units;
1945  const char **dflt;
1947  struct lys_ext_instance **ext;
1948 };
1954  const char *target_name;
1956  const char *dsc;
1957  const char *ref;
1960  uint8_t deviate_size;
1961  uint8_t ext_size;
1962  struct lys_deviate *deviate;
1964 };
1969 struct lys_import {
1970  struct lys_module *module;
1971  const char *prefix;
1972  char rev[LY_REV_SIZE];
1973  uint8_t ext_size;
1974  struct lys_ext_instance **ext;
1975  const char *dsc;
1976  const char *ref;
1977 };
1982 struct lys_include {
1985  uint8_t ext_size;
1986  struct lys_ext_instance **ext;
1987  const char *dsc;
1988  const char *ref;
1989 };
1990 
1996  uint8_t ext_size;
1998  const char *dsc;
1999  const char *ref;
2000 };
2001 
2005 struct lys_tpdf {
2006  const char *name;
2007  const char *dsc;
2008  const char *ref;
2009  uint16_t flags;
2010  uint8_t ext_size;
2011  uint8_t padding_iffsize;
2012  uint8_t has_union_leafref;
2014  /* 24b padding for compatibility with ::lys_node */
2015  uint8_t padding[3];
2018  const char *units;
2019  struct lys_module *module;
2022  struct lys_type type;
2024  const char *dflt;
2025 };
2026 
2030 struct lys_unique {
2031  const char **expr;
2032  uint8_t expr_size;
2033  uint8_t trg_type;
2034 };
2035 
2039 struct lys_feature {
2040  const char *name;
2041  const char *dsc;
2042  const char *ref;
2043  uint16_t flags;
2045  uint8_t ext_size;
2046  uint8_t iffeature_size;
2048  /* 32b padding for compatibility with ::lys_node */
2049  uint8_t padding[4];
2051  struct lys_ext_instance **ext;
2053  struct lys_module *module;
2055 };
2056 
2060 struct lys_restr {
2061  const char *expr;
2064  const char *dsc;
2065  const char *ref;
2066  const char *eapptag;
2067  const char *emsg;
2069  uint8_t ext_size;
2070  uint16_t flags;
2071 };
2072 
2076 struct lys_when {
2077  const char *cond;
2078  const char *dsc;
2079  const char *ref;
2080  struct lys_ext_instance **ext;
2081  uint8_t ext_size;
2082  uint16_t flags;
2083 };
2084 
2090 struct lys_ident {
2091  const char *name;
2092  const char *dsc;
2093  const char *ref;
2094  uint16_t flags;
2095  uint8_t ext_size;
2096  uint8_t iffeature_size;
2098  /* 32b padding for compatibility with ::lys_node */
2099  uint8_t padding[3];
2100  uint8_t base_size;
2104  struct lys_module *module;
2106  struct lys_ident **base;
2107  struct ly_set *der;
2108 };
2109 
2119 const struct lys_module *lys_parse_mem(struct ly_ctx *ctx, const char *data, LYS_INFORMAT format);
2120 
2132 const struct lys_module *lys_parse_fd(struct ly_ctx *ctx, int fd, LYS_INFORMAT format);
2133 
2142 const struct lys_module *lys_parse_path(struct ly_ctx *ctx, const char *path, LYS_INFORMAT format);
2143 
2159 int lys_search_localfile(const char * const *searchpaths, int cwd, const char *name, const char *revision, char **localfile, LYS_INFORMAT *format);
2160 
2174 const char **lys_features_list(const struct lys_module *module, uint8_t **states);
2175 
2185 int lys_features_enable(const struct lys_module *module, const char *feature);
2186 
2196 int lys_features_disable(const struct lys_module *module, const char *feature);
2197 
2208 int lys_features_state(const struct lys_module *module, const char *feature);
2209 
2221 const struct lys_node *lys_is_disabled(const struct lys_node *node, int recursive);
2222 
2229 int lys_iffeature_value(const struct lys_iffeature *iff);
2230 
2238 const struct lys_node_list *lys_is_key(const struct lys_node_leaf *node, uint8_t *index);
2239 
2261 const struct lys_node *lys_getnext(const struct lys_node *last, const struct lys_node *parent,
2262  const struct lys_module *module, int options);
2263 
2264 #define LYS_GETNEXT_WITHCHOICE 0x01
2265 #define LYS_GETNEXT_WITHCASE 0x02
2266 #define LYS_GETNEXT_WITHGROUPING 0x04
2267 #define LYS_GETNEXT_WITHINOUT 0x08
2269 #define LYS_GETNEXT_WITHUSES 0x10
2270 #define LYS_GETNEXT_INTOUSES 0x20
2272 #define LYS_GETNEXT_INTONPCONT 0x40
2273 #define LYS_GETNEXT_PARENTUSES 0x80
2275 #define LYS_GETNEXT_NOSTATECHECK 0x100
2285 const struct lys_type *lys_getnext_union_type(const struct lys_type *last, const struct lys_type *type);
2298 struct ly_set *lys_find_path(const struct lys_module *cur_module, const struct lys_node *cur_node, const char *path);
2299 
2303 enum lyxp_node_type {
2304  /* XML document roots */
2305  LYXP_NODE_ROOT, /* access to all the data (node value first top-level node) */
2306  LYXP_NODE_ROOT_CONFIG, /* <running> data context, no state data (node value first top-level node) */
2307 
2308  /* XML elements */
2309  LYXP_NODE_ELEM, /* XML element (most common) */
2310  LYXP_NODE_TEXT, /* XML text element (extremely specific use, unlikely to be ever needed) */
2311  LYXP_NODE_ATTR, /* XML attribute (in YANG cannot happen, do not use for the context node) */
2312 
2313  LYXP_NODE_NONE /* invalid node type, do not use */
2314 };
2315 
2329 struct ly_set *lys_xpath_atomize(const struct lys_node *ctx_node, enum lyxp_node_type ctx_node_type,
2330  const char *expr, int options);
2332 #define LYXP_MUST 0x01
2333 #define LYXP_WHEN 0x02
2342 struct ly_set *lys_node_xpath_atomize(const struct lys_node *node, int options);
2343 
2344 #define LYXP_RECURSIVE 0x01
2345 #define LYXP_NO_LOCAL 0x02
2358 char *lys_path(const struct lys_node *node, int options);
2360 #define LYS_PATH_FIRST_PREFIX 0x01
2370 char *lys_data_path(const struct lys_node *node);
2382 struct lys_node *lys_parent(const struct lys_node *node);
2383 
2393 struct lys_module *lys_node_module(const struct lys_node *node);
2394 
2404 struct lys_module *lys_main_module(const struct lys_module *module);
2405 
2421 struct lys_module *lys_implemented_module(const struct lys_module *mod);
2422 
2442 int lys_set_implemented(const struct lys_module *module);
2443 
2460 int lys_set_disabled(const struct lys_module *module);
2461 
2476 int lys_set_enabled(const struct lys_module *module);
2477 
2487 void *lys_set_private(const struct lys_node *node, void *priv);
2488 
2502 int lys_print_mem(char **strp, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node,
2503  int line_length, int options);
2504 
2517 int lys_print_fd(int fd, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node,
2518  int line_length, int options);
2519 
2532 int lys_print_file(FILE *f, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node,
2533  int line_length, int options);
2534 
2547 int lys_print_path(const char *path, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node,
2548  int line_length, int options);
2549 
2563 int lys_print_clb(ssize_t (*writeclb)(void *arg, const void *buf, size_t count), void *arg,
2564  const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node, int line_length, int options);
2565 
2568 #ifdef __cplusplus
2569 }
2570 #endif
2571 
2572 #endif /* LY_TREE_SCHEMA_H_ */
uint8_t augment_size
Definition: tree_schema.h:715
struct lys_deviation * deviation
Definition: tree_schema.h:728
int ly_register_types(struct lytype_plugin_list *plugin, const char *log_name)
Directly register a YANG type by pointer.
const struct lys_module * lys_parse_mem(struct ly_ctx *ctx, const char *data, LYS_INFORMAT format)
Load a schema into the specified context.
struct lys_module * module
Definition: tree_schema.h:1255
const char * ref
Definition: tree_schema.h:462
uint8_t ext_size
Definition: tree_schema.h:464
Common structure representing single YANG data statement describing.
Definition: tree_schema.h:1239
const char * emsg
Definition: tree_schema.h:2089
struct ly_set * backlinks
Definition: tree_schema.h:1393
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.
LY_STMT_CARD
Possible cardinalities of the YANG statements.
Definition: tree_schema.h:382
Schema leaf node structure.
Definition: tree_schema.h:1375
const 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....
Schema grouping node structure.
Definition: tree_schema.h:1638
struct lys_type * types
Definition: tree_schema.h:963
LYS_NODE nodetype
Definition: tree_schema.h:504
struct lys_type_bit * bit
Definition: tree_schema.h:855
int lys_iffeature_value(const struct lys_iffeature *iff)
Learn how the if-feature statement currently evaluates.
uint8_t implemented
Definition: tree_schema.h:700
struct lys_type_info_bits bits
Definition: tree_schema.h:974
unsigned int count
Definition: tree_schema.h:856
struct lys_ident * ident
Definition: tree_schema.h:725
struct lys_type_info_inst inst
Definition: tree_schema.h:978
struct lys_node * target
Definition: tree_schema.h:1881
Submodule schema node structure that can be included into a YANG module.
Definition: tree_schema.h:744
Schema choice node structure.
Definition: tree_schema.h:1333
struct lys_type_info_num num
Definition: tree_schema.h:979
const 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 statem...
struct lys_unique * unique
Definition: tree_schema.h:1522
uint8_t type
Definition: tree_schema.h:690
struct lys_node * dflt
Definition: tree_schema.h:1361
const char * target_name
Definition: tree_schema.h:1856
const char * arg_value
Definition: tree_schema.h:485
struct lys_restr * patterns
Definition: tree_schema.h:945
uint8_t padding[4]
Definition: tree_schema.h:1247
struct lys_refine_mod_list list
Definition: tree_schema.h:1900
struct lys_module * lys_main_module(const struct lys_module *module)
Return main module of the module.
LYS_NODE nodetype
Definition: tree_schema.h:1257
struct lys_ext * extensions
Definition: tree_schema.h:729
uint8_t trg_type
Definition: tree_schema.h:2055
uint8_t deviated
Definition: tree_schema.h:695
uint8_t iffeature_size
Definition: tree_schema.h:842
struct lys_ident ** ref
Definition: tree_schema.h:903
const char * cond
Definition: tree_schema.h:2099
YANG uses's refine substatement structure, see RFC 6020 sec. 7.12.2
Definition: tree_schema.h:1907
YANG import structure used to reference other schemas (modules).
Definition: tree_schema.h:1991
Container for list modifications in lys_refine_mod.
Definition: tree_schema.h:1890
Container for information about string types (LY_TYPE_STRING), used in lys_type_info.
Definition: tree_schema.h:942
void * fill1[2]
Definition: tree_schema.h:1724
struct lys_node * data
Definition: tree_schema.h:733
const char ** dflt
Definition: tree_schema.h:1470
struct lys_import * imp
Definition: tree_schema.h:722
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.
unsigned int pat_count
Definition: tree_schema.h:951
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.
YANG typedef structure providing information from the schema.
Definition: tree_schema.h:2027
struct lys_restr * length
Definition: tree_schema.h:943
uint8_t min_set
Definition: tree_schema.h:1955
lyxp_node_type
Types of context nodes, LYXP_NODE_ROOT_CONFIG used only in when or must conditions.
Definition: tree_schema.h:2329
uint8_t padding[5]
Definition: tree_schema.h:465
struct lys_type * type
Definition: tree_schema.h:1965
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.
Single enumeration value specification for lys_type_info_enums.
Definition: tree_schema.h:875
const char * prefix
Definition: tree_schema.h:684
Union for holding type-specific information in lys_type.
Definition: tree_schema.h:972
#define LY_REV_SIZE
Definition: tree_schema.h:190
int lys_features_disable(const struct lys_module *module, const char *feature)
Disable specified feature in the module.
void * priv
Definition: tree_schema.h:1269
uint8_t padding[3]
Definition: tree_schema.h:764
struct lys_node * child
Definition: tree_schema.h:1259
Container for information about leafref types (LY_TYPE_LEAFREF), used in lys_type_info.
Definition: tree_schema.h:929
struct lys_tpdf * tpdf
Definition: tree_schema.h:724
uint8_t padding1
Definition: tree_schema.h:703
Compiled if-feature expression structure.
Definition: tree_schema.h:1085
struct lys_node_leaf ** keys
Definition: tree_schema.h:1521
union lys_type_info info
Definition: tree_schema.h:997
Schema leaf-list node structure.
Definition: tree_schema.h:1428
const char * contact
Definition: tree_schema.h:688
YANG augment structure (covering both possibilities - uses's substatement as well as (sub)module's su...
Definition: tree_schema.h:1855
uint8_t inc_size
Definition: tree_schema.h:709
LYS_OUTFORMAT
Schema output formats accepted by libyang printer functions.
Definition: tree_schema.h:204
void ly_load_plugins(void)
Load the available YANG extension and type plugins from the plugin directory (LIBDIR/libyang/).
struct lys_node * orig_node
Definition: tree_schema.h:1980
uint8_t max_set
Definition: tree_schema.h:1956
LYS_DEVIATE_TYPE mod
Definition: tree_schema.h:1949
struct lys_type_enum * enm
Definition: tree_schema.h:895
Container for information about enumeration types (LY_TYPE_ENUM), used in lys_type_info.
Definition: tree_schema.h:894
uint16_t ident_size
Definition: tree_schema.h:711
struct ly_set * der
Definition: tree_schema.h:2129
Container for information about integer types, used in lys_type_info.
Definition: tree_schema.h:921
uint8_t flags
Definition: tree_schema.h:1951
int ly_register_exts(struct lyext_plugin_list *plugin, const char *log_name)
Directly register a YANG extension by pointer.
LY_STMT stmt
Definition: tree_schema.h:451
const char * argument
Definition: tree_schema.h:467
struct lys_ext * def
Definition: tree_schema.h:480
const char * dsc
Definition: tree_schema.h:461
Union to hold target modification in lys_refine.
Definition: tree_schema.h:1898
uint16_t unres_count
Definition: tree_schema.h:1647
Schema anydata (and anyxml) node structure.
Definition: tree_schema.h:1543
Container for information about decimal64 types (LY_TYPE_DEC64), used in lys_type_info.
Definition: tree_schema.h:862
uint8_t insubstmt_index
Definition: tree_schema.h:488
int lys_set_implemented(const struct lys_module *module)
Mark imported module as "implemented".
struct lys_ext_instance ** ext
Definition: tree_schema.h:466
uint8_t has_union_leafref
Definition: tree_schema.h:2034
int lys_features_enable(const struct lys_module *module, const char *feature)
Enable specified feature in the module.
Structure to hold a set of (not necessary somehow connected) lyd_node or lys_node objects....
Definition: libyang.h:1720
const char * ref
Definition: tree_schema.h:686
struct lys_type_info_lref lref
Definition: tree_schema.h:980
char rev[11]
Definition: tree_schema.h:1994
struct lys_module * belongsto
Definition: tree_schema.h:793
const char * keys_str
Definition: tree_schema.h:1527
struct lys_module * module
Definition: tree_schema.h:468
uint8_t keys_size
Definition: tree_schema.h:1495
const char * dflt
Definition: tree_schema.h:1415
uint8_t latest_revision
Definition: tree_schema.h:701
const char * filepath
Definition: tree_schema.h:689
struct lyext_plugin * plugin
Definition: tree_schema.h:469
struct lys_iffeature * iffeature
Definition: tree_schema.h:848
Container for information about identity types (LY_TYPE_IDENT), used in lys_type_info.
Definition: tree_schema.h:902
YANG when restriction, see RFC 6020 sec. 7.19.5
Definition: tree_schema.h:2098
const void * lys_ext_instance_substmt(const struct lys_ext_instance *ext)
Get address of the substatement structure to which the extension instance refers.
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.
Container for information about bits types (LY_TYPE_BINARY), used in lys_type_info.
Definition: tree_schema.h:854
struct lyext_substmt * substmt
Definition: tree_schema.h:539
uint8_t * expr
Definition: tree_schema.h:1086
lys_deviate_type
Possible deviation modifications, see RFC 6020 sec. 7.18.3.2
Definition: tree_schema.h:1938
LYS_INFORMAT
Schema input formats accepted by libyang parser functions.
Definition: tree_schema.h:195
const 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.
Schema case node structure.
Definition: tree_schema.h:1677
struct lys_submodule * submodule
Definition: tree_schema.h:2005
struct lys_include * inc
Definition: tree_schema.h:723
int lys_features_state(const struct lys_module *module, const char *feature)
Get the current status of the specified feature in the module.
struct lys_node_augment * augment
Definition: tree_schema.h:727
uint8_t tpdf_size
Definition: tree_schema.h:1494
int lys_set_enabled(const struct lys_module *module)
Enable previously disabled module.
Schema list node structure.
Definition: tree_schema.h:1484
uint8_t features_size
Definition: tree_schema.h:714
const char * ns
Definition: tree_schema.h:734
struct lys_revision * rev
Definition: tree_schema.h:720
Container for information about instance-identifier types (LY_TYPE_INST), used in lys_type_info.
Definition: tree_schema.h:910
struct lys_feature * features
Definition: tree_schema.h:726
Main schema node structure representing YANG module.
Definition: tree_schema.h:681
struct lys_module * lys_node_module(const struct lys_node *node)
Return main module of the schema tree node.
Complex extension instance structure.
Definition: tree_schema.h:513
const 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.
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 returne...
uint32_t pos
Definition: tree_schema.h:845
struct lys_deviate * deviate
Definition: tree_schema.h:1984
int ly_clean_plugins(void)
Unload all the YANG extension and type plugins.
uint8_t unique_size
Definition: tree_schema.h:1496
RPC input and output node structure.
Definition: tree_schema.h:1722
uint8_t version
Definition: tree_schema.h:691
LY_DATA_TYPE _PACKED base
Definition: tree_schema.h:989
LY_DATA_TYPE
YANG built-in types.
Definition: tree_schema.h:799
uint8_t ext_size
Definition: tree_schema.h:718
struct lys_node * next
Definition: tree_schema.h:1263
struct lys_node_leaf * target
Definition: tree_schema.h:932
struct lys_node_grp * grp
Definition: tree_schema.h:1624
struct lys_type_info_dec64 dec64
Definition: tree_schema.h:975
struct lys_type_info_binary binary
Definition: tree_schema.h:973
struct lys_type type
Definition: tree_schema.h:1411
struct lys_module * lys_implemented_module(const struct lys_module *mod)
Find the implemented revision of the given module in the context.
uint16_t flags
Definition: tree_schema.h:839
YANG type structure providing information from the schema.
Definition: tree_schema.h:988
uint16_t flags
Definition: tree_schema.h:463
char date[11]
Definition: tree_schema.h:2017
void * padding_iff
Definition: tree_schema.h:1651
struct lys_when * when
Definition: tree_schema.h:1318
LYS_VERSION
supported YANG schema version values
Definition: tree_schema.h:668
YANG list's unique statement structure, see RFC 6020 sec. 7.8.3
Definition: tree_schema.h:2052
uint8_t imp_size
Definition: tree_schema.h:708
struct lys_refine * refine
Definition: tree_schema.h:1622
void * lys_ext_complex_get_substmt(LY_STMT stmt, struct lys_ext_instance_complex *ext, struct lyext_substmt **info)
get pointer to the place where the specified extension's substatement is supposed to be stored in the...
Structure to hold information about identity, see RFC 6020 sec. 7.16
Definition: tree_schema.h:2112
uint8_t padding[1]
Definition: tree_schema.h:1294
struct ly_set * depfeatures
Definition: tree_schema.h:2076
uint8_t refine_size
Definition: tree_schema.h:1602
struct lys_node * prev
Definition: tree_schema.h:1264
struct lys_tpdf * der
Definition: tree_schema.h:993
struct lys_ident ** base
Definition: tree_schema.h:2128
const char * org
Definition: tree_schema.h:687
Description of the extension instance substatement.
Definition: tree_schema.h:450
uint8_t rev_size
Definition: tree_schema.h:707
YANG deviate statement structure, see RFC 6020 sec. 7.18.3.2
Definition: tree_schema.h:1948
struct lys_restr * range
Definition: tree_schema.h:863
uint8_t base_size
Definition: tree_schema.h:2122
const char * name
Definition: tree_schema.h:460
const char *const * ly_get_loaded_plugins(void)
Get list of all the loaded plugins, both extension and user type ones.
uint8_t extensions_size
Definition: tree_schema.h:717
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.
struct lys_type_info_enums enums
Definition: tree_schema.h:976
const char * presence
Definition: tree_schema.h:1321
Schema uses node structure.
Definition: tree_schema.h:1591
const char * units
Definition: tree_schema.h:1412
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).
struct lys_type_info_union uni
Definition: tree_schema.h:982
Schema notification node structure.
Definition: tree_schema.h:1760
void * lys_set_private(const struct lys_node *node, void *priv)
Set a schema private pointer to a user pointer.
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.
const char * name
Definition: tree_schema.h:683
LY_STMT
List of YANG statements.
Definition: tree_schema.h:290
union lys_refine_mod mod
Definition: tree_schema.h:1931
const char ** expr
Definition: tree_schema.h:2053
YANG validity restriction (must, length, etc.) structure providing information from the schema.
Definition: tree_schema.h:2082
const 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.
int32_t value
Definition: tree_schema.h:885
uint8_t expr_size
Definition: tree_schema.h:2054
#define _PACKED
Compiler flag for packed data types.
Definition: libyang.h:38
enum lys_deviate_type LYS_DEVIATE_TYPE
Possible deviation modifications, see RFC 6020 sec. 7.18.3.2
LYEXT_TYPE
Extension types.
Definition: tree_schema.h:392
Schema rpc/action node structure.
Definition: tree_schema.h:1807
uint8_t padding_iffsize
Definition: tree_schema.h:1644
struct lys_restr * must
Definition: tree_schema.h:1319
Generic extension instance structure.
Definition: tree_schema.h:479
Container for information about union types (LY_TYPE_UNION), used in lys_type_info.
Definition: tree_schema.h:962
struct lys_tpdf * parent
Definition: tree_schema.h:995
uint8_t parent_type
Definition: tree_schema.h:498
YANG extension definition.
Definition: tree_schema.h:459
struct ly_ctx * ctx
Definition: tree_schema.h:682
uint8_t value_flags
Definition: tree_schema.h:990
uint8_t disabled
Definition: tree_schema.h:699
YANG revision statement for (sub)modules.
Definition: tree_schema.h:2016
struct lys_type_info_str str
Definition: tree_schema.h:981
YANG include structure used to reference submodules.
Definition: tree_schema.h:2004
uint8_t deviate_size
Definition: tree_schema.h:1982
YANG feature definition structure.
Definition: tree_schema.h:2061
uint8_t padding2[2]
Definition: tree_schema.h:704
struct lys_feature ** features
Definition: tree_schema.h:1088
uint16_t tpdf_size
Definition: tree_schema.h:712
const char * eapptag
Definition: tree_schema.h:2088
const char * path
Definition: tree_schema.h:930
enum lys_nodetype LYS_NODE
YANG schema node types.
Single bit value specification for lys_type_info_bits.
Definition: tree_schema.h:835
uint16_t target_type
Definition: tree_schema.h:1916
uint8_t padding[2]
Definition: tree_schema.h:1437
uint8_t deviation_size
Definition: tree_schema.h:716
int lys_ext_instance_presence(struct lys_ext *def, struct lys_ext_instance **ext, uint8_t ext_size)
Get the position of the extension instance in the extensions list.
libyang context handler.
const char * dsc
Definition: tree_schema.h:685
struct lys_type_info_ident ident
Definition: tree_schema.h:977
struct lys_ext_instance ** ext
Definition: tree_schema.h:730
Schema container node structure.
Definition: tree_schema.h:1285
struct lys_node * parent
Definition: tree_schema.h:1258
YANG deviation statement structure, see RFC 6020 sec. 7.18.3
Definition: tree_schema.h:1975
struct lys_node * lys_parent(const struct lys_node *node)
Return parent node in the schema tree.
const char * expr
Definition: tree_schema.h:2083
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.