unbound 0.1
Data Structures | Enumerations | Functions
ldns-testpkts.h File Reference

This is a debugging aid. More...

#include <ldns/ldns.h>

Data Structures

struct  reply_packet
 struct to keep a linked list of reply packets for a query More...
struct  entry
 data structure to keep the canned queries in. More...

Enumerations

enum  transport_type { transport_any = 0, transport_udp, transport_tcp }
 Type of transport, since some entries match based on UDP or TCP of query.

Functions

struct entryread_datafile (const char *name)
 reads the canned reply file and returns a list of structs does an exit on error.
void delete_entry (struct entry *list)
 Delete linked list of entries.
struct entryread_entry (FILE *in, const char *name, int *lineno, uint32_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev_rr)
 Read one entry from the data file.
struct entryfind_match (struct entry *entries, ldns_pkt *query_pkt, enum transport_type transport)
 finds entry in list, or returns NULL.
void adjust_packet (struct entry *match, ldns_pkt *answer_pkt, ldns_pkt *query_pkt)
 copy & adjust packet
void handle_query (uint8_t *inbuf, ssize_t inlen, struct entry *entries, int *count, enum transport_type transport, void(*sendfunc)(uint8_t *, size_t, void *), void *userdata, FILE *verbose_out)
 Parses data buffer to a query, finds the correct answer and calls the given function for every packet to send.

Detailed Description

This is a debugging aid.

It is not efficient, especially with a long config file, but it can give any reply to any query. This can help the developer pre-script replies for queries.

You can specify a packet RR by RR with header flags to return.

Missing features:


Function Documentation

struct entry* read_entry ( FILE *  in,
const char *  name,
int *  lineno,
uint32_t *  default_ttl,
ldns_rdf **  origin,
ldns_rdf **  prev_rr 
) [read]

Read one entry from the data file.

Parameters:
in,:file to read from. Filepos must be at the start of a new line.
name,:name of the file for prettier errors.
lineno,:line number in file, incremented as lines are read. for prettier errors.
default_ttl,:on first call set to default TTL for entries, later it stores the $TTL value last seen. Try 3600 first call.
origin,:domain name for origin appending. Can be &NULL on first call. later it stores the $ORIGIN value last seen. Often &NULL or the zone name on first call.
prev_rr,:previous rr name for correcter parsing. &NULL on first call.
Returns:
: The entry read (malloced) or NULL if no entry could be read.

References adjustline(), data_buffer2wire(), entry_add_reply(), error(), get_origin(), isendline(), entry::lineno, matchline(), MAX_LINE, new_entry(), reply_packet::reply, reply_packet::reply_from_hex, replyline(), and str_keyword().

Referenced by read_datafile(), replay_moment_read(), and replay_range_read().

void handle_query ( uint8_t *  inbuf,
ssize_t  inlen,
struct entry entries,
int *  count,
enum transport_type  transport,
void(*)(uint8_t *, size_t, void *)  sendfunc,
void *  userdata,
FILE *  verbose_out 
)

Parses data buffer to a query, finds the correct answer and calls the given function for every packet to send.

if verbose_out filename is given, packets are dumped there.

Parameters:
inbuf,:the packet that came in
inlen,:length of packet.
entries,:entries read in from datafile.
count,:is increased to count number of queries answered.
transport,:set to UDP or TCP to match some types of entries.
sendfunc,:called to send answer (buffer, size, userarg).
userdata,:userarg to give to sendfunc.
verbose_out,:if not NULL, verbose messages are printed there.

References adjust_packet(), entry::copy_id, find_match(), reply_packet::next, reply_packet::packet_sleep, reply_packet::reply, reply_packet::reply_from_hex, entry::reply_list, and verbose().