Maintained by: NLnet Labs
Data Structures | Functions
authzone.h File Reference

This file contains the functions for an authority zone. More...

#include "util/rbtree.h"
#include "util/locks.h"

Data Structures

struct  auth_zones
 Authoritative zones, shared. More...
 
struct  auth_zone
 Auth zone. More...
 
struct  auth_data
 Auth data. More...
 
struct  auth_rrset
 A auth data RRset. More...
 

Functions

struct auth_zonesauth_zones_create (void)
 Create auth zones structure.
 
int auth_zones_apply_config (struct auth_zones *az, struct config_file *cfg)
 Apply configuration to auth zones. More...
 
void auth_zones_delete (struct auth_zones *az)
 Delete auth zones structure.
 
int auth_zone_write_file (struct auth_zone *z, const char *fname)
 Write auth zone data to file, in zonefile format.
 
int auth_zones_lookup (struct auth_zones *az, struct query_info *qinfo, struct regional *region, struct dns_msg **msg, int *fallback, uint8_t *dp_nm, size_t dp_nmlen)
 Use auth zones to lookup the answer to a query. More...
 
struct auth_zoneauth_zones_find_zone (struct auth_zones *az, struct query_info *qinfo)
 Find the auth zone that is above the given qname. More...
 
struct auth_zoneauth_zone_find (struct auth_zones *az, uint8_t *nm, size_t nmlen, uint16_t dclass)
 find an auth zone by name (exact match by name or NULL returned)
 
struct auth_zoneauth_zone_create (struct auth_zones *az, uint8_t *nm, size_t nmlen, uint16_t dclass)
 create an auth zone. More...
 
int auth_zone_set_zonefile (struct auth_zone *z, char *zonefile)
 set auth zone zonefile string. More...
 
int auth_zone_set_fallback (struct auth_zone *z, char *fallbackstr)
 set auth zone fallback. More...
 
int auth_zone_read_zonefile (struct auth_zone *z)
 read auth zone from zonefile. More...
 
int auth_zone_cmp (const void *z1, const void *z2)
 compare auth_zones for sorted rbtree
 
int auth_data_cmp (const void *z1, const void *z2)
 compare auth_data for sorted rbtree
 

Detailed Description

This file contains the functions for an authority zone.

This zone is queried by the iterator, just like a stub or forward zone, but then the data is locally held.

Function Documentation

◆ auth_zones_apply_config()

int auth_zones_apply_config ( struct auth_zones az,
struct config_file cfg 
)

Apply configuration to auth zones.

Reads zonefiles.

References auth_zones_cfg_fallback(), auth_zones_cfg_zonefile(), and auth_zones_read_zones().

◆ auth_zones_lookup()

int auth_zones_lookup ( struct auth_zones az,
struct query_info qinfo,
struct regional region,
struct dns_msg **  msg,
int *  fallback,
uint8_t *  dp_nm,
size_t  dp_nmlen 
)

Use auth zones to lookup the answer to a query.

The query is from the iterator. And the auth zones attempts to provide the answer instead of going to the internet.

Parameters
azauth zones structure.
qinfoquery info to lookup.
regionregion to use to allocate the reply in.
msgreply is stored here (if one).
fallbackif true, fallback to making a query to the internet.
dp_nmname of delegation point to look for. This zone is used to answer the query. If the dp_nm is not found, fallback is set to true and false returned.
dp_nmlenlength of dp_nm.
Returns
0: failure (an error of some sort, like servfail). if 0 and fallback is true, fallback to the internet. if 0 and fallback is false, like getting servfail. If true, an answer is available.

References auth_zone_find(), auth_zone_generate_answer(), auth_zones::lock, auth_zone::lock, query_info::qclass, VERB_ALGO, and verbose().

Referenced by q_ans_query().

◆ auth_zones_find_zone()

struct auth_zone* auth_zones_find_zone ( struct auth_zones az,
struct query_info qinfo 
)

Find the auth zone that is above the given qname.

Return NULL when there is no auth_zone above the give name, otherwise returns the closest auth_zone above the qname that pertains to it.

Parameters
azauth zones structure.
qinfoquery info to lookup.
Returns
NULL or auth_zone that pertains to the query.

Find the auth zone that is above the given qname.

References auth_zone_find(), auth_zone_find_less_equal(), dname_count_size_labels(), dname_get_shared_topdomain(), dname_is_root(), dname_remove_label(), auth_zone::name, query_info::qclass, query_info::qname, and query_info::qname_len.

◆ auth_zone_create()

struct auth_zone* auth_zone_create ( struct auth_zones az,
uint8_t *  nm,
size_t  nmlen,
uint16_t  dclass 
)

◆ auth_zone_set_zonefile()

int auth_zone_set_zonefile ( struct auth_zone z,
char *  zonefile 
)

set auth zone zonefile string.

caller must have lock on zone

References log_err().

Referenced by auth_zones_cfg_zonefile().

◆ auth_zone_set_fallback()

int auth_zone_set_fallback ( struct auth_zone z,
char *  fallbackstr 
)

set auth zone fallback.

caller must have lock on zone. fallbackstr is "yes" or "no". false on parse failure.

caller must have lock on zone

References log_err().

Referenced by auth_zones_cfg_fallback().

◆ auth_zone_read_zonefile()

int auth_zone_read_zonefile ( struct auth_zone z)