* different.
*/
struct query_info {
- /** salient data on the query: qname, in wireformat. */
+ /**
+ * Salient data on the query: qname, in wireformat.
+ * can be allocated or a pointer to outside buffer.
+ * User has to keep track on the status of this.
+ */
uint8_t* qname;
/** length of qname (including last 0 octet) */
size_t qnamesize;
uint8_t* reply;
/** the reply size */
size_t replysize;
- /** the flags for the answer, host order. */
+
+ /** the flags for the answer, host byte order. */
uint16_t flags;
+ /**
+ * 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;
+
/**
* network order counts: qdcount ancount nscount arcount.
* so this is wireformat for the counts as they appear in the message.
*/
uint16_t counts[4];
- /** Total number of rrsets in reply: ancount+nscount+arcount. */
+ /** Total number of rrsets in reply: ancount+nscount+arcount.
+ * Use the accessor function to get this value.
+ */
size_t num_rrsets;
/**
* List of pointers (only) to the rrsets in the order in which
- * They appear in the reply message.
- * number of elements is ancount+nscount+arcount.
- * this is a pointer to that array.
+ * they appear in the reply message.
+ * Number of elements is ancount+nscount+arcount.
+ * This is a pointer to that array.
+ * Use the accessor function for access.
*/
struct packed_rrset_key** rrsets;
* These are sorted in ascending pointer, the locking order. So
* this list can be locked (and id, ttl checked), to see if
* all the data is available and recent enough.
+ *
+ * This is defined as an array of size 1, so that the compiler
+ * associates the identifier with this position in the structure.
+ * Array bound overflow on this array then gives access to the further
+ * elements of the array, which are allocated after the main structure.
+ *
+ * It could be more pure to define as array of size 0, ref[0].
+ * But ref[1] may be less confusing for compilers.
+ * Use the accessor function for access.
*/
struct rrset_ref ref[1];
};
* clearing the cache. */
typedef uint64_t rrset_id_t;
+/**
+ * The identifying information for an RRset.
+ */
+struct packed_rrset_key {
+ /**
+ * The domain name. If not null (for id=0) it is allocated, and
+ * contains the wireformat domain name.
+ * This dname is not canonicalized.
+ * After the dname uint16_t type and uint16_t class is stored
+ * in wireformat.
+ * Use accessor functions to get type and class values.
+ */
+ uint8_t* dname;
+ /**
+ * Length of the domain name, including last 0 root octet.
+ * The value+sizeof(uint16_t)*2 is actually allocated.
+ */
+ size_t dname_len;
+};
+
/**
* This structure contains an RRset. A set of resource records that
* share the same domain name, type and class.
* deleted, although the data can be. The id can be set to 0 to store and the
* structure can be recycled with a new id.
*/
-struct packed_rrset_key {
+struct ub_packed_rrset_key {
/**
* entry into hashtable. Note the lock is never destroyed,
* even when this key is retired to the cache.
* the id (which needs a writelock on entry.lock).
*/
rrset_id_t id;
-
- /**
- * The domain name. If not null (for id=0) it is allocated, and
- * contains the wireformat domain name.
- * This dname is canonicalized.
- * After the dname uint16_t type and uint16_t class is stored
- * in wireformat.
- */
- uint8_t* dname;
- /**
- * Length of the domain name, including last 0 root octet.
- * The value+sizeof(uint16_t)*2 is actually allocated.
- */
- size_t dname_len;
+ /** key data: dname, type and class */
+ struct packed_rrset_key rk;
};
/**
* and rr_data starts with the rdlength.
* the ttl value to send changes due to time.
*/
-struct packed_rrset {
- /** TTL (in seconds like time()) of the rrset */
+struct packed_rrset_data {
+ /** TTL (in seconds like time()) of the rrset.
+ * Same for all RRs see rfc2181(5.2). */
uint32_t ttl;
/** number of rrs. */
- size_t num;
+ size_t count;
/**
* Array of pointers to every rr's rdata.
* The rr_data[i] rdata is stored in uncompressed wireformat.
uint8_t** rr_data;
/** length of every rr's rdata, rr_len[i] is size of rr_data[i]. */
size_t* rr_len;
- /** TTL of every rr (equal or bigger than the rrset ttl). */
- uint32_t* rr_ttl;
/** if this rrset is signed with an RRSIG, it is stored here. */
uint8_t* rrsig_data;
/** length of rrsig rdata (only examine if rrsig_data is not null) */
size_t rrsig_len;
};
+/**
+ * An RRset can be represented using both key and data together.
+ * Split into key and data structures to simplify implementation of
+ * caching schemes.
+ */
+struct packed_rrset {
+ /** domain name, type and class */
+ struct packed_rrset_key* k;
+ /** ttl, count and rdatas (and rrsig) */
+ struct packed_rrset_data* d;
+};
+
#endif /* UTIL_DATA_PACKED_RRSET_H */