|
Electroneum
|

Go to the source code of this file.
Classes | |
| struct | dns_msg |
Macros | |
| #define | DNSCACHE_STORE_ZEROTTL 0x100000 |
Functions | |
| int | dns_cache_store (struct module_env *env, struct query_info *qinf, struct reply_info *rep, int is_referral, time_t leeway, int pside, struct regional *region, uint32_t flags) |
| void | dns_cache_store_msg (struct module_env *env, struct query_info *qinfo, hashvalue_type hash, struct reply_info *rep, time_t leeway, int pside, struct reply_info *qrep, uint32_t flags, struct regional *region) |
| struct delegpt * | dns_cache_find_delegation (struct module_env *env, uint8_t *qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, struct regional *region, struct dns_msg **msg, time_t timenow) |
| struct dns_msg * | tomsg (struct module_env *env, struct query_info *q, struct reply_info *r, struct regional *region, time_t now, struct regional *scratch) |
| struct dns_msg * | dns_cache_lookup (struct module_env *env, uint8_t *qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, uint16_t flags, struct regional *region, struct regional *scratch, int no_partial) |
| int | cache_fill_missing (struct module_env *env, uint16_t qclass, struct regional *region, struct delegpt *dp) |
| struct dns_msg * | dns_msg_create (uint8_t *qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, struct regional *region, size_t capacity) |
| int | dns_msg_authadd (struct dns_msg *msg, struct regional *region, struct ub_packed_rrset_key *rrset, time_t now) |
| int | dns_msg_ansadd (struct dns_msg *msg, struct regional *region, struct ub_packed_rrset_key *rrset, time_t now) |
| int | dns_cache_prefetch_adjust (struct module_env *env, struct query_info *qinfo, time_t adjust, uint16_t flags) |
| struct msgreply_entry * | msg_cache_lookup (struct module_env *env, uint8_t *qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, uint16_t flags, time_t now, int wr) |
This file contains the DNS cache.
Definition in file dns.h.
| #define DNSCACHE_STORE_ZEROTTL 0x100000 |
Flags to control behavior of dns_cache_store() and dns_cache_store_msg(). Must be an unsigned 32-bit value larger than 0xffff Allow caching a DNS message with a zero TTL.
| int cache_fill_missing | ( | struct module_env * | env, |
| uint16_t | qclass, | ||
| struct regional * | region, | ||
| struct delegpt * | dp | ||
| ) |
find and add A and AAAA records for missing nameservers in delegpt
| env | module environment with rrset cache |
| qclass | which class to look in. |
| region | where to store new dp info. |
| dp | delegation point to fill missing entries. |
| struct delegpt* dns_cache_find_delegation | ( | struct module_env * | env, |
| uint8_t * | qname, | ||
| size_t | qnamelen, | ||
| uint16_t | qtype, | ||
| uint16_t | qclass, | ||
| struct regional * | region, | ||
| struct dns_msg ** | msg, | ||
| time_t | timenow | ||
| ) |
Find a delegation from the cache.
| env | module environment with the DNS cache. |
| qname | query name. |
| qnamelen | length of qname. |
| qtype | query type. |
| qclass | query class. |
| region | where to allocate result delegation. |
| msg | if not NULL, delegation message is returned here, synthesized from the cache. |
| timenow | the time now, for checking if TTL on cache entries is OK. |
| struct dns_msg* dns_cache_lookup | ( | struct module_env * | env, |
| uint8_t * | qname, | ||
| size_t | qnamelen, | ||
| uint16_t | qtype, | ||
| uint16_t | qclass, | ||
| uint16_t | flags, | ||
| struct regional * | region, | ||
| struct regional * | scratch, | ||
| int | no_partial | ||
| ) |
Find cached message
| env | module environment with the DNS cache. |
| qname | query name. |
| qnamelen | length of qname. |
| qtype | query type. |
| qclass | query class. |
| flags | flags with BIT_CD for AAAA queries in dns64 translation. |
| region | where to allocate result. |
| scratch | where to allocate temporary data. |
| no_partial | if true, only complete messages and not a partial one (with only the start of the CNAME chain and not the rest). |
| int dns_cache_prefetch_adjust | ( | struct module_env * | env, |
| struct query_info * | qinfo, | ||
| time_t | adjust, | ||
| uint16_t | flags | ||
| ) |
Adjust the prefetch_ttl for a cached message. This adds a value to the prefetch ttl - postponing the time when it will be prefetched for future incoming queries.
| env | module environment with caches and time. |
| qinfo | query info for the query that needs adjustment. |
| adjust | time in seconds to add to the prefetch_leeway. |
| flags | flags with BIT_CD for AAAA queries in dns64 translation. |
| int dns_cache_store | ( | struct module_env * | env, |
| struct query_info * | qinf, | ||
| struct reply_info * | rep, | ||
| int | is_referral, | ||
| time_t | leeway, | ||
| int | pside, | ||
| struct regional * | region, | ||
| uint32_t | flags | ||
| ) |
Allocate a dns_msg with malloc/alloc structure and store in dns cache.
| env | environment, with alloc structure and dns cache. |
| qinf | query info, the query for which answer is stored. this is allocated in a region, and will be copied to malloc area before insertion. |
| rep | reply in dns_msg from dns_alloc_msg for example. this is allocated in a region, and will be copied to malloc area before insertion. |
| is_referral | If true, then the given message to be stored is a referral. The cache implementation may use this as a hint. It will store only the RRsets, not the message. |
| leeway | TTL value, if not 0, other rrsets are considered expired that many seconds before actual TTL expiry. |
| pside | if true, information came from a server which was fetched from the parentside of the zonecut. This means that the type NS can be updated to full TTL even in prefetch situations. |
| region | region to allocate better entries from cache into. (used when is_referral is false). |
| flags | flags with BIT_CD for AAAA queries in dns64 translation. The higher 16 bits are used internally to customize the cache policy. (See DNSCACHE_STORE_xxx flags). |
| void dns_cache_store_msg | ( | struct module_env * | env, |
| struct query_info * | qinfo, | ||
| hashvalue_type | hash, | ||
| struct reply_info * | rep, | ||
| time_t | leeway, | ||
| int | pside, | ||
| struct reply_info * | qrep, | ||
| uint32_t | flags, | ||
| struct regional * | region | ||
| ) |
Store message in the cache. Stores in message cache and rrset cache. Both qinfo and rep should be malloced and are put in the cache. They should not be used after this call, as they are then in shared cache. Does not return errors, they are logged and only lead to less cache.
| env | module environment with the DNS cache. |
| qinfo | query info |
| hash | hash over qinfo. |
| rep | reply info, together with qinfo makes up the message. Adjusts the reply info TTLs to absolute time. |
| leeway | TTL value, if not 0, other rrsets are considered expired that many seconds before actual TTL expiry. |
| pside | if true, information came from a server which was fetched from the parentside of the zonecut. This means that the type NS can be updated to full TTL even in prefetch situations. |
| qrep | message that can be altered with better rrs from cache. |
| flags | customization flags for the cache policy. |
| region | to allocate into for qmsg. |
| int dns_msg_ansadd | ( | struct dns_msg * | msg, |
| struct regional * | region, | ||
| struct ub_packed_rrset_key * | rrset, | ||
| time_t | now | ||
| ) |
Add rrset to authority section in unpacked dns_msg message. Must have enough space left, does not grow the array.
| msg | msg to put it in. |
| region | region to alloc in |
| rrset | to add in authority section |
| now | now. |
| int dns_msg_authadd | ( | struct dns_msg * | msg, |
| struct regional * | region, | ||
| struct ub_packed_rrset_key * | rrset, | ||
| time_t | now | ||
| ) |
Add rrset to authority section in unpacked dns_msg message. Must have enough space left, does not grow the array.
| msg | msg to put it in. |
| region | region to alloc in |
| rrset | to add in authority section |
| now | now. |
| struct dns_msg* dns_msg_create | ( | uint8_t * | qname, |
| size_t | qnamelen, | ||
| uint16_t | qtype, | ||
| uint16_t | qclass, | ||
| struct regional * | region, | ||
| size_t | capacity | ||
| ) |
Utility, create new, unpacked data structure for cache response. QR bit set, no AA. Query set as indicated. Space for number of rrsets.
| qname | query section name |
| qnamelen | len of qname |
| qtype | query section type |
| qclass | query section class |
| region | where to alloc. |
| capacity | number of rrsets space to create in the array. |
| struct msgreply_entry* msg_cache_lookup | ( | struct module_env * | env, |
| uint8_t * | qname, | ||
| size_t | qnamelen, | ||
| uint16_t | qtype, | ||
| uint16_t | qclass, | ||
| uint16_t | flags, | ||
| time_t | now, | ||
| int | wr | ||
| ) |
lookup message in message cache the returned nonNULL entry is locked and has to be unlocked by the caller
| struct dns_msg* tomsg | ( | struct module_env * | env, |
| struct query_info * | q, | ||
| struct reply_info * | r, | ||
| struct regional * | region, | ||
| time_t | now, | ||
| struct regional * | scratch | ||
| ) |
generate dns_msg from cached message
| env | module environment with the DNS cache. NULL if the LRU from cache does not need to be touched. |
| q | query info, contains qname that will make up the dns message. |
| r | reply info that, together with qname, will make up the dns message. |
| region | where to allocate dns message. |
| now | the time now, for check if TTL on cache entry is ok. |
| scratch | where to allocate temporary data. |