libyang  2.2.8
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 #include <stddef.h>
30 #include <stdint.h>
31 #include <time.h>
32 
33 #include "log.h"
34 #include "ly_config.h"
35 #include "tree.h"
36 #include "tree_schema.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 struct ly_ctx;
43 struct ly_path;
44 struct ly_set;
45 struct lyd_node;
46 struct lyd_node_opaq;
47 struct lyd_node_term;
48 struct timespec;
49 struct lyxp_var;
50 struct rb_node;
51 
423 /* *INDENT-OFF* */
424 
450 #define LYD_TREE_DFS_BEGIN(START, ELEM) \
451  { ly_bool LYD_TREE_DFS_continue = 0; struct lyd_node *LYD_TREE_DFS_next; \
452  for ((ELEM) = (LYD_TREE_DFS_next) = (struct lyd_node *)(START); \
453  (ELEM); \
454  (ELEM) = (LYD_TREE_DFS_next), LYD_TREE_DFS_continue = 0)
455 
470 #define LYD_TREE_DFS_END(START, ELEM) \
471  /* select element for the next run - children first */ \
472  if (LYD_TREE_DFS_continue) { \
473  (LYD_TREE_DFS_next) = NULL; \
474  } else { \
475  (LYD_TREE_DFS_next) = lyd_child(ELEM); \
476  }\
477  if (!(LYD_TREE_DFS_next)) { \
478  /* no children */ \
479  if ((ELEM) == (struct lyd_node *)(START)) { \
480  /* we are done, (START) has no children */ \
481  break; \
482  } \
483  /* try siblings */ \
484  (LYD_TREE_DFS_next) = (ELEM)->next; \
485  } \
486  while (!(LYD_TREE_DFS_next)) { \
487  /* parent is already processed, go to its sibling */ \
488  (ELEM) = (struct lyd_node *)(ELEM)->parent; \
489  /* no siblings, go back through parents */ \
490  if ((ELEM)->parent == (START)->parent) { \
491  /* we are done, no next element to process */ \
492  break; \
493  } \
494  (LYD_TREE_DFS_next) = (ELEM)->next; \
495  } }
496 
504 #define LYD_LIST_FOR_INST(START, SCHEMA, ELEM) \
505  for (lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
506  (ELEM) && ((ELEM)->schema == (SCHEMA)); \
507  (ELEM) = (ELEM)->next)
508 
517 #define LYD_LIST_FOR_INST_SAFE(START, SCHEMA, NEXT, ELEM) \
518  for ((NEXT) = (ELEM) = NULL, lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
519  (ELEM) && ((ELEM)->schema == (SCHEMA)) ? ((NEXT) = (ELEM)->next, 1) : 0; \
520  (ELEM) = (NEXT))
521 
522 /* *INDENT-ON* */
523 
527 #define LYD_CTX(node) ((node)->schema ? (node)->schema->module->ctx : ((const struct lyd_node_opaq *)(node))->ctx)
528 
536 #define LYD_NODE_IS_ALONE(NODE) \
537  (((NODE)->prev == NODE) || \
538  (((NODE)->prev->schema != (NODE)->schema) && (!(NODE)->next || ((NODE)->schema != (NODE)->next->schema))))
539 
544 typedef enum {
549 } LYD_FORMAT;
550 
554 typedef enum {
565 
571 struct lyd_value {
572  const char *_canonical;
575  const struct lysc_type *realtype;
583  union {
584  int8_t boolean;
585  int64_t dec64;
586  int8_t int8;
587  int16_t int16;
588  int32_t int32;
589  int64_t int64;
590  uint8_t uint8;
591  uint16_t uint16;
592  uint32_t uint32;
593  uint64_t uint64;
594  struct lysc_type_bitenum_item *enum_item;
595  struct lysc_ident *ident;
596  struct ly_path *target;
598  struct lyd_value_union *subvalue;
600  void *dyn_mem;
601  uint8_t fixed_mem[LYD_VALUE_FIXED_MEM_SIZE];
602  };
604 };
605 
614 #define LYD_VALUE_GET(value, type_val) \
615  ((sizeof *(type_val) > LYD_VALUE_FIXED_MEM_SIZE) \
616  ? ((type_val) = (((value)->dyn_mem))) \
617  : ((type_val) = ((void *)((value)->fixed_mem))))
618 
627  struct lyd_value value;
629  void *original;
630  size_t orig_len;
631  uint32_t hints;
635  void *prefix_data;
636  const struct lysc_node *ctx_node;
637 };
638 
643  char *bitmap;
648 };
649 
654  void *data;
655  size_t size;
656 };
657 
662  struct in_addr addr;
663 };
664 
669  struct in_addr addr;
670  const char *zone;
671 };
672 
677  struct in_addr addr;
678  uint8_t prefix;
679 };
680 
685  struct in6_addr addr;
686 };
687 
692  struct in6_addr addr;
693  const char *zone;
694 };
695 
700  struct in6_addr addr;
701  uint8_t prefix;
702 };
703 
708  time_t time;
709  char *fractions_s;
711 };
712 
717  struct lyxp_expr *exp;
718  const struct ly_ctx *ctx;
719  void *prefix_data;
721 };
722 
727  struct rb_node *rbt;
728 };
729 
737 struct ly_opaq_name {
738  const char *name;
739  const char *prefix;
741  union {
742  const char *module_ns;
743  const char *module_name;
744  };
745 };
746 
750 struct lyd_attr {
752  struct lyd_attr *next;
754  const char *value;
755  uint32_t hints;
758 };
759 
760 #define LYD_NODE_INNER (LYS_CONTAINER|LYS_LIST|LYS_RPC|LYS_ACTION|LYS_NOTIF)
761 #define LYD_NODE_TERM (LYS_LEAF|LYS_LEAFLIST)
762 #define LYD_NODE_ANY (LYS_ANYDATA)
789 #define LYD_DEFAULT 0x01
790 #define LYD_WHEN_TRUE 0x02
791 #define LYD_NEW 0x04
792 #define LYD_EXT 0x08
799 struct lyd_node {
800  uint32_t hash;
804  uint32_t flags;
805  const struct lysc_node *schema;
807  struct lyd_node *next;
808  struct lyd_node *prev;
812  struct lyd_meta *meta;
813  void *priv;
814 };
815 
820  union {
821  struct lyd_node node;
823  struct {
824  uint32_t hash;
829  uint32_t flags;
830  const struct lysc_node *schema;
831  struct lyd_node_inner *parent;
832  struct lyd_node *next;
833  struct lyd_node *prev;
837  struct lyd_meta *meta;
838  void *priv;
839  };
840  };
842  struct lyd_node *child;
843  struct ly_ht *children_ht;
845 #define LYD_HT_MIN_ITEMS 4
846 };
847 
852  union {
853  struct lyd_node node;
855  struct {
856  uint32_t hash;
861  uint32_t flags;
862  const struct lysc_node *schema;
863  struct lyd_node_inner *parent;
864  struct lyd_node *next;
865  struct lyd_node *prev;
869  struct lyd_meta *meta;
870  void *priv;
871  };
872  };
874  struct lyd_value value;
875 };
876 
881  struct lyd_node *tree;
882  const char *str;
883  const char *xml;
884  const char *json;
885  char *mem;
886 };
887 
892 struct lyd_node_any {
893  union {
894  struct lyd_node node;
896  struct {
897  uint32_t hash;
902  uint32_t flags;
903  const struct lysc_node *schema;
904  struct lyd_node_inner *parent;
905  struct lyd_node *next;
906  struct lyd_node *prev;
910  struct lyd_meta *meta;
911  void *priv;
912  };
913  };
915  union lyd_any_value value;
917 };
918 
925 #define LYD_NAME(node) ((node)->schema ? (node)->schema->name : ((struct lyd_node_opaq *)node)->name.name)
926 
936 #define LYD_VALHINT_STRING 0x0001
937 #define LYD_VALHINT_DECNUM 0x0002
938 #define LYD_VALHINT_OCTNUM 0x0004
939 #define LYD_VALHINT_HEXNUM 0x0008
940 #define LYD_VALHINT_NUM64 0x0010
941 #define LYD_VALHINT_BOOLEAN 0x0020
942 #define LYD_VALHINT_EMPTY 0x0040
956 #define LYD_NODEHINT_LIST 0x0080
957 #define LYD_NODEHINT_LEAFLIST 0x0100
972 #define LYD_HINT_DATA 0x01F3
976 #define LYD_HINT_SCHEMA 0x01FF
987 struct lyd_node_opaq {
988  union {
989  struct lyd_node node;
991  struct {
992  uint32_t hash;
993  uint32_t flags;
994  const struct lysc_node *schema;
995  struct lyd_node_inner *parent;
996  struct lyd_node *next;
997  struct lyd_node *prev;
1001  struct lyd_meta *meta;
1002  void *priv;
1003  };
1004  };
1006  struct lyd_node *child;
1008  struct ly_opaq_name name;
1009  const char *value;
1010  uint32_t hints;
1011  LY_VALUE_FORMAT format;
1012  void *val_prefix_data;
1014  struct lyd_attr *attr;
1015  const struct ly_ctx *ctx;
1016 };
1022  const struct lyd_node_term *node;
1023  const struct lyd_node_term **leafref_nodes;
1029  const struct lyd_node_term **target_nodes;
1032 };
1033 
1041 static inline struct lyd_node *
1042 lyd_parent(const struct lyd_node *node)
1043 {
1044  return (node && node->parent) ? &node->parent->node : NULL;
1045 }
1046 
1057 static inline struct lyd_node *
1058 lyd_child(const struct lyd_node *node)
1059 {
1060  if (!node) {
1061  return NULL;
1062  }
1063 
1064  if (!node->schema) {
1065  /* opaq node */
1066  return ((const struct lyd_node_opaq *)node)->child;
1067  }
1068 
1070  return ((const struct lyd_node_inner *)node)->child;
1071  }
1072 
1073  return NULL;
1074 }
1075 
1086 LIBYANG_API_DECL struct lyd_node *lyd_child_no_keys(const struct lyd_node *node);
1087 
1097 LIBYANG_API_DECL const struct lys_module *lyd_owner_module(const struct lyd_node *node);
1098 
1105 LIBYANG_API_DECL const struct lys_module *lyd_node_module(const struct lyd_node *node);
1106 
1113 LIBYANG_API_DECL ly_bool lyd_is_default(const struct lyd_node *node);
1114 
1122 LIBYANG_API_DECL uint32_t lyd_list_pos(const struct lyd_node *instance);
1123 
1130 LIBYANG_API_DECL struct lyd_node *lyd_first_sibling(const struct lyd_node *node);
1131 
1139 LIBYANG_API_DECL int lyd_lyb_data_length(const char *data);
1140 
1150 LIBYANG_API_DECL LY_ERR lyd_parse_opaq_error(const struct lyd_node *node);
1151 
1161 LIBYANG_API_DECL const char *lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value);
1162 
1169 static inline const char *
1170 lyd_get_value(const struct lyd_node *node)
1171 {
1172  if (!node) {
1173  return NULL;
1174  }
1175 
1176  if (!node->schema) {
1177  return ((const struct lyd_node_opaq *)node)->value;
1178  } else if (node->schema->nodetype & LYD_NODE_TERM) {
1179  const struct lyd_value *value = &((const struct lyd_node_term *)node)->value;
1180 
1181  return value->_canonical ? value->_canonical : lyd_value_get_canonical(LYD_CTX(node), value);
1182  }
1183 
1184  return NULL;
1185 }
1186 
1194 LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, char **value_str);
1195 
1204 LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const union lyd_any_value *value,
1205  LYD_ANYDATA_VALUETYPE value_type);
1206 
1213 LIBYANG_API_DECL const struct lysc_node *lyd_node_schema(const struct lyd_node *node);
1214 
1230 LIBYANG_API_DECL LY_ERR lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name,
1231  ly_bool output, struct lyd_node **node);
1232 
1246 LIBYANG_API_DECL LY_ERR lyd_new_ext_inner(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node);
1247 
1269 #define LYD_NEW_VAL_OUTPUT 0x01
1271 #define LYD_NEW_VAL_STORE_ONLY 0x02
1272 #define LYD_NEW_VAL_BIN 0x04
1274 #define LYD_NEW_VAL_CANON 0x08
1277 #define LYD_NEW_META_CLEAR_DFLT 0x10
1278 #define LYD_NEW_PATH_UPDATE 0x20
1282 #define LYD_NEW_PATH_OPAQ 0x40
1285 #define LYD_NEW_PATH_WITH_OPAQ 0x80
1286 #define LYD_NEW_ANY_USE_VALUE 0x100
1303 LIBYANG_API_DECL LY_ERR lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name,
1304  uint32_t options, struct lyd_node **node, ...);
1305 
1321 LIBYANG_API_DECL LY_ERR lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, uint32_t options,
1322  struct lyd_node **node, ...);
1323 
1337 LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name,
1338  const char *keys, uint32_t options, struct lyd_node **node);
1339 
1352 LIBYANG_API_DECL LY_ERR lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const char *name,
1353  const char **key_values, uint32_t *value_lengths, uint32_t options, struct lyd_node **node);
1354 
1369 LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name,
1370  const char *value, uint32_t options, struct lyd_node **node);
1371 
1384 LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name,
1385  const void *value, size_t value_len, uint32_t options, struct lyd_node **node);
1386 
1401 LIBYANG_API_DECL LY_ERR lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const void *value,
1402  size_t value_len, uint32_t options, struct lyd_node **node);
1403 
1418 LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name,
1419  const void *value, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node);
1420 
1435 LIBYANG_API_DECL LY_ERR lyd_new_ext_any(const struct lysc_ext_instance *ext, const char *name, const void *value,
1436  LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node);
1437 
1452 LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module,
1453  const char *name, const char *val_str, uint32_t options, struct lyd_meta **meta);
1454 
1467 LIBYANG_API_DECL LY_ERR lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, uint32_t options,
1468  const struct lyd_attr *attr, struct lyd_meta **meta);
1469 
1482 LIBYANG_API_DECL LY_ERR lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1483  const char *prefix, const char *module_name, struct lyd_node **node);
1484 
1497 LIBYANG_API_DECL LY_ERR lyd_new_opaq2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1498  const char *prefix, const char *module_ns, struct lyd_node **node);
1499 
1513 LIBYANG_API_DECL LY_ERR lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *value,
1514  struct lyd_attr **attr);
1515 
1528 LIBYANG_API_DECL LY_ERR lyd_new_attr2(struct lyd_node *parent, const char *module_ns, const char *name, const char *value,
1529  struct lyd_attr **attr);
1530 
1559 LIBYANG_API_DECL LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value,
1560  uint32_t options, struct lyd_node **node);
1561 
1586 LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value,
1587  size_t value_len, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **new_parent,
1588  struct lyd_node **new_node);
1589 
1612 LIBYANG_API_DECL LY_ERR lyd_new_ext_path(struct lyd_node *parent, const struct lysc_ext_instance *ext, const char *path,
1613  const void *value, uint32_t options, struct lyd_node **node);
1614 
1628 #define LYD_IMPLICIT_NO_STATE 0x01
1629 #define LYD_IMPLICIT_NO_CONFIG 0x02
1630 #define LYD_IMPLICIT_OUTPUT 0x04
1631 #define LYD_IMPLICIT_NO_DEFAULTS 0x08
1644 LIBYANG_API_DECL LY_ERR lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff);
1657 LIBYANG_API_DECL LY_ERR lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options,
1658  struct lyd_node **diff);
1659 
1671 LIBYANG_API_DECL LY_ERR lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module,
1672  uint32_t implicit_options, struct lyd_node **diff);
1673 
1687 LIBYANG_API_DECL LY_ERR lyd_change_term(struct lyd_node *term, const char *val_str);
1688 
1703 LIBYANG_API_DECL LY_ERR lyd_change_term_bin(struct lyd_node *term, const void *value, size_t value_len);
1704 
1719 LIBYANG_API_DECL LY_ERR lyd_change_term_canon(struct lyd_node *term, const char *val_str);
1720 
1730 LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str);
1731 
1743 LIBYANG_API_DECL LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node);
1744 
1757 LIBYANG_API_DECL LY_ERR lyd_insert_sibling(struct lyd_node *sibling, struct lyd_node *node, struct lyd_node **first);
1758 
1770 LIBYANG_API_DECL LY_ERR lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node);
1771 
1783 LIBYANG_API_DECL LY_ERR lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node);
1784 
1792 LIBYANG_API_DECL LY_ERR lyd_unlink_siblings(struct lyd_node *node);
1793 
1801 LIBYANG_API_DECL LY_ERR lyd_unlink_tree(struct lyd_node *node);
1802 
1808 LIBYANG_API_DECL void lyd_free_all(struct lyd_node *node);
1809 
1815 LIBYANG_API_DECL void lyd_free_siblings(struct lyd_node *node);
1816 
1822 LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node);
1823 
1829 LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta);
1830 
1836 LIBYANG_API_DECL void lyd_free_meta_siblings(struct lyd_meta *meta);
1837 
1844 LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr);
1845 
1852 LIBYANG_API_DECL void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr);
1853 
1872 LIBYANG_API_DECL LY_ERR lyd_value_validate(const struct ly_ctx *ctx, const struct lysc_node *schema, const char *value,
1873  size_t value_len, const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical);
1874 
1887 LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, size_t value_len);
1888 
1895 #define LYD_COMPARE_FULL_RECURSION 0x01 /* Lists and containers are the same only in case all they children
1896  (subtree, so direct as well as indirect children) are the same. By default,
1897  containers are the same in case of the same schema node and lists are the same
1898  in case of equal keys (keyless lists do the full recursion comparison all the time). */
1899 #define LYD_COMPARE_DEFAULTS 0x02 /* By default, implicit and explicit default nodes are considered to be equal. This flag
1900  changes this behavior and implicit (automatically created default node) and explicit
1901  (explicitly created node with the default value) default nodes are considered different. */
1902 #define LYD_COMPARE_OPAQ 0x04 /* Opaque nodes can normally be never equal to data nodes. Using this flag even
1903  opaque nodes members are compared to data node schema and value and can result
1904  in a match. */
1905 
1918 LIBYANG_API_DECL LY_ERR lyd_compare_single(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1919 
1931 LIBYANG_API_DECL LY_ERR lyd_compare_siblings(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1932 
1943 LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2);
1944 
1957 #define LYD_DUP_RECURSIVE 0x01
1959 #define LYD_DUP_NO_META 0x02
1961 #define LYD_DUP_WITH_PARENTS 0x04
1963 #define LYD_DUP_WITH_FLAGS 0x08
1965 #define LYD_DUP_NO_EXT 0x10
1966 #define LYD_DUP_WITH_PRIV 0x20
1968 #define LYD_DUP_NO_LYDS 0x40
1986 LIBYANG_API_DECL LY_ERR lyd_dup_single(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options,
1987  struct lyd_node **dup);
1988 
2001 LIBYANG_API_DECL LY_ERR lyd_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
2002  struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup);
2003 
2015 LIBYANG_API_DECL LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options,
2016  struct lyd_node **dup);
2017 
2031 LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
2032  struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup);
2033 
2042 LIBYANG_API_DECL LY_ERR lyd_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *parent, struct lyd_meta **dup);
2043 
2058 #define LYD_MERGE_DESTRUCT 0x01
2059 #define LYD_MERGE_DEFAULTS 0x02
2060 #define LYD_MERGE_WITH_FLAGS 0x04
2084 LIBYANG_API_DECL LY_ERR lyd_merge_tree(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2085 
2107 LIBYANG_API_DECL LY_ERR lyd_merge_siblings(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2108 
2118 typedef LY_ERR (*lyd_merge_cb)(struct lyd_node *trg_node, const struct lyd_node *src_node, void *cb_data);
2119 
2135 LIBYANG_API_DECL LY_ERR lyd_merge_module(struct lyd_node **target, const struct lyd_node *source, const struct lys_module *mod,
2136  lyd_merge_cb merge_cb, void *cb_data, uint16_t options);
2137 
2149 #define LYD_DIFF_DEFAULTS 0x01
2180 LIBYANG_API_DECL LY_ERR lyd_diff_tree(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2181  struct lyd_node **diff);
2182 
2195 LIBYANG_API_DECL LY_ERR lyd_diff_siblings(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2196  struct lyd_node **diff);
2197 
2206 typedef LY_ERR (*lyd_diff_cb)(const struct lyd_node *diff_node, struct lyd_node *data_node, void *cb_data);
2207 
2224 LIBYANG_API_DECL LY_ERR lyd_diff_apply_module(struct lyd_node **data, const struct lyd_node *diff,
2225  const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data);
2226 
2237 LIBYANG_API_DECL LY_ERR lyd_diff_apply_all(struct lyd_node **data, const struct lyd_node *diff);
2238 
2250 #define LYD_DIFF_MERGE_DEFAULTS 0x01
2278 LIBYANG_API_DECL LY_ERR lyd_diff_merge_module(struct lyd_node **diff, const struct lyd_node *src_diff,
2279  const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2280 
2297 LIBYANG_API_DECL LY_ERR lyd_diff_merge_tree(struct lyd_node **diff_first, struct lyd_node *diff_parent,
2298  const struct lyd_node *src_sibling, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2299 
2311 LIBYANG_API_DECL LY_ERR lyd_diff_merge_all(struct lyd_node **diff, const struct lyd_node *src_diff, uint16_t options);
2312 
2322 LIBYANG_API_DECL LY_ERR lyd_diff_reverse_all(const struct lyd_node *src_diff, struct lyd_node **diff);
2323 
2327 typedef enum {
2328  LYD_PATH_STD,
2332 } LYD_PATH_TYPE;
2333 
2349 LIBYANG_API_DECL char *lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen);
2350 
2360 LIBYANG_API_DECL struct lyd_meta *lyd_find_meta(const struct lyd_meta *first, const struct lys_module *module,
2361  const char *name);
2362 
2374 LIBYANG_API_DECL LY_ERR lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target,
2375  struct lyd_node **match);
2376 
2401 LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema,
2402  const char *key_or_value, size_t val_len, struct lyd_node **match);
2403 
2415 LIBYANG_API_DECL LY_ERR lyd_find_sibling_dup_inst_set(const struct lyd_node *siblings, const struct lyd_node *target,
2416  struct ly_set **set);
2417 
2428 LIBYANG_API_DECL LY_ERR lyd_find_sibling_opaq_next(const struct lyd_node *first, const char *name, struct lyd_node **match);
2429 
2441 LIBYANG_API_DECL LY_ERR lyxp_vars_set(struct lyxp_var **vars, const char *name, const char *value);
2442 
2448 LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars);
2449 
2467 LIBYANG_API_DECL LY_ERR lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set);
2468 
2482 LIBYANG_API_DECL LY_ERR lyd_find_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars,
2483  struct ly_set **set);
2484 
2502 LIBYANG_API_DECL LY_ERR lyd_find_xpath3(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath,
2503  LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, struct ly_set **set);
2504 
2516 LIBYANG_API_DECL LY_ERR lyd_eval_xpath(const struct lyd_node *ctx_node, const char *xpath, ly_bool *result);
2517 
2530 LIBYANG_API_DECL LY_ERR lyd_eval_xpath2(const struct lyd_node *ctx_node, const char *xpath,
2531  const struct lyxp_var *vars, ly_bool *result);
2532 
2548 LIBYANG_API_DECL LY_ERR lyd_eval_xpath3(const struct lyd_node *ctx_node, const struct lys_module *cur_mod,
2549  const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, ly_bool *result);
2550 
2554 typedef enum {
2556  LY_XPATH_STRING,
2557  LY_XPATH_NUMBER,
2559 } LY_XPATH_TYPE;
2560 
2583 LIBYANG_API_DECL LY_ERR lyd_eval_xpath4(const struct lyd_node *ctx_node, const struct lyd_node *tree,
2584  const struct lys_module *cur_mod, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data,
2585  const struct lyxp_var *vars, LY_XPATH_TYPE *ret_type, struct ly_set **node_set, char **string,
2586  long double *number, ly_bool *boolean);
2587 
2597 LIBYANG_API_DEF LY_ERR lyd_trim_xpath(struct lyd_node **tree, const char *xpath, const struct lyxp_var *vars);
2598 
2616 LIBYANG_API_DECL LY_ERR lyd_find_path(const struct lyd_node *ctx_node, const char *path, ly_bool output,
2617  struct lyd_node **match);
2618 
2629 LIBYANG_API_DECL LY_ERR lyd_find_target(const struct ly_path *path, const struct lyd_node *tree, struct lyd_node **match);
2630 
2636 LIBYANG_API_DECL int ly_time_tz_offset(void);
2637 
2644 LIBYANG_API_DECL int ly_time_tz_offset_at(time_t time);
2645 
2654 LIBYANG_API_DECL LY_ERR ly_time_str2time(const char *value, time_t *time, char **fractions_s);
2655 
2664 LIBYANG_API_DECL LY_ERR ly_time_time2str(time_t time, const char *fractions_s, char **str);
2665 
2673 LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts);
2674 
2682 LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str);
2683 
2694 LIBYANG_API_DECL LY_ERR lyd_leafref_get_links(const struct lyd_node_term *node, const struct lyd_leafref_links_rec **record);
2695 
2705 LIBYANG_API_DECL LY_ERR lyd_leafref_link_node_tree(const struct lyd_node *tree);
2706 
2707 #ifdef __cplusplus
2708 }
2709 #endif
2710 
2711 #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:677
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:575
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:2142
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:880
#define LYS_CONTAINER
Definition: tree_schema.h:240
Generic prefix and namespace mapping, meaning depends on the format.
Definition: tree_data.h:737
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:693
LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars)
Free the XPath variables.
const char * str
Definition: tree_data.h:882
const char * prefix
Definition: tree_data.h:739
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:669
Generic structure for a data node.
Definition: tree_data.h:799
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:436
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:800
const char * xml
Definition: tree_data.h:883
const char * zone
Definition: tree_data.h:670
struct lyd_node_opaq * parent
Definition: tree_data.h:751
const char * name
Definition: metadata.h:40
void * priv
Definition: tree_data.h:813
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:2353
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:629
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:668
struct rb_node * rbt
Definition: tree_data.h:727
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:684
Special lyd_value structure for ietf-inet-types ipv4-address-no-zone values.
Definition: tree_data.h:661
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:630
Data node structure for the inner data tree nodes - containers, lists, RPCs, actions and Notification...
Definition: tree_data.h:819
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:842
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:700
void * prefix_data
Definition: tree_data.h:719
Special lyd_value structure for ietf-yang-types date-and-time values.
Definition: tree_data.h:707
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:812
Data node structure for the terminal data tree nodes - leaves and leaf-lists.
Definition: tree_data.h:851
struct lyd_node_inner * parent
Definition: tree_data.h:806
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:805
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:636
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:753
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:755
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:646
libyang hash table.
Special lyd_value structure for ietf-inet-types ipv6-address values.
Definition: tree_data.h:691
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
Definition: tree_data.h:544
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:571
const char * _canonical
Definition: tree_data.h:572
LY_XPATH_TYPE
XPath result type.
Definition: tree_data.h:2580
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.
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:718
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:738
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:631
#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:676
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:757
struct lyd_node_term ** target_nodes
Definition: tree_data.h:1035
uint32_t flags
Definition: tree_data.h:804
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:635
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:692
char * mem
Definition: tree_data.h:885
Special lyd_value structure for lyds tree value.
Definition: tree_data.h:726
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:2232
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:884
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:754
Special lyd_value structure for ietf-inet-types ipv6-prefix values.
Definition: tree_data.h:699
Generic attribute structure.
Definition: tree_data.h:750
struct lys_module * module
Definition: tree_schema.h:1443
Special lyd_value structure for ietf-yang-types xpath1.0 values.
Definition: tree_data.h:716
#define LYD_CTX(node)
Macro to get context from a data tree node.
Definition: tree_data.h:527
struct lyd_attr * next
Definition: tree_data.h:752
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:720
LY_VALUE_FORMAT format
Definition: tree_data.h:756
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:1028
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:761
#define LYS_RPC
Definition: tree_schema.h:249
char * bitmap
Definition: tree_data.h:643
struct lyd_value value
Definition: tree_data.h:874
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:916
LYD_ANYDATA_VALUETYPE
List of possible value types stored in lyd_node_any.
Definition: tree_data.h:554
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 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:993
struct lyxp_expr * exp
Definition: tree_data.h:717
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:892
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:1029
Special lyd_value structure for built-in bits values.
Definition: tree_data.h:642
Special lyd_value structure for built-in union values.
Definition: tree_data.h:626
struct lyd_node * prev
Definition: tree_data.h:808
LY_VALUE_FORMAT format
Definition: tree_data.h:632
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_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:843
struct lyd_node * tree
Definition: tree_data.h:881
Special lyd_value structure for built-in binary values.
Definition: tree_data.h:653
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:627
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:807
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.