[PATCH 7/9] rpc: virnetserverclient: Implement client connection transport retrieval

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Although we document 6 types of transport that we support, internally we can
only differentiate between TCP, TLS, and UNIX transports only, since both SSH
and libssh2 transports, due to using netcat, behave in the exactly the same
way as a UNIX socket.

Signed-off-by: Erik Skultety <eskultet@xxxxxxxxxx>
---
 src/rpc/virnetserverclient.c | 22 ++++++++++++++++++++++
 src/rpc/virnetserverclient.h |  2 +-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index a1543b9..a9d70e1 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -1568,3 +1568,25 @@ virNetServerClientStartKeepAlive(virNetServerClientPtr client)
     virObjectUnlock(client);
     return ret;
 }
+
+int
+virNetServerClientGetTransport(virNetServerClientPtr client)
+{
+    int ret = -1;
+
+    virObjectLock(client);
+
+    if (client->sock && virNetSocketIsLocal(client->sock))
+        ret = VIR_CLIENT_TRANS_UNIX;
+    else
+        ret = VIR_CLIENT_TRANS_TCP;
+
+#ifdef WITH_GNUTLS
+    if (client->tls)
+        ret = VIR_CLIENT_TRANS_TLS;
+#endif
+
+    virObjectUnlock(client);
+
+    return ret;
+}
diff --git a/src/rpc/virnetserverclient.h b/src/rpc/virnetserverclient.h
index e68ef76..55a8af1 100644
--- a/src/rpc/virnetserverclient.h
+++ b/src/rpc/virnetserverclient.h
@@ -144,6 +144,6 @@ int virNetServerClientSendMessage(virNetServerClientPtr client,
                                   virNetMessagePtr msg);
 
 bool virNetServerClientNeedAuth(virNetServerClientPtr client);
-
+int virNetServerClientGetTransport(virNetServerClientPtr client);
 
 #endif /* __VIR_NET_SERVER_CLIENT_H__ */
-- 
2.4.11

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]