libyang  3.6.1
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 #ifdef _WIN32
20 # include <winsock2.h>
21 # include <ws2tcpip.h>
22 #else
23 # include <arpa/inet.h>
24 # if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__)
25 # include <netinet/in.h>
26 # include <sys/socket.h>
27 # endif
28 #endif
29 
30 #define PCRE2_CODE_UNIT_WIDTH 8
31 
32 #include <pcre2.h>
33 #include <stddef.h>
34 #include <stdint.h>
35 #include <time.h>
36 
37 #include "log.h"
38 #include "ly_config.h"
39 #include "tree.h"
40 #include "tree_schema.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 struct ly_ctx;
47 struct ly_path;
48 struct ly_set;
49 struct lyd_node;
50 struct lyd_node_opaq;
51 struct lyd_node_term;
52 struct timespec;
53 struct lyxp_var;
54 struct rb_node;
55 
427 /* *INDENT-OFF* */
428 
454 #define LYD_TREE_DFS_BEGIN(START, ELEM) \
455  { ly_bool LYD_TREE_DFS_continue = 0; struct lyd_node *LYD_TREE_DFS_next; \
456  for ((ELEM) = (LYD_TREE_DFS_next) = (struct lyd_node *)(START); \
457  (ELEM); \
458  (ELEM) = (LYD_TREE_DFS_next), LYD_TREE_DFS_continue = 0)
459 
474 #define LYD_TREE_DFS_END(START, ELEM) \
475  /* select element for the next run - children first */ \
476  if (LYD_TREE_DFS_continue) { \
477  (LYD_TREE_DFS_next) = NULL; \
478  } else { \
479  (LYD_TREE_DFS_next) = lyd_child(ELEM); \
480  }\
481  if (!(LYD_TREE_DFS_next)) { \
482  /* no children */ \
483  if ((ELEM) == (struct lyd_node *)(START)) { \
484  /* we are done, (START) has no children */ \
485  break; \
486  } \
487  /* try siblings */ \
488  (LYD_TREE_DFS_next) = (ELEM)->next; \
489  } \
490  while (!(LYD_TREE_DFS_next)) { \
491  /* parent is already processed, go to its sibling */ \
492  (ELEM) = (struct lyd_node *)(ELEM)->parent; \
493  /* no siblings, go back through parents */ \
494  if ((ELEM)->parent == (START)->parent) { \
495  /* we are done, no next element to process */ \
496  break; \
497  } \
498  (LYD_TREE_DFS_next) = (ELEM)->next; \
499  } }
500 
508 #define LYD_LIST_FOR_INST(START, SCHEMA, ELEM) \
509  for (lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
510  (ELEM) && ((ELEM)->schema == (SCHEMA)); \
511  (ELEM) = (ELEM)->next)
512 
521 #define LYD_LIST_FOR_INST_SAFE(START, SCHEMA, NEXT, ELEM) \
522  for ((NEXT) = (ELEM) = NULL, lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
523  (ELEM) && ((ELEM)->schema == (SCHEMA)) ? ((NEXT) = (ELEM)->next, 1) : 0; \
524  (ELEM) = (NEXT))
525 
526 /* *INDENT-ON* */
527 
531 #define LYD_CTX(node) ((node)->schema ? (node)->schema->module->ctx : ((const struct lyd_node_opaq *)(node))->ctx)
532 
540 #define LYD_NODE_IS_ALONE(NODE) \
541  (((NODE)->prev == NODE) || \
542  (((NODE)->prev->schema != (NODE)->schema) && (!(NODE)->next || ((NODE)->schema != (NODE)->next->schema))))
543 
548 typedef enum {
553 } LYD_FORMAT;
554 
558 typedef enum {
569 
575 struct lyd_value {
576  const char *_canonical;
579  const struct lysc_type *realtype;
587  union {
588  int8_t boolean;
589  int64_t dec64;
590  int8_t int8;
591  int16_t int16;
592  int32_t int32;
593  int64_t int64;
594  uint8_t uint8;
595  uint16_t uint16;
596  uint32_t uint32;
597  uint64_t uint64;
598  struct lysc_type_bitenum_item *enum_item;
599  struct lysc_ident *ident;
600  struct ly_path *target;
602  struct lyd_value_union *subvalue;
604  void *dyn_mem;
605  uint8_t fixed_mem[LYD_VALUE_FIXED_MEM_SIZE];
606  };
608 };
609 
618 #define LYD_VALUE_GET(value, type_val) \
619  ((sizeof *(type_val) > LYD_VALUE_FIXED_MEM_SIZE) \
620  ? ((type_val) = (((value)->dyn_mem))) \
621  : ((type_val) = ((void *)((value)->fixed_mem))))
622 
631  struct lyd_value value;
633  void *original;
634  size_t orig_len;
635  uint32_t hints;
639  void *prefix_data;
640  const struct lysc_node *ctx_node;
641 };
642 
647  char *bitmap;
652 };
653 
658  void *data;
659  size_t size;
660 };
661 
666  struct in_addr addr;
667 };
668 
673  struct in_addr addr;
674  const char *zone;
675 };
676 
681  struct in_addr addr;
682  uint8_t prefix;
683 };
684 
689  struct in6_addr addr;
690 };
691 
696  struct in6_addr addr;
697  const char *zone;
698 };
699 
704  struct in6_addr addr;
705  uint8_t prefix;
706 };
707 
712  time_t time;
713  char *fractions_s;
715 };
716 
721  struct lyxp_expr *exp;
722  const struct ly_ctx *ctx;
723  void *prefix_data;
725 };
726 
731  struct rb_node *rbt;
732 };
733 
741 struct ly_opaq_name {
742  const char *name;
743  const char *prefix;
745  union {
746  const char *module_ns;
747  const char *module_name;
748  };
749 };
750 
754 struct lyd_attr {
756  struct lyd_attr *next;
758  const char *value;
759  uint32_t hints;
762 };
763 
764 #define LYD_NODE_INNER (LYS_CONTAINER|LYS_LIST|LYS_RPC|LYS_ACTION|LYS_NOTIF)
765 #define LYD_NODE_TERM (LYS_LEAF|LYS_LEAFLIST)
766 #define LYD_NODE_ANY (LYS_ANYDATA)
793 #define LYD_DEFAULT 0x01
794 #define LYD_WHEN_TRUE 0x02
795 #define LYD_NEW 0x04
796 #define LYD_EXT 0x08
803 struct lyd_node {
804  uint32_t hash;
808  uint32_t flags;
809  const struct lysc_node *schema;
811  struct lyd_node *next;
812  struct lyd_node *prev;
816  struct lyd_meta *meta;
817  void *priv;
818 };
819 
824  union {
825  struct lyd_node node;
827  struct {
828  uint32_t hash;
833  uint32_t flags;
834  const struct lysc_node *schema;
835  struct lyd_node_inner *parent;
836  struct lyd_node *next;
837  struct lyd_node *prev;
841  struct lyd_meta *meta;
842  void *priv;
843  };
844  };
846  struct lyd_node *child;
847  struct ly_ht *children_ht;
849 #define LYD_HT_MIN_ITEMS 4
850 };
851 
856  union {
857  struct lyd_node node;
859  struct {
860  uint32_t hash;
865  uint32_t flags;
866  const struct lysc_node *schema;
867  struct lyd_node_inner *parent;
868  struct lyd_node *next;
869  struct lyd_node *prev;
873  struct lyd_meta *meta;
874  void *priv;
875  };
876  };
878  struct lyd_value value;
879 };
880 
885  struct lyd_node *tree;
886  const char *str;
887  const char *xml;
888  const char *json;
889  char *mem;
890 };
891 
896 struct lyd_node_any {
897  union {
898  struct lyd_node node;
900  struct {
901  uint32_t hash;
906  uint32_t flags;
907  const struct lysc_node *schema;
908  struct lyd_node_inner *parent;
909  struct lyd_node *next;
910  struct lyd_node *prev;
914  struct lyd_meta *meta;
915  void *priv;
916  };
917  };
919  union lyd_any_value value;
921 };
922 
929 #define LYD_NAME(node) ((node)->schema ? (node)->schema->name : ((struct lyd_node_opaq *)node)->name.name)
930 
940 #define LYD_VALHINT_STRING 0x0001
941 #define LYD_VALHINT_DECNUM 0x0002
942 #define LYD_VALHINT_OCTNUM 0x0004
943 #define LYD_VALHINT_HEXNUM 0x0008
944 #define LYD_VALHINT_NUM64 0x0010
945 #define LYD_VALHINT_BOOLEAN 0x0020
946 #define LYD_VALHINT_EMPTY 0x0040
960 #define LYD_NODEHINT_LIST 0x0080
961 #define LYD_NODEHINT_LEAFLIST 0x0100
962 #define LYD_NODEHINT_CONTAINER 0x0200
977 #define LYD_HINT_DATA 0x03F3
981 #define LYD_HINT_SCHEMA 0x03FF
992 struct lyd_node_opaq {
993  union {
994  struct lyd_node node;
996  struct {
997  uint32_t hash;
998  uint32_t flags;
999  const struct lysc_node *schema;
1000  struct lyd_node_inner *parent;
1001  struct lyd_node *next;
1002  struct lyd_node *prev;
1006  struct lyd_meta *meta;
1007  void *priv;
1008  };
1009  };
1011  struct lyd_node *child;
1013  struct ly_opaq_name name;
1014  const char *value;
1015  uint32_t hints;
1016  LY_VALUE_FORMAT format;
1017  void *val_prefix_data;
1019  struct lyd_attr *attr;
1020  const struct ly_ctx *ctx;
1021 };
1027  const struct lyd_node_term *node;
1028  const struct lyd_node_term **leafref_nodes;
1034  const struct lyd_node_term **target_nodes;
1037 };
1038 
1046 static inline struct lyd_node *
1047 lyd_parent(const struct lyd_node *node)
1048 {
1049  return (node && node->parent) ? &node->parent->node : NULL;
1050 }
1051 
1062 static inline struct lyd_node *
1063 lyd_child(const struct lyd_node *node)
1064 {
1065  if (!node) {
1066  return NULL;
1067  }
1068 
1069  if (!node->schema) {
1070  /* opaq node */
1071  return ((const struct lyd_node_opaq *)node)->child;
1072  }
1073 
1075  return ((const struct lyd_node_inner *)node)->child;
1076  }
1077 
1078  return NULL;
1079 }
1080 
1091 LIBYANG_API_DECL struct lyd_node *lyd_child_no_keys(const struct lyd_node *node);
1092 
1102 LIBYANG_API_DECL const struct lys_module *lyd_owner_module(const struct lyd_node *node);
1103 
1110 LIBYANG_API_DECL const struct lys_module *lyd_node_module(const struct lyd_node *node);
1111 
1118 LIBYANG_API_DECL ly_bool lyd_is_default(const struct lyd_node *node);
1119 
1127 LIBYANG_API_DECL uint32_t lyd_list_pos(const struct lyd_node *instance);
1128 
1135 LIBYANG_API_DECL struct lyd_node *lyd_first_sibling(const struct lyd_node *node);
1136 
1144 LIBYANG_API_DECL int lyd_lyb_data_length(const char *data);
1145 
1155 LIBYANG_API_DECL LY_ERR lyd_parse_opaq_error(const struct lyd_node *node);
1156 
1166 LIBYANG_API_DECL const char *lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value);
1167 
1174 static inline const char *
1175 lyd_get_value(const struct lyd_node *node)
1176 {
1177  if (!node) {
1178  return NULL;
1179  }
1180 
1181  if (!node->schema) {
1182  return ((const struct lyd_node_opaq *)node)->value;
1183  } else if (node->schema->nodetype & LYD_NODE_TERM) {
1184  const struct lyd_value *value = &((const struct lyd_node_term *)node)->value;
1185 
1186  return value->_canonical ? value->_canonical : lyd_value_get_canonical(LYD_CTX(node), value);
1187  }
1188 
1189  return NULL;
1190 }
1191 
1199 LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, char **value_str);
1200 
1209 LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const union lyd_any_value *value,
1210  LYD_ANYDATA_VALUETYPE value_type);
1211 
1218 LIBYANG_API_DECL const struct lysc_node *lyd_node_schema(const struct lyd_node *node);
1219 
1227 LIBYANG_API_DECL ly_bool lyd_meta_is_internal(const struct lyd_meta *meta);
1228 
1244 LIBYANG_API_DECL LY_ERR lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name,
1245  ly_bool output, struct lyd_node **node);
1246 
1260 LIBYANG_API_DECL LY_ERR lyd_new_ext_inner(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node);
1261 
1283 #define LYD_NEW_VAL_OUTPUT 0x01
1285 #define LYD_NEW_VAL_STORE_ONLY 0x02
1286 #define LYD_NEW_VAL_BIN 0x04
1288 #define LYD_NEW_VAL_CANON 0x08
1291 #define LYD_NEW_META_CLEAR_DFLT 0x10
1292 #define LYD_NEW_PATH_UPDATE 0x20
1296 #define LYD_NEW_PATH_OPAQ 0x40
1300 #define LYD_NEW_PATH_WITH_OPAQ 0x80
1301 #define LYD_NEW_ANY_USE_VALUE 0x100
1318 LIBYANG_API_DECL LY_ERR lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name,
1319  uint32_t options, struct lyd_node **node, ...);
1320 
1336 LIBYANG_API_DECL LY_ERR lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, uint32_t options,
1337  struct lyd_node **node, ...);
1338 
1352 LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name,
1353  const char *keys, uint32_t options, struct lyd_node **node);
1354 
1367 LIBYANG_API_DECL LY_ERR lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const char *name,
1368  const char **key_values, uint32_t *value_lengths, uint32_t options, struct lyd_node **node);
1369 
1384 LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name,
1385  const char *value, uint32_t options, struct lyd_node **node);
1386 
1399 LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name,
1400  const void *value, size_t value_len, uint32_t options, struct lyd_node **node);
1401 
1416 LIBYANG_API_DECL LY_ERR lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const void *value,
1417  size_t value_len, uint32_t options, struct lyd_node **node);
1418 
1433 LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name,
1434  const void *value, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node);
1435 
1450 LIBYANG_API_DECL LY_ERR lyd_new_ext_any(const struct lysc_ext_instance *ext, const char *name, const void *value,
1451  LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node);
1452 
1467 LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module,
1468  const char *name, const char *val_str, uint32_t options, struct lyd_meta **meta);
1469 
1482 LIBYANG_API_DECL LY_ERR lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, uint32_t options,
1483  const struct lyd_attr *attr, struct lyd_meta **meta);
1484 
1497 LIBYANG_API_DECL LY_ERR lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1498  const char *prefix, const char *module_name, struct lyd_node **node);
1499 
1512 LIBYANG_API_DECL LY_ERR lyd_new_opaq2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1513  const char *prefix, const char *module_ns, struct lyd_node **node);
1514 
1528 LIBYANG_API_DECL LY_ERR lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *value,
1529  struct lyd_attr **attr);
1530 
1543 LIBYANG_API_DECL LY_ERR lyd_new_attr2(struct lyd_node *parent, const char *module_ns, const char *name, const char *value,
1544  struct lyd_attr **attr);
1545 
1574 LIBYANG_API_DECL LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value,
1575  uint32_t options, struct lyd_node **node);
1576 
1601 LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value,
1602  size_t value_len, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **new_parent,
1603  struct lyd_node **new_node);
1604 
1627 LIBYANG_API_DECL LY_ERR lyd_new_ext_path(struct lyd_node *parent, const struct lysc_ext_instance *ext, const char *path,
1628  const void *value, uint32_t options, struct lyd_node **node);
1629 
1643 #define LYD_IMPLICIT_NO_STATE 0x01
1644 #define LYD_IMPLICIT_NO_CONFIG 0x02
1645 #define LYD_IMPLICIT_OUTPUT 0x04
1646 #define LYD_IMPLICIT_NO_DEFAULTS 0x08
1659 LIBYANG_API_DECL LY_ERR lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff);
1672 LIBYANG_API_DECL LY_ERR lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options,
1673  struct lyd_node **diff);
1674 
1686 LIBYANG_API_DECL LY_ERR lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module,
1687  uint32_t implicit_options, struct lyd_node **diff);
1688 
1702 LIBYANG_API_DECL LY_ERR lyd_change_term(struct lyd_node *term, const char *val_str);
1703 
1718 LIBYANG_API_DECL LY_ERR lyd_change_term_bin(struct lyd_node *term, const void *value, size_t value_len);
1719 
1734 LIBYANG_API_DECL LY_ERR lyd_change_term_canon(struct lyd_node *term, const char *val_str);
1735 
1745 LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str);
1746 
1758 LIBYANG_API_DECL LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node);
1759 
1772 LIBYANG_API_DECL LY_ERR lyd_insert_sibling(struct lyd_node *sibling, struct lyd_node *node, struct lyd_node **first);
1773 
1785 LIBYANG_API_DECL LY_ERR lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node);
1786 
1798 LIBYANG_API_DECL LY_ERR lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node);
1799 
1807 LIBYANG_API_DECL LY_ERR lyd_unlink_siblings(struct lyd_node *node);
1808 
1816 LIBYANG_API_DECL LY_ERR lyd_unlink_tree(struct lyd_node *node);
1817 
1823 LIBYANG_API_DECL void lyd_free_all(struct lyd_node *node);
1824 
1830 LIBYANG_API_DECL void lyd_free_siblings(struct lyd_node *node);
1831 
1837 LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node);
1838 
1844 LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta);
1845 
1851 LIBYANG_API_DECL void lyd_free_meta_siblings(struct lyd_meta *meta);
1852 
1859 LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr);
1860 
1867 LIBYANG_API_DECL void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr);
1868 
1887 LIBYANG_API_DECL LY_ERR lyd_value_validate(const struct ly_ctx *ctx, const struct lysc_node *schema, const char *value,
1888  size_t value_len, const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical);
1889 
1902 LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, size_t value_len);
1903 
1910 #define LYD_COMPARE_FULL_RECURSION 0x01 /* Lists and containers are the same only in case all they children
1911  (subtree, so direct as well as indirect children) are the same. By default,
1912  containers are the same in case of the same schema node and lists are the same
1913  in case of equal keys (keyless lists do the full recursion comparison all the time). */
1914 #define LYD_COMPARE_DEFAULTS 0x02 /* By default, implicit and explicit default nodes are considered to be equal. This flag
1915  changes this behavior and implicit (automatically created default node) and explicit
1916  (explicitly created node with the default value) default nodes are considered different. */
1917 #define LYD_COMPARE_OPAQ 0x04 /* Opaque nodes can normally be never equal to data nodes. Using this flag even
1918  opaque nodes members are compared to data node schema and value and can result
1919  in a match. */
1920 
1933 LIBYANG_API_DECL LY_ERR lyd_compare_single(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1946 LIBYANG_API_DECL LY_ERR lyd_compare_siblings(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1947 
1958 LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2);
1959 
1972 #define LYD_DUP_RECURSIVE 0x01
1974 #define LYD_DUP_NO_META 0x02
1976 #define LYD_DUP_WITH_PARENTS 0x04
1978 #define LYD_DUP_WITH_FLAGS 0x08
1980 #define LYD_DUP_NO_EXT 0x10
1981 #define LYD_DUP_WITH_PRIV 0x20
1983 #define LYD_DUP_NO_LYDS 0x40
2001 LIBYANG_API_DECL LY_ERR lyd_dup_single(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options,
2002  struct lyd_node **dup);
2003 
2016 LIBYANG_API_DECL LY_ERR lyd_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
2017  struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup);
2018 
2030 LIBYANG_API_DECL LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options,
2031  struct lyd_node **dup);
2032 
2046 LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
2047  struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup);
2048 
2057 LIBYANG_API_DECL LY_ERR lyd_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *parent, struct lyd_meta **dup);
2058 
2073 #define LYD_MERGE_DESTRUCT 0x01
2074 #define LYD_MERGE_DEFAULTS 0x02
2075 #define LYD_MERGE_WITH_FLAGS 0x04
2099 LIBYANG_API_DECL LY_ERR lyd_merge_tree(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2122 LIBYANG_API_DECL LY_ERR lyd_merge_siblings(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2123 
2133 typedef LY_ERR (*lyd_merge_cb)(struct lyd_node *trg_node, const struct lyd_node *src_node, void *cb_data);
2134 
2150 LIBYANG_API_DECL LY_ERR lyd_merge_module(struct lyd_node **target, const struct lyd_node *source, const struct lys_module *mod,
2151  lyd_merge_cb merge_cb, void *cb_data, uint16_t options);
2152 
2164 #define LYD_DIFF_DEFAULTS 0x01
2195 LIBYANG_API_DECL LY_ERR lyd_diff_tree(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2196  struct lyd_node **diff);
2197 
2210 LIBYANG_API_DECL LY_ERR lyd_diff_siblings(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2211  struct lyd_node **diff);
2212 
2221 typedef LY_ERR (*lyd_diff_cb)(const struct lyd_node *diff_node, struct lyd_node *data_node, void *cb_data);
2222 
2239 LIBYANG_API_DECL LY_ERR lyd_diff_apply_module(struct lyd_node **data, const struct lyd_node *diff,
2240  const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data);
2241 
2252 LIBYANG_API_DECL LY_ERR lyd_diff_apply_all(struct lyd_node **data, const struct lyd_node *diff);
2253 
2265 #define LYD_DIFF_MERGE_DEFAULTS 0x01
2293 LIBYANG_API_DECL LY_ERR lyd_diff_merge_module(struct lyd_node **diff, const struct lyd_node *src_diff,
2294  const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2295 
2312 LIBYANG_API_DECL LY_ERR lyd_diff_merge_tree(struct lyd_node **diff_first, struct lyd_node *diff_parent,
2313  const struct lyd_node *src_sibling, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2314 
2326 LIBYANG_API_DECL LY_ERR lyd_diff_merge_all(struct lyd_node **diff, const struct lyd_node *src_diff, uint16_t options);
2327 
2337 LIBYANG_API_DECL LY_ERR lyd_diff_reverse_all(const struct lyd_node *src_diff, struct lyd_node **diff);
2338 
2342 typedef enum {
2343  LYD_PATH_STD,
2347 } LYD_PATH_TYPE;
2348 
2364 LIBYANG_API_DECL char *lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen);
2365 
2375 LIBYANG_API_DECL struct lyd_meta *lyd_find_meta(const struct lyd_meta *first, const struct lys_module *module,
2376  const char *name);
2377 
2389 LIBYANG_API_DECL LY_ERR lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target,
2390  struct lyd_node **match);
2391 
2416 LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema,
2417  const char *key_or_value, size_t val_len, struct lyd_node **match);
2418 
2430 LIBYANG_API_DECL LY_ERR lyd_find_sibling_dup_inst_set(const struct lyd_node *siblings, const struct lyd_node *target,
2431  struct ly_set **set);
2432 
2443 LIBYANG_API_DECL LY_ERR lyd_find_sibling_opaq_next(const struct lyd_node *first, const char *name, struct lyd_node **match);
2444 
2456 LIBYANG_API_DECL LY_ERR lyxp_vars_set(struct lyxp_var **vars, const char *name, const char *value);
2457 
2463 LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars);
2464 
2482 LIBYANG_API_DECL LY_ERR lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set);
2483 
2497 LIBYANG_API_DECL LY_ERR lyd_find_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars,
2498  struct ly_set **set);
2499 
2517 LIBYANG_API_DECL LY_ERR lyd_find_xpath3(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath,
2518  LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, struct ly_set **set);
2519 
2531 LIBYANG_API_DECL LY_ERR lyd_eval_xpath(const struct lyd_node *ctx_node, const char *xpath, ly_bool *result);
2532 
2545 LIBYANG_API_DECL LY_ERR lyd_eval_xpath2(const struct lyd_node *ctx_node, const char *xpath,
2546  const struct lyxp_var *vars, ly_bool *result);
2547 
2563 LIBYANG_API_DECL LY_ERR lyd_eval_xpath3(const struct lyd_node *ctx_node, const struct lys_module *cur_mod,
2564  const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, ly_bool *result);
2565 
2569 typedef enum {
2571  LY_XPATH_STRING,
2572  LY_XPATH_NUMBER,
2574 } LY_XPATH_TYPE;
2575 
2598 LIBYANG_API_DECL LY_ERR lyd_eval_xpath4(const struct lyd_node *ctx_node, const struct lyd_node *tree,
2599  const struct lys_module *cur_mod, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data,
2600  const struct lyxp_var *vars, LY_XPATH_TYPE *ret_type, struct ly_set **node_set, char **string,
2601  long double *number, ly_bool *boolean);
2602 
2612 LIBYANG_API_DEF LY_ERR lyd_trim_xpath(struct lyd_node **tree, const char *xpath, const struct lyxp_var *vars);
2613 
2631 LIBYANG_API_DECL LY_ERR lyd_find_path(const struct lyd_node *ctx_node, const char *path, ly_bool output,
2632  struct lyd_node **match);
2633 
2644 LIBYANG_API_DECL LY_ERR lyd_find_target(const struct ly_path *path, const struct lyd_node *tree, struct lyd_node **match);
2645 
2651 LIBYANG_API_DECL int ly_time_tz_offset(void);
2652 
2659 LIBYANG_API_DECL int ly_time_tz_offset_at(time_t time);
2660 
2669 LIBYANG_API_DECL LY_ERR ly_time_str2time(const char *value, time_t *time, char **fractions_s);
2670 
2679 LIBYANG_API_DECL LY_ERR ly_time_time2str(time_t time, const char *fractions_s, char **str);
2680 
2688 LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts);
2689 
2697 LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str);
2698 
2709 LIBYANG_API_DECL LY_ERR lyd_leafref_get_links(const struct lyd_node_term *node, const struct lyd_leafref_links_rec **record);
2710 
2720 LIBYANG_API_DECL LY_ERR lyd_leafref_link_node_tree(const struct lyd_node *tree);
2721 
2735 LIBYANG_API_DECL LY_ERR ly_pattern_match(const struct ly_ctx *ctx, const char *pattern, const char *string,
2736  uint32_t str_len, pcre2_code **pcode);
2737 
2747 LIBYANG_API_DECL LY_ERR ly_pattern_compile(const struct ly_ctx *ctx, const char *pattern, pcre2_code **pcode);
2748 
2749 #ifdef __cplusplus
2750 }
2751 #endif
2752 
2753 #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:681
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:579
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:2158
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:884
#define LYS_CONTAINER
Definition: tree_schema.h:240
Generic prefix and namespace mapping, meaning depends on the format.
Definition: tree_data.h:741
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:697
LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars)
Free the XPath variables.
const char * str
Definition: tree_data.h:886
const char * prefix
Definition: tree_data.h:743
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:673
Generic structure for a data node.
Definition: tree_data.h:803
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:804
const char * xml
Definition: tree_data.h:887
const char * zone
Definition: tree_data.h:674
struct lyd_node_opaq * parent
Definition: tree_data.h:755
const char * name
Definition: metadata.h:40
void * priv
Definition: tree_data.h:817
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:2369
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:633
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:672
struct rb_node * rbt
Definition: tree_data.h:731
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:688
Special lyd_value structure for ietf-inet-types ipv4-address-no-zone values.
Definition: tree_data.h:665
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:634
Data node structure for the inner data tree nodes - containers, lists, RPCs, actions and Notification...
Definition: tree_data.h:823
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:846
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:704
void * prefix_data
Definition: tree_data.h:723
Special lyd_value structure for ietf-yang-types date-and-time values.
Definition: tree_data.h:711
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:816
Data node structure for the terminal data tree nodes - leaves and leaf-lists.
Definition: tree_data.h:855
struct lyd_node_inner * parent
Definition: tree_data.h:810
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:809
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:640
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:757
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:759
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:650
libyang hash table.
Special lyd_value structure for ietf-inet-types ipv6-address values.
Definition: tree_data.h:695
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
Definition: tree_data.h:548
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:575
const char * _canonical
Definition: tree_data.h:576
LY_XPATH_TYPE
XPath result type.
Definition: tree_data.h:2596
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:722
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:742
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:635
#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:680
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:761
struct lyd_node_term ** target_nodes
Definition: tree_data.h:1040
uint32_t flags
Definition: tree_data.h:808
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:639
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:2131
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:696
char * mem
Definition: tree_data.h:889
Special lyd_value structure for lyds tree value.
Definition: tree_data.h:730
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:2248
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:888
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:758
Special lyd_value structure for ietf-inet-types ipv6-prefix values.
Definition: tree_data.h:703
Generic attribute structure.
Definition: tree_data.h:754
struct lys_module * module
Definition: tree_schema.h:1443
Special lyd_value structure for ietf-yang-types xpath1.0 values.
Definition: tree_data.h:720
#define LYD_CTX(node)
Macro to get context from a data tree node.
Definition: tree_data.h:531
struct lyd_attr * next
Definition: tree_data.h:756
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:724
LY_VALUE_FORMAT format
Definition: tree_data.h:760
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:1033
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:765
#define LYS_RPC
Definition: tree_schema.h:249
char * bitmap
Definition: tree_data.h:647
struct lyd_value value
Definition: tree_data.h:878
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:920
LYD_ANYDATA_VALUETYPE
List of possible value types stored in lyd_node_any.
Definition: tree_data.h:558
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:998
struct lyxp_expr * exp
Definition: tree_data.h:721
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:896
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:1034
Special lyd_value structure for built-in bits values.
Definition: tree_data.h:646
Special lyd_value structure for built-in union values.
Definition: tree_data.h:630
struct lyd_node * prev
Definition: tree_data.h:812
LY_VALUE_FORMAT format
Definition: tree_data.h:636
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:847
struct lyd_node * tree
Definition: tree_data.h:885
Special lyd_value structure for built-in binary values.
Definition: tree_data.h:657
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:631
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:811
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.