[PATCH 06/12] vpn-util: Add wrappers for GResolv hostname lookup use

Jussi Laakkonen <[email protected]>
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
To avoid linking GResolv with every VPN plugin that uses it, add wrappers
for the required calls in VPN utils.
---
 vpn/vpn-util.c | 30 ++++++++++++++++++++++++++++++
 vpn/vpn.h      | 10 ++++++++++
 2 files changed, 40 insertions(+)

diff --git a/vpn/vpn-util.c b/vpn/vpn-util.c
index bc3b01dd..2e526701 100644
--- a/vpn/vpn-util.c
+++ b/vpn/vpn-util.c
@@ -222,3 +222,33 @@ out:
 	return err;
 }
 
+unsigned int vpn_util_resolve_hostname(GResolv *resolv,
+				const char *hostname, GResolvResultFunc func,
+				gpointer user_data)
+{
+	DBG("resolve %s", hostname);
+
+	return g_resolv_lookup_hostname(resolv, hostname, func, user_data);
+}
+
+bool vpn_util_cancel_resolve(GResolv *resolv, unsigned int id)
+{
+	DBG("");
+
+	return g_resolv_cancel_lookup(resolv, id);
+}
+
+GResolv *vpn_util_resolve_new(int index)
+{
+	return g_resolv_new(index);
+}
+
+void vpn_util_resolve_unref(GResolv *resolv)
+{
+	g_resolv_unref(resolv);
+}
+
+int vpn_util_get_resolve_error(GResolv *resolv)
+{
+	return g_resolv_get_error(resolv);
+}
diff --git a/vpn/vpn.h b/vpn/vpn.h
index 1f8c8fcd..88afce45 100644
--- a/vpn/vpn.h
+++ b/vpn/vpn.h
@@ -134,3 +134,13 @@ bool vpn_settings_is_system_user(const char *user);
 struct passwd *vpn_util_get_passwd(const char *username);
 struct group *vpn_util_get_group(const char *groupname);
 int vpn_util_create_path(const char *path, uid_t uid, gid_t grp, int mode);
+
+#include <gweb/gresolv.h>
+
+unsigned int vpn_util_resolve_hostname(GResolv *resolv,
+				const char *hostname, GResolvResultFunc func,
+				gpointer user_data);
+bool vpn_util_cancel_resolve(GResolv *resolv, unsigned int id);
+GResolv *vpn_util_resolve_new(int index);
+void vpn_util_resolve_unref(GResolv *resolv);
+int vpn_util_get_resolve_error(GResolv *resolv);
-- 
2.39.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.