lib UPDATE libyang v3 updates
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1660880..cf78488 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -72,9 +72,9 @@
 set(LIBNETCONF2_SOVERSION ${LIBNETCONF2_MAJOR_SOVERSION})
 
 # Version of libyang library that this project depends on
-set(LIBYANG_DEP_VERSION 2.1.19)
-set(LIBYANG_DEP_SOVERSION 2.28.0)
-set(LIBYANG_DEP_SOVERSION_MAJOR 2)
+set(LIBYANG_DEP_VERSION 2.0.0)
+set(LIBYANG_DEP_SOVERSION 3.0.0)
+set(LIBYANG_DEP_SOVERSION_MAJOR 3)
 
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -fvisibility=hidden -std=c99")
 
diff --git a/examples/server.c b/examples/server.c
index 713aecb..a43a5bc 100644
--- a/examples/server.c
+++ b/examples/server.c
@@ -127,7 +127,7 @@
     }
 
     /* create the get RPC anyxml "data" output node with the requested data */
-    if (lyd_new_any(duplicate, NULL, "data", root, 1, LYD_ANYDATA_DATATREE, 1, NULL)) {
+    if (lyd_new_any(duplicate, NULL, "data", root, LYD_ANYDATA_DATATREE, LYD_NEW_ANY_USE_VALUE | LYD_NEW_VAL_OUTPUT, NULL)) {
         err = nc_err(ctx, NC_ERR_OP_FAILED, NC_ERR_TYPE_APP);
         goto error;
     }
diff --git a/src/log.c b/src/log.c
index 8463482..8838ec2 100644
--- a/src/log.c
+++ b/src/log.c
@@ -127,7 +127,8 @@
 }
 
 static void
-nc_ly_log_clb(LY_LOG_LEVEL lvl, const char *msg, const char *UNUSED(path))
+nc_ly_log_clb(LY_LOG_LEVEL lvl, const char *msg, const char *UNUSED(data_path), const char *UNUSED(schema_path),
+        uint64_t UNUSED(line))
 {
     if (print_clb) {
         print_clb(NULL, (NC_VERB_LEVEL)lvl, msg);
@@ -141,5 +142,5 @@
 {
     print_clb = clb;
     depr_print_clb = NULL;
-    ly_set_log_clb(nc_ly_log_clb, 1);
+    ly_set_log_clb(nc_ly_log_clb);
 }
diff --git a/src/session_client.c b/src/session_client.c
index 8fd0003..f195c54 100644
--- a/src/session_client.c
+++ b/src/session_client.c
@@ -694,7 +694,7 @@
         struct module_info *modules, ly_module_imp_clb user_clb, void *user_data, int has_get_schema, struct lys_module **mod)
 {
     int ret = 0;
-    struct ly_err_item *eitem;
+    const struct ly_err_item *eitem;
     const char *module_data = NULL;
     struct ly_in *in;
     LYS_INFORMAT format;
@@ -1204,7 +1204,7 @@
 
     /* validate the data for the parent reference prefixes to be resolved */
     if (lyd_validate_all(&oper_data, NULL, LYD_VALIDATE_PRESENT, NULL)) {
-        ERR(session, "Invalid operational data received from the server (%s).", ly_errmsg(LYD_CTX(oper_data)));
+        ERR(session, "Invalid operational data received from the server (%s).", ly_err_last(LYD_CTX(oper_data))->msg);
         rc = -1;
         goto cleanup;
     }
@@ -2129,7 +2129,7 @@
         ret = recv_reply_check_msgid(session, *envp, msgid);
         goto cleanup;
     } else {
-        ERR(session, "Received an invalid message (%s).", ly_errmsg(LYD_CTX(op)));
+        ERR(session, "Received an invalid message (%s).", ly_err_last(LYD_CTX(op))->msg);
         lyd_free_tree(*envp);
         *envp = NULL;
         ret = NC_MSG_ERROR;
@@ -2353,7 +2353,7 @@
     if (!lyrc) {
         goto cleanup;
     } else {
-        ERR(session, "Received an invalid message (%s).", ly_errmsg(session->ctx));
+        ERR(session, "Received an invalid message (%s).", ly_err_last(session->ctx)->msg);
         lyd_free_tree(*envp);
         *envp = NULL;
         ret = NC_MSG_ERROR;
@@ -2642,10 +2642,10 @@
         CHECK_LYRC_BREAK(lyd_new_term(cont, mod, ncds2str[rpc_gc->source], NULL, 0, NULL));
         if (rpc_gc->filter) {
             if (!rpc_gc->filter[0] || (rpc_gc->filter[0] == '<')) {
-                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "filter", rpc_gc->filter, 0, LYD_ANYDATA_XML, 0, &node));
+                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "filter", rpc_gc->filter, LYD_ANYDATA_XML, 0, &node));
                 CHECK_LYRC_BREAK(lyd_new_meta(NULL, node, NULL, "ietf-netconf:type", "subtree", 0, NULL));
             } else {
-                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "filter", NULL, 0, LYD_ANYDATA_STRING, 0, &node));
+                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "filter", NULL, LYD_ANYDATA_STRING, 0, &node));
                 CHECK_LYRC_BREAK(lyd_new_meta(NULL, node, NULL, "ietf-netconf:type", "xpath", 0, NULL));
                 CHECK_LYRC_BREAK(lyd_new_meta(NULL, node, NULL, "ietf-netconf:select", rpc_gc->filter, 0, NULL));
             }
