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#ifdef __cplusplus
26extern "C" {
27#endif
28
29/**
30 * Ask the resolver about name
31 * and return all address records
32 * \param[in] r the resolver to use
33 * \param[in] name the name to look for
34 * \param[in] c the class to use
35 * \param[in] flags give some optional flags to the query
36 */
37ldns_rr_list *ldns_get_rr_list_addr_by_name(ldns_resolver *r, ldns_rdf *name, ldns_rr_class c, uint16_t flags);
38
39/**
40 * ask the resolver about the address
41 * and return the name
42 * \param[in] r the resolver to use
43 * \param[in] addr the addr to look for
44 * \param[in] c the class to use
45 * \param[in] flags give some optional flags to the query
46 */
47ldns_rr_list *ldns_get_rr_list_name_by_addr(ldns_resolver *r, ldns_rdf *addr, ldns_rr_class c, uint16_t flags);
48
49/**
50 * wade through fp (a /etc/hosts like file)
51 * and return a rr_list containing all the
52 * defined hosts in there
53 * \param[in] fp the file pointer to use
54 * \return ldns_rr_list * with the names
55 */
56ldns_rr_list *ldns_get_rr_list_hosts_frm_fp(FILE *fp);
57
58/**
59 * wade through fp (a /etc/hosts like file)
60 * and return a rr_list containing all the
61 * defined hosts in there
62 * \param[in] fp the file pointer to use
63 * \param[in] line_nr pointer to an integer containing the current line number (for debugging purposes)
64 * \return ldns_rr_list * with the names
65 */
66ldns_rr_list *ldns_get_rr_list_hosts_frm_fp_l(FILE *fp, int *line_nr);
67
68/**
69 * wade through fp (a /etc/hosts like file)
70 * and return a rr_list containing all the
71 * defined hosts in there
72 * \param[in] filename the filename to use (NULL for /etc/hosts)
73 * \return ldns_rr_list * with the names
74 */
75ldns_rr_list *ldns_get_rr_list_hosts_frm_file(char *filename);
76
77/**
78 * This function is a wrapper function for ldns_get_rr_list_name_by_addr
79 * and ldns_get_rr_list_addr_by_name. It's name is from the getaddrinfo()
80 * library call. It tries to mimic that call, but without the lowlevel
81 * stuff.
82 * \param[in] res The resolver. If this value is NULL then a resolver will
83 * be created by ldns_getaddrinfo.
84 * \param[in] node the name or ip address to look up
85 * \param[in] c the class to look in
86 * \param[out] list put the found RR's in this list
87 * \return the number of RR found.
88 */
89uint16_t ldns_getaddrinfo(ldns_resolver *res, ldns_rdf *node, ldns_rr_class c, ldns_rr_list **list);
90
91/**
92 * Check if t is enumerated in the nsec type rdata
93 * \param[in] nsec the NSEC Record to look in
94 * \param[in] t the type to check for
95 * \return true when t is found, otherwise return false
96 */
97bool ldns_nsec_type_check(ldns_rr *nsec, ldns_rr_type t);
98
99/**
100 * Print a number of rdf's of the RR. The rdfnum-list must
101 * be ended by -1, otherwise unpredictable things might happen.
102 * rdfs may be printed multiple times
103 * \param[in] fp FILE * to write to
104 * \param[in] r RR to write
105 * \param[in] rdfnum a list of rdf to print.
106 */
107void ldns_print_rr_rdf(FILE *fp, ldns_rr *r, int rdfnum, ...);
108
109#ifdef __cplusplus
110}
111#endif
112
113#endif /* LDNS_HIGHER_H */
114