]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli/dns: Add dns_cli_request() sync wrapper
authorVolker Lendecke <vl@samba.org>
Thu, 23 Apr 2026 09:13:17 +0000 (11:13 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 3 Jul 2026 08:08:36 +0000 (08:08 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
libcli/dns/dns.c
libcli/dns/libdns.h

index 2795ad24ca262936924fabfb2793f1193bd1d92f..717def985bc804bc693f8ca55a5ae3a546861869 100644 (file)
@@ -653,6 +653,33 @@ done:
        return ret;
 }
 
+int dns_cli_request(TALLOC_CTX *mem_ctx,
+                   const char *nameserver,
+                   const struct dns_name_packet *q,
+                   struct dns_name_packet **reply)
+{
+       TALLOC_CTX *frame = talloc_stackframe();
+       struct tevent_context *ev = NULL;
+       struct tevent_req *req = NULL;
+       int ret = ENOMEM;
+
+       ev = samba_tevent_context_init(frame);
+       if (ev == NULL) {
+               goto fail;
+       }
+       req = dns_cli_request_send(frame, ev, nameserver, q);
+       if (req == NULL) {
+               goto fail;
+       }
+       if (!tevent_req_poll_unix(req, ev, &ret)) {
+               goto fail;
+       }
+       ret = dns_cli_request_recv(req, mem_ctx, reply);
+fail:
+       TALLOC_FREE(frame);
+       return ret;
+}
+
 struct dns_name_packet *dns_cli_create_query(TALLOC_CTX *mem_ctx,
                                             const char *name,
                                             enum dns_qclass qclass,
index 8d00feb31384fb833e70fb297e4fe3aa24d13c53..af5ddd7b519e7f643201783262ff1abb66e1db55 100644 (file)
@@ -36,6 +36,10 @@ struct tevent_req *dns_cli_request_send(TALLOC_CTX *mem_ctx,
                                        const struct dns_name_packet *q);
 int dns_cli_request_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
                         struct dns_name_packet **reply);
+int dns_cli_request(TALLOC_CTX *mem_ctx,
+                   const char *nameserver,
+                   const struct dns_name_packet *q,
+                   struct dns_name_packet **reply);
 struct dns_name_packet *dns_cli_create_query(TALLOC_CTX *mem_ctx,
                                             const char *name,
                                             enum dns_qclass qclass,