@@ -2679,7 +2679,7 @@
             CHECK_LYRC_BREAK(lyd_new_term(data, mod, "error-option", rpcedit_erropt2str[rpc_e->error_opt], 0, NULL));
         }
         if (!rpc_e->edit_cont[0] || (rpc_e->edit_cont[0] == '<')) {
-            CHECK_LYRC_BREAK(lyd_new_any(data, mod, "config", rpc_e->edit_cont, 0, LYD_ANYDATA_XML, 0, NULL));
+            CHECK_LYRC_BREAK(lyd_new_any(data, mod, "config", rpc_e->edit_cont, LYD_ANYDATA_XML, 0, NULL));
         } else {
             CHECK_LYRC_BREAK(lyd_new_term(data, mod, "url", rpc_e->edit_cont, 0, NULL));
         }
@@ -2699,7 +2699,7 @@
         CHECK_LYRC_BREAK(lyd_new_inner(data, mod, "source", 0, &cont));
         if (rpc_cp->url_config_src) {
             if (!rpc_cp->url_config_src[0] || (rpc_cp->url_config_src[0] == '<')) {
-                CHECK_LYRC_BREAK(lyd_new_any(cont, mod, "config", rpc_cp->url_config_src, 0, LYD_ANYDATA_XML, 0, NULL));
+                CHECK_LYRC_BREAK(lyd_new_any(cont, mod, "config", rpc_cp->url_config_src, LYD_ANYDATA_XML, 0, NULL));
             } else {
                 CHECK_LYRC_BREAK(lyd_new_term(cont, mod, "url", rpc_cp->url_config_src, 0, NULL));
             }
@@ -2752,10 +2752,10 @@
         CHECK_LYRC_BREAK(lyd_new_inner(NULL, mod, "get", 0, &data));
         if (rpc_g->filter) {
             if (!rpc_g->filter[0] || (rpc_g->filter[0] == '<')) {
-                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "filter", rpc_g->filter, 0, LYD_ANYDATA_XML, 0, &node));
+                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "filter", rpc_g->filter, LYD_ANYDATA_XML, 0, &node));
                 CHECK_LYRC_BREAK(lyd_new_meta(NULL, node, NULL, "ietf-netconf:type", "subtree", 0, NULL));
             } else {
-                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "filter", NULL, 0, LYD_ANYDATA_STRING, 0, &node));
+                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "filter", NULL, LYD_ANYDATA_STRING, 0, &node));
                 CHECK_LYRC_BREAK(lyd_new_meta(NULL, node, NULL, "ietf-netconf:type", "xpath", 0, NULL));
                 CHECK_LYRC_BREAK(lyd_new_meta(NULL, node, NULL, "ietf-netconf:select", rpc_g->filter, 0, NULL));
             }
