unbound 0.1
cachedump.c File Reference

This file contains functions to read and write the cache(s) to text format. More...

#include "config.h"
#include <openssl/ssl.h>
#include "daemon/cachedump.h"
#include "daemon/remote.h"
#include "daemon/worker.h"
#include "services/cache/rrset.h"
#include "services/cache/dns.h"
#include "services/cache/infra.h"
#include "services/outside_network.h"
#include "util/data/msgreply.h"
#include "util/regional.h"
#include "util/net_help.h"
#include "util/data/dname.h"
#include "util/config_file.h"
#include "iterator/iterator.h"
#include "iterator/iter_delegpt.h"
#include "iterator/iter_utils.h"
#include "iterator/iter_fwd.h"
#include "iterator/iter_hints.h"
#include "sldns/sbuffer.h"
#include "sldns/wire2str.h"
#include "sldns/str2wire.h"

Data Structures

struct  dump_info
 Struct for dump information. More...

Functions

static void spool_txt_printf (struct config_strlist_head *txt, const char *format,...)
 Print item to spool list.
static void static void spool_txt_string (struct config_strlist_head *txt, char *str)
 Append to strlist at end, and log error if out of memory.
static void spool_txt_vmsg (struct config_strlist_head *txt, const char *format, va_list args)
 Spool txt to spool list.
static void dump_rrset_line (struct config_strlist_head *txt, struct ub_packed_rrset_key *k, time_t now, size_t i)
 dump one rrset zonefile line
static void dump_rrset (struct config_strlist_head *txt, struct ub_packed_rrset_key *k, struct packed_rrset_data *d, time_t now)
 dump rrset key and data info
static int spool_strlist (RES *ssl, struct config_strlist *list)
 Spool strlist to the output.
static int dump_lruhash (struct lruhash *table, void(*func)(struct lruhash_entry *, struct config_strlist_head *, void *), RES *ssl, void *arg)
 dump lruhash cache and call callback for every item.
static int dump_slabhash (struct slabhash *sh, void(*func)(struct lruhash_entry *, struct config_strlist_head *, void *), RES *ssl, void *arg)
 dump slabhash cache and call callback for every item.
static void dump_rrset_entry (struct lruhash_entry *e, struct config_strlist_head *txt, void *arg)
 Dump the rrset cache entry.
static int dump_rrset_cache (RES *ssl, struct worker *worker)
 dump rrset cache
static void dump_msg_ref (struct config_strlist_head *txt, struct ub_packed_rrset_key *k)
 dump message to rrset reference
static void dump_msg (struct config_strlist_head *txt, struct query_info *k, struct reply_info *d, time_t now)
 dump message entry
static int copy_msg (struct regional *region, struct lruhash_entry *e, struct query_info **k, struct reply_info **d)
 copy msg to worker pad
static void dump_msg_entry (struct lruhash_entry *e, struct config_strlist_head *txt, void *arg)
 Dump the msg entry.
static int dump_msg_cache (RES *ssl, struct worker *worker)
 dump msg cache
int dump_cache (RES *ssl, struct worker *worker)
 Dump cache(s) to text.
static int ssl_read_buf (RES *ssl, sldns_buffer *buf)
 read a line from ssl into buffer
static int read_fixed (RES *ssl, sldns_buffer *buf, const char *str)
 check fixed text on line
static int load_rr (RES *ssl, sldns_buffer *buf, struct regional *region, struct ub_packed_rrset_key *rk, struct packed_rrset_data *d, unsigned int i, int is_rrsig, int *go_on, time_t now)
 load an RR into rrset
static int move_into_cache (struct ub_packed_rrset_key *k, struct packed_rrset_data *d, struct worker *worker)
 move entry into cache
static int load_rrset (RES *ssl, sldns_buffer *buf, struct worker *worker)
 load an rrset entry
static int load_rrset_cache (RES *ssl, struct worker *worker)
 load rrset cache
static char * load_qinfo (char *str, struct query_info *qinfo, struct regional *region)
 read qinfo from next three words
static int load_ref (RES *ssl, sldns_buffer *buf, struct worker *worker, struct regional *region, struct ub_packed_rrset_key **rrset, int *go_on)
 load a msg rrset reference
static int load_msg (RES *ssl, sldns_buffer *buf, struct worker *worker)
 load a msg entry
static int load_msg_cache (RES *ssl, struct worker *worker)
 load msg cache
int load_cache (RES *ssl, struct worker *worker)
 Load cache(s) from text.
static void print_dp_details (RES *ssl, struct worker *worker, struct delegpt *dp)
 print details on a delegation point
static void print_dp_main (RES *ssl, struct delegpt *dp, struct dns_msg *msg)
 print main dp info
