libyang  3.13.3
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tree_data.h
Go to the documentation of this file.
1 
16 #ifndef LY_TREE_DATA_H_
17 #define LY_TREE_DATA_H_
18 
19 /* socket/ip includes in ly_config.h */
20 
21 #define PCRE2_CODE_UNIT_WIDTH 8
22 
23 #include <pcre2.h>
24 #include <stddef.h>
25 #include <stdint.h>
26 #include <time.h>
27 
28 #include "log.h"
29 #include "ly_config.h"
30 #include "tree.h"
31 #include "tree_schema.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 struct ly_ctx;
38 struct ly_path;
39 struct ly_set;
40 struct lyd_node;
41 struct lyd_node_opaq;
42 struct lyd_node_term;
43 struct timespec;
44 struct lyxp_var;
45 struct rb_node;
46 
418 /* *INDENT-OFF* */
419 
445 #define LYD_TREE_DFS_BEGIN(START, ELEM) \
446  { ly_bool LYD_TREE_DFS_continue = 0; struct lyd_node *LYD_TREE_DFS_next; \
447  for ((ELEM) = (LYD_TREE_DFS_next) = (struct lyd_node *)(START); \
448  (ELEM); \
449  (ELEM) = (LYD_TREE_DFS_next), LYD_TREE_DFS_continue = 0)
450 
465 #define LYD_TREE_DFS_END(START, ELEM) \
466  /* select element for the next run - children first */ \
467  if (LYD_TREE_DFS_continue) { \
468  (LYD_TREE_DFS_next) = NULL; \
469  } else { \
470  (LYD_TREE_DFS_next) = lyd_child(ELEM); \
471  }\
472  if (!(LYD_TREE_DFS_next)) { \
473  /* no children */ \
474  if ((ELEM) == (struct lyd_node *)(START)) { \
475  /* we are done, (START) has no children */ \
476  break; \
477  } \
478  /* try siblings */ \
479  (LYD_TREE_DFS_next) = (ELEM)->next; \
480  } \
481  while (!(LYD_TREE_DFS_next)) { \
482  /* parent is already processed, go to its sibling */ \
483  (ELEM) = (struct lyd_node *)(ELEM)->parent; \
484  /* no siblings, go back through parents */ \
485  if ((ELEM)->parent == (START)->parent) { \
486  /* we are done, no next element to process */ \
487  break; \
488  } \
489  (LYD_TREE_DFS_next) = (ELEM)->next; \
490  } }
491 
499 #define LYD_LIST_FOR_INST(START, SCHEMA, ELEM) \
500  for (lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
501  (ELEM) && ((ELEM)->schema == (SCHEMA)); \
502  (ELEM) = (ELEM)->next)
503 
512 #define LYD_LIST_FOR_INST_SAFE(START, SCHEMA, NEXT, ELEM) \
513  for ((NEXT) = (ELEM) = NULL, lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
514  (ELEM) && ((ELEM)->schema == (SCHEMA)) ? ((NEXT) = (ELEM)->next, 1) : 0; \
515  (ELEM) = (NEXT))
516 
517 /* *INDENT-ON* */
518 
522 #define LYD_CTX(node) ((node)->schema ? (node)->schema->module->ctx : ((const struct lyd_node_opaq *)(node))->ctx)
523 
531 #define LYD_NODE_IS_ALONE(NODE) \
532  (((NODE)->prev == NODE) || \
533  (((NODE)->prev->schema != (NODE)->schema) && (!(NODE)->next || ((NODE)->schema != (NODE)->next->schema))))
534 
539 typedef enum {
544 } LYD_FORMAT;
545 
549 typedef enum {
561 
567 struct lyd_value {
568  const char *_canonical;
571  const struct lysc_type *realtype;
579  union {
580  int8_t boolean;
581  int64_t dec64;
582  int8_t int8;
583  int16_t int16;
584  int32_t int32;
585  int64_t int64;
586  uint8_t uint8;
587  uint16_t uint16;
588  uint32_t uint32;
589  uint64_t uint64;
590  struct lysc_type_bitenum_item *enum_item;
591  struct lysc_ident *ident;
592  struct ly_path *target;
594  struct lyd_value_union *subvalue;
596  void *dyn_mem;
597  uint8_t fixed_mem[LYD_VALUE_FIXED_MEM_SIZE];
598  };
600 };
601 
610 #define LYD_VALUE_GET(value, type_val) \
611  ((sizeof *(type_val) > LYD_VALUE_FIXED_MEM_SIZE) \
612  ? ((type_val) = (((value)->dyn_mem))) \
613  : ((type_val) = ((void *)((value)->fixed_mem))))
614 
623  struct lyd_value value;
625  void *original;
626  size_t orig_len;
627  uint32_t hints;
631  void *prefix_data;
632  const struct lysc_node *ctx_node;
633 };
634 
639  char *bitmap;
644 };
645 
650  void *data;
651  size_t size;
652 };
653 
658  struct in_addr addr;
659 };
660 
665  struct in_addr addr;
666  const char *zone;
667 };
668 
673  struct in_addr addr;
674  uint8_t prefix;
675 };
676 
681  struct in6_addr addr;
682 };
683 
688  struct in6_addr addr;
689  const char *zone;
690 };
691 
696  struct in6_addr addr;
697  uint8_t prefix;
698 };
699 
704  time_t time;
705  char *fractions_s;
707 };
708 
713  struct lyxp_expr *exp;
714  const struct ly_ctx *ctx;
715  void *prefix_data;
717 };
718 
723  struct rb_node *rbt;
724 };
725 
733 struct ly_opaq_name {
734  const char *name;
735  const char *prefix;
737  union {
738  const char *module_ns;
739  const char *module_name;
740  };
741 };
742 
746 struct lyd_attr {
748  struct lyd_attr *next;
750  const char *value;
751  uint32_t hints;
754 };
755 
756 #define LYD_NODE_INNER (LYS_CONTAINER|LYS_LIST|LYS_RPC|LYS_ACTION|LYS_NOTIF)
757 #define LYD_NODE_TERM (LYS_LEAF|LYS_LEAFLIST)
758 #define LYD_NODE_ANY (LYS_ANYDATA)
785 #define LYD_DEFAULT 0x01
786 #define LYD_WHEN_TRUE 0x02
787 #define LYD_NEW 0x04
788 #define LYD_EXT 0x08
795 struct lyd_node {
796  uint32_t hash;
800  uint32_t flags;
801  const struct lysc_node *schema;
803  struct lyd_node *next;
804  struct lyd_node *prev;
808  struct lyd_meta *meta;
809  void *priv;
810 };
811 
816  union {
817  struct lyd_node node;
819  struct {
820  uint32_t hash;
825  uint32_t flags;
826  const struct lysc_node *schema;
827  struct lyd_node_inner *parent;
828  struct lyd_node *next;
829  struct lyd_node *prev;
833  struct lyd_meta *meta;
834  void *priv;
835  };
836  };
838  struct lyd_node *child;
839  struct ly_ht *children_ht;
841 #define LYD_HT_MIN_ITEMS 4
842 };
843 
848  union {
849  struct lyd_node node;
851  struct {
852  uint32_t hash;
857  uint32_t flags;
858  const struct lysc_node *schema;
859  struct lyd_node_inner *parent;
860  struct lyd_node *next;
861  struct lyd_node *prev;
865  struct lyd_meta *meta;
866  void *priv;
867  };
868  };
870  struct lyd_value value;
871 };
872 
877  struct lyd_node *tree;
878  const char *str;
879  const char *xml;
880  const char *json;
881  char *mem;
882 };
883 
888 struct lyd_node_any {
889  union {
890  struct lyd_node node;
892  struct {
893  uint32_t hash;
898  uint32_t flags;
899  const struct lysc_node *schema;
900  struct lyd_node_inner *parent;
901  struct lyd_node *next;
902  struct lyd_node *prev;
906  struct lyd_meta *meta;
907  void *priv;
908  };
909  };
911  union lyd_any_value value;
913 };
914 
921 #define LYD_NAME(node) ((node)->schema ? (node)->schema->name : ((struct lyd_node_opaq *)node)->name.name)
922 
932 #define LYD_VALHINT_STRING 0x0001
933 #define LYD_VALHINT_DECNUM 0x0002
934 #define LYD_VALHINT_OCTNUM 0x0004
935 #define LYD_VALHINT_HEXNUM 0x0008
936 #define LYD_VALHINT_NUM64 0x0010
937 #define LYD_VALHINT_BOOLEAN 0x0020
938 #define LYD_VALHINT_EMPTY 0x0040
939 #define LYD_VALHINT_STRING_DATATYPES 0x0080
953 #define LYD_NODEHINT_LIST 0x0080
954 #define LYD_NODEHINT_LEAFLIST 0x0100
955 #define LYD_NODEHINT_CONTAINER 0x0200
970 #define LYD_HINT_DATA 0x03F3
974 #define LYD_HINT_SCHEMA 0x03FF
985 struct lyd_node_opaq {
986  union {
987  struct lyd_node node;
989  struct {
990  uint32_t hash;
991  uint32_t flags;
992  const struct lysc_node *schema;
993  struct lyd_node_inner *parent;
994  struct lyd_node *next;
995  struct lyd_node *prev;
999  struct lyd_meta *meta;
1000  void *priv;
1001  };
1002  };
1004  struct lyd_node *child;
1006  struct ly_opaq_name name;
1007  const char *value;
1008  uint32_t hints;
1009  LY_VALUE_FORMAT format;
1010  void *val_prefix_data;
1012  struct lyd_attr *attr;
1013  const struct ly_ctx *ctx;
1014 };
1020  const struct lyd_node_term *node;
1021  const struct lyd_node_term **leafref_nodes;
1027  const struct lyd_node_term **target_nodes;
1030 };
1031 
1039 static inline struct lyd_node *
1040 lyd_parent(const struct lyd_node *node)
1041 {
1042  return (node && node->parent) ? &node->parent->node : NULL;
1043 }
1044 
1055 static inline struct lyd_node *
1056 lyd_child(const struct lyd_node *node)
1057 {
1058  if (!node) {
1059  return NULL;
1060  }
1061 
1062  if (!node->schema) {
1063  /* opaq node */
1064  return ((const struct lyd_node_opaq *)node)->child;
1065  }
1066 
1068  return ((const struct lyd_node_inner *)node)->child;
1069  }
1070 
1071  return NULL;
1072 }
1073 
1084 LIBYANG_API_DECL struct lyd_node *lyd_child_no_keys(const struct lyd_node *node);
1085 
1095 LIBYANG_API_DECL const struct lys_module *lyd_owner_module(const struct lyd_node *node);
1096 
1103 LIBYANG_API_DECL const struct lys_module *lyd_node_module(const struct lyd_node *node);
1104 
1111 LIBYANG_API_DECL ly_bool lyd_is_default(const struct lyd_node *node);
1112 
1120 LIBYANG_API_DECL uint32_t lyd_list_pos(const struct lyd_node *instance);
1121 
1128 LIBYANG_API_DECL struct lyd_node *lyd_first_sibling(const struct lyd_node *node);
1129 
1137 LIBYANG_API_DECL int lyd_lyb_data_length(const char *data);
1138 
1148 LIBYANG_API_DECL LY_ERR lyd_parse_opaq_error(const struct lyd_node *node);
1149 
1159 LIBYANG_API_DECL const char *lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value);
1160 
1167 static inline const char *
1168 lyd_get_value(const struct lyd_node *node)
1169 {
1170  if (!node) {
1171  return NULL;
1172  }
1173 
1174  if (!node->schema) {
1175  return ((const struct lyd_node_opaq *)node)->value;
1176  } else if (node->schema->nodetype & LYD_NODE_TERM) {
1177  const struct lyd_value *value = &((const struct lyd_node_term *)node)->value;
1178 
1179  return value->_canonical ? value->_canonical : lyd_value_get_canonical(LYD_CTX(node), value);
1180  }
1181 
1182  return NULL;
1183 }
1184 
1192 LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, char **value_str);
1193 
1202 LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const union lyd_any_value *value,
1203  LYD_ANYDATA_VALUETYPE value_type);
1204 
1211 LIBYANG_API_DECL const struct lysc_node *lyd_node_schema(const struct lyd_node *node);
1212 
1220 LIBYANG_API_DECL ly_bool lyd_meta_is_internal(const struct lyd_meta *meta);
1221 
1237 LIBYANG_API_DECL LY_ERR lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name,
1238  ly_bool output, struct lyd_node **node);
1239 
1253 LIBYANG_API_DECL LY_ERR lyd_new_ext_inner(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node);
1254 
1276 #define LYD_NEW_VAL_OUTPUT 0x01
1278 #define LYD_NEW_VAL_STORE_ONLY 0x02
1279 #define LYD_NEW_VAL_BIN 0x04
1281 #define LYD_NEW_VAL_CANON 0x08
1284 #define LYD_NEW_META_CLEAR_DFLT 0x10
1285 #define LYD_NEW_PATH_UPDATE 0x20
1289 #define LYD_NEW_PATH_OPAQ 0x40
1293 #define LYD_NEW_PATH_WITH_OPAQ 0x80
1294 #define LYD_NEW_ANY_USE_VALUE 0x100
1311 LIBYANG_API_DECL LY_ERR lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name,
1312  uint32_t options, struct lyd_node **node, ...);
1313 
1329 LIBYANG_API_DECL LY_ERR lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, uint32_t options,
1330  struct lyd_node **node, ...);
1331 
1345 LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name,
1346  const char *keys, uint32_t options, struct lyd_node **node);
1347 
1361 LIBYANG_API_DECL LY_ERR lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const char *name,
1362  const char **key_values, uint32_t *value_lengths, uint32_t options, struct lyd_node **node);
1363 
1378 LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name,
1379  const char *value, uint32_t options, struct lyd_node **node);
1380 
1393 LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name,
1394  const void *value, size_t value_len, uint32_t options, struct lyd_node **node);
1395 
1410 LIBYANG_API_DECL LY_ERR lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const void *value,
1411  size_t value_len, uint32_t options, struct lyd_node **node);
1412 
1427 LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name,
1428  const void *value, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node);
1429 
1444 LIBYANG_API_DECL LY_ERR lyd_new_ext_any(const struct lysc_ext_instance *ext, const char *name, const void *value,
1445  LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node);
1446 
1461 LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module,
1462  const char *name, const char *val_str, uint32_t options, struct lyd_meta **meta);
1463 
1476 LIBYANG_API_DECL LY_ERR lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, uint32_t options,
1477  const struct lyd_attr *attr, struct lyd_meta **meta);
1478 
1491 LIBYANG_API_DECL LY_ERR lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1492  const char *prefix, const char *module_name, struct lyd_node **node);
1493 
1506 LIBYANG_API_DECL LY_ERR lyd_new_opaq2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1507  const char *prefix, const char *module_ns, struct lyd_node **node);
1508 
1522 LIBYANG_API_DECL LY_ERR lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *value,
1523  struct lyd_attr **attr);
1524 
1537 LIBYANG_API_DECL LY_ERR lyd_new_attr2(struct lyd_node *parent, const char *module_ns, const char *name, const char *value,
1538  struct lyd_attr **attr);
1539 
1568 LIBYANG_API_DECL LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value,
1569  uint32_t options, struct lyd_node **node);
1570 
1595 LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value,
1596  size_t value_len, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **new_parent,
1597  struct lyd_node **new_node);
1598 
1621 LIBYANG_API_DECL LY_ERR lyd_new_ext_path(struct lyd_node *parent, const struct lysc_ext_instance *ext, const char *path,
1622  const void *value, uint32_t options, struct lyd_node **node);
1623 
1637 #define LYD_IMPLICIT_NO_STATE 0x01
1638 #define LYD_IMPLICIT_NO_CONFIG 0x02
1639 #define LYD_IMPLICIT_OUTPUT 0x04
1640 #define LYD_IMPLICIT_NO_DEFAULTS 0x08
1653 LIBYANG_API_DECL LY_ERR lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff);
1666 LIBYANG_API_DECL LY_ERR lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options,
1667  struct lyd_node **diff);
1668 
1680 LIBYANG_API_DECL LY_ERR lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module,
1681  uint32_t implicit_options, struct lyd_node **diff);
1682 
1696 LIBYANG_API_DECL LY_ERR lyd_change_term(struct lyd_node *term, const char *val_str);
1697 
1712 LIBYANG_API_DECL LY_ERR lyd_change_term_bin(struct lyd_node *term, const void *value, size_t value_len);
1713 
1728 LIBYANG_API_DECL LY_ERR lyd_change_term_canon(struct lyd_node *term, const char *val_str);
1729 
1739 LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str);
1740 
1752 LIBYANG_API_DECL LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node);
1753 
1766 LIBYANG_API_DECL LY_ERR lyd_insert_sibling(struct lyd_node *sibling, struct lyd_node *node, struct lyd_node **first);
1767 
1779 LIBYANG_API_DECL LY_ERR lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node);
1780 
1792 LIBYANG_API_DECL LY_ERR lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node);
1793 
1801 LIBYANG_API_DECL LY_ERR lyd_unlink_siblings(struct lyd_node *node);
1802 
1810 LIBYANG_API_DECL LY_ERR lyd_unlink_tree(struct lyd_node *node);
1811 
1817 LIBYANG_API_DECL void lyd_free_all(struct lyd_node *node);
1818 
1824 LIBYANG_API_DECL void lyd_free_siblings(struct lyd_node *node);
1825 
1831 LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node);
1832 
1838 LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta);
1839 
1845 LIBYANG_API_DECL void lyd_free_meta_siblings(struct lyd_meta *meta);
1846 
1853 LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr);
1854 
1861 LIBYANG_API_DECL void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr);
1862 
1881 LIBYANG_API_DECL LY_ERR lyd_value_validate(const struct ly_ctx *ctx, const struct lysc_node *schema, const char *value,
1882  size_t value_len, const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical);
1883 
1896 LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, size_t value_len);
1897 
1904 #define LYD_COMPARE_FULL_RECURSION 0x01 /* Lists and containers are the same only in case all they children
1905  (subtree, so direct as well as indirect children) are the same. By default,
1906  containers are the same in case of the same schema node and lists are the same
1907  in case of equal keys (keyless lists do the full recursion comparison all the time). */
1908 #define LYD_COMPARE_DEFAULTS 0x02 /* By default, implicit and explicit default nodes are considered to be equal. This flag
1909  changes this behavior and implicit (automatically created default node) and explicit
1910  (explicitly created node with the default value) default nodes are considered different. */
1911 #define LYD_COMPARE_OPAQ 0x04 /* Opaque nodes can normally be never equal to data nodes. Using this flag even
1912  opaque nodes members are compared to data node schema and value and can result
1913  in a match. */
1914 
1927 LIBYANG_API_DECL LY_ERR lyd_compare_single(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1940 LIBYANG_API_DECL LY_ERR lyd_compare_siblings(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1941 
1952 LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2);
1953 
1966 #define LYD_DUP_RECURSIVE 0x01
1968 #define LYD_DUP_NO_META 0x02
1970 #define LYD_DUP_WITH_PARENTS 0x04
1972 #define LYD_DUP_WITH_FLAGS 0x08
1974 #define LYD_DUP_NO_EXT 0x10
1975 #define LYD_DUP_WITH_PRIV 0x20
1977 #define LYD_DUP_NO_LYDS 0x40
1995 LIBYANG_API_DECL LY_ERR lyd_dup_single(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options,
1996  struct lyd_node **dup);
1997 
2011 LIBYANG_API_DECL LY_ERR lyd_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
2012  struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup);
2013 
2025 LIBYANG_API_DECL LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options,
2026  struct lyd_node **dup);
2027 
2042 LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
2043  struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup);
2044 
2053 LIBYANG_API_DECL LY_ERR lyd_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *parent, struct lyd_meta **dup);
2054 
2069 #define LYD_MERGE_DESTRUCT 0x01
2070 #define LYD_MERGE_DEFAULTS 0x02
2071 #define LYD_MERGE_WITH_FLAGS 0x04
2095 LIBYANG_API_DECL LY_ERR lyd_merge_tree(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2118 LIBYANG_API_DECL LY_ERR lyd_merge_siblings(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2119 
2129 typedef LY_ERR (*lyd_merge_cb)(struct lyd_node *trg_node, const struct lyd_node *src_node, void *cb_data);
2130 
2146 LIBYANG_API_DECL LY_ERR lyd_merge_module(struct lyd_node **target, const struct lyd_node *source, const struct lys_module *mod,
2147  lyd_merge_cb merge_cb, void *cb_data, uint16_t options);
2148 
2163 #define LYD_DIFF_DEFAULTS 0x01
2166 #define LYD_DIFF_META 0x02
2197 LIBYANG_API_DECL LY_ERR lyd_diff_tree(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2198  struct lyd_node **diff);
2199 
2212 LIBYANG_API_DECL LY_ERR lyd_diff_siblings(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2213  struct lyd_node **diff);
2214 
2223 typedef LY_ERR (*lyd_diff_cb)(const struct lyd_node *diff_node, struct lyd_node *data_node, void *cb_data);
2224 
2241 LIBYANG_API_DECL LY_ERR lyd_diff_apply_module(struct lyd_node **data, const struct lyd_node *diff,
2242  const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data);
2243 
2254 LIBYANG_API_DECL LY_ERR lyd_diff_apply_all(struct lyd_node **data, const struct lyd_node *diff);
2255 
2267 #define LYD_DIFF_MERGE_DEFAULTS 0x01
2295 LIBYANG_API_DECL LY_ERR lyd_diff_merge_module(struct lyd_node **diff, const struct lyd_node *src_diff,
2296  const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2297 
2314 LIBYANG_API_DECL LY_ERR lyd_diff_merge_tree(struct lyd_node **diff_first, struct lyd_node *diff_parent,
2315  const struct lyd_node *src_sibling, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2316 
2328 LIBYANG_API_DECL LY_ERR lyd_diff_merge_all(struct lyd_node **diff, const struct lyd_node *src_diff, uint16_t options);
2329 
2339 LIBYANG_API_DECL LY_ERR lyd_diff_reverse_all(const struct lyd_node *src_diff, struct lyd_node **diff);
2340 
2344 typedef enum {
2345  LYD_PATH_STD,
2349 } LYD_PATH_TYPE;
2350 
2366 LIBYANG_API_DECL char *lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen);
2367 
2377 LIBYANG_API_DECL struct lyd_meta *lyd_find_meta(const struct lyd_meta *first, const struct lys_module *module,
2378  const char *name);
2379 
2391 LIBYANG_API_DECL LY_ERR lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target,
2392  struct lyd_node **match);
2393 
2418 LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema,
2419  const char *key_or_value, size_t val_len, struct lyd_node **match);
2420 
2432 LIBYANG_API_DECL LY_ERR lyd_find_sibling_dup_inst_set(const struct lyd_node *siblings, const struct lyd_node *target,
2433  struct ly_set **set);
2434 
2445 LIBYANG_API_DECL LY_ERR lyd_find_sibling_opaq_next(const struct lyd_node *first, const char *name, struct lyd_node **match);
2446 
2458 LIBYANG_API_DECL LY_ERR lyxp_vars_set(struct lyxp_var **vars, const char *name, const char *value);
2459 
2465 LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars);
2466 
2484 LIBYANG_API_DECL LY_ERR lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set);
2485 
2499 LIBYANG_API_DECL LY_ERR lyd_find_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars,
2500  struct ly_set **set);
2501 
2519 LIBYANG_API_DECL LY_ERR lyd_find_xpath3(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath,
2520  LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, struct ly_set **set);
2521 
2533 LIBYANG_API_DECL LY_ERR lyd_eval_xpath(const struct lyd_node *ctx_node, const char *xpath, ly_bool *result);
2534 
2547 LIBYANG_API_DECL LY_ERR lyd_eval_xpath2(const struct lyd_node *ctx_node, const char *xpath,
2548  const struct lyxp_var *vars, ly_bool *result);
2549 
2565 LIBYANG_API_DECL LY_ERR lyd_eval_xpath3(const struct lyd_node *ctx_node, const struct lys_module *cur_mod,
2566  const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, ly_bool *result);
2567 
2571 typedef enum {
2573  LY_XPATH_STRING,
2574  LY_XPATH_NUMBER,
2576 } LY_XPATH_TYPE;
2577 
2600 LIBYANG_API_DECL LY_ERR lyd_eval_xpath4(const struct lyd_node *ctx_node, const struct lyd_node *tree,
2601  const struct lys_module *cur_mod, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data,
2602  const struct lyxp_var *vars, LY_XPATH_TYPE *ret_type, struct ly_set **node_set, char **string,
2603  long double *number, ly_bool *boolean);
2614 LIBYANG_API_DEF LY_ERR lyd_trim_xpath(struct lyd_node **tree, const char *xpath, const struct lyxp_var *vars);
2615 
2633 LIBYANG_API_DECL LY_ERR lyd_find_path(const struct lyd_node *ctx_node, const char *path, ly_bool output,
2634  struct lyd_node **match);
2635 
2646 LIBYANG_API_DECL LY_ERR lyd_find_target(const struct ly_path *path, const struct lyd_node *tree, struct lyd_node **match);
2647 
2653 LIBYANG_API_DECL int ly_time_tz_offset(void);
2654 
2661 LIBYANG_API_DECL int ly_time_tz_offset_at(time_t time);
2662 
2671 LIBYANG_API_DECL LY_ERR ly_time_str2time(const char *value, time_t *time, char **fractions_s);
2672 
2681 LIBYANG_API_DECL LY_ERR ly_time_time2str(time_t time, const char *fractions_s, char **str);
2682 
2690 LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts);
2691 
2699 LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str);
2700 
2711 LIBYANG_API_DECL LY_ERR lyd_leafref_get_links(const struct lyd_node_term *node, const struct lyd_leafref_links_rec **record);
2712 
2722 LIBYANG_API_DECL LY_ERR lyd_leafref_link_node_tree(const struct lyd_node *tree);
2723 
2737 LIBYANG_API_DECL LY_ERR ly_pattern_match(const struct ly_ctx *ctx, const char *pattern, const char *string,
2738  uint32_t str_len, pcre2_code **pcode);
2739 
2749 LIBYANG_API_DECL LY_ERR ly_pattern_compile(const struct ly_ctx *ctx, const char *pattern, pcre2_code **pcode);
2750 
2751 #ifdef __cplusplus
2752 }
2753 #endif
2754 
2755 #endif /* LY_TREE_DATA_H_ */
LIBYANG_API_DECL LY_ERR lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target, struct lyd_node **match)
Search in the given siblings (NOT recursively) for the first target instance with the same value...
struct in_addr addr
Definition: tree_data.h:673
LIBYANG_API_DECL LY_ERR lyd_diff_reverse_all(const struct lyd_node *src_diff, struct lyd_node **diff)
Reverse a diff and make the opposite changes. Meaning change create to delete, delete to create...
LIBYANG_API_DECL LY_ERR lyd_diff_apply_module(struct lyd_node **data, const struct lyd_node *diff, const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data)
Apply the whole diff on a data tree but restrict the operation to one module.
struct lysc_type * realtype
Definition: tree_data.h:571
LIBYANG_API_DECL LY_ERR ly_time_time2str(time_t time, const char *fractions_s, char **str)
Convert UNIX timestamp and fractions of a second into canonical date-and-time string value...
Compiled YANG data node.
Definition: tree_schema.h:1439
LIBYANG_API_DECL LY_ERR lyd_merge_siblings(struct lyd_node **target, const struct lyd_node *source, uint16_t options)
Merge the source data tree with any following siblings into the target data tree. Merge may not be co...
LY_ERR(* lyd_merge_cb)(struct lyd_node *trg_node, const struct lyd_node *src_node, void *cb_data)
Callback for matching merge nodes.
Definition: tree_data.h:2154
LIBYANG_API_DECL LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value, uint32_t options, struct lyd_node **node)
Create a new node in the data tree based on a path. If creating anyxml/anydata nodes, lyd_new_path2 should be used instead, this function expects the value as string.
LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str)
Convert timespec into date-and-time string value.
LIBYANG_API_DECL LY_ERR lyd_eval_xpath4(const struct lyd_node *ctx_node, const struct lyd_node *tree, const struct lys_module *cur_mod, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, LY_XPATH_TYPE *ret_type, struct ly_set **node_set, char **string, long double *number, ly_bool *boolean)
Evaluate an XPath on data and return the result or convert it first to an expected result type...
union for anydata/anyxml value representation.
Definition: tree_data.h:876
#define LYS_CONTAINER
Definition: tree_schema.h:240
Generic prefix and namespace mapping, meaning depends on the format.
Definition: tree_data.h:733
LIBYANG_API_DECL LY_ERR lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node)
Insert a node after another node, can be used only for user-ordered nodes. If inserting several sibli...
const char * zone
Definition: tree_data.h:689
LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars)
Free the XPath variables.
const char * str
Definition: tree_data.h:878
const char * prefix
Definition: tree_data.h:735
LIBYANG_API_DECL LY_ERR lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output, struct lyd_node **node)
Create a new inner node in the data tree.
struct in_addr addr
Definition: tree_data.h:665
Generic structure for a data node.
Definition: tree_data.h:795
LIBYANG_API_DECL LY_ERR lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set)
Search in the given data for instances of nodes matching the provided XPath.
YANG extension compiled instance.
Definition: plugins_exts.h:437
LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2)
Compare 2 metadata.
uint32_t hash
Definition: tree_data.h:796
const char * xml
Definition: tree_data.h:879
const char * zone
Definition: tree_data.h:666
struct lyd_node_opaq * parent
Definition: tree_data.h:747
const char * name
Definition: metadata.h:40
void * priv
Definition: tree_data.h:809
uint8_t ly_bool
Type to indicate boolean value.
Definition: log.h:28
LYD_PATH_TYPE
Types of the different data paths.
Definition: tree_data.h:2373
LIBYANG_API_DECL LY_ERR lyd_diff_merge_tree(struct lyd_node **diff_first, struct lyd_node *diff_parent, const struct lyd_node *src_sibling, lyd_diff_cb diff_cb, void *cb_data, uint16_t options)
Merge 2 diff trees into each other.
LIBYANG_API_DECL LY_ERR lyxp_vars_set(struct lyxp_var **vars, const char *name, const char *value)
Set a new XPath variable to vars.
const char * name
Definition: tree_schema.h:1450
void * original
Definition: tree_data.h:625
YANG identity-stmt.
Definition: tree_schema.h:1230
struct lysc_node * parent
Definition: tree_schema.h:1444
libyang representation of YANG schema trees.
Special lyd_value structure for ietf-inet-types ipv4-address values.
Definition: tree_data.h:664
struct rb_node * rbt
Definition: tree_data.h:723
libyang generic macros and functions to work with YANG schema or data trees.
LIBYANG_API_DEF LY_ERR lyd_trim_xpath(struct lyd_node **tree, const char *xpath, const struct lyxp_var *vars)
Evaluate an XPath on data and free all the nodes except the subtrees selected by the expression...
Special lyd_value structure for ietf-inet-types ipv6-address-no-zone values.
Definition: tree_data.h:680
Special lyd_value structure for ietf-inet-types ipv4-address-no-zone values.
Definition: tree_data.h:657
LIBYANG_API_DECL LY_ERR lyd_find_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars, struct ly_set **set)
Search in the given data for instances of nodes matching the provided XPath.
size_t orig_len
Definition: tree_data.h:626
Data node structure for the inner data tree nodes - containers, lists, RPCs, actions and Notification...
Definition: tree_data.h:815
LIBYANG_API_DECL char * lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen)
Generate path of the given node in the requested format.
struct lyd_value value
Definition: metadata.h:41
struct lyd_node * child
Definition: tree_data.h:838
LIBYANG_API_DECL LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node)
Insert a child into a parent.
dup realtype
Definition: lyds_tree.c:89
LIBYANG_API_DECL LY_ERR lyd_find_target(const struct ly_path *path, const struct lyd_node *tree, struct lyd_node **match)
Find the target node of a compiled path (lyd_value instance-identifier).
struct in6_addr addr
Definition: tree_data.h:696
void * prefix_data
Definition: tree_data.h:715
Special lyd_value structure for ietf-yang-types date-and-time values.
Definition: tree_data.h:703
LIBYANG_API_DECL LY_ERR lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const void *value, size_t value_len, uint32_t options, struct lyd_node **node)
Create a new top-level term node defined in the given extension instance.
uint16_t nodetype
Definition: tree_schema.h:1440
struct lyd_meta * meta
Definition: tree_data.h:808
Data node structure for the terminal data tree nodes - leaves and leaf-lists.
Definition: tree_data.h:847
struct lyd_node_inner * parent
Definition: tree_data.h:802
LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema, const char *key_or_value, size_t val_len, struct lyd_node **match)
Search in the given siblings for the first schema instance. Uses hashes - should be used whenever pos...
LIBYANG_API_DECL LY_ERR lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node)
Insert a node before another node, can be used only for user-ordered nodes. If inserting several sibl...
LIBYANG_API_DECL LY_ERR lyd_diff_merge_all(struct lyd_node **diff, const struct lyd_node *src_diff, uint16_t options)
Merge 2 diffs into each other.
LIBYANG_API_DECL LY_ERR lyd_find_sibling_opaq_next(const struct lyd_node *first, const char *name, struct lyd_node **match)
Search the given siblings for an opaque node with a specific name.
LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx, struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node with any following siblings. Schema references are assi...
struct lysc_node * schema
Definition: tree_data.h:801
LIBYANG_API_DECL struct lys_module * lyd_owner_module(const struct lyd_node *node)
Get the owner module of the data node. It is the module of the top-level schema node. Generally, in case of augments it is the target module, recursively, otherwise it is the module where the data node is defined.
LIBYANG_API_DECL LY_ERR lyd_find_path(const struct lyd_node *ctx_node, const char *path, ly_bool output, struct lyd_node **match)
Search in given data for a node uniquely identified by a path.
struct lysc_node * ctx_node
Definition: tree_data.h:632
LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts)
Convert date-and-time from string to timespec.
struct ly_opaq_name name
Definition: tree_data.h:749
LIBYANG_API_DECL LY_ERR lyd_new_opaq2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value, const char *prefix, const char *module_ns, struct lyd_node **node)
Create a new XML opaque node in the data tree. To create a JSON opaque node, use lyd_new_opaq().
uint32_t hints
Definition: tree_data.h:751
LIBYANG_API_DECL LY_ERR lyd_eval_xpath3(const struct lyd_node *ctx_node, const struct lys_module *cur_mod, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, ly_bool *result)
Evaluate an XPath on data and return the result converted to boolean.
LIBYANG_API_DECL LY_ERR lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const char *name, const char **key_values, uint32_t *value_lengths, uint32_t options, struct lyd_node **node)
Create a new list node in the data tree.
LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module, const char *name, const char *val_str, uint32_t options, struct lyd_meta **meta)
Create a new metadata.
struct lysc_type_bitenum_item ** items
Definition: tree_data.h:642
libyang hash table.
Special lyd_value structure for ietf-inet-types ipv6-address values.
Definition: tree_data.h:687
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
Definition: tree_data.h:539
LIBYANG_API_DECL struct lysc_node * lyd_node_schema(const struct lyd_node *node)
Get schema node of a data node. Useful especially for opaque nodes.
YANG data representation.
Definition: tree_data.h:567
const char * _canonical
Definition: tree_data.h:568
LY_XPATH_TYPE
XPath result type.
Definition: tree_data.h:2600
LIBYANG_API_DECL LY_ERR lyd_compare_single(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options)
Compare 2 data nodes if they are equivalent.
LIBYANG_API_DECL int ly_time_tz_offset(void)
Get current timezone (including DST setting) UTC (GMT) time offset in seconds.
LIBYANG_API_DECL struct lyd_node * lyd_child_no_keys(const struct lyd_node *node)
Get the child pointer of a generic data node but skip its keys in case it is LYS_LIST.
LIBYANG_API_DECL LY_ERR ly_pattern_match(const struct ly_ctx *ctx, const char *pattern, const char *string, uint32_t str_len, pcre2_code **pcode)
Check a string matches an XML Schema regex used in YANG.
Metadata structure.
Definition: metadata.h:36
LIBYANG_API_DECL LY_ERR lyd_new_ext_any(const struct lysc_ext_instance *ext, const char *name, const void *value, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node)
Create a new top-level any node defined in the given extension instance.
struct ly_ctx * ctx
Definition: tree_data.h:714
LIBYANG_API_DECL LY_ERR lyd_new_ext_inner(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node)
Create a new top-level inner node defined in the given extension instance.
LIBYANG_API_DECL LY_ERR lyd_eval_xpath(const struct lyd_node *ctx_node, const char *xpath, ly_bool *result)
Evaluate an XPath on data and return the result converted to boolean.
LIBYANG_API_DECL const char * lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value)
Get the (canonical) value of a lyd_value.
LIBYANG_API_DECL LY_ERR lyd_compare_siblings(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options)
Compare 2 lists of siblings if they are equivalent.
LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str)
Change the value of a metadata instance.
LIBYANG_API_DECL LY_ERR lyd_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx, struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node. Schema references are assigned from trg_ctx...
LIBYANG_API_DECL LY_ERR lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, uint32_t options, const struct lyd_attr *attr, struct lyd_meta **meta)
Create new metadata from an opaque node attribute if possible.
LIBYANG_API_DECL struct lys_module * lyd_node_module(const struct lyd_node *node)
Get the module of a node. Useful mainly for opaque nodes.
LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node)
Free (and unlink) the specified data (sub)tree.
LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *keys, uint32_t options, struct lyd_node **node)
Create a new list node in the data tree.
const char * name
Definition: tree_data.h:734
LIBYANG_API_DECL struct lyd_node * lyd_first_sibling(const struct lyd_node *node)
Get the first sibling of the given node.
uint32_t hints
Definition: tree_data.h:627
#define LYS_ACTION
Definition: tree_schema.h:250
LIBYANG_API_DECL LY_ERR lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *value, struct lyd_attr **attr)
Create new JSON attribute for an opaque data node. To create an XML attribute, use lyd_new_attr2()...
LIBYANG_API_DECL LY_ERR lyd_value_validate(const struct ly_ctx *ctx, const struct lysc_node *schema, const char *value, size_t value_len, const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical)
Check type restrictions applicable to the particular leaf/leaf-list with the given string value...
LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value, size_t value_len, uint32_t options, struct lyd_node **node)
Create a new term node in the data tree based on binary value.
Special lyd_value structure for ietf-inet-types ipv4-prefix values.
Definition: tree_data.h:672
LIBYANG_API_DECL LY_ERR lyd_leafref_link_node_tree(const struct lyd_node *tree)
Traverse through data tree including root node siblings and adds leafrefs links to the given nodes...
LIBYANG_API_DECL int lyd_lyb_data_length(const char *data)
Learn the length of LYB data.
void * val_prefix_data
Definition: tree_data.h:753
struct lyd_node_term ** target_nodes
Definition: tree_data.h:1033
uint32_t flags
Definition: tree_data.h:800
Structure to hold a set of (not necessary somehow connected) objects. Usually used for lyd_node...
Definition: set.h:47
void * prefix_data
Definition: tree_data.h:631
LIBYANG_API_DECL LY_ERR lyd_insert_sibling(struct lyd_node *sibling, struct lyd_node *node, struct lyd_node **first)
Insert a node into siblings.
LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta)
Free a single metadata instance.
LIBYANG_API_DECL LY_ERR lyd_new_attr2(struct lyd_node *parent, const char *module_ns, const char *name, const char *value, struct lyd_attr **attr)
Create new XML attribute for an opaque data node. To create a JSON attribute, use lyd_new_attr()...
LIBYANG_API_DECL LY_ERR lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value, const char *prefix, const char *module_name, struct lyd_node **node)
Create a new JSON opaque node in the data tree. To create an XML opaque node, use lyd_new_opaq2()...
Available YANG schema tree structures representing YANG module.
Definition: tree_schema.h:2157
LIBYANG_API_DECL LY_ERR ly_time_str2time(const char *value, time_t *time, char **fractions_s)
Convert date-and-time from string to UNIX timestamp and fractions of a second.
struct in6_addr addr
Definition: tree_data.h:688
char * mem
Definition: tree_data.h:881
Special lyd_value structure for lyds tree value.
Definition: tree_data.h:722
LY_ERR(* lyd_diff_cb)(const struct lyd_node *diff_node, struct lyd_node *data_node, void *cb_data)
Callback for diff nodes.
Definition: tree_data.h:2252
LIBYANG_API_DECL ly_bool lyd_is_default(const struct lyd_node *node)
Check whether a node value equals to its default one.
LIBYANG_API_DECL struct lyd_meta * lyd_find_meta(const struct lyd_meta *first, const struct lys_module *module, const char *name)
Find a specific metadata.
LIBYANG_API_DECL void lyd_free_all(struct lyd_node *node)
Free all the nodes (even parents of the node) in the data tree.
LIBYANG_API_DECL LY_ERR lyd_change_term(struct lyd_node *term, const char *val_str)
Change the value of a term (leaf or leaf-list) node to a string value.
LIBYANG_API_DECL void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr)
Free the attribute with any following attributes.
const char * json
Definition: tree_data.h:880
LIBYANG_API_DECL LY_ERR lyd_unlink_siblings(struct lyd_node *node)
Unlink the specified node with all the following siblings.
LIBYANG_API_DECL LY_ERR lyd_change_term_canon(struct lyd_node *term, const char *val_str)
Change the value of a term (leaf or leaf-list) node to a canonical string value.
LIBYANG_API_DECL LY_ERR lyd_parse_opaq_error(const struct lyd_node *node)
Check node parsed into an opaque node for the reason (error) why it could not be parsed as data node...
const char * value
Definition: tree_data.h:750
Special lyd_value structure for ietf-inet-types ipv6-prefix values.
Definition: tree_data.h:695
Generic attribute structure.
Definition: tree_data.h:746
struct lys_module * module
Definition: tree_schema.h:1443
Special lyd_value structure for ietf-yang-types xpath1.0 values.
Definition: tree_data.h:712
#define LYD_CTX(node)
Macro to get context from a data tree node.
Definition: tree_data.h:522
struct lyd_attr * next
Definition: tree_data.h:748
LIBYANG_API_DECL void lyd_free_siblings(struct lyd_node *node)
Free all the sibling nodes (preceding as well as succeeding).
LY_VALUE_FORMAT format
Definition: tree_data.h:716
LY_VALUE_FORMAT format
Definition: tree_data.h:752
LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const union lyd_any_value *value, LYD_ANYDATA_VALUETYPE value_type)
Copy anydata value from one node to another. Target value is freed first.
LIBYANG_API_DECL LY_ERR lyd_find_sibling_dup_inst_set(const struct lyd_node *siblings, const struct lyd_node *target, struct ly_set **set)
Search the given siblings for all the exact same instances of a specific node instance. Uses hashes to whatever extent possible.
LIBYANG_API_DECL int ly_time_tz_offset_at(time_t time)
Get UTC (GMT) timezone offset in seconds at a specific timestamp (including DST setting).
struct lyd_node_term * node
Definition: tree_data.h:1026
LY_VALUE_FORMAT
All kinds of supported value formats and prefix mappings to modules.
Definition: tree.h:234
#define LYS_NOTIF
Definition: tree_schema.h:251
LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *value, uint32_t options, struct lyd_node **node)
Create a new term node in the data tree.
LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, size_t value_len)
Compare the node&#39;s value with the given string value. The string value is first validated according t...
#define LYD_NODE_TERM
Definition: tree_data.h:757
#define LYS_RPC
Definition: tree_schema.h:249
char * bitmap
Definition: tree_data.h:639
struct lyd_value value
Definition: tree_data.h:870
LIBYANG_API_DECL uint32_t lyd_list_pos(const struct lyd_node *instance)
Learn the relative position of a list or leaf-list instance within other instances of the same schema...
LIBYANG_API_DECL LY_ERR lyd_diff_siblings(const struct lyd_node *first, const struct lyd_node *second, uint16_t options, struct lyd_node **diff)
Learn the differences between 2 data trees including all the following siblings.
LIBYANG_API_DECL LY_ERR lyd_eval_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars, ly_bool *result)
Evaluate an XPath on data and return the result converted to boolean.
LYD_ANYDATA_VALUETYPE value_type
Definition: tree_data.h:912
LYD_ANYDATA_VALUETYPE
List of possible value types stored in lyd_node_any.
Definition: tree_data.h:549
LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, char **value_str)
Get anydata string value.
LIBYANG_API_DECL LY_ERR lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module, uint32_t implicit_options, struct lyd_node **diff)
Add any missing implicit nodes of one module. Default nodes with a false &quot;when&quot; are not added...
LIBYANG_API_DECL LY_ERR ly_pattern_compile(const struct ly_ctx *ctx, const char *pattern, pcre2_code **pcode)
Compile an XML Schema regex pattern prior to matching.
LIBYANG_API_DECL LY_ERR lyd_merge_module(struct lyd_node **target, const struct lyd_node *source, const struct lys_module *mod, lyd_merge_cb merge_cb, void *cb_data, uint16_t options)
Merge all the nodes of a module from source data tree into the target data tree. Merge may not be com...
LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node)
Create a new any node in the data tree.
Data node structure for unparsed (opaque) nodes.
Definition: tree_data.h:991
struct lyxp_expr * exp
Definition: tree_data.h:713
LIBYANG_API_DECL LY_ERR lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, uint32_t options, struct lyd_node **node,...)
Create a new top-level list node defined in the given extension instance.
LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr)
Free a single attribute.
Data node structure for the anydata data tree nodes - anydata or anyxml.
Definition: tree_data.h:888
Logger manipulation routines and error definitions.
LIBYANG_API_DECL void lyd_free_meta_siblings(struct lyd_meta *meta)
Free the metadata instance with any following instances.
struct lyd_node_term ** leafref_nodes
Definition: tree_data.h:1027
Special lyd_value structure for built-in bits values.
Definition: tree_data.h:638
Special lyd_value structure for built-in union values.
Definition: tree_data.h:622
struct lyd_node * prev
Definition: tree_data.h:804
LY_VALUE_FORMAT format
Definition: tree_data.h:628
LIBYANG_API_DECL LY_ERR lyd_unlink_tree(struct lyd_node *node)
Unlink the specified data subtree.
LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value, size_t value_len, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **new_parent, struct lyd_node **new_node)
Create a new node in the data tree based on a path. All node types can be created.
LIBYANG_API_DECL ly_bool lyd_meta_is_internal(const struct lyd_meta *meta)
Check whether metadata are not an instance of internal metadata.
LIBYANG_API_DECL LY_ERR lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options, struct lyd_node **diff)
Add any missing implicit nodes. Default nodes with a false &quot;when&quot; are not added.
LIBYANG_API_DECL LY_ERR lyd_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *parent, struct lyd_meta **dup)
Create a copy of the metadata.
#define LYS_LIST
Definition: tree_schema.h:244
LY_ERR
libyang&#39;s error codes returned by the libyang functions.
Definition: log.h:240
LIBYANG_API_DECL LY_ERR lyd_diff_apply_all(struct lyd_node **data, const struct lyd_node *diff)
Apply the whole diff tree on a data tree.
libyang context handler.
struct ly_ht * children_ht
Definition: tree_data.h:839
struct lyd_node * tree
Definition: tree_data.h:877
Special lyd_value structure for built-in binary values.
Definition: tree_data.h:649
LIBYANG_API_DECL LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node with any following siblings. Schema references are kept...
struct lyd_value value
Definition: tree_data.h:623
LIBYANG_API_DECL LY_ERR lyd_change_term_bin(struct lyd_node *term, const void *value, size_t value_len)
Change the value of a term (leaf or leaf-list) node to a binary value.
LIBYANG_API_DECL LY_ERR lyd_new_ext_path(struct lyd_node *parent, const struct lysc_ext_instance *ext, const char *path, const void *value, uint32_t options, struct lyd_node **node)
Create a new node defined in the given extension instance. In case of anyxml/anydata nodes...
LIBYANG_API_DECL LY_ERR lyd_find_xpath3(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, struct ly_set **set)
Search in the given data for instances of nodes matching the provided XPath.
struct lyd_node * next
Definition: tree_data.h:803
LIBYANG_API_DECL LY_ERR lyd_leafref_get_links(const struct lyd_node_term *node, const struct lyd_leafref_links_rec **record)
Gets the leafref links record for given node.