diff options
Diffstat (limited to 'util/data')
| -rw-r--r-- | util/data/msgencode.c | 16 | ||||
| -rw-r--r-- | util/data/msgencode.h | 4 | ||||
| -rw-r--r-- | util/data/msgparse.h | 4 | ||||
| -rw-r--r-- | util/data/msgreply.c | 14 | ||||
| -rw-r--r-- | util/data/msgreply.h | 12 | ||||
| -rw-r--r-- | util/data/packed_rrset.c | 14 | ||||
| -rw-r--r-- | util/data/packed_rrset.h | 12 |
7 files changed, 37 insertions, 39 deletions
diff --git a/util/data/msgencode.c b/util/data/msgencode.c index 157796deb95b..33f14b4dacc8 100644 --- a/util/data/msgencode.c +++ b/util/data/msgencode.c @@ -441,7 +441,7 @@ rrset_belongs_in_reply(ldns_pkt_section s, uint16_t rrtype, uint16_t qtype, /** store rrset in buffer in wireformat, return RETVAL_* */ static int packed_rrset_encode(struct ub_packed_rrset_key* key, ldns_buffer* pkt, - uint16_t* num_rrs, uint32_t timenow, struct regional* region, + uint16_t* num_rrs, time_t timenow, struct regional* region, int do_data, int do_sig, struct compress_tree_node** tree, ldns_pkt_section s, uint16_t qtype, int dnssec, size_t rr_offset) { @@ -528,7 +528,7 @@ packed_rrset_encode(struct ub_packed_rrset_key* key, ldns_buffer* pkt, /** store msg section in wireformat buffer, return RETVAL_* */ static int insert_section(struct reply_info* rep, size_t num_rrsets, uint16_t* num_rrs, - ldns_buffer* pkt, size_t rrsets_before, uint32_t timenow, + ldns_buffer* pkt, size_t rrsets_before, time_t timenow, struct regional* region, struct compress_tree_node** tree, ldns_pkt_section s, uint16_t qtype, int dnssec, size_t rr_offset) { @@ -624,7 +624,7 @@ positive_answer(struct reply_info* rep, uint16_t qtype) { int reply_info_encode(struct query_info* qinfo, struct reply_info* rep, - uint16_t id, uint16_t flags, ldns_buffer* buffer, uint32_t timenow, + uint16_t id, uint16_t flags, ldns_buffer* buffer, time_t timenow, struct regional* region, uint16_t udpsize, int dnssec) { uint16_t ancount=0, nscount=0, arcount=0; @@ -658,8 +658,9 @@ reply_info_encode(struct query_info* qinfo, struct reply_info* rep, return 0; } } - /* roundrobin offset. using query id for random number */ - rr_offset = RRSET_ROUNDROBIN?id:0; + /* roundrobin offset. using query id for random number. With ntohs + * for different roundrobins for sequential id client senders. */ + rr_offset = RRSET_ROUNDROBIN?ntohs(id):0; /* insert answer section */ if((r=insert_section(rep, rep->an_numrrsets, &ancount, buffer, @@ -708,9 +709,6 @@ reply_info_encode(struct query_info* qinfo, struct reply_info* rep, return 0; } ldns_buffer_write_u16_at(buffer, 10, arcount); - } else { - ldns_buffer_write_u16_at(buffer, 8, nscount); - ldns_buffer_write_u16_at(buffer, 10, arcount); } ldns_buffer_flip(buffer); return 1; @@ -750,7 +748,7 @@ attach_edns_record(ldns_buffer* pkt, struct edns_data* edns) int reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep, - uint16_t id, uint16_t qflags, ldns_buffer* pkt, uint32_t timenow, + uint16_t id, uint16_t qflags, ldns_buffer* pkt, time_t timenow, int cached, struct regional* region, uint16_t udpsize, struct edns_data* edns, int dnssec, int secure) { diff --git a/util/data/msgencode.h b/util/data/msgencode.h index 74d6c1fb2dd6..13f0c1b4d334 100644 --- a/util/data/msgencode.h +++ b/util/data/msgencode.h @@ -66,7 +66,7 @@ struct edns_data; * @return: 0 on error (server failure). */ int reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep, - uint16_t id, uint16_t qflags, ldns_buffer* dest, uint32_t timenow, + uint16_t id, uint16_t qflags, ldns_buffer* dest, time_t timenow, int cached, struct regional* region, uint16_t udpsize, struct edns_data* edns, int dnssec, int secure); @@ -88,7 +88,7 @@ int reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep, * 0 on error: malloc failure (no log_err has been done). */ int reply_info_encode(struct query_info* qinfo, struct reply_info* rep, - uint16_t id, uint16_t flags, ldns_buffer* buffer, uint32_t timenow, + uint16_t id, uint16_t flags, ldns_buffer* buffer, time_t timenow, struct regional* region, uint16_t udpsize, int dnssec); /** diff --git a/util/data/msgparse.h b/util/data/msgparse.h index 830d68e16cd6..83d2aaaa6ea7 100644 --- a/util/data/msgparse.h +++ b/util/data/msgparse.h @@ -71,9 +71,9 @@ struct regional; /** number of buckets in parse rrset hash table. Must be power of 2. */ #define PARSE_TABLE_SIZE 32 /** Maximum TTL that is allowed. */ -extern uint32_t MAX_TTL; +extern time_t MAX_TTL; /** Minimum TTL that is allowed. */ -extern uint32_t MIN_TTL; +extern time_t MIN_TTL; /** Negative cache time (for entries without any RRs.) */ #define NORR_TTL 5 /* seconds */ diff --git a/util/data/msgreply.c b/util/data/msgreply.c index 6d711fff3a27..004d6c928f57 100644 --- a/util/data/msgreply.c +++ b/util/data/msgreply.c @@ -53,9 +53,9 @@ #include "util/data/msgencode.h" /** MAX TTL default for messages and rrsets */ -uint32_t MAX_TTL = 3600 * 24 * 10; /* ten days */ +time_t MAX_TTL = 3600 * 24 * 10; /* ten days */ /** MIN TTL default for messages and rrsets */ -uint32_t MIN_TTL = 0; +time_t MIN_TTL = 0; /** allocate qinfo, return 0 on error */ static int @@ -79,7 +79,7 @@ parse_create_qinfo(ldns_buffer* pkt, struct msg_parse* msg, /** constructor for replyinfo */ static struct reply_info* construct_reply_info_base(struct regional* region, uint16_t flags, size_t qd, - uint32_t ttl, uint32_t prettl, size_t an, size_t ns, size_t ar, + time_t ttl, time_t prettl, size_t an, size_t ns, size_t ar, size_t total, enum sec_status sec) { struct reply_info* rep; @@ -154,7 +154,7 @@ repinfo_alloc_rrset_keys(struct reply_info* rep, struct alloc_cache* alloc, /** do the rdata copy */ static int rdata_copy(ldns_buffer* pkt, struct packed_rrset_data* data, uint8_t* to, - struct rr_parse* rr, uint32_t* rr_ttl, uint16_t type) + struct rr_parse* rr, time_t* rr_ttl, uint16_t type) { uint16_t pkt_len; const ldns_rr_descriptor* desc; @@ -245,7 +245,7 @@ parse_rr_copy(ldns_buffer* pkt, struct rrset_parse* pset, data->rr_len = (size_t*)((uint8_t*)data + sizeof(struct packed_rrset_data)); data->rr_data = (uint8_t**)&(data->rr_len[total]); - data->rr_ttl = (uint32_t*)&(data->rr_data[total]); + data->rr_ttl = (time_t*)&(data->rr_data[total]); nextrdata = (uint8_t*)&(data->rr_ttl[total]); for(i=0; i<data->count; i++) { data->rr_len[i] = rr->size; @@ -278,7 +278,7 @@ parse_create_rrset(ldns_buffer* pkt, struct rrset_parse* pset, /* allocate */ size_t s = sizeof(struct packed_rrset_data) + (pset->rr_count + pset->rrsig_count) * - (sizeof(size_t)+sizeof(uint8_t*)+sizeof(uint32_t)) + + (sizeof(size_t)+sizeof(uint8_t*)+sizeof(time_t)) + pset->size; if(region) *data = regional_alloc(region, s); @@ -465,7 +465,7 @@ reply_info_sortref(struct reply_info* rep) } void -reply_info_set_ttls(struct reply_info* rep, uint32_t timenow) +reply_info_set_ttls(struct reply_info* rep, time_t timenow) { size_t i, j; rep->ttl += timenow; diff --git a/util/data/msgreply.h b/util/data/msgreply.h index a32f2b1edab4..6087c6b2057c 100644 --- a/util/data/msgreply.h +++ b/util/data/msgreply.h @@ -116,21 +116,21 @@ struct reply_info { */ uint8_t qdcount; + /** 32 bit padding to pad struct member alignment to 64 bits. */ + uint32_t padding; + /** * TTL of the entire reply (for negative caching). * only for use when there are 0 RRsets in this message. * if there are RRsets, check those instead. */ - uint32_t ttl; + time_t ttl; /** * TTL for prefetch. After it has expired, a prefetch is suitable. * Smaller than the TTL, otherwise the prefetch would not happen. */ - uint32_t prefetch_ttl; - - /** 32 bit padding to pad struct member alignment to 64 bits. */ - uint32_t padding; + time_t prefetch_ttl; /** * The security status from DNSSEC validation of this message. @@ -253,7 +253,7 @@ void reply_info_sortref(struct reply_info* rep); * Also refs must be filled in. * @param timenow: the current time. */ -void reply_info_set_ttls(struct reply_info* rep, uint32_t timenow); +void reply_info_set_ttls(struct reply_info* rep, time_t timenow); /** * Delete reply_info and packed_rrsets (while they are not yet added to the diff --git a/util/data/packed_rrset.c b/util/data/packed_rrset.c index e1fc2e5291ea..1bf2e8f00b81 100644 --- a/util/data/packed_rrset.c +++ b/util/data/packed_rrset.c @@ -183,7 +183,7 @@ packed_rrset_ptr_fixup(struct packed_rrset_data* data) data->rr_len = (size_t*)((uint8_t*)data + sizeof(struct packed_rrset_data)); data->rr_data = (uint8_t**)&(data->rr_len[total]); - data->rr_ttl = (uint32_t*)&(data->rr_data[total]); + data->rr_ttl = (time_t*)&(data->rr_data[total]); nextrdata = (uint8_t*)&(data->rr_ttl[total]); for(i=0; i<total; i++) { data->rr_data[i] = nextrdata; @@ -215,7 +215,7 @@ get_cname_target(struct ub_packed_rrset_key* rrset, uint8_t** dname, } void -packed_rrset_ttl_add(struct packed_rrset_data* data, uint32_t add) +packed_rrset_ttl_add(struct packed_rrset_data* data, time_t add) { size_t i; size_t total = data->count + data->rrsig_count; @@ -266,7 +266,7 @@ void log_rrset_key(enum verbosity_value v, const char* str, ntohs(rrset->rk.type), ntohs(rrset->rk.rrset_class)); } -uint32_t +time_t ub_packed_rrset_ttl(struct ub_packed_rrset_key* key) { struct packed_rrset_data* d = (struct packed_rrset_data*)key-> @@ -276,7 +276,7 @@ ub_packed_rrset_ttl(struct ub_packed_rrset_key* key) struct ub_packed_rrset_key* packed_rrset_copy_region(struct ub_packed_rrset_key* key, - struct regional* region, uint32_t now) + struct regional* region, time_t now) { struct ub_packed_rrset_key* ck = regional_alloc(region, sizeof(struct ub_packed_rrset_key)); @@ -315,7 +315,7 @@ packed_rrset_copy_region(struct ub_packed_rrset_key* key, struct ub_packed_rrset_key* packed_rrset_copy_alloc(struct ub_packed_rrset_key* key, - struct alloc_cache* alloc, uint32_t now) + struct alloc_cache* alloc, time_t now) { struct packed_rrset_data* fd, *dd; struct ub_packed_rrset_key* dk = alloc_special_obtain(alloc); @@ -386,7 +386,7 @@ packed_rrset_heap_data(ldns_rr_list* rrset) /* allocate */ total = count + rrsig_count; - len += sizeof(*data) + total*(sizeof(size_t) + sizeof(uint32_t) + + len += sizeof(*data) + total*(sizeof(size_t) + sizeof(time_t) + sizeof(uint8_t*)); data = (struct packed_rrset_data*)calloc(1, len); if(!data) @@ -399,7 +399,7 @@ packed_rrset_heap_data(ldns_rr_list* rrset) data->rr_len = (size_t*)((uint8_t*)data + sizeof(struct packed_rrset_data)); data->rr_data = (uint8_t**)&(data->rr_len[total]); - data->rr_ttl = (uint32_t*)&(data->rr_data[total]); + data->rr_ttl = (time_t*)&(data->rr_data[total]); nextrdata = (uint8_t*)&(data->rr_ttl[total]); /* fill out len, ttl, fields */ diff --git a/util/data/packed_rrset.h b/util/data/packed_rrset.h index ad11a804226d..9530aa604f12 100644 --- a/util/data/packed_rrset.h +++ b/util/data/packed_rrset.h @@ -215,7 +215,7 @@ enum sec_status { struct packed_rrset_data { /** TTL (in seconds like time()) of the rrset. * Same for all RRs see rfc2181(5.2). */ - uint32_t ttl; + time_t ttl; /** number of rrs. */ size_t count; /** number of rrsigs, if 0 no rrsigs */ @@ -227,7 +227,7 @@ struct packed_rrset_data { /** length of every rr's rdata, rr_len[i] is size of rr_data[i]. */ size_t* rr_len; /** ttl of every rr. rr_ttl[i] ttl of rr i. */ - uint32_t *rr_ttl; + time_t *rr_ttl; /** * Array of pointers to every rr's rdata. * The rr_data[i] rdata is stored in uncompressed wireformat. @@ -281,7 +281,7 @@ size_t packed_rrset_sizeof(struct packed_rrset_data* data); * @param key: rrset key, with data to examine. * @return ttl value. */ -uint32_t ub_packed_rrset_ttl(struct ub_packed_rrset_key* key); +time_t ub_packed_rrset_ttl(struct ub_packed_rrset_key* key); /** * Calculate memory size of rrset entry. For hash table usage. @@ -343,7 +343,7 @@ void packed_rrset_ptr_fixup(struct packed_rrset_data* data); * @param data: rrset data structure. Otherwise correctly filled in. * @param add: how many seconds to add, pass time(0) for example. */ -void packed_rrset_ttl_add(struct packed_rrset_data* data, uint32_t add); +void packed_rrset_ttl_add(struct packed_rrset_data* data, time_t add); /** * Utility procedure to extract CNAME target name from its rdata. @@ -392,7 +392,7 @@ void log_rrset_key(enum verbosity_value v, const char* str, */ struct ub_packed_rrset_key* packed_rrset_copy_region( struct ub_packed_rrset_key* key, struct regional* region, - uint32_t now); + time_t now); /** * Allocate rrset with malloc (from region or you are holding the lock). @@ -403,7 +403,7 @@ struct ub_packed_rrset_key* packed_rrset_copy_region( */ struct ub_packed_rrset_key* packed_rrset_copy_alloc( struct ub_packed_rrset_key* key, struct alloc_cache* alloc, - uint32_t now); + time_t now); /** * Create a ub_packed_rrset_key allocated on the heap. |
