+ int rslot, wslot, total;
+ int ca_len=MIN(ans->nrrs,MAX_PEER_ADDRS);
+ struct comm_addr ca_buf[ca_len];
+ FILLZERO(ca_buf);
+ for (rslot=0, wslot=0, total=0;
+ rslot<ans->nrrs;
+ rslot++) {
+ total++;
+ if (!(wslot<ca_len)) continue;
+ adns_rr_addr *ra=&ans->rrs.addr[rslot];
+ struct comm_addr *ca=&ca_buf[wslot];
+ ca->comm=q->comm;
+ /* copy fields individually so we leave holes zeroed: */
+ switch (ra->addr.sa.sa_family) {
+ case AF_INET:
+ assert(ra->len == sizeof(ca->sin));
+ ca->sin.sin_family=ra->addr.inet.sin_family;
+ ca->sin.sin_addr= ra->addr.inet.sin_addr;
+ ca->sin.sin_port= htons(q->port);
+ wslot++;
+ break;
+ default:
+ break;
+ }
+ }
+ q->answer(q->cst,ca_buf,wslot,total);