summaryrefslogtreecommitdiffabout
path: root/lib/dns.c
Side-by-side diff
Diffstat (limited to 'lib/dns.c') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/dns.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/dns.c b/lib/dns.c
index 708803d..73499e6 100644
--- a/lib/dns.c
+++ b/lib/dns.c
@@ -27,6 +27,7 @@
#include <mailutils/argcv.h>
#include <mailutils/io.h>
#include <mailutils/stream.h>
+#include <mailutils/cstr.h>
#include "libmf.h"
#include "dns.h"
@@ -718,3 +719,32 @@ resolve_hostname(const char *host, char **pipbuf)
}
return dns_to_mf_status(dstat);
}
+
+/* Return NS records for the given DOMAIN. */
+dns_status
+ns_lookup(const char *domain, int resolve, struct dns_reply *reply)
+{
+ dns_status status = dns_failure;
+ int rc;
+ adns_answer *ans;
+ int i;
+
+ rc = adns_synchronous(get_state(), domain, adns_r_ns_raw,
+ DEFAULT_QFLAGS,
+ &ans);
+ if (rc)
+ return errno_to_dns_status(rc);
+ status = adns_to_dns_status(ans->status);
+ if (status != dns_success)
+ return status;
+
+ dns_reply_init(reply, dns_reply_str, ans->nrrs);
+ for (i = 0; i < ans->nrrs; i++)
+ reply->data.str[i] = mu_strdup(ans->rrs.str[i]);
+ free(ans);
+
+ if (resolve)
+ status = dns_reply_resolve(reply);
+
+ return status;
+}

Return to:

Send suggestions and report system problems to the System administrator.