- struct dns_reply *a = &dns_reply[dns_answer_cnt];
- if (dns_answer_cnt == MAX_ANSWER)
- return;
- a->rdata = memdup(rdata, rdlength);
- a->type = type;
- a->rdlength = rdlength;
+ struct blob_attr *attr;
+ struct dns_answer *a;
+
+ attr = blob_new(&ans_buf, 0, sizeof(*a) + rdlength);
+ a = blob_data(attr);
+ a->type = cpu_to_be16(type);
+ a->class = cpu_to_be16(1);
+ a->ttl = cpu_to_be32(announce_ttl);
+ a->rdlength = cpu_to_be16(rdlength);
+ memcpy(a + 1, rdata, rdlength);
+