@@ -2820,7 +2820,7 @@
         CHECK_LYRC_BREAK(lyd_new_inner(data, mod, "source", 0, &cont));
         if (rpc_val->url_config_src) {
             if (!rpc_val->url_config_src[0] || (rpc_val->url_config_src[0] == '<')) {
-                CHECK_LYRC_BREAK(lyd_new_any(cont, mod, "config", rpc_val->url_config_src, 0, LYD_ANYDATA_XML, 0, NULL));
+                CHECK_LYRC_BREAK(lyd_new_any(cont, mod, "config", rpc_val->url_config_src, LYD_ANYDATA_XML, 0, NULL));
             } else {
                 CHECK_LYRC_BREAK(lyd_new_term(cont, mod, "url", rpc_val->url_config_src, 0, NULL));
             }
@@ -2852,10 +2852,10 @@
 
         if (rpc_sub->filter) {
             if (!rpc_sub->filter[0] || (rpc_sub->filter[0] == '<')) {
-                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "filter", rpc_sub->filter, 0, LYD_ANYDATA_XML, 0, &node));
+                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "filter", rpc_sub->filter, LYD_ANYDATA_XML, 0, &node));
                 CHECK_LYRC_BREAK(lyd_new_meta(NULL, node, NULL, "ietf-netconf:type", "subtree", 0, NULL));
             } else {
-                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "filter", NULL, 0, LYD_ANYDATA_STRING, 0, &node));
+                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "filter", NULL, LYD_ANYDATA_STRING, 0, &node));
                 CHECK_LYRC_BREAK(lyd_new_meta(NULL, node, NULL, "ietf-netconf:type", "xpath", 0, NULL));
                 CHECK_LYRC_BREAK(lyd_new_meta(NULL, node, NULL, "ietf-netconf:select", rpc_sub->filter, 0, NULL));
             }
@@ -2876,7 +2876,7 @@
 
         if (rpc_getd->filter) {
             if (!rpc_getd->filter[0] || (rpc_getd->filter[0] == '<')) {
-                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "subtree-filter", rpc_getd->filter, 0, LYD_ANYDATA_XML, 0, NULL));
+                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "subtree-filter", rpc_getd->filter, LYD_ANYDATA_XML, 0, NULL));
             } else {
                 CHECK_LYRC_BREAK(lyd_new_term(data, mod, "xpath-filter", rpc_getd->filter, 0, NULL));
             }
@@ -2913,7 +2913,7 @@
                     NULL));
         }
         if (!rpc_editd->edit_cont[0] || (rpc_editd->edit_cont[0] == '<')) {
-            CHECK_LYRC_BREAK(lyd_new_any(data, mod, "config", rpc_editd->edit_cont, 0, LYD_ANYDATA_XML, 0, NULL));
+            CHECK_LYRC_BREAK(lyd_new_any(data, mod, "config", rpc_editd->edit_cont, LYD_ANYDATA_XML, 0, NULL));
         } else {
             CHECK_LYRC_BREAK(lyd_new_term(data, mod, "url", rpc_editd->edit_cont, 0, NULL));
         }