int print_deleg_lookup (RES *ssl, struct worker *worker, uint8_t *nm, size_t nmlen, int ATTR_UNUSED(nmlabs))

Detailed Description

This file contains functions to read and write the cache(s) to text format.

Function Documentation

◆ spool_txt_printf()

void spool_txt_printf ( struct config_strlist_head * txt,
const char * format,
... )
static

Print item to spool list.

On alloc failure the list is as before.

References spool_txt_printf(), and spool_txt_vmsg().

Referenced by dump_msg(), dump_msg_ref(), dump_rrset(), and spool_txt_printf().

◆ spool_txt_string()

void static void spool_txt_string ( struct config_strlist_head * txt,
char * str )
static

Append to strlist at end, and log error if out of memory.

References cfg_strlist_append(), log_err(), and spool_txt_string().

Referenced by dump_msg_ref(), dump_rrset_line(), spool_txt_string(), and spool_txt_vmsg().

◆ spool_txt_vmsg()

void spool_txt_vmsg ( struct config_strlist_head * txt,
const char * format,
va_list args )
static

Spool txt to spool list.

References spool_txt_string(), and spool_txt_vmsg().

Referenced by spool_txt_printf(), and spool_txt_vmsg().

◆ dump_rrset_line()

void dump_rrset_line ( struct config_strlist_head * txt,
struct ub_packed_rrset_key * k,
time_t now,
size_t i )
static

dump one rrset zonefile line

References dump_rrset_line(), packed_rr_to_string(), and spool_txt_string().

Referenced by dump_rrset(), and dump_rrset_line().

◆ dump_rrset()

◆ spool_strlist()

int spool_strlist ( RES * ssl,
struct config_strlist * list )
static

Spool strlist to the output.

References config_strlist::next, spool_strlist(), ssl_printf(), and config_strlist::str.

Referenced by dump_lruhash(), print_dp_main(), and spool_strlist().

◆ dump_lruhash()

int dump_lruhash ( struct lruhash * table,
void(* func )(struct lruhash_entry *, struct config_strlist_head *, void *),
RES * ssl,
void * arg )
static

◆ dump_slabhash()

int dump_slabhash ( struct slabhash * sh,
void(* func )(struct lruhash_entry *, struct config_strlist_head *, void *),
RES * ssl,
void * arg )
static

dump slabhash cache and call callback for every item.

References slabhash::array, dump_lruhash(), dump_slabhash(), and slabhash::size.

Referenced by dump_msg_cache(), dump_rrset_cache(), and dump_slabhash().

◆ dump_rrset_entry()

void dump_rrset_entry ( struct lruhash_entry * e,
struct config_strlist_head * txt,
void * arg )
static

◆ dump_rrset_cache()

int dump_rrset_cache ( RES * ssl,
struct worker * worker )
static

◆ dump_msg_ref()

◆ dump_msg()

◆ copy_msg()

int copy_msg ( struct regional * region,
struct lruhash_entry * e,
struct query_info ** k,
struct reply_info ** d )
static

◆ dump_msg_entry()

void dump_msg_entry ( struct lruhash_entry * e,
struct config_strlist_head * txt,
void * arg )
static

◆ dump_msg_cache()

int dump_msg_cache ( RES * ssl,
struct worker * worker )
static

◆ dump_cache()

int dump_cache ( RES * ssl,
struct worker * worker )

Dump cache(s) to text.

Parameters
sslto print to
workerworker that is available (buffers, etc) and has ptrs to the caches.
Returns
false on ssl print error.

References dump_cache(), dump_msg_cache(), dump_rrset_cache(), dump_info::ssl, and ssl_printf().

Referenced by dump_cache(), and execute_cmd().

◆ ssl_read_buf()

int ssl_read_buf ( RES * ssl,
sldns_buffer * buf )
static

◆ read_fixed()

int read_fixed ( RES * ssl,
sldns_buffer * buf,
const char * str )
static

◆ load_rr()

◆ move_into_cache()

◆ load_rrset()

◆ load_rrset_cache()

int load_rrset_cache ( RES * ssl,
struct worker * worker )
static

◆ load_qinfo()

◆ load_ref()

◆ load_msg()

◆ load_msg_cache()

int load_msg_cache ( RES * ssl,
struct worker * worker )
static

◆ load_cache()

int load_cache ( RES * ssl,
struct worker * worker )

Load cache(s) from text.

Parameters
sslto read from
workerworker that is available (buffers, etc) and has ptrs to the caches.
Returns
false on ssl error.

References worker::env, load_cache(), load_msg_cache(), load_rrset_cache(), read_fixed(), and module_env::scratch_buffer.

Referenced by execute_cmd(), and load_cache().

◆ print_dp_details()

◆ print_dp_main()