20 June 2007: Wouter
- new -C option to enable coredumps after forking away.
- doc update.
+ - fixup CNAME generation by scrubber, and memory allocation of it.
19 June 2007: Wouter
- nicer layout in stats.c, review 0.3 change.
cn->hash=pkt_hash_rrset(pkt, cn->dname, cn->type, cn->rrset_class, 0);
/* allocate TTL + rdatalen + uncompressed dname */
memset(cn->rr_first, 0, sizeof(struct rr_parse));
+ cn->rr_first->outside_packet = 1;
cn->rr_first->ttl_data = (uint8_t*)region_alloc(region,
sizeof(uint32_t)+sizeof(uint16_t)+aliaslen);
if(!cn->rr_first->ttl_data)
}
/* synth a CNAME rrset */
prev = synth_cname_rrset(&sname, &snamelen, alias,
- aliaslen, region, msg, rrset, prev, nx, pkt);
+ aliaslen, region, msg, rrset, rrset, nx, pkt);
if(!prev) {
log_err("out of memory synthesizing CNAME");
return 0;
/* new */
insert = (struct rr_parse*)region_alloc(region,
sizeof(struct rr_parse));
+ insert->outside_packet = 0;
insert->ttl_data = sig->ttl_data;
insert->size = sig->size;
} else {
/* create rr */
if(!(rr = (struct rr_parse*)region_alloc(region, sizeof(*rr))))
return LDNS_RCODE_SERVFAIL;
+ rr->outside_packet = 0;
rr->ttl_data = ldns_buffer_current(pkt);
rr->next = 0;
if(type == LDNS_RR_TYPE_RRSIG && rrset->type != LDNS_RR_TYPE_RRSIG) {
* its dname, type and class are the same and stored for the rrset.
*/
uint8_t* ttl_data;
+ /** true if ttl_data is not part of the packet, but elsewhere in mem.
+ * Set for generated CNAMEs for DNAMEs. */
+ int outside_packet;
/** the length of the rdata if allocated (with no dname compression)*/
size_t size;
/** next in list of RRs. */
{
uint16_t pkt_len;
const ldns_rr_descriptor* desc;
- ldns_buffer_set_position(pkt, (size_t)
- (rr->ttl_data - ldns_buffer_begin(pkt)));
- log_assert(ldns_buffer_remaining(pkt) >= 6 /* ttl + rdatalen */);
- *rr_ttl = ldns_buffer_read_u32(pkt);
+
+ *rr_ttl = ldns_read_uint32(rr->ttl_data);
/* RFC 2181 Section 8. if msb of ttl is set treat as if zero. */
if(*rr_ttl & 0x80000000U)
*rr_ttl = 0;
if(*rr_ttl < data->ttl)
data->ttl = *rr_ttl;
+
+ if(rr->outside_packet) {
+ /* uncompressed already, only needs copy */
+ memmove(to, rr->ttl_data+sizeof(uint32_t), rr->size);
+ return 1;
+ }
+
+ ldns_buffer_set_position(pkt, (size_t)
+ (rr->ttl_data - ldns_buffer_begin(pkt) + sizeof(uint32_t)));
/* insert decompressed size into rdata len stored in memory */
/* -2 because rdatalen bytes are not included. */
pkt_len = htons(rr->size - 2);