|
unbound
0.1
|
This is a debugging aid. More...
Defines | |
| #define | MAX_LINE 10240 |
| max line length | |
Enumerations | |
| enum | verbosity_value { NO_VERBOSE = 0, NO_VERBOSE = 0, VERB_OPS, VERB_DETAIL, VERB_QUERY, VERB_ALGO, VERB_CLIENT } |
| verbosity definition for compat More... | |
Functions | |
| void | verbose (enum verbosity_value lvl, const char *msg,...) ATTR_FORMAT(printf |
| logging routine, provided by caller | |
| void static void | error (const char *msg,...) |
| print error and exit | |
| static bool | isendline (char c) |
| return if string is empty or comment | |
| static bool | str_keyword (char **str, const char *keyword) |
| true if the string starts with the keyword given. | |
| static struct reply_packet * | entry_add_reply (struct entry *entry) |
| Add reply packet to entry. | |
| static void | matchline (char *line, struct entry *e) |
| parse MATCH line | |
| static void | replyline (char *line, ldns_pkt *reply) |
| parse REPLY line | |
| static void | adjustline (char *line, struct entry *e, struct reply_packet *pkt) |
| parse ADJUST line | |
| static struct entry * | new_entry () |
| create new entry | |
| static size_t | hexstr2bin (char *hexstr, int len, uint8_t *buf, size_t offset, size_t buf_len) |
| Converts a hex string to binary data. | |
| static ldns_buffer * | data_buffer2wire (ldns_buffer *data_buffer) |
| convert hex buffer to binary buffer | |
| static void | get_origin (const char *name, int lineno, ldns_rdf **origin, char *parse) |
| parse ORIGIN | |
| struct entry * | read_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 entry * | read_datafile (const char *name) |
| reads the canned reply file and returns a list of structs does an exit on error. | |
| static ldns_rr_type | get_qtype (ldns_pkt *p) |
| get qtype from rr | |
| static ldns_rdf * | get_owner (ldns_pkt *p) |
| returns owner from rr | |
| static uint32_t | get_serial (ldns_pkt *p) |
| get authority section SOA serial value | |
| static int | match_list (ldns_rr_list *q, ldns_rr_list *p, bool mttl) |
| match two rr lists | |
| static int | cmp_bool (int x, int y) |
| compare two booleans | |
| static int | match_all (ldns_pkt *q, ldns_pkt *p, bool mttl) |
| match all of the packet | |
| struct entry * | find_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. | |
| void | delete_replylist (struct reply_packet *replist) |
| delete the list of reply packets | |
| void | delete_entry (struct entry *list) |
| Delete linked list of entries. | |
Variables | |
| static const char * | prog_name = "ldns-testpkts" |
| string to show in warnings and errors | |
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:
| enum verbosity_value |
| static bool str_keyword | ( | char ** | str, |
| const char * | keyword | ||
| ) | [static] |
true if the string starts with the keyword given.
Moves the str ahead.
| str,: | before keyword, afterwards after keyword and spaces. |
| keyword,: | the keyword to match |
Referenced by adjustline(), matchline(), read_entry(), and replyline().
| static size_t hexstr2bin | ( | char * | hexstr, |
| int | len, | ||
| uint8_t * | buf, | ||
| size_t | offset, | ||
| size_t | buf_len | ||
| ) | [static] |
Converts a hex string to binary data.
| hexstr,: | string of hex. |
| len,: | is the length of the string |
| buf,: | is the buffer to store the result in |
| offset,: | is the starting position in the result buffer |
| buf_len,: | is the length of buf. |
Referenced by data_buffer2wire().
| 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.
| 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. |
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.
| 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().
1.7.6.1