This is a debugging aid. More...
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 entry * | read_datafile (const char *name, int skip_whitespace) |
reads the canned reply file and returns a list of structs does an exit on error. More... | |
void | delete_entry (struct entry *list) |
Delete linked list of entries. | |
struct entry * | read_entry (FILE *in, const char *name, struct sldns_file_parse_state *pstate, int skip_whitespace) |
Read one entry from the data file. More... | |
struct entry * | find_match (struct entry *entries, uint8_t *query_pkt, size_t query_pkt_len, enum transport_type transport) |
finds entry in list, or returns NULL. | |
int | match_all (uint8_t *q, size_t qlen, uint8_t *p, size_t plen, int mttl, int noloc, int noedns) |
match two packets, all must match More... | |
void | adjust_packet (struct entry *match, uint8_t **answer_pkt, size_t *answer_pkt_len, uint8_t *query_pkt, size_t query_pkt_len) |
copy & adjust packet, mallocs a copy. More... | |
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. More... | |
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:
struct entry* read_datafile | ( | const char * | name, |
int | skip_whitespace | ||
) |
reads the canned reply file and returns a list of structs does an exit on error.
name | name of the file to read. |
skip_whitespace | skip leftside whitespace. |
References error(), entry::next, prog_name, read_entry(), and verbose().
Referenced by dstest_file(), nsec3_hash_test(), and verifytest_file().
struct entry* read_entry | ( | FILE * | in, |
const char * | name, | ||
struct sldns_file_parse_state * | pstate, | ||
int | skip_whitespace | ||
) |
Read one entry from the data file.
in | file to read from. Filepos must be at the start of a new line. |
name | name of the file for prettier errors. |
pstate | file parse state with lineno, default_ttl, origin and prev_rr name. |
skip_whitespace | skip leftside whitespace. |
References MAX_LINE.
Referenced by read_datafile(), and replay_range_read().
int match_all | ( | uint8_t * | q, |
size_t | qlen, | ||
uint8_t * | p, | ||
size_t | plen, | ||
int | mttl, | ||
int | noloc, | ||
int | noedns | ||
) |
match two packets, all must match
q | packet 1 |
qlen | length of q. |
p | packet 2 |
plen | length of p. |
mttl | if true, ttls must match, if false, ttls do not need to match |
noloc | if true, rrs may be reordered in their packet-section. rrs are then matches without location of the rr being important. |
noedns | if true, edns is not compared, if false, edns must match. |
match two packets, all must match
References error(), ignore_edns_lines(), lowercase_pkt(), match_noloc(), memdup(), sldns_wire2str_pkt(), verbose(), and zerottls().
Referenced by test_buffers().
void adjust_packet | ( | struct entry * | match, |
uint8_t ** | answer_pkt, | ||
size_t * | answer_pkt_len, | ||
uint8_t * | query_pkt, | ||
size_t | query_pkt_len | ||
) |
copy & adjust packet, mallocs a copy.
Assume there is only one EDNS option, which is ECS. Copy source mask from query to scope mask in reply. Assume rest of ECS data in response (eg address) matches the query.
References match().
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.
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 verbose().