Fix working with libyang parsed info

Before now, yang_schema expected that parsed info was available,
however, in most cases it was not:

For YangAccess, we directly manage the context, so we'll just use the
flag needed.

For NetconfAccess, we need to create our custom context and supply it.
This context is treated by libnetconf2 as shared and it won't try to
free it. We will hold a reference to this context via a new member
variable inside NetconfAccess so that it stays alive for the whole
netconf client session.

sysrepo does not support this flag as of now. Simply patching sysrepo to
always use this flag doesn't work (it gives internal errors), so it
needs an upstream patch.

Change-Id: Ie7e4567a779a09daa7b3a8b3923e73a3dfd6ba1d
diff --git a/src/netconf-client.hpp b/src/netconf-client.hpp
index 5a16cf2..719a21d 100644
--- a/src/netconf-client.hpp
+++ b/src/netconf-client.hpp
@@ -3,6 +3,7 @@
 #include <functional>
 #include <libnetconf2/log.h>
 #include <libnetconf2/messages_client.h>
+#include <libyang-cpp/Context.hpp>
 #include <memory>
 #include <optional>
 #include <string>
@@ -10,6 +11,7 @@
 #include <vector>
 
 struct nc_session;
+struct ly_ctx;
 
 namespace libyang {
 class Context;
@@ -41,10 +43,10 @@
 public:
     Session(struct nc_session* session);
     ~Session();
-    static std::unique_ptr<Session> connectPubkey(const std::string& host, const uint16_t port, const std::string& user, const std::string& pubPath, const std::string& privPath);
-    static std::unique_ptr<Session> connectKbdInteractive(const std::string& host, const uint16_t port, const std::string& user, const KbdInteractiveCb& callback);
-    static std::unique_ptr<Session> connectSocket(const std::string& path);
-    static std::unique_ptr<Session> connectFd(const int source, const int sink);
+    static std::unique_ptr<Session> connectPubkey(const std::string& host, const uint16_t port, const std::string& user, const std::string& pubPath, const std::string& privPath, std::optional<libyang::Context> ctx = std::nullopt);
+    static std::unique_ptr<Session> connectKbdInteractive(const std::string& host, const uint16_t port, const std::string& user, const KbdInteractiveCb& callback, std::optional<libyang::Context> ctx = std::nullopt);
+    static std::unique_ptr<Session> connectSocket(const std::string& path, std::optional<libyang::Context> ctx = std::nullopt);
+    static std::unique_ptr<Session> connectFd(const int source, const int sink, std::optional<libyang::Context> ctx = std::nullopt);
     [[nodiscard]] std::vector<std::string_view> capabilities() const;
     std::optional<libyang::DataNode> get(const std::optional<std::string>& filter = std::nullopt);
     std::optional<libyang::DataNode> getData(const NmdaDatastore datastore, const std::optional<std::string>& filter = std::nullopt);