@@ -2926,7 +2926,7 @@
 
         if (rpc_estsub->filter) {
             if (!rpc_estsub->filter[0] || (rpc_estsub->filter[0] == '<')) {
-                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "stream-subtree-filter", rpc_estsub->filter, 0, LYD_ANYDATA_XML,
+                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "stream-subtree-filter", rpc_estsub->filter, LYD_ANYDATA_XML,
                         0, NULL));
             } else if (rpc_estsub->filter[0] == '/') {
                 CHECK_LYRC_BREAK(lyd_new_term(data, mod, "stream-xpath-filter", rpc_estsub->filter, 0, NULL));
@@ -2957,7 +2957,7 @@
 
         if (rpc_modsub->filter) {
             if (!rpc_modsub->filter[0] || (rpc_modsub->filter[0] == '<')) {
-                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "stream-subtree-filter", rpc_modsub->filter, 0, LYD_ANYDATA_XML,
+                CHECK_LYRC_BREAK(lyd_new_any(data, mod, "stream-subtree-filter", rpc_modsub->filter, LYD_ANYDATA_XML,
                         0, NULL));
             } else if (rpc_modsub->filter[0] == '/') {
                 CHECK_LYRC_BREAK(lyd_new_term(data, mod, "stream-xpath-filter", rpc_modsub->filter, 0, NULL));
@@ -2996,7 +2996,7 @@
 
         if (rpc_estpush->filter) {
             if (!rpc_estpush->filter[0] || (rpc_estpush->filter[0] == '<')) {
-                CHECK_LYRC_BREAK(lyd_new_any(data, mod2, "datastore-subtree-filter", rpc_estpush->filter, 0,
+                CHECK_LYRC_BREAK(lyd_new_any(data, mod2, "datastore-subtree-filter", rpc_estpush->filter,
                         LYD_ANYDATA_XML, 0, NULL));
             } else if (rpc_estpush->filter[0] == '/') {
                 CHECK_LYRC_BREAK(lyd_new_term(data, mod2, "datastore-xpath-filter", rpc_estpush->filter, 0, NULL));
@@ -3047,7 +3047,7 @@
 
         if (rpc_modpush->filter) {
             if (!rpc_modpush->filter[0] || (rpc_modpush->filter[0] == '<')) {
-                CHECK_LYRC_BREAK(lyd_new_any(data, mod2, "datastore-subtree-filter", rpc_modpush->filter, 0,
+                CHECK_LYRC_BREAK(lyd_new_any(data, mod2, "datastore-subtree-filter", rpc_modpush->filter,
                         LYD_ANYDATA_XML, 0, NULL));
             } else if (rpc_modpush->filter[0] == '/') {
                 CHECK_LYRC_BREAK(lyd_new_term(data, mod2, "datastore-xpath-filter", rpc_modpush->filter, 0, NULL));
diff --git a/src/session_server.c b/src/session_server.c
index 105bd76..7eb38a8 100644
--- a/src/session_server.c
+++ b/src/session_server.c
@@ -736,7 +736,7 @@
         free(model_data);
         return NULL;
     }
-    if (lyd_new_any(data, NULL, "data", model_data, 1, LYD_ANYDATA_STRING, 1, NULL)) {
+    if (lyd_new_any(data, NULL, "data", model_data, LYD_ANYDATA_STRING, LYD_NEW_ANY_USE_VALUE | LYD_NEW_VAL_OUTPUT, NULL)) {
         ERRINT;
         free(model_data);
         lyd_free_tree(data);
@@ -1423,7 +1423,7 @@
         if ((*rpc)->envp) {
             /* at least the envelopes were parsed */
             e = nc_err(session->ctx, NC_ERR_OP_FAILED, NC_ERR_TYPE_APP);
-            nc_err_set_msg(e, ly_errmsg(session->ctx), "en");
+            nc_err_set_msg(e, ly_err_last(session->ctx)->msg, "en");
             reply = nc_server_reply_err(e);
         } else if (session->version == NC_VERSION_11) {
             /* completely malformed message, NETCONF version 1.1 defines sending error reply from
diff --git a/tests/test_fd_comm.c b/tests/test_fd_comm.c
index 48dbce7..c2eb746 100644
--- a/tests/test_fd_comm.c
+++ b/tests/test_fd_comm.c
@@ -61,7 +61,7 @@
     assert_string_equal(rpc->schema->name, "get-config");
     assert_ptr_equal(session, server_session);
 
-    lyd_new_path(NULL, session->ctx, "/ietf-netconf:get-config/data", NULL, LYD_NEW_PATH_OUTPUT, &data);
+    lyd_new_path(NULL, session->ctx, "/ietf-netconf:get-config/data", NULL, LYD_NEW_VAL_OUTPUT, &data);
     assert_non_null(data);
 
     return nc_server_reply_data(data, NC_WD_EXPLICIT, NC_PARAMTYPE_FREE);