Support connecting to NETCONF clients via SSH

libnetconf doesn't have nice APIs for ssh connection, but allows users
to supply the connection by themselves. One way is to use libssh (which
libnetconf uses) and supply that. However, I found that using libssh to
implement an interactive CLI isn't very easy and I'd have to implement a
lot of functionality (like authentication) by myself, attempts were
made, but I was really only imitating the interface of OpenSSH.
Fortunately, libnetconf can also communicate over file descriptors, and
it is easy to get that from OpenSSH, so I fork it and use its
stdin/stdout. On top of that, OpenSSH is very clever and knows that I'm
using it like this, so it still allows entering passwords and accepting
host keys even though its stdin/stdout isn't a terminal.

Change-Id: I27816e038bed0a82a028c8e83c15455fd514c35e
diff --git a/src/netconf-client.cpp b/src/netconf-client.cpp
index 5b3fa4d..42e9edc 100644
--- a/src/netconf-client.cpp
+++ b/src/netconf-client.cpp
@@ -20,6 +20,14 @@
 
 namespace impl {
 
+static client::LogCb logCallback;
+
+static void logViaCallback(NC_VERB_LEVEL level, const char* message)
+{
+    logCallback(level, message);
+}
+
+
 /** @short Initialization of the libnetconf2 library client
 
 Just a safe wrapper over nc_client_init and nc_client_destroy, really.
@@ -28,7 +36,6 @@
     ClientInit()
     {
         nc_client_init();
-        nc_verbosity(NC_VERB_DEBUG);
     }
 
     ~ClientInit()
@@ -178,6 +185,17 @@
 
 namespace client {
 
+void setLogLevel(NC_VERB_LEVEL level)
+{
+    nc_verbosity(level);
+}
+
+void setLogCallback(const client::LogCb& callback)
+{
+    impl::logCallback = callback;
+    nc_set_print_clb(impl::logViaCallback);
+}
+
 struct nc_session* Session::session_internal()
 {
     return m_session;