Initial vendor import of ldns-1.6.4 into contrib.
[dragonfly.git] / contrib / ldns / ldns / higher.h
1 /**
2  * \file higher.h
3  *
4  * Specifies some higher level functions that could
5  * be useful for certain applications
6  */
7
8 /*
9  * a Net::DNS like library for C
10  *
11  * (c) NLnet Labs, 2005-2006
12  *
13  * See the file LICENSE for the license
14  */
15
16 #ifndef LDNS_HIGHER_H
17 #define LDNS_HIGHER_H
18
19 #include <ldns/resolver.h>
20 #include <ldns/rdata.h>
21 #include <ldns/rr.h>
22 #include <ldns/host2str.h>
23 #include <ldns/tsig.h>
24
25 /**
26  * Ask the resolver about name
27  * and return all address records
28  * \param[in] r the resolver to use
29  * \param[in] name the name to look for
30  * \param[in] c the class to use
31  * \param[in] flags give some optional flags to the query
32  */
33 ldns_rr_list *ldns_get_rr_list_addr_by_name(ldns_resolver *r, ldns_rdf *name, ldns_rr_class c, uint16_t flags);
34
35 /**
36  * ask the resolver about the address
37  * and return the name
38  * \param[in] r the resolver to use
39  * \param[in] addr the addr to look for
40  * \param[in] c the class to use
41  * \param[in] flags give some optional flags to the query
42  */
43 ldns_rr_list *ldns_get_rr_list_name_by_addr(ldns_resolver *r, ldns_rdf *addr, ldns_rr_class c, uint16_t flags);
44
45 /**
46  * wade through fp (a /etc/hosts like file)
47  * and return a rr_list containing all the 
48  * defined hosts in there
49  * \param[in] fp the file pointer to use
50  * \return ldns_rr_list * with the names
51  */
52 ldns_rr_list *ldns_get_rr_list_hosts_frm_fp(FILE *fp);
53
54 /**
55  * wade through fp (a /etc/hosts like file)
56  * and return a rr_list containing all the 
57  * defined hosts in there
58  * \param[in] fp the file pointer to use
59  * \param[in] line_nr pointer to an integer containing the current line number (for debugging purposes)
60  * \return ldns_rr_list * with the names
61  */
62 ldns_rr_list *ldns_get_rr_list_hosts_frm_fp_l(FILE *fp, int *line_nr);
63
64 /**
65  * wade through fp (a /etc/hosts like file)
66  * and return a rr_list containing all the 
67  * defined hosts in there
68  * \param[in] filename the filename to use (NULL for /etc/hosts)
69  * \return ldns_rr_list * with the names
70  */
71 ldns_rr_list *ldns_get_rr_list_hosts_frm_file(char *filename);
72
73 /**
74  * This function is a wrapper function for ldns_get_rr_list_name_by_addr
75  * and ldns_get_rr_list_addr_by_name. It's name is from the getaddrinfo() 
76  * library call. It tries to mimic that call, but without the lowlevel
77  * stuff.
78  * \param[in] res The resolver. If this value is NULL then a resolver will
79  * be created by ldns_getaddrinfo.
80  * \param[in] node the name or ip address to look up
81  * \param[in] c the class to look in
82  * \param[out] list put the found RR's in this list
83  * \return the number of RR found.
84  */
85 uint16_t ldns_getaddrinfo(ldns_resolver *res, ldns_rdf *node, ldns_rr_class c, ldns_rr_list **list);
86
87 /**
88  * Check if t is enumerated in the nsec type rdata
89  * \param[in] nsec the NSEC Record to look in
90  * \param[in] t the type to check for
91  * \return true when t is found, otherwise return false
92  */
93 bool ldns_nsec_type_check(ldns_rr *nsec, ldns_rr_type t);
94
95 /**
96  * Print a number of rdf's of the RR. The rdfnum-list must 
97  * be ended by -1, otherwise unpredictable things might happen.
98  * rdfs may be printed multiple times
99  * \param[in] fp FILE * to write to
100  * \param[in] r RR to write
101  * \param[in] rdfnum a list of rdf to print.
102  */
103 void ldns_print_rr_rdf(FILE *fp, ldns_rr *r, int rdfnum, ...);
104
105 #endif /* LDNS_HIGHER_H */