if (!(pai->qu->flags & adns_qf_cname_loose)) nflags |= adns_qf_cname_forbid;
st= adns__internal_submit(pai->ads, &nqu, adns__findtype(adns_r_addr),
+ ((adns_r_addr & adns_rrt_reprmask) |
+ (pai->qu->answer->type & ~adns_rrt_reprmask)),
&pai->qu->vb, id, nflags, pai->now, &ctx);
if (st) return st;
memset(&ctx.pinfo,0,sizeof(ctx.pinfo));
memset(&ctx.tinfo,0,sizeof(ctx.tinfo));
st= adns__internal_submit(pai->ads, &nqu, adns__findtype(adns_r_a),
- &pai->qu->vb, id,
- adns_qf_quoteok_query, pai->now, &ctx);
+ adns_r_a, &pai->qu->vb, id, adns_qf_quoteok_query,
+ pai->now, &ctx);
if (st) return st;
nqu->parent= pai->qu;
return csp_hostaddr(vb,&rrp->ha);
}
-static void postsort_srv(adns_state ads, void *array, int nrrs,
+static void postsort_srv(adns_state ads, void *array, int nrrs,int rrsz,
const struct typeinfo *typei) {
/* we treat everything in the array as if it were an adns_rr_srvha
* even though the array might be of adns_rr_srvraw. That's OK
* because they have the same prefix, which is all we access.
- * We use typei->rrsz, too, rather than naive array indexing, of course.
+ * We use rrsz, too, rather than naive array indexing, of course.
*/
char *workbegin, *workend, *search, *arrayend;
const adns_rr_srvha *rr;
int cpriority, totalweight, runtotal;
long randval;
- for (workbegin= array, arrayend= workbegin + typei->rrsz * nrrs;
+ assert(rrsz <= sizeof(rrtmp));
+ for (workbegin= array, arrayend= workbegin + rrsz * nrrs;
workbegin < arrayend;
workbegin= workend) {
cpriority= (rr=(void*)workbegin)->priority;
for (workend= workbegin, totalweight= 0;
workend < arrayend && (rr=(void*)workend)->priority == cpriority;
- workend += typei->rrsz) {
+ workend += rrsz) {
totalweight += rr->weight;
}
* workbegin (swapping with the one that was there, and then
* advance workbegin. */
for (;
- workbegin + typei->rrsz < workend; /* don't bother if just one */
- workbegin += typei->rrsz) {
+ workbegin + rrsz < workend; /* don't bother if just one */
+ workbegin += rrsz) {
randval= nrand48(ads->rand48xsubi);
randval %= (totalweight + 1);
for (search=workbegin, runtotal=0;
(runtotal += (rr=(void*)search)->weight) < randval;
- search += typei->rrsz);
+ search += rrsz);
assert(search < arrayend);
totalweight -= rr->weight;
if (search != workbegin) {
- memcpy(&rrtmp, workbegin, typei->rrsz);
- memcpy(workbegin, search, typei->rrsz);
- memcpy(search, &rrtmp, typei->rrsz);
+ memcpy(&rrtmp, workbegin, rrsz);
+ memcpy(workbegin, search, rrsz);
+ memcpy(search, &rrtmp, rrsz);
}
}
}
#define DEEP_TYPE(code,rrt,fmt,memb,parser,comparer,/*printer*/...) \
{ adns_r_##code&adns_rrt_reprmask, rrt,fmt,TYPESZ_M(memb), mf_##memb, \
GLUE(cs_, CAR(__VA_ARGS__)),pa_##parser,di_##comparer, \
- adns__ckl_hostname, CDR(__VA_ARGS__) }
+ adns__ckl_hostname, 0, adns__getrrsz_default, CDR(__VA_ARGS__) }
#define FLAT_TYPE(code,rrt,fmt,memb,parser,comparer,/*printer*/...) \
{ adns_r_##code&adns_rrt_reprmask, rrt,fmt,TYPESZ_M(memb), mf_flat, \
GLUE(cs_, CAR(__VA_ARGS__)),pa_##parser,di_##comparer, \
- adns__ckl_hostname, CDR(__VA_ARGS__) }
+ adns__ckl_hostname, 0, adns__getrrsz_default, CDR(__VA_ARGS__) }
#define di_0 0