static WERROR add_response_rr(const char *name,
const struct dnsp_DnssrvRpcRecord *rec,
- struct dns_res_rec **answers, uint16_t *ancount)
+ struct dns_res_rec **answers)
{
struct dns_res_rec *ans = *answers;
- uint16_t ai = *ancount;
+ uint16_t ai = talloc_array_length(ans);
char *tmp;
uint32_t i;
ans[ai].rr_class = DNS_QCLASS_IN;
ans[ai].ttl = rec->dwTtlSeconds;
ans[ai].length = UINT16_MAX;
- ai++;
*answers = ans;
- *ancount = ai;
return WERR_OK;
}
static WERROR add_zone_authority_record(struct dns_server *dns,
TALLOC_CTX *mem_ctx,
const struct dns_name_question *question,
- struct dns_res_rec **nsrecs, uint16_t *nscount)
+ struct dns_res_rec **nsrecs)
{
const char *zone = NULL;
struct dnsp_DnssrvRpcRecord *recs;
struct dns_res_rec *ns = *nsrecs;
- uint16_t rec_count, ni = *nscount;
+ uint16_t rec_count;
struct ldb_dn *dn = NULL;
unsigned int ri;
WERROR werror;
for (ri = 0; ri < rec_count; ri++) {
if (recs[ri].wType == DNS_TYPE_SOA) {
- werror = add_response_rr(zone, &recs[ri],
- &ns, &ni);
+ werror = add_response_rr(zone, &recs[ri], &ns);
if (!W_ERROR_IS_OK(werror)) {
return werror;
}
}
}
- *nscount = ni;
*nsrecs = ns;
return WERR_OK;
static WERROR handle_question(struct dns_server *dns,
TALLOC_CTX *mem_ctx,
const struct dns_name_question *question,
- struct dns_res_rec **answers, uint16_t *ancount,
- struct dns_res_rec **nsrecs, uint16_t *nscount)
+ struct dns_res_rec **answers,
+ struct dns_res_rec **nsrecs)
{
struct dns_res_rec *ans = *answers;
struct dns_res_rec *ns = *nsrecs;
WERROR werror, werror_return;
unsigned int ri;
struct dnsp_DnssrvRpcRecord *recs;
- uint16_t rec_count, ai = *ancount, ni = *nscount;
+ uint16_t rec_count;
struct ldb_dn *dn = NULL;
werror = dns_name2dn(dns, mem_ctx, question->name, &dn);
/* First put in the CNAME record */
werror = add_response_rr(question->name, &recs[ri],
- &ans, &ai);
+ &ans);
if (!W_ERROR_IS_OK(werror)) {
TALLOC_FREE(new_q);
return werror;
return WERR_NOMEM;
}
/* and then call the lookup again */
- werror = handle_question(dns, mem_ctx, new_q, &ans, &ai, &ns, &ni);
+ werror = handle_question(dns, mem_ctx, new_q,
+ &ans, &ns);
if (!W_ERROR_IS_OK(werror)) {
goto done;
}
werror_return = WERR_OK;
continue;
}
- werror = add_response_rr(question->name, &recs[ri],
- &ans, &ai);
+ werror = add_response_rr(question->name, &recs[ri], &ans);
if (!W_ERROR_IS_OK(werror)) {
return werror;
}
done:
/* Always add an authority record to replies we should know about */
- add_zone_authority_record(dns, mem_ctx, question, &ns, &ni);
+ add_zone_authority_record(dns, mem_ctx, question, &ns);
- *ancount = ai;
*answers = ans;
- *nscount = ni;
*nsrecs = ns;
return werror_return;
}
err = handle_question(dns, state, &in->questions[0],
- &state->answers, &state->ancount,
- &state->nsrecs, &state->nscount);
+ &state->answers, &state->nsrecs);
if (W_ERROR_EQUAL(err, DNS_ERR(NAME_ERROR))) {
err = WERR_OK;
return tevent_req_post(req, ev);
}
+ state->ancount = talloc_array_length(state->answers);
+ state->nscount = talloc_array_length(state->nsrecs);
+
tevent_req_done(req);
return tevent_req_post(req, ev);
}