1libsres(3) Programmer's Manual libsres(3)
2
3
4
6 query_send(), response_rcv(), get() - send queries and receive
7 responses from a DNS name server.
8
9 clone_ns(), clone_ns_list(), free_name_server(), free_name_servers() -
10 manage name server lists
11
12 print_response() - display answers returned from the name server
13
15 #include <resolver.h>
16
17 int query_send(const char *name,
18 const unsigned short type,
19 const unsigned short class,
20 struct name_server *nslist,
21 int edns0_size,
22 int *trans_id);
23
24 int response_recv(int *trans_id,
25 fd_set *pending_desc,
26 struct timeval *closest_event,
27 struct name_server **respondent,
28 unsigned char **response,
29 size_t *response_length);
30
31 int get(const char *name_n,
32 const unsigned short type_h,
33 const unsigned short class_h,
34 struct name_server *nslist,
35 struct name_server **respondent,
36 unsigned char **response,
37 size_t *response_length);
38
39 int clone_ns(struct name_server **cloned_ns,
40 struct name_server *ns);
41
42 int clone_ns_list(struct name_server **ns_list,
43 struct name_server *orig_ns_list);
44
45 void free_name_server(struct name_server **ns);
46
47 void free_name_servers(struct name_server **ns);
48
49 void print_response(unsigned char *response,
50 size_t response_length);
51
53 The query_send() function sends a query to the name servers specified
54 in nslist. The query is comprised of the <name, class, type> tuple and
55 trans_id provides a handle to this transaction within the libsres
56 library. The buffer size advertised in the EDNS0 option can be set
57 using the ends0_size argument.
58
59 The response_recv() function returns the answers, if available, from
60 the name server that responds for the query identified by trans_id.
61 The response is available in response and the responding name server is
62 returned in respondent. The length of the response in bytes is
63 returned in response_length.
64
65 The get() function provides a wrapper around the query_send() and
66 response_recv() functions. After sending a request, it blocks until a
67 response is received from some name server or until the request times
68 out. The libsres library does not automatically follow referrals;
69 responses containing referrals are treated as valid responses.
70
71 The memory pointed to by *respondent is internally allocated by the
72 libsres library and must be freed by the invoker using
73 free_name_server(). An entire list of name servers can be freed using
74 free_name_servers(). A copy of the name server can be created using
75 clone_ns() and a copy of a name server list can be made using
76 clone_ns_list().
77
78 print_response() provides a convenient way to display answers returned
79 in response by the name server.
80
81 The name_server structure is defined in resolver.h as follows:
82
83 #define NS_MAXCDNAME 255
84 struct name_server
85 {
86 unsigned char ns_name_n[NS_MAXCDNAME];
87 void *ns_tsig;
88 unsigned int ns_security_options;
89 unsigned int ns_status;
90 unsigned long ns_options;
91 int ns_retry;
92 int ns_retrans;
93 struct name_server *ns_next;
94 int ns_number_of_addresses;
95 struct sockaddr_storage **ns_address;
96 };
97
98 ns_name_n
99 The name of the zone for which this name server is authoritative.
100
101 ns_tsig
102 The tsig key that should be used to protect messages sent to this
103 name server. This field is currently unused and must be set to
104 NULL.
105
106 ns_security_options
107 The security options for the zone. This field is currently unused
108 and must be set to ZONE_USE_NOTHING.
109
110 ns_status
111 The status of the zone. This field indicates how the zone informa‐
112 tion was obtained. The invoker must set this value to SR_ZI_STA‐
113 TUS_UNSET. Zone information obtained through referrals have a value
114 of SR_ZI_STATUS_LEARNED for this field.
115
116 ns_options
117 Specifies additional resolver flags. Currently defined flags are
118 RES_RECURSE, which sets the "Recursion Desired" flag;
119 RES_USE_DNSSEC, which sets the "DNSSEC OK" bit in the EDNS0 header;
120 and RES_DEBUG, which enables debugging.
121
122 ns_retry
123 Specifies the maximum number of attempts that must be made to
124 obtain a name from an unresponsive name server before giving up.
125
126 ns_retrans
127 Specifies the retransmission interval in seconds for queries sent
128 to unresponsive name servers.
129
130 ns_next
131 The address of the next name server in the list.
132
133 ns_number_of_addresses
134 The number of elements in the array ns_addresses. This field is
135 currently unused.
136
137 ns_addresses
138 The IP address of the name server.
139
141 The libsres library also exports the following BIND functions, documen‐
142 tation for which can be found in the BIND sources and documentation
143 manuals:
144
145 res_nametoclass
146 res_nametotype
147 ns_name_ntop
148 ns_name_pton
149 ns_name_unpack
150 ns_parse_ttl
151 p_class
152 p_section
153 p_type
154
155 The p_type() function exported from libsres has been augmented such
156 that it recognizes the various DNSSEC type codes such DNSKEY, RRSIG,
157 NSEC, NSEC3 and DLV.
158
160 SR_UNSET
161 No error.
162
163 SR_CALL_ERROR
164 An invalid parameter was passed to get(), query_send(), or
165 response_recv().
166
167 SR_INTERNAL_ERROR
168 The resolver encountered some internal error.
169
170 SR_TSIG_ERROR
171 The resolver encountered some TSIG-related error. This is cur‐
172 rently not implemented.
173
174 SR_NO_ANSWER
175 No answers were received from any name server.
176
177 SR_NO_ANSWER_YET
178 No answer currently available; the query is still active.
179
180 SR_HEADER_ERROR
181 The length and count of records in the header were incorrect.
182
183 SR_NXDOMAIN
184 The queried name did not exist.
185
186 SR_FORMERR
187 The name server was not able to parse the query message.
188
189 SR_SERVFAIL
190 The name server was not reachable.
191
192 SR_NOTIMPL
193 A particular functionality is not yet implemented.
194
195 SR_REFUSED
196 The name server refused to answer this query.
197
198 SR_DNS_GENERIC_FAILURE
199 Other failure returned by the name server and reflected in the
200 returned message RCODE.
201
202 SR_EDNS_VERSION_ERROR
203 The EDNS version was not recognized
204
205 SR_NAME_EXPANSION_FAILURE
206 A failure was encountered while trying to expand a compressed
207 domain name.
208
210 There is currently no support for IPv6.
211
212 There is limited support for specifying resolver policy; members of the
213 struct name_server are still subject to change.
214
216 Copyright 2004-2011 SPARTA, Inc. All rights reserved. See the COPYING
217 file included with the dnssec-tools package for details.
218
220 libval(3)
221
222 http://dnssec-tools.sourceforge.net
223
224
225
226perl v5.8.9 2011-06-28 libsres(3)