unbound.h revision 249141
1219888Sed/*
2257547Sray * unbound.h - unbound validating resolver public API
3219888Sed *
4219888Sed * Copyright (c) 2007, NLnet Labs. All rights reserved.
5219888Sed *
6219888Sed * This software is open source.
7219888Sed *
8257547Sray * Redistribution and use in source and binary forms, with or without
9257547Sray * modification, are permitted provided that the following conditions
10257547Sray * are met:
11219888Sed *
12219888Sed * Redistributions of source code must retain the above copyright notice,
13219888Sed * this list of conditions and the following disclaimer.
14219888Sed *
15219888Sed * Redistributions in binary form must reproduce the above copyright notice,
16219888Sed * this list of conditions and the following disclaimer in the documentation
17219888Sed * and/or other materials provided with the distribution.
18219888Sed *
19219888Sed * Neither the name of the NLNET LABS nor the names of its contributors may
20219888Sed * be used to endorse or promote products derived from this software without
21219888Sed * specific prior written permission.
22219888Sed *
23219888Sed * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24219888Sed * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25219888Sed * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26219888Sed * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
27219888Sed * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28219888Sed * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29219888Sed * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30219888Sed * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31219888Sed * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32219888Sed * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33219888Sed * POSSIBILITY OF SUCH DAMAGE.
34219888Sed */
35219888Sed
36219888Sed/**
37219888Sed * \file
38219888Sed *
39219888Sed * This file contains functions to resolve DNS queries and
40219888Sed * validate the answers. Synchonously and asynchronously.
41219888Sed *
42219888Sed * Several ways to use this interface from an application wishing
43263817Sray * to perform (validated) DNS lookups.
44219888Sed *
45219888Sed * All start with
46257974Sray *	ctx = ub_ctx_create();
47219888Sed *	err = ub_ctx_add_ta(ctx, "...");
48256145Sray *	err = ub_ctx_add_ta(ctx, "...");
49219888Sed *	... some lookups
50257966Sray *	... call ub_ctx_delete(ctx); when you want to stop.
51263817Sray *
52257966Sray * Application not threaded. Blocking.
53263817Sray *	int err = ub_resolve(ctx, "www.example.com", ...
54263817Sray *	if(err) fprintf(stderr, "lookup error: %s\n", ub_strerror(err));
55263817Sray *	... use the answer
56263817Sray *
57263817Sray * Application not threaded. Non-blocking ('asynchronous').
58257966Sray *      err = ub_resolve_async(ctx, "www.example.com", ... my_callback);
59257966Sray *	... application resumes processing ...
60257966Sray *	... and when either ub_poll(ctx) is true
61257966Sray *	... or when the file descriptor ub_fd(ctx) is readable,
62219888Sed *	... or whenever, the app calls ...
63257966Sray *	ub_process(ctx);
64257966Sray *	... if no result is ready, the app resumes processing above,
65257966Sray *	... or process() calls my_callback() with results.
66258165Sray *
67258165Sray *      ... if the application has nothing more to do, wait for answer
68258165Sray *      ub_wait(ctx);
69258165Sray *
70219888Sed * Application threaded. Blocking.
71219888Sed *	Blocking, same as above. The current thread does the work.
72257966Sray *	Multiple threads can use the *same context*, each does work and uses
73257966Sray *	shared cache data from the context.
74257966Sray *
75257966Sray * Application threaded. Non-blocking ('asynchronous').
76257966Sray *	... setup threaded-asynchronous config option
77257966Sray *	err = ub_ctx_async(ctx, 1);
78257966Sray *	... same as async for non-threaded
79257966Sray *	... the callbacks are called in the thread that calls process(ctx)
80256145Sray *
81256145Sray * If no threading is compiled in, the above async example uses fork(2) to
82256145Sray * create a process to perform the work. The forked process exits when the
83256145Sray * calling process exits, or ctx_delete() is called.
84256145Sray * Otherwise, for asynchronous with threading, a worker thread is created.
85256145Sray *
86256145Sray * The blocking calls use shared ctx-cache when threaded. Thus
87256145Sray * ub_resolve() and ub_resolve_async() && ub_wait() are
88256145Sray * not the same. The first makes the current thread do the work, setting
89256145Sray * up buffers, etc, to perform the work (but using shared cache data).
90219888Sed * The second calls another worker thread (or process) to perform the work.
91219888Sed * And no buffers need to be set up, but a context-switch happens.
92219888Sed */
93257815Sray#ifndef _UB_UNBOUND_H
94257815Sray#define _UB_UNBOUND_H
95219888Sed
96219888Sed#ifdef __cplusplus
97219888Sedextern "C" {
98219888Sed#endif
99219888Sed
100219888Sed/**
101219888Sed * The validation context is created to hold the resolver status,
102219888Sed * validation keys and a small cache (containing messages, rrsets,
103219888Sed * roundtrip times, trusted keys, lameness information).
104219888Sed *
105219888Sed * Its contents are internally defined.
106219888Sed */
107219888Sedstruct ub_ctx;
108219888Sed
109219888Sed/**
110219888Sed * The validation and resolution results.
111219888Sed * Allocated by the resolver, and need to be freed by the application
112219888Sed * with ub_resolve_free().
113219888Sed */
114219888Sedstruct ub_result {
115257815Sray	/** The original question, name text string. */
116258090Sray	char* qname;
117219888Sed	/** the type asked for */
118219888Sed	int qtype;
119257974Sray	/** the class asked for */
120257974Sray	int qclass;
121257974Sray
122257974Sray	/**
123257974Sray	 * a list of network order DNS rdata items, terminated with a
124257974Sray	 * NULL pointer, so that data[0] is the first result entry,
125219888Sed	 * data[1] the second, and the last entry is NULL.
126219888Sed	 * If there was no data, data[0] is NULL.
127219888Sed	 */
128219888Sed	char** data;
129219888Sed
130219888Sed	/** the length in bytes of the data items, len[i] for data[i] */
131219888Sed	int* len;
132219888Sed
133219888Sed	/**
134219888Sed	 * canonical name for the result (the final cname).
135219888Sed	 * zero terminated string.
136256145Sray	 * May be NULL if no canonical name exists.
137257974Sray	 */
138263817Sray	char* canonname;
139219888Sed
140258165Sray	/**
141219888Sed	 * DNS RCODE for the result. May contain additional error code if
142219888Sed	 * there was no data due to an error. 0 (NOERROR) if okay.
143219888Sed	 */
144219888Sed	int rcode;
145219888Sed
146219888Sed	/**
147219888Sed	 * The DNS answer packet. Network formatted. Can contain DNSSEC types.
148219888Sed	 */
149219888Sed	void* answer_packet;
150219888Sed	/** length of the answer packet in octets. */
151219888Sed	int answer_len;
152219888Sed
153219888Sed	/**
154219888Sed	 * If there is any data, this is true.
155219888Sed	 * If false, there was no data (nxdomain may be true, rcode can be set).
156219888Sed	 */
157219888Sed	int havedata;
158219888Sed
159219888Sed	/**
160219888Sed	 * If there was no data, and the domain did not exist, this is true.
161219888Sed	 * If it is false, and there was no data, then the domain name
162256145Sray	 * is purported to exist, but the requested data type is not available.
163219888Sed	 */
164219888Sed	int nxdomain;
165219888Sed
166256145Sray	/**
167256145Sray	 * True, if the result is validated securely.
168256964Sray	 * False, if validation failed or domain queried has no security info.
169256145Sray	 *
170257723Sray	 * It is possible to get a result with no data (havedata is false),
171256145Sray	 * and secure is true. This means that the non-existance of the data
172256145Sray	 * was cryptographically proven (with signatures).
173219888Sed	 */
174257972Sray	int secure;
175257972Sray
176258130Sray	/**
177219888Sed	 * If the result was not secure (secure==0), and this result is due
178219888Sed	 * to a security failure, bogus is true.
179219888Sed	 * This means the data has been actively tampered with, signatures
180256145Sray	 * failed, expected signatures were not present, timestamps on
181219888Sed	 * signatures were out of date and so on.
182219888Sed	 *
183219888Sed	 * If !secure and !bogus, this can happen if the data is not secure
184256145Sray	 * because security is disabled for that domain name.
185219888Sed	 * This means the data is from a domain where data is not signed.
186219888Sed	 */
187256145Sray	int bogus;
188219888Sed
189219888Sed	/**
190258090Sray	 * If the result is bogus this contains a string (zero terminated)
191219888Sed	 * that describes the failure.  There may be other errors as well
192256145Sray	 * as the one described, the description may not be perfectly accurate.
193263817Sray	 * Is NULL if the result is not bogus.
194263817Sray	 */
195263817Sray	char* why_bogus;
196263817Sray
197258090Sray	/**
198258090Sray	 * TTL for the result, in seconds.  If the security is bogus, then
199258090Sray	 * you also cannot trust this value.
200263817Sray	 */
201256145Sray	int ttl;
202258090Sray};
203257973Sray
204257973Sray/**
205257973Sray * Callback for results of async queries.
206257973Sray * The readable function definition looks like:
207257973Sray * void my_callback(void* my_arg, int err, struct ub_result* result);
208258130Sray * It is called with
209257973Sray *	void* my_arg: your pointer to a (struct of) data of your choice,
210258090Sray *		or NULL.
211258090Sray *	int err: if 0 all is OK, otherwise an error occured and no results
212256145Sray *	     are forthcoming.
213256145Sray *	struct result: pointer to more detailed result structure.
214256145Sray *		This structure is allocated on the heap and needs to be
215256145Sray *		freed with ub_resolve_free(result);
216256145Sray */
217256145Sraytypedef void (*ub_callback_t)(void*, int, struct ub_result*);
218256145Sray
219219888Sed/**
220256145Sray * Create a resolving and validation context.
221219888Sed * The information from /etc/resolv.conf and /etc/hosts is not utilised by
222257975Sray * default. Use ub_ctx_resolvconf and ub_ctx_hosts to read them.
223219888Sed * @return a new context. default initialisation.
224219888Sed * 	returns NULL on error.
225219888Sed */
226219888Sedstruct ub_ctx* ub_ctx_create(void);
227256145Sray
228219888Sed/**
229219888Sed * Destroy a validation context and free all its resources.
230219888Sed * Outstanding async queries are killed and callbacks are not called for them.
231219888Sed * @param ctx: context to delete.
232256145Sray */
233256145Srayvoid ub_ctx_delete(struct ub_ctx* ctx);
234256145Sray
235219888Sed/**
236219888Sed * Set an option for the context.
237219888Sed * @param ctx: context.
238219888Sed * @param opt: option name from the unbound.conf config file format.
239219888Sed *	(not all settings applicable). The name includes the trailing ':'
240219888Sed *	for example ub_ctx_set_option(ctx, "logfile:", "mylog.txt");
241219888Sed * 	This is a power-users interface that lets you specify all sorts
242219888Sed * 	of options.
243219888Sed * 	For some specific options, such as adding trust anchors, special
244219888Sed * 	routines exist.
245219888Sed * @param val: value of the option.
246219888Sed * @return: 0 if OK, else error.
247257076Sray */
248219888Sedint ub_ctx_set_option(struct ub_ctx* ctx, char* opt, char* val);
249263817Sray
250219888Sed/**
251219888Sed * Get an option from the context.
252219888Sed * @param ctx: context.
253219888Sed * @param opt: option name from the unbound.conf config file format.
254256145Sray *	(not all settings applicable). The name excludes the trailing ':'
255258327Sray *	for example ub_ctx_get_option(ctx, "logfile", &result);
256256145Sray * 	This is a power-users interface that lets you specify all sorts
257256145Sray * 	of options.
258256145Sray * @param str: the string is malloced and returned here. NULL on error.
259256145Sray * 	The caller must free() the string.  In cases with multiple
260256145Sray * 	entries (auto-trust-anchor-file), a newline delimited list is
261256145Sray * 	returned in the string.
262256145Sray * @return 0 if OK else an error code (malloc failure, syntax error).
263219888Sed */
264219888Sedint ub_ctx_get_option(struct ub_ctx* ctx, char* opt, char** str);
265256145Sray
266256145Sray/**
267256145Sray * setup configuration for the given context.
268256145Sray * @param ctx: context.
269256145Sray * @param fname: unbound config file (not all settings applicable).
270256145Sray * 	This is a power-users interface that lets you specify all sorts
271219888Sed * 	of options.
272219888Sed * 	For some specific options, such as adding trust anchors, special
273219888Sed * 	routines exist.
274256527Sray * @return: 0 if OK, else error.
275219888Sed */
276219888Sedint ub_ctx_config(struct ub_ctx* ctx, char* fname);
277219888Sed
278219888Sed/**
279219888Sed * Set machine to forward DNS queries to, the caching resolver to use.
280256145Sray * IP4 or IP6 address. Forwards all DNS requests to that machine, which
281219888Sed * is expected to run a recursive resolver. If the proxy is not
282256527Sray * DNSSEC-capable, validation may fail. Can be called several times, in
283257988Sray * that case the addresses are used as backup servers.
284257988Sray *
285264113Sray * To read the list of nameservers from /etc/resolv.conf (from DHCP or so),
286264113Sray * use the call ub_ctx_resolvconf.
287264113Sray *
288219888Sed * @param ctx: context.
289219888Sed *	At this time it is only possible to set configuration before the
290263817Sray *	first resolve is done.
291263817Sray * @param addr: address, IP4 or IP6 in string format.
292263817Sray * 	If the addr is NULL, forwarding is disabled.
293263817Sray * @return 0 if OK, else error.
294263817Sray */
295263817Srayint ub_ctx_set_fwd(struct ub_ctx* ctx, char* addr);
296219888Sed
297219888Sed/**
298219888Sed * Read list of nameservers to use from the filename given.
299256145Sray * Usually "/etc/resolv.conf". Uses those nameservers as caching proxies.
300219888Sed * If they do not support DNSSEC, validation may fail.
301219888Sed *
302256145Sray * Only nameservers are picked up, the searchdomain, ndots and other
303256527Sray * settings from resolv.conf(5) are ignored.
304264113Sray *
305263817Sray * @param ctx: context.
306263817Sray *	At this time it is only possible to set configuration before the
307219888Sed *	first resolve is done.
308263817Sray * @param fname: file name string. If NULL "/etc/resolv.conf" is used.
309263817Sray * @return 0 if OK, else error.
310263817Sray */
311263817Srayint ub_ctx_resolvconf(struct ub_ctx* ctx, char* fname);
312263817Sray
313263817Sray/**
314219888Sed * Read list of hosts from the filename given.
315256145Sray * Usually "/etc/hosts".
316256145Sray * These addresses are not flagged as DNSSEC secure when queried for.
317256145Sray *
318256145Sray * @param ctx: context.
319256145Sray *	At this time it is only possible to set configuration before the
320256145Sray *	first resolve is done.
321256145Sray * @param fname: file name string. If NULL "/etc/hosts" is used.
322256902Sray * @return 0 if OK, else error.
323256902Sray */
324256902Srayint ub_ctx_hosts(struct ub_ctx* ctx, char* fname);
325219888Sed
326219888Sed/**
327219888Sed * Add a trust anchor to the given context.
328219888Sed * The trust anchor is a string, on one line, that holds a valid DNSKEY or
329219888Sed * DS RR.
330219888Sed * @param ctx: context.
331219888Sed *	At this time it is only possible to add trusted keys before the
332219888Sed *	first resolve is done.
333219888Sed * @param ta: string, with zone-format RR on one line.
334219888Sed * 	[domainname] [TTL optional] [type] [class optional] [rdata contents]
335219888Sed * @return 0 if OK, else error.
336219888Sed */
337219888Sedint ub_ctx_add_ta(struct ub_ctx* ctx, char* ta);
338219888Sed
339257724Sray/**
340257724Sray * Add trust anchors to the given context.
341257724Sray * Pass name of a file with DS and DNSKEY records (like from dig or drill).
342257724Sray * @param ctx: context.
343257724Sray *	At this time it is only possible to add trusted keys before the
344257724Sray *	first resolve is done.
345257724Sray * @param fname: filename of file with keyfile with trust anchors.
346219888Sed * @return 0 if OK, else error.
347219888Sed */
348219888Sedint ub_ctx_add_ta_file(struct ub_ctx* ctx, char* fname);
349219888Sed
350219888Sed/**
351219888Sed * Add trust anchors to the given context.
352219888Sed * Pass the name of a bind-style config file with trusted-keys{}.
353219888Sed * @param ctx: context.
354219888Sed *	At this time it is only possible to add trusted keys before the
355258090Sray *	first resolve is done.
356258165Sray * @param fname: filename of file with bind-style config entries with trust
357219888Sed * 	anchors.
358256145Sray * @return 0 if OK, else error.
359256145Sray */
360256145Srayint ub_ctx_trustedkeys(struct ub_ctx* ctx, char* fname);
361256145Sray
362219888Sed/**
363219888Sed * Set debug output (and error output) to the specified stream.
364219888Sed * Pass NULL to disable. Default is stderr.
365219888Sed * @param ctx: context.
366219888Sed * @param out: FILE* out file stream to log to.
367256145Sray * 	Type void* to avoid stdio dependency of this header file.
368256145Sray * @return 0 if OK, else error.
369256145Sray */
370256145Srayint ub_ctx_debugout(struct ub_ctx* ctx, void* out);
371219888Sed
372257972Sray/**
373257972Sray * Set debug verbosity for the context
374257972Sray * Output is directed to stderr.
375257972Sray * @param ctx: context.
376257972Sray * @param d: debug level, 0 is off, 1 is very minimal, 2 is detailed,
377257972Sray *	and 3 is lots.
378257972Sray * @return 0 if OK, else error.
379257972Sray */
380256145Srayint ub_ctx_debuglevel(struct ub_ctx* ctx, int d);
381219888Sed
382219888Sed/**
383219888Sed * Set a context behaviour for asynchronous action.
384219888Sed * @param ctx: context.
385219888Sed * @param dothread: if true, enables threading and a call to resolve_async()
386219888Sed *	creates a thread to handle work in the background.
387219888Sed *	If false, a process is forked to handle work in the background.
388219888Sed *	Changes to this setting after async() calls have been made have
389219888Sed *	no effect (delete and re-create the context to change).
390219888Sed * @return 0 if OK, else error.
391219888Sed */
392219888Sedint ub_ctx_async(struct ub_ctx* ctx, int dothread);
393219888Sed
394219888Sed/**
395219888Sed * Poll a context to see if it has any new results
396219888Sed * Do not poll in a loop, instead extract the fd below to poll for readiness,
397219888Sed * and then check, or wait using the wait routine.
398219888Sed * @param ctx: context.
399219888Sed * @return: 0 if nothing to read, or nonzero if a result is available.
400219888Sed * 	If nonzero, call ctx_process() to do callbacks.
401219888Sed */
402219888Sedint ub_poll(struct ub_ctx* ctx);
403219888Sed
404219888Sed/**
405219888Sed * Wait for a context to finish with results. Calls ub_process() after
406219888Sed * the wait for you. After the wait, there are no more outstanding
407219888Sed * asynchronous queries.
408219888Sed * @param ctx: context.
409219888Sed * @return: 0 if OK, else error.
410219888Sed */
411263817Srayint ub_wait(struct ub_ctx* ctx);
412219888Sed
413263817Sray/**
414263817Sray * Get file descriptor. Wait for it to become readable, at this point
415219888Sed * answers are returned from the asynchronous validating resolver.
416219888Sed * Then call the ub_process to continue processing.
417219888Sed * This routine works immediately after context creation, the fd
418263817Sray * does not change.
419257967Sray * @param ctx: context.
420257967Sray * @return: -1 on error, or file descriptor to use select(2) with.
421257967Sray */
422257967Srayint ub_fd(struct ub_ctx* ctx);
423257967Sray
424257967Sray/**
425263817Sray * Call this routine to continue processing results from the validating
426257967Sray * resolver (when the fd becomes readable).
427219888Sed * Will perform necessary callbacks.
428219888Sed * @param ctx: context
429219888Sed * @return: 0 if OK, else error.
430219888Sed */
431219888Sedint ub_process(struct ub_ctx* ctx);
432219888Sed
433219888Sed/**
434263817Sray * Perform resolution and validation of the target name.
435263817Sray * @param ctx: context.
436258327Sray *	The context is finalized, and can no longer accept config changes.
437263817Sray * @param name: domain name in text format (a zero terminated text string).
438258327Sray * @param rrtype: type of RR in host order, 1 is A (address).
439258327Sray * @param rrclass: class of RR in host order, 1 is IN (for internet).
440219888Sed * @param result: the result data is returned in a newly allocated result
441219888Sed * 	structure. May be NULL on return, return value is set to an error
442258327Sray * 	in that case (out of memory).
443 * @return 0 if OK, else error.
444 */
445int ub_resolve(struct ub_ctx* ctx, char* name, int rrtype,
446	int rrclass, struct ub_result** result);
447
448/**
449 * Perform resolution and validation of the target name.
450 * Asynchronous, after a while, the callback will be called with your
451 * data and the result.
452 * @param ctx: context.
453 *	If no thread or process has been created yet to perform the
454 *	work in the background, it is created now.
455 *	The context is finalized, and can no longer accept config changes.
456 * @param name: domain name in text format (a string).
457 * @param rrtype: type of RR in host order, 1 is A.
458 * @param rrclass: class of RR in host order, 1 is IN (for internet).
459 * @param mydata: this data is your own data (you can pass NULL),
460 * 	and is passed on to the callback function.
461 * @param callback: this is called on completion of the resolution.
462 * 	It is called as:
463 * 	void callback(void* mydata, int err, struct ub_result* result)
464 * 	with mydata: the same as passed here, you may pass NULL,
465 * 	with err: is 0 when a result has been found.
466 * 	with result: a newly allocated result structure.
467 *		The result may be NULL, in that case err is set.
468 *
469 * 	If an error happens during processing, your callback will be called
470 * 	with error set to a nonzero value (and result==NULL).
471 * @param async_id: if you pass a non-NULL value, an identifier number is
472 *	returned for the query as it is in progress. It can be used to
473 *	cancel the query.
474 * @return 0 if OK, else error.
475 */
476int ub_resolve_async(struct ub_ctx* ctx, char* name, int rrtype,
477	int rrclass, void* mydata, ub_callback_t callback, int* async_id);
478
479/**
480 * Cancel an async query in progress.
481 * Its callback will not be called.
482 *
483 * @param ctx: context.
484 * @param async_id: which query to cancel.
485 * @return 0 if OK, else error.
486 * This routine can return an error if the async_id passed does not exist
487 * or has already been delivered. If another thread is processing results
488 * at the same time, the result may be delivered at the same time and the
489 * cancel fails with an error.  Also the cancel can fail due to a system
490 * error, no memory or socket failures.
491 */
492int ub_cancel(struct ub_ctx* ctx, int async_id);
493
494/**
495 * Free storage associated with a result structure.
496 * @param result: to free
497 */
498void ub_resolve_free(struct ub_result* result);
499
500/**
501 * Convert error value to a human readable string.
502 * @param err: error code from one of the ub_val* functions.
503 * @return pointer to constant text string, zero terminated.
504 */
505const char* ub_strerror(int err);
506
507/**
508 * Debug routine.  Print the local zone information to debug output.
509 * @param ctx: context.  Is finalized by the routine.
510 * @return 0 if OK, else error.
511 */
512int ub_ctx_print_local_zones(struct ub_ctx* ctx);
513
514/**
515 * Add a new zone with the zonetype to the local authority info of the
516 * library.
517 * @param ctx: context.  Is finalized by the routine.
518 * @param zone_name: name of the zone in text, "example.com"
519 *	If it already exists, the type is updated.
520 * @param zone_type: type of the zone (like for unbound.conf) in text.
521 * @return 0 if OK, else error.
522 */
523int ub_ctx_zone_add(struct ub_ctx* ctx, char *zone_name, char *zone_type);
524
525/**
526 * Remove zone from local authority info of the library.
527 * @param ctx: context.  Is finalized by the routine.
528 * @param zone_name: name of the zone in text, "example.com"
529 *	If it does not exist, nothing happens.
530 * @return 0 if OK, else error.
531 */
532int ub_ctx_zone_remove(struct ub_ctx* ctx, char *zone_name);
533
534/**
535 * Add localdata to the library local authority info.
536 * Similar to local-data config statement.
537 * @param ctx: context.  Is finalized by the routine.
538 * @param data: the resource record in text format, for example
539 *	"www.example.com IN A 127.0.0.1"
540 * @return 0 if OK, else error.
541 */
542int ub_ctx_data_add(struct ub_ctx* ctx, char *data);
543
544/**
545 * Remove localdata from the library local authority info.
546 * @param ctx: context.  Is finalized by the routine.
547 * @param data: the name to delete all data from, like "www.example.com".
548 * @return 0 if OK, else error.
549 */
550int ub_ctx_data_remove(struct ub_ctx* ctx, char *data);
551
552/**
553 * Get a version string from the libunbound implementation.
554 * @return a static constant string with the version number.
555 */
556const char* ub_version(void);
557
558#ifdef __cplusplus
559}
560#endif
561
562#endif /* _UB_UNBOUND_H */
563