2 Unix SMB/CIFS implementation.
4 DNS server handler for queries
6 Copyright (C) 2010 Kai Blin <kai@samba.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "smbd/service_task.h"
24 #include "libcli/util/werror.h"
25 #include "librpc/ndr/libndr.h"
26 #include "librpc/gen_ndr/ndr_dns.h"
27 #include "librpc/gen_ndr/ndr_dnsp.h"
29 #include "param/param.h"
30 #include "dsdb/samdb/samdb.h"
31 #include "dsdb/common/util.h"
32 #include "dns_server/dns_server.h"
33 #include "libcli/dns/libdns.h"
34 #include "lib/util/util_net.h"
35 #include "lib/util/tevent_werror.h"
36 #include "auth/auth.h"
37 #include "auth/credentials/credentials.h"
38 #include "auth/gensec/gensec.h"
41 #define DBGC_CLASS DBGC_DNS
43 static WERROR
create_response_rr(const struct dns_name_question
*question
,
44 const struct dnsp_DnssrvRpcRecord
*rec
,
45 struct dns_res_rec
**answers
, uint16_t *ancount
)
47 struct dns_res_rec
*ans
= *answers
;
48 uint16_t ai
= *ancount
;
56 ans
[ai
].rdata
.cname_record
= talloc_strdup(ans
, rec
->data
.cname
);
57 W_ERROR_HAVE_NO_MEMORY(ans
[ai
].rdata
.cname_record
);
60 ans
[ai
].rdata
.ipv4_record
= talloc_strdup(ans
, rec
->data
.ipv4
);
61 W_ERROR_HAVE_NO_MEMORY(ans
[ai
].rdata
.ipv4_record
);
64 ans
[ai
].rdata
.ipv6_record
= talloc_strdup(ans
, rec
->data
.ipv6
);
65 W_ERROR_HAVE_NO_MEMORY(ans
[ai
].rdata
.ipv6_record
);
68 ans
[ai
].rdata
.ns_record
= talloc_strdup(ans
, rec
->data
.ns
);
69 W_ERROR_HAVE_NO_MEMORY(ans
[ai
].rdata
.ns_record
);
72 ans
[ai
].rdata
.srv_record
.priority
= rec
->data
.srv
.wPriority
;
73 ans
[ai
].rdata
.srv_record
.weight
= rec
->data
.srv
.wWeight
;
74 ans
[ai
].rdata
.srv_record
.port
= rec
->data
.srv
.wPort
;
75 ans
[ai
].rdata
.srv_record
.target
= talloc_strdup(
76 ans
, rec
->data
.srv
.nameTarget
);
77 W_ERROR_HAVE_NO_MEMORY(ans
[ai
].rdata
.srv_record
.target
);
80 ans
[ai
].rdata
.soa_record
.mname
= talloc_strdup(
81 ans
, rec
->data
.soa
.mname
);
82 W_ERROR_HAVE_NO_MEMORY(ans
[ai
].rdata
.soa_record
.mname
);
83 ans
[ai
].rdata
.soa_record
.rname
= talloc_strdup(
84 ans
, rec
->data
.soa
.rname
);
85 W_ERROR_HAVE_NO_MEMORY(ans
[ai
].rdata
.soa_record
.rname
);
86 ans
[ai
].rdata
.soa_record
.serial
= rec
->data
.soa
.serial
;
87 ans
[ai
].rdata
.soa_record
.refresh
= rec
->data
.soa
.refresh
;
88 ans
[ai
].rdata
.soa_record
.retry
= rec
->data
.soa
.retry
;
89 ans
[ai
].rdata
.soa_record
.expire
= rec
->data
.soa
.expire
;
90 ans
[ai
].rdata
.soa_record
.minimum
= rec
->data
.soa
.minimum
;
93 ans
[ai
].rdata
.ptr_record
= talloc_strdup(ans
, rec
->data
.ptr
);
96 ans
[ai
].rdata
.mx_record
.preference
= rec
->data
.mx
.wPriority
;
97 ans
[ai
].rdata
.mx_record
.exchange
= talloc_strdup(
98 ans
, rec
->data
.mx
.nameTarget
);
99 if (ans
[ai
].rdata
.mx_record
.exchange
== NULL
) {
104 tmp
= talloc_asprintf(ans
, "\"%s\"", rec
->data
.txt
.str
[0]);
105 W_ERROR_HAVE_NO_MEMORY(tmp
);
106 for (i
=1; i
<rec
->data
.txt
.count
; i
++) {
107 tmp
= talloc_asprintf_append_buffer(
108 tmp
, " \"%s\"", rec
->data
.txt
.str
[i
]);
109 W_ERROR_HAVE_NO_MEMORY(tmp
);
111 ans
[ai
].rdata
.txt_record
.txt
= tmp
;
114 DEBUG(0, ("Got unhandled type %u query.\n", rec
->wType
));
115 return DNS_ERR(NOT_IMPLEMENTED
);
118 ans
[ai
].name
= talloc_strdup(ans
, question
->name
);
119 W_ERROR_HAVE_NO_MEMORY(ans
[ai
].name
);
120 ans
[ai
].rr_type
= rec
->wType
;
121 ans
[ai
].rr_class
= DNS_QCLASS_IN
;
122 ans
[ai
].ttl
= rec
->dwTtlSeconds
;
123 ans
[ai
].length
= UINT16_MAX
;
132 struct ask_forwarder_state
{
133 struct tevent_context
*ev
;
135 struct dns_name_packet in_packet
;
138 static void ask_forwarder_done(struct tevent_req
*subreq
);
140 static struct tevent_req
*ask_forwarder_send(
141 struct dns_server
*dns
,
142 TALLOC_CTX
*mem_ctx
, struct tevent_context
*ev
,
143 const char *forwarder
, struct dns_name_question
*question
)
145 struct tevent_req
*req
, *subreq
;
146 struct ask_forwarder_state
*state
;
147 struct dns_res_rec
*options
;
148 struct dns_name_packet out_packet
= { 0, };
150 enum ndr_err_code ndr_err
;
153 req
= tevent_req_create(mem_ctx
, &state
, struct ask_forwarder_state
);
158 generate_random_buffer((uint8_t *)&state
->id
, sizeof(state
->id
));
160 if (!is_ipaddress(forwarder
)) {
161 DEBUG(0, ("Invalid 'dns forwarder' setting '%s', needs to be "
162 "an IP address\n", forwarder
));
163 tevent_req_werror(req
, DNS_ERR(NAME_ERROR
));
164 return tevent_req_post(req
, ev
);
167 out_packet
.id
= state
->id
;
168 out_packet
.operation
|= DNS_OPCODE_QUERY
| DNS_FLAG_RECURSION_DESIRED
;
169 out_packet
.qdcount
= 1;
170 out_packet
.questions
= question
;
172 werr
= dns_generate_options(dns
, state
, &options
);
173 if (!W_ERROR_IS_OK(werr
)) {
174 tevent_req_werror(req
, werr
);
175 return tevent_req_post(req
, ev
);
178 out_packet
.arcount
= 1;
179 out_packet
.additional
= options
;
181 ndr_err
= ndr_push_struct_blob(
182 &out_blob
, state
, &out_packet
,
183 (ndr_push_flags_fn_t
)ndr_push_dns_name_packet
);
184 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
185 tevent_req_werror(req
, DNS_ERR(SERVER_FAILURE
));
186 return tevent_req_post(req
, ev
);
188 subreq
= dns_udp_request_send(state
, ev
, forwarder
, out_blob
.data
,
190 if (tevent_req_nomem(subreq
, req
)) {
191 return tevent_req_post(req
, ev
);
193 tevent_req_set_callback(subreq
, ask_forwarder_done
, req
);
197 static void ask_forwarder_done(struct tevent_req
*subreq
)
199 struct tevent_req
*req
= tevent_req_callback_data(
200 subreq
, struct tevent_req
);
201 struct ask_forwarder_state
*state
= tevent_req_data(
202 req
, struct ask_forwarder_state
);
204 enum ndr_err_code ndr_err
;
207 ret
= dns_udp_request_recv(subreq
, state
,
208 &in_blob
.data
, &in_blob
.length
);
210 if (tevent_req_werror(req
, ret
)) {
214 ndr_err
= ndr_pull_struct_blob(
215 &in_blob
, state
, &state
->in_packet
,
216 (ndr_pull_flags_fn_t
)ndr_pull_dns_name_packet
);
217 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err
)) {
218 tevent_req_werror(req
, DNS_ERR(SERVER_FAILURE
));
221 if (state
->in_packet
.id
!= state
->id
) {
222 tevent_req_werror(req
, DNS_ERR(NAME_ERROR
));
225 tevent_req_done(req
);
228 static WERROR
ask_forwarder_recv(
229 struct tevent_req
*req
, TALLOC_CTX
*mem_ctx
,
230 struct dns_res_rec
**answers
, uint16_t *ancount
,
231 struct dns_res_rec
**nsrecs
, uint16_t *nscount
,
232 struct dns_res_rec
**additional
, uint16_t *arcount
)
234 struct ask_forwarder_state
*state
= tevent_req_data(
235 req
, struct ask_forwarder_state
);
236 struct dns_name_packet
*in_packet
= &state
->in_packet
;
239 if (tevent_req_is_werror(req
, &err
)) {
243 *ancount
= in_packet
->ancount
;
244 *answers
= talloc_move(mem_ctx
, &in_packet
->answers
);
246 *nscount
= in_packet
->nscount
;
247 *nsrecs
= talloc_move(mem_ctx
, &in_packet
->nsrecs
);
249 *arcount
= in_packet
->arcount
;
250 *additional
= talloc_move(mem_ctx
, &in_packet
->additional
);
255 static WERROR
handle_question(struct dns_server
*dns
,
257 const struct dns_name_question
*question
,
258 struct dns_res_rec
**answers
, uint16_t *ancount
)
260 struct dns_res_rec
*ans
= *answers
;
261 WERROR werror
, werror_return
;
263 struct dnsp_DnssrvRpcRecord
*recs
;
264 uint16_t rec_count
, ai
= *ancount
;
265 struct ldb_dn
*dn
= NULL
;
267 werror
= dns_name2dn(dns
, mem_ctx
, question
->name
, &dn
);
268 W_ERROR_NOT_OK_RETURN(werror
);
270 werror
= dns_lookup_records(dns
, mem_ctx
, dn
, &recs
, &rec_count
);
271 W_ERROR_NOT_OK_RETURN(werror
);
273 ans
= talloc_realloc(mem_ctx
, ans
, struct dns_res_rec
, rec_count
+ ai
);
278 /* Set up for an NXDOMAIN reply if no match is found */
279 werror_return
= DNS_ERR(NAME_ERROR
);
281 for (ri
= 0; ri
< rec_count
; ri
++) {
282 if ((recs
[ri
].wType
== DNS_TYPE_CNAME
) &&
283 ((question
->question_type
== DNS_QTYPE_A
) ||
284 (question
->question_type
== DNS_QTYPE_AAAA
))) {
285 struct dns_name_question
*new_q
=
286 talloc(mem_ctx
, struct dns_name_question
);
292 /* We reply with one more record, so grow the array */
293 ans
= talloc_realloc(mem_ctx
, ans
, struct dns_res_rec
,
300 /* First put in the CNAME record */
301 werror
= create_response_rr(question
, &recs
[ri
], &ans
, &ai
);
302 if (!W_ERROR_IS_OK(werror
)) {
306 /* And then look up the name it points at.. */
308 /* First build up the new question */
309 new_q
->question_type
= question
->question_type
;
310 new_q
->question_class
= question
->question_class
;
311 if (new_q
->question_type
== DNS_QTYPE_A
) {
312 new_q
->name
= talloc_strdup(new_q
, recs
[ri
].data
.ipv4
);
313 } else if (new_q
->question_type
== DNS_QTYPE_AAAA
) {
314 new_q
->name
= talloc_strdup(new_q
, recs
[ri
].data
.ipv6
);
316 if (new_q
->name
== NULL
) {
320 /* and then call the lookup again */
321 werror
= handle_question(dns
, mem_ctx
, new_q
, &ans
, &ai
);
322 if (!W_ERROR_IS_OK(werror
)) {
325 werror_return
= WERR_OK
;
330 if ((question
->question_type
!= DNS_QTYPE_ALL
) &&
331 (recs
[ri
].wType
!= (enum dns_record_type
) question
->question_type
)) {
332 werror_return
= WERR_OK
;
335 werror
= create_response_rr(question
, &recs
[ri
], &ans
, &ai
);
336 if (!W_ERROR_IS_OK(werror
)) {
339 werror_return
= WERR_OK
;
345 return werror_return
;
348 static NTSTATUS
create_tkey(struct dns_server
*dns
,
350 const char* algorithm
,
351 struct dns_server_tkey
**tkey
)
354 struct dns_server_tkey_store
*store
= dns
->tkeys
;
355 struct dns_server_tkey
*k
= talloc_zero(store
, struct dns_server_tkey
);
358 return NT_STATUS_NO_MEMORY
;
361 k
->name
= talloc_strdup(k
, name
);
363 if (k
->name
== NULL
) {
364 return NT_STATUS_NO_MEMORY
;
367 k
->algorithm
= talloc_strdup(k
, algorithm
);
368 if (k
->algorithm
== NULL
) {
369 return NT_STATUS_NO_MEMORY
;
372 status
= samba_server_gensec_start(k
,
373 dns
->task
->event_ctx
,
376 dns
->server_credentials
,
379 if (!NT_STATUS_IS_OK(status
)) {
380 DEBUG(1, ("Failed to start GENSEC server code: %s\n", nt_errstr(status
)));
385 gensec_want_feature(k
->gensec
, GENSEC_FEATURE_SIGN
);
387 status
= gensec_start_mech_by_oid(k
->gensec
, GENSEC_OID_SPNEGO
);
389 if (!NT_STATUS_IS_OK(status
)) {
390 DEBUG(1, ("Failed to start GENSEC server code: %s\n",
396 if (store
->tkeys
[store
->next_idx
] != NULL
) {
397 TALLOC_FREE(store
->tkeys
[store
->next_idx
]);
400 store
->tkeys
[store
->next_idx
] = k
;
402 store
->next_idx
%= store
->size
;
408 static NTSTATUS
accept_gss_ticket(TALLOC_CTX
*mem_ctx
,
409 struct dns_server
*dns
,
410 struct dns_server_tkey
*tkey
,
411 const DATA_BLOB
*key
,
413 uint16_t *dns_auth_error
)
417 status
= gensec_update_ev(tkey
->gensec
, mem_ctx
, dns
->task
->event_ctx
,
420 if (NT_STATUS_EQUAL(NT_STATUS_MORE_PROCESSING_REQUIRED
, status
)) {
421 *dns_auth_error
= DNS_RCODE_OK
;
425 if (NT_STATUS_IS_OK(status
)) {
427 status
= gensec_session_info(tkey
->gensec
, tkey
, &tkey
->session_info
);
428 if (!NT_STATUS_IS_OK(status
)) {
429 *dns_auth_error
= DNS_RCODE_BADKEY
;
432 *dns_auth_error
= DNS_RCODE_OK
;
438 static WERROR
handle_tkey(struct dns_server
*dns
,
440 const struct dns_name_packet
*in
,
441 struct dns_request_state
*state
,
442 struct dns_res_rec
**answers
,
445 struct dns_res_rec
*in_tkey
= NULL
;
446 struct dns_res_rec
*ret_tkey
;
449 for (i
= 0; i
< in
->arcount
; i
++) {
450 if (in
->additional
[i
].rr_type
== DNS_QTYPE_TKEY
) {
451 in_tkey
= &in
->additional
[i
];
456 /* If this is a TKEY query, it should have a TKEY RR.
457 * Behaviour is not really specified in RFC 2930 or RFC 3645, but
458 * FORMAT_ERROR seems to be what BIND uses .*/
459 if (in_tkey
== NULL
) {
460 return DNS_ERR(FORMAT_ERROR
);
463 ret_tkey
= talloc_zero(mem_ctx
, struct dns_res_rec
);
464 if (ret_tkey
== NULL
) {
468 ret_tkey
->name
= talloc_strdup(ret_tkey
, in_tkey
->name
);
469 if (ret_tkey
->name
== NULL
) {
473 ret_tkey
->rr_type
= DNS_QTYPE_TKEY
;
474 ret_tkey
->rr_class
= DNS_QCLASS_ANY
;
475 ret_tkey
->length
= UINT16_MAX
;
477 ret_tkey
->rdata
.tkey_record
.algorithm
= talloc_strdup(ret_tkey
,
478 in_tkey
->rdata
.tkey_record
.algorithm
);
479 if (ret_tkey
->rdata
.tkey_record
.algorithm
== NULL
) {
483 ret_tkey
->rdata
.tkey_record
.inception
= in_tkey
->rdata
.tkey_record
.inception
;
484 ret_tkey
->rdata
.tkey_record
.expiration
= in_tkey
->rdata
.tkey_record
.expiration
;
485 ret_tkey
->rdata
.tkey_record
.mode
= in_tkey
->rdata
.tkey_record
.mode
;
487 switch (in_tkey
->rdata
.tkey_record
.mode
) {
488 case DNS_TKEY_MODE_DH
:
489 /* FIXME: According to RFC 2930, we MUST support this, but we don't.
490 * Still, claim it's a bad key instead of a bad mode */
491 ret_tkey
->rdata
.tkey_record
.error
= DNS_RCODE_BADKEY
;
493 case DNS_TKEY_MODE_GSSAPI
: {
495 struct dns_server_tkey
*tkey
;
499 tkey
= dns_find_tkey(dns
->tkeys
, in
->questions
[0].name
);
500 if (tkey
!= NULL
&& tkey
->complete
) {
501 /* TODO: check if the key is still valid */
502 DEBUG(1, ("Rejecting tkey negotiation for already established key\n"));
503 ret_tkey
->rdata
.tkey_record
.error
= DNS_RCODE_BADNAME
;
508 status
= create_tkey(dns
, in
->questions
[0].name
,
509 in_tkey
->rdata
.tkey_record
.algorithm
,
511 if (!NT_STATUS_IS_OK(status
)) {
512 ret_tkey
->rdata
.tkey_record
.error
= DNS_RCODE_BADKEY
;
513 return ntstatus_to_werror(status
);
517 key
.data
= in_tkey
->rdata
.tkey_record
.key_data
;
518 key
.length
= in_tkey
->rdata
.tkey_record
.key_size
;
520 status
= accept_gss_ticket(ret_tkey
, dns
, tkey
, &key
, &reply
,
521 &ret_tkey
->rdata
.tkey_record
.error
);
522 if (NT_STATUS_EQUAL(status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)) {
523 DEBUG(1, ("More processing required\n"));
524 ret_tkey
->rdata
.tkey_record
.error
= DNS_RCODE_BADKEY
;
525 } else if (NT_STATUS_IS_OK(status
)) {
526 DEBUG(1, ("Tkey handshake completed\n"));
527 ret_tkey
->rdata
.tkey_record
.key_size
= reply
.length
;
528 ret_tkey
->rdata
.tkey_record
.key_data
= talloc_memdup(ret_tkey
,
532 state
->key_name
= talloc_strdup(state
->mem_ctx
, tkey
->name
);
533 if (state
->key_name
== NULL
) {
537 DEBUG(1, ("GSS key negotiation returned %s\n", nt_errstr(status
)));
538 ret_tkey
->rdata
.tkey_record
.error
= DNS_RCODE_BADKEY
;
543 case DNS_TKEY_MODE_DELETE
:
544 /* TODO: implement me */
545 DEBUG(1, ("Should delete tkey here\n"));
546 ret_tkey
->rdata
.tkey_record
.error
= DNS_RCODE_OK
;
548 case DNS_TKEY_MODE_NULL
:
549 case DNS_TKEY_MODE_SERVER
:
550 case DNS_TKEY_MODE_CLIENT
:
551 case DNS_TKEY_MODE_LAST
:
552 /* We don't have to implement these, return a mode error */
553 ret_tkey
->rdata
.tkey_record
.error
= DNS_RCODE_BADMODE
;
556 DEBUG(1, ("Unsupported TKEY mode %d\n",
557 in_tkey
->rdata
.tkey_record
.mode
));
566 struct dns_server_process_query_state
{
567 struct dns_res_rec
*answers
;
569 struct dns_res_rec
*nsrecs
;
571 struct dns_res_rec
*additional
;
575 static void dns_server_process_query_got_response(struct tevent_req
*subreq
);
577 struct tevent_req
*dns_server_process_query_send(
578 TALLOC_CTX
*mem_ctx
, struct tevent_context
*ev
,
579 struct dns_server
*dns
, struct dns_request_state
*req_state
,
580 const struct dns_name_packet
*in
)
582 struct tevent_req
*req
, *subreq
;
583 struct dns_server_process_query_state
*state
;
585 req
= tevent_req_create(mem_ctx
, &state
,
586 struct dns_server_process_query_state
);
590 if (in
->qdcount
!= 1) {
591 tevent_req_werror(req
, DNS_ERR(FORMAT_ERROR
));
592 return tevent_req_post(req
, ev
);
595 /* Windows returns NOT_IMPLEMENTED on this as well */
596 if (in
->questions
[0].question_class
== DNS_QCLASS_NONE
) {
597 tevent_req_werror(req
, DNS_ERR(NOT_IMPLEMENTED
));
598 return tevent_req_post(req
, ev
);
601 if (in
->questions
[0].question_type
== DNS_QTYPE_TKEY
) {
604 err
= handle_tkey(dns
, state
, in
, req_state
,
605 &state
->answers
, &state
->ancount
);
606 if (tevent_req_werror(req
, err
)) {
607 return tevent_req_post(req
, ev
);
609 tevent_req_done(req
);
610 return tevent_req_post(req
, ev
);
613 if (dns_authorative_for_zone(dns
, in
->questions
[0].name
)) {
616 req_state
->flags
|= DNS_FLAG_AUTHORITATIVE
;
617 err
= handle_question(dns
, state
, &in
->questions
[0],
618 &state
->answers
, &state
->ancount
);
619 if (tevent_req_werror(req
, err
)) {
620 return tevent_req_post(req
, ev
);
622 tevent_req_done(req
);
623 return tevent_req_post(req
, ev
);
626 if ((req_state
->flags
& DNS_FLAG_RECURSION_DESIRED
) &&
627 (req_state
->flags
& DNS_FLAG_RECURSION_AVAIL
)) {
628 DEBUG(2, ("Not authoritative for '%s', forwarding\n",
629 in
->questions
[0].name
));
631 subreq
= ask_forwarder_send(
633 state
, ev
, lpcfg_dns_forwarder(dns
->task
->lp_ctx
),
635 if (tevent_req_nomem(subreq
, req
)) {
636 return tevent_req_post(req
, ev
);
638 tevent_req_set_callback(
639 subreq
, dns_server_process_query_got_response
, req
);
643 tevent_req_werror(req
, DNS_ERR(NAME_ERROR
));
644 return tevent_req_post(req
, ev
);
647 static void dns_server_process_query_got_response(struct tevent_req
*subreq
)
649 struct tevent_req
*req
= tevent_req_callback_data(
650 subreq
, struct tevent_req
);
651 struct dns_server_process_query_state
*state
= tevent_req_data(
652 req
, struct dns_server_process_query_state
);
655 err
= ask_forwarder_recv(subreq
, state
,
656 &state
->answers
, &state
->ancount
,
657 &state
->nsrecs
, &state
->nscount
,
658 &state
->additional
, &state
->arcount
);
660 if (tevent_req_werror(req
, err
)) {
663 tevent_req_done(req
);
666 WERROR
dns_server_process_query_recv(
667 struct tevent_req
*req
, TALLOC_CTX
*mem_ctx
,
668 struct dns_res_rec
**answers
, uint16_t *ancount
,
669 struct dns_res_rec
**nsrecs
, uint16_t *nscount
,
670 struct dns_res_rec
**additional
, uint16_t *arcount
)
672 struct dns_server_process_query_state
*state
= tevent_req_data(
673 req
, struct dns_server_process_query_state
);
676 if (tevent_req_is_werror(req
, &err
)) {
679 *answers
= talloc_move(mem_ctx
, &state
->answers
);
680 *ancount
= state
->ancount
;
681 *nsrecs
= talloc_move(mem_ctx
, &state
->nsrecs
);
682 *nscount
= state
->nscount
;
683 *additional
= talloc_move(mem_ctx
, &state
->additional
);
684 *arcount
= state
->arcount
;