Codebase list getdns / ec09d6b
Make just the src/getdns files part of doxygen by default. Add documentation to cover getdns_extra.h. Re-org of functions to align better with getdns.h Also some work on the README. Sara Dickinson 7 years ago
15 changed file(s) with 915 addition(s) and 802 deletion(s). Raw diff Collapse all Expand all
0 getdns API
1 ==========
2
3 * Date: 2016-03-24
0 getdns
1 ======
2
3 # Overview of getdns
4
45 * GitHub: <https://github.com/getdnsapi/getdns>
56
67 getdns is an implementation of a modern asynchronous DNS API specification
78 originally edited by Paul Hoffman. It is intended to make all types of DNS
89 information easily available to application developers and non-DNS experts.
910 The project home page at [getdnsapi.net](https://getdnsapi.net) provides
10 documentation, binary downloads and new regarding the getdns API
11 documentation, binary downloads and news regarding the getdns API
1112 implementation. This implementation is licensed under the New BSD License
1213 (BSD-new).
14
15 This file captures the goals and direction of the project and the current state
16 of the implementation.
17
18 If you are just getting started with the library take a look at the section
19 below that describes building and handling external dependencies for the
20 library. Once it is built you should take a look at src/examples to see how
21 the library is used.
22
23 ## Download
1324
1425 Download the sources from our [github repo](https://github.com/getdnsapi/getdns)
1526 or from [getdnsapi.net](https://getdnsapi.net) and verify the download using
1930 * willem@nlnetlabs.nl, key id E5F8F8212F77A498
2031 * gwiley@verisign.com, key id 9DC3D572A6B73532
2132
22 We have a [users list](https://getdnsapi.net/mailman/listinfo/spec) for this implementation.
33 ## Mailing lists
34
35 We have a [getdns users list](https://getdnsapi.net/mailman/listinfo/spec) for this implementation.
2336
2437 The [getdns-api mailing list](https://getdnsapi.net/mailman/listinfo/spec)
2538 is a good place to engage in discussions regarding the design of the API.
2639
27 If you are just getting started with the library take a look at the section
28 below that describes building and handling external dependencies for the
29 library. Once it is built you should take a look at src/examples to see how
30 the library is used.
31
32 This file captures the goals and direction of the project and the current state
33 of the implementation.
40 ## Motivation for providing the API
41
42 The developers are of the opinion that DNSSEC offers a unique global
43 infrastructure for establishing and enhancing cryptographic trust relations.
44 With the development of this API we intend to offer application developers a
45 modern and flexible way that enables end-to-end trust in the DNS architecture
46 and will inspire application developers towards innovative security solutions
47 in their applications.
48
49 ## Goals
3450
3551 The goals of this implementation of the getdns API are:
3652
4662 Non-goals (things we will not be doing at least initially) include:
4763 * implementation of the traditional DNS related routines (gethostbyname, etc.)
4864
65 ## Official and Additional API
66
67 Note that this implementation offers additional functionality to supplement that
68 in the official getdns API. Some additions are convenient utility functions but other functionality
69 is experimental prior to be being recommended for inclusion in the official API.
70 The 'Modules' page in the doxygen documentation provides a guide to both the
71 official API and the additional functionality.
72
4973 ## Language Bindings
5074
5175 In parallel, the team is actively developing bindings for various languages.
5276 For more information, visit the
5377 [wiki](https://github.com/getdnsapi/getdns/wiki/Language-Bindings).
54
55 Motivation for providing the API
56 ================================
57
58 The developers are of the opinion that DNSSEC offers a unique global
59 infrastructure for establishing and enhancing cryptographic trust relations.
60 With the development of this API we intend to offer application developers a
61 modern and flexible way that enables end-to-end trust in the DNS architecture
62 and will inspire application developers towards innovative security solutions
63 in their applications.
6478
6579
6680 Releases
100114
101115 # libtoolize -ci (use glibtoolize for OS X, libtool is installed as glibtool to avoid name conflict on OS X)
102116 # autoreconf -fi
117
118 If you want to make use of the configuration files that utilise a JSON-like format, you must do
119
120 # git submodule update --init
121
122 before building.
123
124 If you want to use the getdns_query command line wrapper script for testing or to enable getdns as a daemon then you must build it using
125
126 # make getdns_query
103127
104128 ## Minimal dependencies
105129
142166 # mkdir -p /etc/unbound
143167 # unbound-anchor -a /etc/unbound/getdns-root.key
144168
145 #Unsupported Features
169 # Unsupported Features
146170
147171 The following API calls are documented in getDNS but *not supported* by the implementation at this time:
148172
150174 * Detecting changes to resolv.conf and hosts
151175 * MDNS, NIS and NetBIOS namespaces (only DNS and LOCALFILES are supported)
152176
153 #Known Issues
177 # Known Issues
154178
155179 There are a few known issues which we have summarized below - the most recent
156180 and helpful list is being maintained in the git issues list in the repository.
159183 * When doing a synchronous lookup with a context that has outstanding asynchronous lookups, the callbacks for the asynchronous lookups might get called as a side effect of the synchronous lookup.
160184
161185
162 #Supported Platforms
186 # Supported Platforms
163187
164188 The primary platforms targeted are Linux and FreeBSD, other platform are supported as we get time. The names listed here are intended to help ensure that we catch platform specific breakage, not to limit the work that folks are doing.
165189
171195 We intend to add Android and other platforms to the releases as we have time to port it.
172196
173197
174 ##Platform Specific Build Reports
198 ## Platform Specific Build Reports
175199
176200 [![Build Status](https://travis-ci.org/getdnsapi/getdns.png?branch=master)](https://travis-ci.org/getdnsapi/getdns)
177201
178 ###FreeBSD
202 ### FreeBSD
179203
180204 If you're using [FreeBSD](https://www.freebsd.org/), you may install getdns via the [ports tree](https://www.freshports.org/dns/getdns/) by running: `cd /usr/ports/dns/getdns && make install clean`
181205
182206 If you are using FreeBSD 10 getdns can be intalled via 'pkg install getdns'.
183207
184 ###CentOS/RHEL 6.5
208 ### CentOS/RHEL 6.5
185209
186210 We rely on the most excellent package manager fpm to build the linux packages which
187211 means that the packaging platform requires ruby 2.1.0. There are other ways to
199223 # . /usr/local/rvm/config/alias
200224 # fpm -x "*.la" -a native -s dir -t rpm -n getdns -v 0.2.0rc1 -d "unbound" -d "libevent" -d "libidn" --prefix /usr --vendor "Verisign Inc., NLnet Labs" --license "BSD New" --url "https://getdnsapi.net" --description "Modern asynchronous API to the DNS" .
201225
202 ###OSX
226 ### OSX
203227
204228 # sw_vers
205229 ProductName: Mac OS X
275299 ./getdns_query.exe -s gmadkat.com A @64.6.64.6 -T +return_call_reporting (TCP)
276300 ./getdns_query.exe -s gmadkat.com A -l L @185.49.141.37 +return_call_reporting (TLS without authentication)
277301 ./getdns_query.exe -s www.huque.com A +dnssec_return_status +return_call_reporting (DNSSEC)
278
279302
280303 Contributors
281304 ============
312335 * Glen Wiley, Verisign, Inc.
313336 * Paul Wouters
314337
338
315339 Acknowledgements
316340 ================
317341 The development team explicitly acknowledges Paul Hoffman for his initiative and efforts to develop a consensus based DNS API. We would like to thank the participants of the [mailing list](https://getdnsapi.net/mailman/listinfo/spec) for their contributions.
4949 # identify the project. Note that if you do not use Doxywizard you need
5050 # to put quotes around the project name if it contains spaces.
5151
52 PROJECT_NAME = "getdns API"
52 PROJECT_NAME = "getdns"
5353
5454 # The PROJECT_NUMBER tag can be used to enter a project or revision number.
5555 # This could be handy for archiving the generated documentation or
6161 # for a project that appears at the top of each page and should give viewer
6262 # a quick idea about the purpose of the project. Keep the description short.
6363
64 PROJECT_BRIEF = "A modern asynchronous API for fetching DNS data"
64 PROJECT_BRIEF = "An implementation of the getdns API - a modern asynchronous API for fetching DNS data"
6565
6666 # With the PROJECT_LOGO tag one can specify an logo or icon that is
6767 # included in the documentation. The maximum height of the logo should not
691691 # directories like "/usr/src/myproject". Separate the files or directories
692692 # with spaces.
693693
694 INPUT = @srcdir@ \
695 getdns/ \
696 @srcdir@/getdns/ \
697 @srcdir@/example/ \
698 @srcdir@/test/ \
694 INPUT = @srcdir@/getdns/ \
695 getdns/getdns.h \
696 getdns/getdns_extra.h \
699697 @srcdir@/../README.md
698 # @srcdir@/../spec/example/ \
699 # getdns/ \
700 # @srcdir@ \
701 # @srcdir@/test/ \
702
700703
701704 # This tag can be used to specify the character encoding of the source files
702705 # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
819822 # This can be useful if you have a project on for instance GitHub and want reuse
820823 # the introduction page also for the doxygen output.
821824
822 USE_MDFILE_AS_MAINPAGE = ../README.md
825 USE_MDFILE_AS_MAINPAGE = @srcdir@/../README.md
823826
824827 #---------------------------------------------------------------------------
825828 # configuration options related to source browsing
664664 getdns_general(getdns_context *context,
665665 const char *name, uint16_t request_type, getdns_dict *extensions,
666666 void *userarg, getdns_transaction_t * transaction_id,
667 getdns_callback_t callback)
667 getdns_callback_t callbackfn)
668668 {
669669 getdns_return_t r;
670670 getdns_network_req *netreq = NULL;
672672 if (!context) return GETDNS_RETURN_INVALID_PARAMETER;
673673 r = _getdns_general_loop(context, context->extension,
674674 name, request_type, extensions,
675 userarg, &netreq, callback, NULL);
675 userarg, &netreq, callbackfn, NULL);
676676 if (netreq && transaction_id)
677677 *transaction_id = netreq->owner->trans_id;
678678 return r;
685685 getdns_return_t
686686 getdns_address(getdns_context *context,
687687 const char *name, getdns_dict *extensions, void *userarg,
688 getdns_transaction_t *transaction_id, getdns_callback_t callback)
688 getdns_transaction_t *transaction_id, getdns_callback_t callbackfn)
689689 {
690690 if (!context) return GETDNS_RETURN_INVALID_PARAMETER;
691691 return _getdns_address_loop(context, context->extension,
692692 name, extensions, userarg,
693 transaction_id, callback);
693 transaction_id, callbackfn);
694694 } /* getdns_address */
695695
696696 /*
700700 getdns_return_t
701701 getdns_hostname(getdns_context *context,
702702 getdns_dict *address, getdns_dict *extensions, void *userarg,
703 getdns_transaction_t *transaction_id, getdns_callback_t callback)
703 getdns_transaction_t *transaction_id, getdns_callback_t callbackfn)
704704 {
705705 if (!context) return GETDNS_RETURN_INVALID_PARAMETER;
706706 return _getdns_hostname_loop(context, context->extension,
707 address, extensions, userarg, transaction_id, callback);
707 address, extensions, userarg, transaction_id, callbackfn);
708708 } /* getdns_hostname */
709709
710710 /*
714714 getdns_return_t
715715 getdns_service(getdns_context *context,
716716 const char *name, getdns_dict *extensions, void *userarg,
717 getdns_transaction_t *transaction_id, getdns_callback_t callback)
717 getdns_transaction_t *transaction_id, getdns_callback_t callbackfn)
718718 {
719719 if (!context) return GETDNS_RETURN_INVALID_PARAMETER;
720720 return _getdns_service_loop(context, context->extension,
721 name, extensions, userarg, transaction_id, callback);
721 name, extensions, userarg, transaction_id, callbackfn);
722722 } /* getdns_service */
723723
724724 /* getdns_general.c */
4646
4747 #define GETDNS_COMPILATION_COMMENT "@GETDNS_COMPILATION_COMMENT@"
4848
49 /**
50 * \defgroup returntypes Return values
49 /** \defgroup getdnsAPI Official getdns API
50 * @{
51 */
52
53
54 /** \defgroup valuesandtexts Values and texts
55 * @{
56 */
57
58 /**
59 * \defgroup returntypestext Return values and texts
5160 * @{
5261 */
5362 typedef enum getdns_return_t {
6776 GETDNS_RETURN_INVALID_PARAMETER = 311,
6877 GETDNS_RETURN_NOT_IMPLEMENTED = 312
6978 } getdns_return_t;
70 /** @}
71 */
72
73 /**
74 * \defgroup returntypestext Return values texts
75 * @{
76 */
79
80
7781 #define GETDNS_RETURN_GOOD_TEXT "Good"
7882 #define GETDNS_RETURN_GENERIC_ERROR_TEXT "Generic error"
7983 #define GETDNS_RETURN_BAD_DOMAIN_NAME_TEXT "Badly-formed domain name in first argument"
112116
113117
114118 /**
115 * \defgroup namespacetypes Namespace types
119 * \defgroup namespacetypestext Namespace types and texts
116120 * @{
117121 */
118122 typedef enum getdns_namespace_t {
122126 GETDNS_NAMESPACE_MDNS = 503,
123127 GETDNS_NAMESPACE_NIS = 504
124128 } getdns_namespace_t;
125 /** @}
126 */
127
128 /**
129 * \defgroup namespacetypestext Namespace types texts
130 * @{
131 */
129
130
132131 #define GETDNS_NAMESPACE_DNS_TEXT "See getdns_context_set_namespaces()"
133132 #define GETDNS_NAMESPACE_LOCALNAMES_TEXT "See getdns_context_set_namespaces()"
134133 #define GETDNS_NAMESPACE_NETBIOS_TEXT "See getdns_context_set_namespaces()"
139138
140139
141140 /**
142 * \defgroup resolutiontypes Resolution types
141 * \defgroup resolutiontypestext Resolution types and texts
143142 * @{
144143 */
145144 typedef enum getdns_resolution_t {
146145 GETDNS_RESOLUTION_STUB = 520,
147146 GETDNS_RESOLUTION_RECURSING = 521
148147 } getdns_resolution_t;
149 /** @}
150 */
151
152 /**
153 * \defgroup resolutiontypestext Resolution types texts
154 * @{
155 */
148
149
156150 #define GETDNS_RESOLUTION_STUB_TEXT "See getdns_context_set_resolution_type()"
157151 #define GETDNS_RESOLUTION_RECURSING_TEXT "See getdns_context_set_resolution_type()"
158152 /** @}
160154
161155
162156 /**
163 * \defgroup redirectpolicytype Redirect policies
157 * \defgroup redirectpoliciestext Redirect policies and texts
164158 * @{
165159 */
166160 typedef enum getdns_redirects_t {
167161 GETDNS_REDIRECTS_FOLLOW = 530,
168162 GETDNS_REDIRECTS_DO_NOT_FOLLOW = 531
169163 } getdns_redirects_t;
170 /** @}
171 */
172
173 /**
174 * \defgroup redirectpoliciestext Redirect policies texts
175 * @{
176 */
164
165
177166 #define GETDNS_REDIRECTS_FOLLOW_TEXT "See getdns_context_set_follow_redirects()"
178167 #define GETDNS_REDIRECTS_DO_NOT_FOLLOW_TEXT "See getdns_context_set_follow_redirects()"
179168 /** @}
181170
182171
183172 /**
184 * \defgroup transporttypes Transport arrangements
173 * \defgroup transporttypestext Transport arrangements and texts
185174 * @{
186175 */
187176 typedef enum getdns_transport_t {
190179 GETDNS_TRANSPORT_TCP_ONLY = 542,
191180 GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN = 543
192181 } getdns_transport_t;
193 /** @}
194 */
195
196 /**
197 * \defgroup transporttypestext Transport arrangements texts
198 * @{
199 */
182
200183 #define GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP_TEXT "See getdns_context_set_dns_transport()"
201184 #define GETDNS_TRANSPORT_UDP_ONLY_TEXT "See getdns_context_set_dns_transport()"
202185 #define GETDNS_TRANSPORT_TCP_ONLY_TEXT "See getdns_context_set_dns_transport()"
206189
207190
208191 /**
209 * \defgroup transportlisttypes Transport list values
192 * \defgroup transportlisttypestext Transport list values and tests
210193 * @{
211194 */
212195 /* Base transports for use in transport list */
215198 GETDNS_TRANSPORT_TCP = 1201,
216199 GETDNS_TRANSPORT_TLS = 1202,
217200 } getdns_transport_list_t;
218 /** @}
219 */
220
221 /**
222 * \defgroup transportlisttypestext Transport list values texts
223 * @{
224 */
201
202
225203 #define GETDNS_TRANSPORT_UDP_TEXT "See getdns_context_set_dns_transport_list()"
226204 #define GETDNS_TRANSPORT_TCP_TEXT "See getdns_context_set_dns_transport_list()"
227205 #define GETDNS_TRANSPORT_TLS_TEXT "See getdns_context_set_dns_transport_list()"
230208
231209
232210 /**
233 * \defgroup suffixappendtypes Suffix appending values
211 * \defgroup suffixappendtypestext Suffix appending values and texts
234212 * @{
235213 */
236214 typedef enum getdns_append_name_t {
239217 GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE = 552,
240218 GETDNS_APPEND_NAME_NEVER = 553
241219 } getdns_append_name_t;
242 /** @}
243 */
244
245 /**
246 * \defgroup suffixappendtypestext Suffix appending values texts
247 * @{
248 */
220
221
249222 #define GETDNS_APPEND_NAME_ALWAYS_TEXT "See getdns_context_set_append_name()"
250223 #define GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE_TEXT "See getdns_context_set_append_name()"
251224 #define GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE_TEXT "See getdns_context_set_append_name()"
255228
256229
257230 /**
258 * \defgroup contextcodetypes Context code values
231 * \defgroup contextcodetypestext Context code values and texts
259232 * @{
260233 */
261234 /* Context codes */
279252 GETDNS_CONTEXT_CODE_TIMEOUT = 616,
280253 GETDNS_CONTEXT_CODE_IDLE_TIMEOUT = 617
281254 } getdns_context_code_t;
282 /** @}
283 */
284
285 /**
286 * \defgroup contextcodetypestext Context code values texts
287 * @{
288 */
255
256
289257 #define GETDNS_CONTEXT_CODE_NAMESPACES_TEXT "Change related to getdns_context_set_namespaces"
290258 #define GETDNS_CONTEXT_CODE_RESOLUTION_TYPE_TEXT "Change related to getdns_context_set_resolution_type"
291259 #define GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS_TEXT "Change related to getdns_context_set_follow_redirects"
309277
310278
311279 /**
312 * \defgroup callbacktype Callback types
280 * \defgroup callbacktype Callback types and texts
313281 * @{
314282 */
315283 typedef enum getdns_callback_type_t {
318286 GETDNS_CALLBACK_TIMEOUT = 702,
319287 GETDNS_CALLBACK_ERROR = 703
320288 } getdns_callback_type_t;
321 /** @}
322 */
323
324 /**
325 * \defgroup callbacktypetext Callback types texts
326 * @{
327 */
289
328290 #define GETDNS_CALLBACK_COMPLETE_TEXT "The response has the requested data in it"
329291 #define GETDNS_CALLBACK_CANCEL_TEXT "The calling program cancelled the callback; response is NULL"
330292 #define GETDNS_CALLBACK_TIMEOUT_TEXT "The requested action timed out; response is filled in with empty structures"
346308
347309
348310 /**
349 * \defgroup respstatus Status Codes for responses and text
311 * \defgroup respstatus Status Codes for responses and texts
350312 * @{
351313 */
352314 #define GETDNS_RESPSTATUS_GOOD 900
363325 */
364326
365327 /**
366 * \defgroup extvals Values associated with extensions
328 * \defgroup extvals Values associated with extensions and texts
367329 * @{
368330 */
369331 #define GETDNS_EXTENSION_TRUE 1000
374336 */
375337
376338 /**
377 * \defgroup dnserrors Values associated with DNS errors found by the API and text
339 * \defgroup dnserrors Values associated with DNS errors found by the API and texts
378340 * @{
379341 */
380342 #define GETDNS_BAD_DNS_CNAME_IN_TARGET 1100
555517 * Indexes are 0 based.
556518 */
557519 typedef struct getdns_list getdns_list;
558
520 /** @}
521 */
522
523
524 /** \defgroup functions Functions
525 * @{
526 */
559527 /* Specify the order of the following groups manually here so they appear in
560528 a better order in doxygen */
561529
568536 * \defgroup getdns_dict_get_functions getdns_dict_get functions
569537 * \defgroup context_create getdns_context creation/destruction functions
570538 * \defgroup context_set getdns_context_set functions
571 * \defgroup callbacks getdns_callback functions
539 * \defgroup callbackfns getdns_callback functions
540 * \defgroup eventloops getdns event loop extension functions
572541 * \defgroup funcs Asynchronous API functions
573 * \defgroup syncfuns Synchronous API functions that do not use callbacks
542 * \defgroup syncfuncs Synchronous API functions that do not use callbacks
574543 * \defgroup utils Utility functions
575544 */
576545
577546
578547 /**
579 * \ingroup getdns_list_get_functions getdns_list_get functions
548 * \addtogroup getdns_list_get_functions getdns_list_get functions
580549 * @{
581550 */
582551
655624
656625
657626 /**
658 * \ingroup getdns_dict_get_functions getdns_dict_get functions
627 * \addtogroup getdns_dict_get_functions getdns_dict_get functions
659628 * @{
660629 */
661630
729698
730699
731700 /**
732 * \ingroup list_create getdns_list creation/destruction functions
701 * \addtogroup list_create getdns_list creation/destruction functions
733702 * @{
734703 */
735704
765734
766735
767736 /**
768 * \ingroup getdns_list_set getdns_list_set functions
737 * \addtogroup getdns_list_set getdns_list_set functions
769738 * @{
770739 */
771740
815784
816785
817786 /**
818 * \ingroup dict_create getdns_dict creation/destruction functions
787 * \addtogroup dict_create getdns_dict creation/destruction functions
819788 * @{
820789 */
821790
848817
849818
850819 /**
851 * \ingroup getdns_dict_set getdns_dict_set functions
820 * \addtogroup getdns_dict_set getdns_dict_set functions
852821 * @{
853822 */
854823
888857
889858
890859 /**
860 * \addtogroup utils
891861 * remove the value associated with the specified name
892862 * @param dict dictionary from which to fetch the integer
893863 * @param name a name/key value to look up in the dictionary
898868
899869
900870 /**
901 * \ingroup callbacks getdns_callback functions
902 * @{
903 */
904
871 * \addtogroup callbackfns getdns_callback functions
872 */
905873 /* Callback arguments */
906874 typedef void (*getdns_callback_t) (getdns_context *context,
907875 getdns_callback_type_t callback_type,
908876 getdns_dict * response,
909877 void *userarg, getdns_transaction_t transaction_id);
910 /** @}
911 */
912
913
914 /**
915 * \ingroup funcs Asynchronous API functions
878
879 /**
880 * \addtogroup funcs Asynchronous API functions
916881 * @{
917882 */
918883
939904 * retrieve address assigned to a DNS name
940905 * @param context pointer to a previously created context to be used for this call
941906 * @param name the ASCII based domain name to lookup
942 * @param request_type RR type for the query, e.g. GETDNS_RR_TYPE_NS
943907 * @param extensions dict data structures, NULL to use no extensions
944908 * @param userarg void* returned to the callback untouched
945909 * @param[out] transaction_id id used to identify the callback, NULL is ignored
957921 * retrieve hostname assigned to an IP address
958922 * @param context pointer to a previously created context to be used for this call
959923 * @param address the address to look up
960 * @param request_type RR type for the query, e.g. GETDNS_RR_TYPE_NS
961924 * @param extensions dict data structures, NULL to use no extensions
962925 * @param userarg void* returned to the callback untouched
963926 * @param[out] transaction_id id used to identify the callback, NULL is ignored
975938 * retrieve a service assigned to a DNS name
976939 * @param context pointer to a previously created context to be used for this call
977940 * @param name the ASCII based domain name to lookup
978 * @param request_type RR type for the query, e.g. GETDNS_RR_TYPE_NS
979941 * @param extensions dict data structures, NULL to use no extensions
980942 * @param userarg void* returned to the callback untouched
981943 * @param[out] transaction_id id used to identify the callback, NULL is ignored
993955
994956
995957 /**
996 * \ingroup context_create getdns_context creation/destruction functions
958 * \addtogroup context_create getdns_context creation/destruction functions
997959 * @{
998960 */
999961
10571019
10581020
10591021 /**
1060 * \ingroup callbacks getdns_callback functions
1061 * @{
1062 */
1022 * \addtogroup callbackfns getdns_callback functions
1023 * @{
1024 */
10631025 getdns_return_t
10641026 getdns_cancel_callback(getdns_context *context,
10651027 getdns_transaction_t transaction_id);
10681030
10691031
10701032 /**
1071 * \ingroup syncfuns Synchronous API functions that do not use callbacks
1072 * These functions do not use callbacks, when the application calls one of these
1033 * \addtogroup syncfuncs Synchronous API functions that do not use callbacks
1034 * @{
1035 */
1036 /** These functions do not use callbacks, when the application calls one of these
10731037 * functions the library retrieves all of the data before returning. Return
10741038 * values are exactly the same as if you had used a callback with the
10751039 * asynchronous functions.
1076 * @{
10771040 */
10781041
10791042 /**
11381101 */
11391102
11401103 /**
1141 * \ingroup utils Utility functions
1104 * \addtogroup utils Utility functions
11421105 * @{
11431106 */
11441107
11801143
11811144
11821145 /**
1183 * \ingroup context_set getdns_context_set functions
1146 * \addtogroup context_set getdns_context_set functions
11841147 * @{
11851148 */
11861149 getdns_return_t
12781241 getdns_dict*
12791242 getdns_context_get_api_information(getdns_context* context);
12801243
1244 /** @}
1245 */
1246
1247 /** @}
1248 */
1249
12811250 #ifdef __cplusplus
12821251 }
12831252 #endif
4343 #include <getdns/getdns_extra.h>
4444 struct ev_loop;
4545
46
47 /**
48 * \ingroup eventloops
49 */
4650 /* For libevent, which we are using for these examples */
4751 getdns_return_t
4852 getdns_extension_set_libev_loop(struct getdns_context *context,
4343 #include <getdns/getdns_extra.h>
4444 struct event_base;
4545
46 /**
47 * \ingroup eventloops
48 */
4649 /* For libevent, which we are using for these examples */
4750 getdns_return_t
4851 getdns_extension_set_libevent_base(struct getdns_context *context,
4343 #include <getdns/getdns_extra.h>
4444 struct uv_loop_s;
4545
46 /**
47 * \ingroup eventloops
48 */
4649 /* For libevent, which we are using for these examples */
4750 getdns_return_t
4851 getdns_extension_set_libuv_loop(struct getdns_context *context,
0 /**
1 * \file
2 * \brief Public interface to getdns that is ADDITIONAL to the official getdns API, include
3 * in your application to use additional functionality offered by
4 * this implementation.
5 */
6
07 /*
18 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
29 * All rights reserved.
3643 extern "C" {
3744 #endif
3845
39 /* Enable the return_dnssec_status extension on every request.
40 value is either GETDNS_EXTENSION_TRUE or GETDNS_EXTENSION_FALSE
41 returns GETDNS_RETURN_GOOD on success or GETDNS_RETURN_INVALID_PARAMETER
42 if context or value is invalid */
43 getdns_return_t getdns_context_set_return_dnssec_status(
44 getdns_context *context, int enabled);
45
46 /* dict util */
47 /* set a string as bindata */
48 getdns_return_t getdns_dict_util_set_string(struct getdns_dict * dict,
49 char *name, const char *value);
50
51 /* get a string from a dict. the result must be freed if valid */
52 getdns_return_t getdns_dict_util_get_string(struct getdns_dict * dict,
53 char *name, char **result);
54
55 /* tells underlying unbound to use background threads or fork */
56 getdns_return_t getdns_context_set_use_threads(getdns_context* context,
57 int use_threads);
58
59 /* Async support */
60 uint32_t getdns_context_get_num_pending_requests(getdns_context* context,
61 struct timeval* next_timeout);
62
63 /* process async reqs */
64 getdns_return_t getdns_context_process_async(getdns_context* context);
65
66 /***************** functions for eventloop extensions ******************/
46 /** \defgroup UnofficialgetdnsAPI Additional API for getdns implementation
47 * @{
48 */
49
50 /** \defgroup Uvaluesandtexts Additional values and texts
51 * @{
52 */
53
54 /**
55 * \defgroup Ureturnvaluesandtext Additional return values and texts
56 * @{
57 */
58 #define GETDNS_RETURN_NEED_MORE_SPACE ((getdns_return_t) 399 )
59 #define GETDNS_RETURN_NEED_MORE_SPACE_TEXT "The buffer was too small"
60 /** @}
61 */
62
63
64 /**
65 * \defgroup Ucontextcodes Additional context codes and texts
66 * @{
67 */
68 #define GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION 618
69 #define GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION_TEXT "Change related to getdns_context_set_tls_authentication"
70 #define GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE 619
71 #define GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE_TEXT "Change related to getdns_context_set_edns_client_subnet_private"
72 #define GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE 620
73 #define GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE_TEXT "Change related to getdns_context_set_tls_query_padding_blocksize"
74 #define GETDNS_CONTEXT_CODE_PUBKEY_PINSET 621
75 #define GETDNS_CONTEXT_CODE_PUBKEY_PINSET_TEXT "Change related to getdns_context_set_pubkey_pinset"
76 /** @}
77 */
78
79
80 /**
81 * \defgroup versions Additional version values
82 * @{
83 */
84 #define GETDNS_VERSION "@GETDNS_VERSION@"
85 #define GETDNS_NUMERIC_VERSION @GETDNS_NUMERIC_VERSION@
86 #define GETDNS_API_VERSION "@API_VERSION@"
87 #define GETDNS_API_NUMERIC_VERSION @API_NUMERIC_VERSION@
88 /** @}
89 */
90
91
92 /* an alias for REQUIRED */
93 #define GETDNS_AUTHENTICATION_HOSTNAME GETDNS_AUTHENTICATION_REQUIRED
94
95 /**
96 * \defgroup authvaulesandtext Additional authentication values and texts
97 * @{
98 */
99 /* Authentication options used when doing TLS */
100 typedef enum getdns_tls_authentication_t {
101 GETDNS_AUTHENTICATION_NONE = 1300,
102 GETDNS_AUTHENTICATION_REQUIRED = 1301
103 } getdns_tls_authentication_t;
104
105 #define GETDNS_AUTHENTICATION_NONE_TEXT "See getdns_context_set_tls_authentication()"
106 #define GETDNS_AUTHENTICATION_REQUIRED_TEXT "See getdns_context_set_tls_authentication()"
107 /** @}
108 */
109
110
111 /**
112 * \defgroup appendname Additional append name values and texts
113 * @{
114 */
115 #define GETDNS_APPEND_NAME_TO_SINGLE_LABEL_FIRST ((getdns_append_name_t) 554 )
116 #define GETDNS_APPEND_NAME_TO_SINGLE_LABEL_FIRST_TEXT "See getdns_context_set_append_name()"
117 /** @}
118 */
119
120
121 /**
122 * \defgroup Uvaluesandtextsdepricated Additional transport values and texts (will be deprecated)
123 * @{
124 */
125
126 /** WARNING! Do not use the constants below. They will be removed from future
127 * releases. Please use the getdns_context_set_dns_transport_list with the
128 * GETDNS_TRANSPORT_UDP, GETDNS_TRANSPORT_TCP and GETDNS_TRANSPORT_TLS
129 * constants instead.
130 */
131 #define GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN 544
132 #define GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN_TEXT "See getdns_context_set_dns_transport()"
133 #define GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN 545
134 #define GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN_TEXT "See getdns_context_set_dns_transport()"
135
136 /** @}
137 */
138 /** @}
139 */
140
141
142 /**
143 * \defgroup Ufunctions Additional functions
144 * @{
145 */
146
147 /**
148 * \defgroup Ueventloops Additional event loop extension functions
149 * @{
150 */
67151
68152 typedef void (*getdns_eventloop_callback)(void *userarg);
69153
130214 /* Run the context's event loop until nothing more to do */
131215 void
132216 getdns_context_run(getdns_context *context);
133
134 /** begin getters **/
135 getdns_return_t
136 getdns_context_get_resolution_type(getdns_context *context,
137 getdns_resolution_t* value);
138
139 /** users must call free on the resulting namespaces if not NULL */
140 getdns_return_t
141 getdns_context_get_namespaces(getdns_context *context,
142 size_t* namespace_count, getdns_namespace_t **namespaces);
143
144 getdns_return_t
145 getdns_context_get_dns_transport(getdns_context *context,
146 getdns_transport_t* value);
147
148 getdns_return_t
149 getdns_context_get_dns_transport_list(getdns_context *context,
150 size_t* transport_count, getdns_transport_list_t **transports);
151
152 getdns_return_t
153 getdns_context_get_limit_outstanding_queries(getdns_context *context,
154 uint16_t* limit);
155
156 getdns_return_t
157 getdns_context_get_timeout(getdns_context *context, uint64_t* timeout);
158
159 getdns_return_t
160 getdns_context_get_idle_timeout(getdns_context *context, uint64_t* timeout);
161
162 getdns_return_t
163 getdns_context_get_follow_redirects(getdns_context *context,
164 getdns_redirects_t* value);
165
166 getdns_return_t
167 getdns_context_get_dns_root_servers(getdns_context *context,
168 getdns_list **addresses);
169
170 getdns_return_t
171 getdns_context_get_append_name(getdns_context *context,
172 getdns_append_name_t* value);
173
174 getdns_return_t
175 getdns_context_get_suffix(getdns_context *context, getdns_list **value);
176
177 getdns_return_t
178 getdns_context_get_dnssec_trust_anchors(getdns_context *context,
179 getdns_list **value);
180
181 getdns_return_t
182 getdns_context_get_dnssec_allowed_skew(getdns_context *context,
183 uint32_t* value);
184
185 getdns_return_t
186 getdns_context_get_upstream_recursive_servers(getdns_context *context,
187 getdns_list **upstream_list);
188
189 getdns_return_t
190 getdns_context_get_edns_maximum_udp_payload_size(getdns_context *context,
191 uint16_t* value);
192
193 getdns_return_t
194 getdns_context_get_edns_extended_rcode(getdns_context *context,
195 uint8_t* value);
196
197 getdns_return_t
198 getdns_context_get_edns_version(getdns_context *context, uint8_t* value);
199
200 getdns_return_t
201 getdns_context_get_edns_do_bit(getdns_context *context, uint8_t* value);
202
203 getdns_return_t
204 getdns_context_set_edns_client_subnet_private(getdns_context *context, uint8_t value);
205 getdns_return_t
206 getdns_context_get_edns_client_subnet_private(getdns_context *context, uint8_t* value);
207
208 getdns_return_t
209 getdns_context_set_tls_query_padding_blocksize(getdns_context *context, uint16_t value);
210 getdns_return_t
211 getdns_context_get_tls_query_padding_blocksize(getdns_context *context, uint16_t* value);
212
213
214 /**
215 * Pretty print the getdns_dict in a given buffer snprintf style.
216 * @param str pointer to the buffer to print to
217 * @param size size of the given buffer. No more than size bytes (including
218 * the terminating null byte) will be written to str.
219 * @param dict getdns_dict to print
220 * @return The number of characters written excluding the terminating null byte
221 * or the number of characters which would have been written if enough space
222 * had been available.
223 */
224 int
225 getdns_pretty_snprint_dict(char *str, size_t size, const getdns_dict *dict);
226
227 /**
228 * creates a string that describes the list in a human readable form.
229 * @param some_list list to pretty print
230 * @return character array (caller must free this) containing pretty string
231 */
232 char *
233 getdns_pretty_print_list(const getdns_list *some_list);
234
235 /**
236 * Pretty print the getdns_list in a given buffer snprintf style.
237 * @param str pointer to the buffer to print to
238 * @param size size of the given buffer. No more than size bytes (including
239 * the terminating null byte) will be written to str.
240 * @param list getdns_list to print
241 * @return The number of characters written excluding the terminating null byte
242 * or the number of characters which would have been written if enough space
243 * had been available.
244 */
245 int
246 getdns_pretty_snprint_list(char *str, size_t size, const getdns_list *list);
247
248 /**
249 * creates a string containing a json representation of some_dict.
250 * bindatas are converted to strings when possible, including bindatas for
251 * addresses, dnames and other printable data. All other bindatas are
252 * converted to lists of byte values.
253 * @param some_dict dict to represent as json data
254 * @param pretty when non-zero returns formatted json
255 * @return character array (caller must free this) containing pretty string
256 */
257 char *
258 getdns_print_json_dict(const getdns_dict *some_dict, int pretty);
259
260 /**
261 * Prints a json representation of dict in a given buffer snprintf style.
262 * bindatas are converted to strings when possible, including bindatas for
263 * addresses, dnames and other printable data. All other bindatas are
264 * converted to lists of byte values.
265 * @param str pointer to the buffer to print to
266 * @param size size of the given buffer. No more than size bytes (including
267 * the terminating null byte) will be written to str.
268 * @param dict dict to represent as json data
269 * @param pretty when non-zero returns formatted json
270 * @return The number of characters written excluding the terminating null byte
271 * or the number of characters which would have been written if enough space
272 * had been available.
273 */
274 int
275 getdns_snprint_json_dict(
276 char *str, size_t size, const getdns_dict *dict, int pretty);
277
278 /**
279 * creates a string containing a json representation of some_list.
280 * bindatas are converted to strings when possible, including bindatas for
281 * addresses, dnames and other printable data. All other bindatas are
282 * converted to lists of byte values.
283 * @param some_list list to represent as json data
284 * @param pretty when non-zero returns formatted json
285 * @return character array (caller must free this) containing pretty string
286 */
287 char *
288 getdns_print_json_list(const getdns_list *some_list, int pretty);
289
290 /**
291 * Prints a json representation of list in a given buffer snprintf style.
292 * bindatas are converted to strings when possible, including bindatas for
293 * addresses, dnames and other printable data. All other bindatas are
294 * converted to lists of byte values.
295 * @param str pointer to the buffer to print to
296 * @param size size of the given buffer. No more than size bytes (including
297 * the terminating null byte) will be written to str.
298 * @param list list to represent as json data
299 * @param pretty when non-zero returns formatted json
300 * @return The number of characters written excluding the terminating null byte
301 * or the number of characters which would have been written if enough space
302 * had been available.
303 */
304 int
305 getdns_snprint_json_list(
306 char *str, size_t size, const getdns_list *list, int pretty);
307
217 /** @}
218 */
219
220
221 /**
222 * \defgroup contextfunction Additional getdns_context async functions
223 * @{
224 */
225 /* process async reqs */
226 getdns_return_t getdns_context_process_async(getdns_context* context);
227 /** @}
228 */
229
230 /**
231 * \defgroup Ucontextset Additional getdns_context_set functions
232 * @{
233 */
308234 /**
309235 * Register a callback function for context changes.
310236 * @param context The context to monitor for changes
320246 getdns_return_t
321247 getdns_context_set_update_callback(getdns_context *context, void *userarg,
322248 void (*value) (getdns_context *, getdns_context_code_t, void *));
249
250 /* Enable the return_dnssec_status extension on every request.
251 value is either GETDNS_EXTENSION_TRUE or GETDNS_EXTENSION_FALSE
252 returns GETDNS_RETURN_GOOD on success or GETDNS_RETURN_INVALID_PARAMETER
253 if context or value is invalid */
254 getdns_return_t getdns_context_set_return_dnssec_status(
255 getdns_context *context, int enabled);
256
257 /* tells underlying unbound to use background threads or fork */
258 getdns_return_t getdns_context_set_use_threads(getdns_context* context,
259 int use_threads);
260
261 getdns_return_t
262 getdns_context_set_tls_authentication(
263 getdns_context *context, getdns_tls_authentication_t value);
264
265 getdns_return_t
266 getdns_context_set_edns_client_subnet_private(getdns_context *context, uint8_t value);
267
268 getdns_return_t
269 getdns_context_set_tls_query_padding_blocksize(getdns_context *context, uint16_t value);
270 /** @}
271 */
272
273 /**
274 * \defgroup Ucontextget Additional getdns_context_get functions
275 * @{
276 */
277 /** begin getters **/
278 getdns_return_t
279 getdns_context_get_resolution_type(getdns_context *context,
280 getdns_resolution_t* value);
281
282 /** users must call free on the resulting namespaces if not NULL */
283 getdns_return_t
284 getdns_context_get_namespaces(getdns_context *context,
285 size_t* namespace_count, getdns_namespace_t **namespaces);
286
287 getdns_return_t
288 getdns_context_get_dns_transport(getdns_context *context,
289 getdns_transport_t* value);
290
291 getdns_return_t
292 getdns_context_get_dns_transport_list(getdns_context *context,
293 size_t* transport_count, getdns_transport_list_t **transports);
294
295 getdns_return_t
296 getdns_context_get_limit_outstanding_queries(getdns_context *context,
297 uint16_t* limit);
298
299 getdns_return_t
300 getdns_context_get_timeout(getdns_context *context, uint64_t* timeout);
301
302 getdns_return_t
303 getdns_context_get_idle_timeout(getdns_context *context, uint64_t* timeout);
304
305 getdns_return_t
306 getdns_context_get_follow_redirects(getdns_context *context,
307 getdns_redirects_t* value);
308
309 getdns_return_t
310 getdns_context_get_dns_root_servers(getdns_context *context,
311 getdns_list **addresses);
312
313 getdns_return_t
314 getdns_context_get_append_name(getdns_context *context,
315 getdns_append_name_t* value);
316
317 getdns_return_t
318 getdns_context_get_suffix(getdns_context *context, getdns_list **value);
319
320 getdns_return_t
321 getdns_context_get_dnssec_trust_anchors(getdns_context *context,
322 getdns_list **value);
323
324 getdns_return_t
325 getdns_context_get_dnssec_allowed_skew(getdns_context *context,
326 uint32_t* value);
327
328 getdns_return_t
329 getdns_context_get_upstream_recursive_servers(getdns_context *context,
330 getdns_list **upstream_list);
331
332 getdns_return_t
333 getdns_context_get_edns_maximum_udp_payload_size(getdns_context *context,
334 uint16_t* value);
335
336 getdns_return_t
337 getdns_context_get_edns_extended_rcode(getdns_context *context,
338 uint8_t* value);
339
340 getdns_return_t
341 getdns_context_get_edns_version(getdns_context *context, uint8_t* value);
342
343 getdns_return_t
344 getdns_context_get_edns_do_bit(getdns_context *context, uint8_t* value);
345
346 getdns_return_t
347 getdns_context_get_edns_client_subnet_private(getdns_context *context, uint8_t* value);
348
349 getdns_return_t
350 getdns_context_get_tls_query_padding_blocksize(getdns_context *context, uint16_t* value);
351
352 getdns_return_t
353 getdns_context_get_tls_authentication(getdns_context *context,
354 getdns_tls_authentication_t* value);
323355
324356 /**
325357 * Get the currently registered callback function and user defined argument
338370 getdns_context_get_update_callback(getdns_context *context, void **userarg,
339371 void (**value) (getdns_context *, getdns_context_code_t, void *));
340372
373 /* Async support */
374 uint32_t getdns_context_get_num_pending_requests(getdns_context* context,
375 struct timeval* next_timeout);
376 /** @}
377 */
378
379
380 /**
381 * \defgroup Uutilityfunctions Additional utility functions
382 * @{
383 */
384
385 const char *getdns_get_version(void);
386 uint32_t getdns_get_version_number(void);
387 const char *getdns_get_api_version(void);
388 uint32_t getdns_get_api_version_number(void);
389
341390 /**
342391 * Returns a text describing the getdns error code, or NULL when the error
343392 * code is unkown.
347396 */
348397 const char *getdns_get_errorstr_by_id(uint16_t err);
349398
350
351
352 /**
353 * Public Key Pinning functionality:
354 *
355 * a public key pinset is a list of dicts. each dict should have a
356 * "digest" and a "value".
357 *
358 * "digest": a string indicating the type of digest. at the moment, we
359 * only support a "digest" of "sha256".
360 *
361 * "value": a binary representation of the digest provided.
362 *
363 * given a such a pinset, we should be able to validate a chain
364 * properly according to section 2.6 of RFC 7469.
365 */
366
367 /**
368 * convert an HPKP-style pin description to an appropriate getdns data
369 * structure. An example string is: (with the quotes, without any
370 * leading or trailing whitespace):
371 *
372 * pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="
373 *
374 * It is the caller's responsibility to call getdns_dict_destroy() on
375 * the dict returned when it is no longer needed.
376 *
377 * @param context a context to use to create the dict, or NULL to create
378 * it generically
379 * @param str the pinning string to parse
380 * @return a dict created from ctx, or NULL if the string did not match.
381 */
382 getdns_dict* getdns_pubkey_pin_create_from_string(
383 getdns_context* context,
384 const char* str);
385
386
387 /**
388 * Test whether a given pinset is reasonable, including:
389 *
390 * is it well-formed?
391 * are there at least two pins?
392 * are the digests used sane?
393 *
394 * @param pinset the set of public key pins to check for sanity. This
395 * should be a list of dicts.
396 * @return errorlist if not NULL, a list of human-readable strings is
397 * appended to errorlist.
398 * @return GETDNS_RETURN_GOOD if the pinset passes the sanity check.
399 */
400 getdns_return_t getdns_pubkey_pinset_sanity_check(
401 const getdns_list* pinset,
402 getdns_list* errorlist);
403
404
405
406 /* WARNING! Function getdns_strerror is not in the API specification and
407 * is likely to be removed from future versions of our implementation, to be
408 * replaced by getdns_get_errorstr_by_id or something similar.
409 * Please use getdns_get_errorstr_by_id instead of getdns_strerror.
410 */
411 getdns_return_t getdns_strerror(getdns_return_t err, char *buf, size_t buflen);
412
413 #define GETDNS_VERSION "@GETDNS_VERSION@"
414 #define GETDNS_NUMERIC_VERSION @GETDNS_NUMERIC_VERSION@
415 #define GETDNS_API_VERSION "@API_VERSION@"
416 #define GETDNS_API_NUMERIC_VERSION @API_NUMERIC_VERSION@
417
418 const char *getdns_get_version(void);
419 uint32_t getdns_get_version_number(void);
420 const char *getdns_get_api_version(void);
421 uint32_t getdns_get_api_version_number(void);
422
423 /* Authentication options used when doing TLS */
424 typedef enum getdns_tls_authentication_t {
425 GETDNS_AUTHENTICATION_NONE = 1300,
426 GETDNS_AUTHENTICATION_REQUIRED = 1301
427 } getdns_tls_authentication_t;
428
429 /* an alias for REQUIRED */
430 #define GETDNS_AUTHENTICATION_HOSTNAME GETDNS_AUTHENTICATION_REQUIRED
431
432 /**
433 * \defgroup authtext Authentication texts
434 * @{
435 */
436 #define GETDNS_AUTHENTICATION_NONE_TEXT "See getdns_context_set_tls_authentication()"
437 #define GETDNS_AUTHENTICATION_REQUIRED_TEXT "See getdns_context_set_tls_authentication()"
438 /** @}
439 */
440
441 #define GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION 618
442 #define GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION_TEXT "Change related to getdns_context_set_tls_authentication"
443 #define GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE 619
444 #define GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE_TEXT "Change related to getdns_context_set_edns_client_subnet_private"
445 #define GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE 620
446 #define GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE_TEXT "Change related to getdns_context_set_tls_query_padding_blocksize"
447 #define GETDNS_CONTEXT_CODE_PUBKEY_PINSET 621
448 #define GETDNS_CONTEXT_CODE_PUBKEY_PINSET_TEXT "Change related to getdns_context_set_pubkey_pinset"
449
450 getdns_return_t
451 getdns_context_set_tls_authentication(
452 getdns_context *context, getdns_tls_authentication_t value);
453
454 getdns_return_t
455 getdns_context_get_tls_authentication(getdns_context *context,
456 getdns_tls_authentication_t* value);
457
458
459 /* WARNING! Do not use the constants below. They will be removed from future
460 * releases. Please use the getdns_context_set_dns_transport_list with the
461 * GETDNS_TRANSPORT_UDP, GETDNS_TRANSPORT_TCP and GETDNS_TRANSPORT_TLS
462 * constants instead.
463 */
464 #define GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN 544
465 #define GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN_TEXT "See getdns_context_set_dns_transport()"
466 #define GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN 545
467 #define GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN_TEXT "See getdns_context_set_dns_transport()"
468
469 #define GETDNS_RETURN_NEED_MORE_SPACE ((getdns_return_t) 399 )
470 #define GETDNS_RETURN_NEED_MORE_SPACE_TEXT "The buffer was too small"
471
472 /**
473 * Convert rr_dict to wireformat representation of the resource record.
474 *
475 * @param rr_dict The getdns dict representation of the resource record
476 * @return wire A newly allocated buffer which will contain the wireformat.
477 * @return wire_sz The size of the allocated buffer and the wireformat.
478 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
479 */
480 getdns_return_t
481 getdns_rr_dict2wire(
482 const getdns_dict *rr_dict, uint8_t **wire, size_t *wire_sz);
483
484 /**
485 * Convert rr_dict to wireformat representation of the resource record.
486 *
487 * @param rr_dict The getdns dict representation of the resource record
488 * @param wire The buffer in which the wireformat will be written
489 * @param wire_sz On input the size of the wire buffer,
490 * On output the amount of wireformat needed for the
491 * wireformat representation of the resource record;
492 * even if it did not fit.
493 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
494 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
495 * small. wire_sz will be set to the needed buffer space then.
496 */
497 getdns_return_t
498 getdns_rr_dict2wire_buf(
499 const getdns_dict *rr_dict, uint8_t *wire, size_t *wire_sz);
500
501 /**
502 * Convert rr_dict to wireformat representation of the resource record.
503 *
504 * @param rr_dict The getdns dict representation of the resource record
505 * @param wire A pointer to the buffer pointer in which the wireformat
506 * will be written.
507 * On output the buffer pointer will have moved along
508 * the buffer and point right after the just written RR.
509 * @param wire_sz On input the size of the wire buffer,
510 * On output the amount of wireformat needed for the
511 * wireformat will have been substracted from wire_sz.
512 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
513 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
514 * small. The function will pretend that it had written beyond the end
515 * of the buffer, and wire will point past the buffer and wire_sz will
516 * contain a negative value.
517 */
518 getdns_return_t
519 getdns_rr_dict2wire_scan(
520 const getdns_dict *rr_dict, uint8_t **wire, int *wire_sz);
521
522
523 /**
524 * Convert wireformat resource record in a getdns rr_dict representation.
525 *
526 * @param wire Buffer containing the wireformat rr
527 * @param wire_sz Size of the wire buffer
528 * @return rr_dict The returned rr_dict
529 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
530 */
531 getdns_return_t
532 getdns_wire2rr_dict(
533 const uint8_t *wire, size_t wire_sz, getdns_dict **rr_dict);
534
535 /**
536 * Convert wireformat resource record in a getdns rr_dict representation.
537 *
538 * @param wire Buffer containing the wireformat rr
539 * @param wire_sz On input the size of the wire buffer
540 * On output the length of the wireformat rr.
541 * @return rr_dict The returned rr_dict
542 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
543 */
544 getdns_return_t
545 getdns_wire2rr_dict_buf(
546 const uint8_t *wire, size_t *wire_sz, getdns_dict **rr_dict);
547
548 /**
549 * Convert wireformat resource record in a getdns rr_dict representation.
550 *
551 * @param wire A pointer to the pointer of the wireformat buffer.
552 * On return this pointer is moved to after first read
553 * in resource record.
554 * @param wire_sz On input the size of the wire buffer
555 * On output the size is decreased with the length
556 * of the wireformat resource record.
557 * @return rr_dict The returned rr_dict
558 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
559 */
560 getdns_return_t
561 getdns_wire2rr_dict_scan(
562 const uint8_t **wire, size_t *wire_sz, getdns_dict **rr_dict);
563
564
565 /**
566 * Convert rr_dict to the string representation of the resource record.
567 *
568 * @param rr_dict The getdns dict representation of the resource record
569 * @return str A newly allocated string representation of the rr
570 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
571 */
572 getdns_return_t
573 getdns_rr_dict2str(
574 const getdns_dict *rr_dict, char **str);
575
576 /**
577 * Convert rr_dict to the string representation of the resource record.
578 *
579 * @param rr_dict The getdns dict representation of the resource record
580 * @param str The buffer in which the string will be written
581 * @param str_len On input the size of the text buffer,
582 * On output the amount of characters needed to write
583 * the string representation of the rr. Even if it does
584 * not fit.
585 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
586 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
587 * small. str_len will be set to the needed buffer space then.
588 */
589 getdns_return_t
590 getdns_rr_dict2str_buf(
591 const getdns_dict *rr_dict, char *str, size_t *str_len);
592
593 /**
594 * Convert rr_dict to the string representation of the resource record.
595 *
596 * @param rr_dict The getdns dict representation of the resource record
597 * @param str A pointer to the buffer pointer in which the string
598 * will be written.
599 * On output the buffer pointer will have moved along
600 * the buffer and point right after the just written RR.
601 * @param str_len On input the size of the str buffer,
602 * On output the number of characters needed for the
603 * string will have been substracted from strlen.
604 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
605 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
606 * small. The function will pretend that it had written beyond the end
607 * of the buffer, and str will point past the buffer and str_len will
608 * contain a negative value.
609 */
610 getdns_return_t
611 getdns_rr_dict2str_scan(
612 const getdns_dict *rr_dict, char **str, int *str_len);
613
614
615 /**
616 * Convert the string representation of the resource record to rr_dict format.
617 *
618 * @param str String representation of the resource record.
619 * @return rr_dict The result getdns dict representation of the resource record
620 * @param origin Default suffix for not fully qualified domain names
621 * @param default_ttl Default ttl
622 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
623 */
624 getdns_return_t
625 getdns_str2rr_dict(
626 const char *str, getdns_dict **rr_dict,
627 const char *origin, uint32_t default_ttl);
628
629 /**
630 * Read the zonefile and convert to a list of rr_dict's.
631 *
632 * @param fp An opened FILE pointer on the zone file.
633 * @return rr_list The result list of rr_dicts representing the zone file.
634 * @param origin Default suffix for not fully qualified domain names
635 * @param default_ttl Default ttl
636 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
637 */
638 getdns_return_t
639 getdns_fp2rr_list(
640 FILE *in, getdns_list **rr_list,
641 const char *origin, uint32_t default_ttl);
642
643 /**
644 * Convert DNS message dict to wireformat representation.
645 *
646 * @param msg_dict The getdns dict representation of a DNS message
647 * @return wire A newly allocated buffer which will contain the wireformat.
648 * @return wire_sz The size of the allocated buffer and the wireformat.
649 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
650 */
651 getdns_return_t
652 getdns_msg_dict2wire(
653 const getdns_dict *msg_dict, uint8_t **wire, size_t *wire_sz);
654
655 /**
656 * Convert DNS message dict to wireformat representation.
657 *
658 * @param msg_dict The getdns dict representation of a DNS message
659 * @param wire The buffer in which the wireformat will be written
660 * @param wire_sz On input the size of the wire buffer,
661 * On output the amount of wireformat needed for the
662 * wireformat representation of the DNS message;
663 * even if it did not fit.
664 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
665 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
666 * small. wire_sz will be set to the needed buffer space then.
667 */
668 getdns_return_t
669 getdns_msg_dict2wire_buf(
670 const getdns_dict *msg_dict, uint8_t *wire, size_t *wire_sz);
671
672 /**
673 * Convert DNS message dict to wireformat representation.
674 *
675 * @param msg_dict The getdns dict representation of the DNS message
676 * @param wire A pointer to the buffer pointer in which the wireformat
677 * will be written.
678 * On output the buffer pointer will have moved along
679 * the buffer and point right after the just written RR.
680 * @param wire_sz On input the size of the wire buffer,
681 * On output the amount of wireformat needed for the
682 * wireformat will have been substracted from wire_sz.
683 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
684 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
685 * small. The function will pretend that it had written beyond the end
686 * of the buffer, and wire will point past the buffer and wire_sz will
687 * contain a negative value.
688 */
689 getdns_return_t
690 getdns_msg_dict2wire_scan(
691 const getdns_dict *msg_dict, uint8_t **wire, int *wire_sz);
692
693
694 /**
695 * Convert wireformat DNS message in a getdns msg_dict representation.
696 *
697 * @param wire Buffer containing the wireformat rr
698 * @param wire_sz Size of the wire buffer
699 * @return msg_dict The returned DNS message
700 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
701 */
702 getdns_return_t
703 getdns_wire2msg_dict(
704 const uint8_t *wire, size_t wire_sz, getdns_dict **msg_dict);
705
706 /**
707 * Convert wireformat DNS message in a getdns msg_dict representation.
708 *
709 * @param wire Buffer containing the wireformat rr
710 * @param wire_sz On input the size of the wire buffer
711 * On output the length of the wireformat rr.
712 * @return msg_dict The returned DNS message
713 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
714 */
715 getdns_return_t
716 getdns_wire2msg_dict_buf(
717 const uint8_t *wire, size_t *wire_sz, getdns_dict **msg_dict);
718
719 /**
720 * Convert wireformat DNS message in a getdns msg_dic representation.
721 *
722 * @param wire A pointer to the pointer of the wireformat buffer.
723 * On return this pointer is moved to after first read
724 * in resource record.
725 * @param wire_sz On input the size of the wire buffer
726 * On output the size is decreased with the length
727 * of the wireformat DNS message.
728 * @return msg_dict The returned DNS message
729 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
730 */
731 getdns_return_t
732 getdns_wire2msg_dict_scan(
733 const uint8_t **wire, size_t *wire_sz, getdns_dict **msg_dict);
734
735
736 /**
737 * Convert msg_dict to the string representation of the DNS message.
738 *
739 * @param msg_dict The getdns dict representation of the DNS message
740 * @return str A newly allocated string representation of the rr
741 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
742 */
743 getdns_return_t
744 getdns_msg_dict2str(
745 const getdns_dict *msg_dict, char **str);
746
747 /**
748 * Convert msg_dict to the string representation of the DNS message.
749 *
750 * @param msg_dict The getdns dict representation of the resource record
751 * @param str The buffer in which the string will be written
752 * @param str_len On input the size of the text buffer,
753 * On output the amount of characters needed to write
754 * the string representation of the rr. Even if it does
755 * not fit.
756 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
757 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
758 * small. str_len will be set to the needed buffer space then.
759 */
760 getdns_return_t
761 getdns_msg_dict2str_buf(
762 const getdns_dict *msg_dict, char *str, size_t *str_len);
763
764 /**
765 * Convert msg_dict to the string representation of the resource record.
766 *
767 * @param msg_dict The getdns dict representation of the resource record
768 * @param str A pointer to the buffer pointer in which the string
769 * will be written.
770 * On output the buffer pointer will have moved along
771 * the buffer and point right after the just written RR.
772 * @param str_len On input the size of the str buffer,
773 * On output the number of characters needed for the
774 * string will have been substracted from strlen.
775 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
776 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
777 * small. The function will pretend that it had written beyond the end
778 * of the buffer, and str will point past the buffer and str_len will
779 * contain a negative value.
780 */
781 getdns_return_t
782 getdns_msg_dict2str_scan(
783 const getdns_dict *msg_dict, char **str, int *str_len);
784
399 /* dict util */
400 /* set a string as bindata */
401 getdns_return_t getdns_dict_util_set_string(struct getdns_dict * dict,
402 char *name, const char *value);
403
404 /* get a string from a dict. the result must be freed if valid */
405 getdns_return_t getdns_dict_util_get_string(struct getdns_dict * dict,
406 char *name, char **result);
785407
786408 /**
787409 * Validate replies or resource records.
817439 getdns_list *trust_anchors,
818440 time_t validation_time, uint32_t skew);
819441
820
821 #define GETDNS_APPEND_NAME_TO_SINGLE_LABEL_FIRST ((getdns_append_name_t) 554 )
822 #define GETDNS_APPEND_NAME_TO_SINGLE_LABEL_FIRST_TEXT "See getdns_context_set_append_name()"
823
442 /**
443 * Public Key Pinning functionality:
444 *
445 * a public key pinset is a list of dicts. each dict should have a
446 * "digest" and a "value".
447 *
448 * "digest": a string indicating the type of digest. at the moment, we
449 * only support a "digest" of "sha256".
450 *
451 * "value": a binary representation of the digest provided.
452 *
453 * given a such a pinset, we should be able to validate a chain
454 * properly according to section 2.6 of RFC 7469.
455 */
456
457 /**
458 * convert an HPKP-style pin description to an appropriate getdns data
459 * structure. An example string is: (with the quotes, without any
460 * leading or trailing whitespace):
461 *
462 * pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="
463 *
464 * It is the caller's responsibility to call getdns_dict_destroy() on
465 * the dict returned when it is no longer needed.
466 *
467 * @param context a context to use to create the dict, or NULL to create
468 * it generically
469 * @param str the pinning string to parse
470 * @return a dict created from ctx, or NULL if the string did not match.
471 */
472 getdns_dict* getdns_pubkey_pin_create_from_string(
473 getdns_context* context,
474 const char* str);
475
476
477 /**
478 * Test whether a given pinset is reasonable, including:
479 *
480 * is it well-formed?
481 * are there at least two pins?
482 * are the digests used sane?
483 *
484 * @param pinset the set of public key pins to check for sanity. This
485 * should be a list of dicts.
486 * @return errorlist if not NULL, a list of human-readable strings is
487 * appended to errorlist.
488 * @return GETDNS_RETURN_GOOD if the pinset passes the sanity check.
489 */
490 getdns_return_t getdns_pubkey_pinset_sanity_check(
491 const getdns_list* pinset,
492 getdns_list* errorlist);
493
494
495 /**
496 * Pretty print the getdns_dict in a given buffer snprintf style.
497 * @param str pointer to the buffer to print to
498 * @param size size of the given buffer. No more than size bytes (including
499 * the terminating null byte) will be written to str.
500 * @param dict getdns_dict to print
501 * @return The number of characters written excluding the terminating null byte
502 * or the number of characters which would have been written if enough space
503 * had been available.
504 */
505 int
506 getdns_pretty_snprint_dict(char *str, size_t size, const getdns_dict *dict);
507
508 /**
509 * creates a string that describes the list in a human readable form.
510 * @param some_list list to pretty print
511 * @return character array (caller must free this) containing pretty string
512 */
513 char *
514 getdns_pretty_print_list(const getdns_list *some_list);
515
516 /**
517 * Pretty print the getdns_list in a given buffer snprintf style.
518 * @param str pointer to the buffer to print to
519 * @param size size of the given buffer. No more than size bytes (including
520 * the terminating null byte) will be written to str.
521 * @param list getdns_list to print
522 * @return The number of characters written excluding the terminating null byte
523 * or the number of characters which would have been written if enough space
524 * had been available.
525 */
526 int
527 getdns_pretty_snprint_list(char *str, size_t size, const getdns_list *list);
528
529 /**
530 * creates a string containing a json representation of some_dict.
531 * bindatas are converted to strings when possible, including bindatas for
532 * addresses, dnames and other printable data. All other bindatas are
533 * converted to lists of byte values.
534 * @param some_dict dict to represent as json data
535 * @param pretty when non-zero returns formatted json
536 * @return character array (caller must free this) containing pretty string
537 */
538 char *
539 getdns_print_json_dict(const getdns_dict *some_dict, int pretty);
540
541 /**
542 * Prints a json representation of dict in a given buffer snprintf style.
543 * bindatas are converted to strings when possible, including bindatas for
544 * addresses, dnames and other printable data. All other bindatas are
545 * converted to lists of byte values.
546 * @param str pointer to the buffer to print to
547 * @param size size of the given buffer. No more than size bytes (including
548 * the terminating null byte) will be written to str.
549 * @param dict dict to represent as json data
550 * @param pretty when non-zero returns formatted json
551 * @return The number of characters written excluding the terminating null byte
552 * or the number of characters which would have been written if enough space
553 * had been available.
554 */
555 int
556 getdns_snprint_json_dict(
557 char *str, size_t size, const getdns_dict *dict, int pretty);
558
559 /**
560 * creates a string containing a json representation of some_list.
561 * bindatas are converted to strings when possible, including bindatas for
562 * addresses, dnames and other printable data. All other bindatas are
563 * converted to lists of byte values.
564 * @param some_list list to represent as json data
565 * @param pretty when non-zero returns formatted json
566 * @return character array (caller must free this) containing pretty string
567 */
568 char *
569 getdns_print_json_list(const getdns_list *some_list, int pretty);
570
571 /**
572 * Prints a json representation of list in a given buffer snprintf style.
573 * bindatas are converted to strings when possible, including bindatas for
574 * addresses, dnames and other printable data. All other bindatas are
575 * converted to lists of byte values.
576 * @param str pointer to the buffer to print to
577 * @param size size of the given buffer. No more than size bytes (including
578 * the terminating null byte) will be written to str.
579 * @param list list to represent as json data
580 * @param pretty when non-zero returns formatted json
581 * @return The number of characters written excluding the terminating null byte
582 * or the number of characters which would have been written if enough space
583 * had been available.
584 */
585 int
586 getdns_snprint_json_list(
587 char *str, size_t size, const getdns_list *list, int pretty);
588
589
590 /**
591 * Convert rr_dict to wireformat representation of the resource record.
592 *
593 * @param rr_dict The getdns dict representation of the resource record
594 * @return wire A newly allocated buffer which will contain the wireformat.
595 * @return wire_sz The size of the allocated buffer and the wireformat.
596 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
597 */
598 getdns_return_t
599 getdns_rr_dict2wire(
600 const getdns_dict *rr_dict, uint8_t **wire, size_t *wire_sz);
601
602 /**
603 * Convert rr_dict to wireformat representation of the resource record.
604 *
605 * @param rr_dict The getdns dict representation of the resource record
606 * @param wire The buffer in which the wireformat will be written
607 * @param wire_sz On input the size of the wire buffer,
608 * On output the amount of wireformat needed for the
609 * wireformat representation of the resource record;
610 * even if it did not fit.
611 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
612 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
613 * small. wire_sz will be set to the needed buffer space then.
614 */
615 getdns_return_t
616 getdns_rr_dict2wire_buf(
617 const getdns_dict *rr_dict, uint8_t *wire, size_t *wire_sz);
618
619 /**
620 * Convert rr_dict to wireformat representation of the resource record.
621 *
622 * @param rr_dict The getdns dict representation of the resource record
623 * @param wire A pointer to the buffer pointer in which the wireformat
624 * will be written.
625 * On output the buffer pointer will have moved along
626 * the buffer and point right after the just written RR.
627 * @param wire_sz On input the size of the wire buffer,
628 * On output the amount of wireformat needed for the
629 * wireformat will have been substracted from wire_sz.
630 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
631 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
632 * small. The function will pretend that it had written beyond the end
633 * of the buffer, and wire will point past the buffer and wire_sz will
634 * contain a negative value.
635 */
636 getdns_return_t
637 getdns_rr_dict2wire_scan(
638 const getdns_dict *rr_dict, uint8_t **wire, int *wire_sz);
639
640
641 /**
642 * Convert wireformat resource record in a getdns rr_dict representation.
643 *
644 * @param wire Buffer containing the wireformat rr
645 * @param wire_sz Size of the wire buffer
646 * @return rr_dict The returned rr_dict
647 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
648 */
649 getdns_return_t
650 getdns_wire2rr_dict(
651 const uint8_t *wire, size_t wire_sz, getdns_dict **rr_dict);
652
653 /**
654 * Convert wireformat resource record in a getdns rr_dict representation.
655 *
656 * @param wire Buffer containing the wireformat rr
657 * @param wire_sz On input the size of the wire buffer
658 * On output the length of the wireformat rr.
659 * @return rr_dict The returned rr_dict
660 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
661 */
662 getdns_return_t
663 getdns_wire2rr_dict_buf(
664 const uint8_t *wire, size_t *wire_sz, getdns_dict **rr_dict);
665
666 /**
667 * Convert wireformat resource record in a getdns rr_dict representation.
668 *
669 * @param wire A pointer to the pointer of the wireformat buffer.
670 * On return this pointer is moved to after first read
671 * in resource record.
672 * @param wire_sz On input the size of the wire buffer
673 * On output the size is decreased with the length
674 * of the wireformat resource record.
675 * @return rr_dict The returned rr_dict
676 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
677 */
678 getdns_return_t
679 getdns_wire2rr_dict_scan(
680 const uint8_t **wire, size_t *wire_sz, getdns_dict **rr_dict);
681
682
683 /**
684 * Convert rr_dict to the string representation of the resource record.
685 *
686 * @param rr_dict The getdns dict representation of the resource record
687 * @return str A newly allocated string representation of the rr
688 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
689 */
690 getdns_return_t
691 getdns_rr_dict2str(
692 const getdns_dict *rr_dict, char **str);
693
694 /**
695 * Convert rr_dict to the string representation of the resource record.
696 *
697 * @param rr_dict The getdns dict representation of the resource record
698 * @param str The buffer in which the string will be written
699 * @param str_len On input the size of the text buffer,
700 * On output the amount of characters needed to write
701 * the string representation of the rr. Even if it does
702 * not fit.
703 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
704 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
705 * small. str_len will be set to the needed buffer space then.
706 */
707 getdns_return_t
708 getdns_rr_dict2str_buf(
709 const getdns_dict *rr_dict, char *str, size_t *str_len);
710
711 /**
712 * Convert rr_dict to the string representation of the resource record.
713 *
714 * @param rr_dict The getdns dict representation of the resource record
715 * @param str A pointer to the buffer pointer in which the string
716 * will be written.
717 * On output the buffer pointer will have moved along
718 * the buffer and point right after the just written RR.
719 * @param str_len On input the size of the str buffer,
720 * On output the number of characters needed for the
721 * string will have been substracted from strlen.
722 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
723 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
724 * small. The function will pretend that it had written beyond the end
725 * of the buffer, and str will point past the buffer and str_len will
726 * contain a negative value.
727 */
728 getdns_return_t
729 getdns_rr_dict2str_scan(
730 const getdns_dict *rr_dict, char **str, int *str_len);
731
732
733 /**
734 * Convert the string representation of the resource record to rr_dict format.
735 *
736 * @param str String representation of the resource record.
737 * @return rr_dict The result getdns dict representation of the resource record
738 * @param origin Default suffix for not fully qualified domain names
739 * @param default_ttl Default ttl
740 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
741 */
742 getdns_return_t
743 getdns_str2rr_dict(
744 const char *str, getdns_dict **rr_dict,
745 const char *origin, uint32_t default_ttl);
746
747 /**
748 * Read the zonefile and convert to a list of rr_dict's.
749 *
750 * @param FILE An opened FILE pointer on the zone file.
751 * @return rr_list The result list of rr_dicts representing the zone file.
752 * @param origin Default suffix for not fully qualified domain names
753 * @param default_ttl Default ttl
754 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
755 */
756 getdns_return_t
757 getdns_fp2rr_list(
758 FILE *in, getdns_list **rr_list,
759 const char *origin, uint32_t default_ttl);
760
761 /**
762 * Convert DNS message dict to wireformat representation.
763 *
764 * @param msg_dict The getdns dict representation of a DNS message
765 * @return wire A newly allocated buffer which will contain the wireformat.
766 * @return wire_sz The size of the allocated buffer and the wireformat.
767 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
768 */
769 getdns_return_t
770 getdns_msg_dict2wire(
771 const getdns_dict *msg_dict, uint8_t **wire, size_t *wire_sz);
772
773 /**
774 * Convert DNS message dict to wireformat representation.
775 *
776 * @param msg_dict The getdns dict representation of a DNS message
777 * @param wire The buffer in which the wireformat will be written
778 * @param wire_sz On input the size of the wire buffer,
779 * On output the amount of wireformat needed for the
780 * wireformat representation of the DNS message;
781 * even if it did not fit.
782 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
783 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
784 * small. wire_sz will be set to the needed buffer space then.
785 */
786 getdns_return_t
787 getdns_msg_dict2wire_buf(
788 const getdns_dict *msg_dict, uint8_t *wire, size_t *wire_sz);
789
790 /**
791 * Convert DNS message dict to wireformat representation.
792 *
793 * @param msg_dict The getdns dict representation of the DNS message
794 * @param wire A pointer to the buffer pointer in which the wireformat
795 * will be written.
796 * On output the buffer pointer will have moved along
797 * the buffer and point right after the just written RR.
798 * @param wire_sz On input the size of the wire buffer,
799 * On output the amount of wireformat needed for the
800 * wireformat will have been substracted from wire_sz.
801 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
802 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
803 * small. The function will pretend that it had written beyond the end
804 * of the buffer, and wire will point past the buffer and wire_sz will
805 * contain a negative value.
806 */
807 getdns_return_t
808 getdns_msg_dict2wire_scan(
809 const getdns_dict *msg_dict, uint8_t **wire, int *wire_sz);
810
811
812 /**
813 * Convert wireformat DNS message in a getdns msg_dict representation.
814 *
815 * @param wire Buffer containing the wireformat rr
816 * @param wire_sz Size of the wire buffer
817 * @return msg_dict The returned DNS message
818 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
819 */
820 getdns_return_t
821 getdns_wire2msg_dict(
822 const uint8_t *wire, size_t wire_sz, getdns_dict **msg_dict);
823
824 /**
825 * Convert wireformat DNS message in a getdns msg_dict representation.
826 *
827 * @param wire Buffer containing the wireformat rr
828 * @param wire_sz On input the size of the wire buffer
829 * On output the length of the wireformat rr.
830 * @return msg_dict The returned DNS message
831 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
832 */
833 getdns_return_t
834 getdns_wire2msg_dict_buf(
835 const uint8_t *wire, size_t *wire_sz, getdns_dict **msg_dict);
836
837 /**
838 * Convert wireformat DNS message in a getdns msg_dic representation.
839 *
840 * @param wire A pointer to the pointer of the wireformat buffer.
841 * On return this pointer is moved to after first read
842 * in resource record.
843 * @param wire_sz On input the size of the wire buffer
844 * On output the size is decreased with the length
845 * of the wireformat DNS message.
846 * @return msg_dict The returned DNS message
847 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
848 */
849 getdns_return_t
850 getdns_wire2msg_dict_scan(
851 const uint8_t **wire, size_t *wire_sz, getdns_dict **msg_dict);
852
853
854 /**
855 * Convert msg_dict to the string representation of the DNS message.
856 *
857 * @param msg_dict The getdns dict representation of the DNS message
858 * @return str A newly allocated string representation of the rr
859 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
860 */
861 getdns_return_t
862 getdns_msg_dict2str(
863 const getdns_dict *msg_dict, char **str);
864
865 /**
866 * Convert msg_dict to the string representation of the DNS message.
867 *
868 * @param msg_dict The getdns dict representation of the resource record
869 * @param str The buffer in which the string will be written
870 * @param str_len On input the size of the text buffer,
871 * On output the amount of characters needed to write
872 * the string representation of the rr. Even if it does
873 * not fit.
874 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
875 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
876 * small. str_len will be set to the needed buffer space then.
877 */
878 getdns_return_t
879 getdns_msg_dict2str_buf(
880 const getdns_dict *msg_dict, char *str, size_t *str_len);
881
882 /**
883 * Convert msg_dict to the string representation of the resource record.
884 *
885 * @param msg_dict The getdns dict representation of the resource record
886 * @param str A pointer to the buffer pointer in which the string
887 * will be written.
888 * On output the buffer pointer will have moved along
889 * the buffer and point right after the just written RR.
890 * @param str_len On input the size of the str buffer,
891 * On output the number of characters needed for the
892 * string will have been substracted from strlen.
893 * @return GETDNS_RETURN_GOOD on success or an error code on failure.
894 * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too
895 * small. The function will pretend that it had written beyond the end
896 * of the buffer, and str will point past the buffer and str_len will
897 * contain a negative value.
898 */
899 getdns_return_t
900 getdns_msg_dict2str_scan(
901 const getdns_dict *msg_dict, char **str, int *str_len);
902 /** @}
903 */
904
905
906 /**
907 * \defgroup Uutilityfunctionsdeprecated Additional utility functions (will be deprecated)
908 * @{
909 */
910 /* WARNING! Function getdns_strerror is not in the API specification and
911 * is likely to be removed from future versions of our implementation, to be
912 * replaced by getdns_get_errorstr_by_id or something similar.
913 * Please use getdns_get_errorstr_by_id instead of getdns_strerror.
914 */
915 getdns_return_t getdns_strerror(getdns_return_t err, char *buf, size_t buflen);
916 /** @}
917 */
918 /** @}
919 */
920
921 /** @}
922 */
824923
825924 #ifdef __cplusplus
826925 }
00 /**
11 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
2 * \brief Testing interfaces to getdns
33 *
44 * This source was taken from the original pseudo-implementation by
55 * Paul Hoffman.
00 /**
11 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
2 * \brief Testing interfaces to getdns
33 *
44 * This source was taken from the original pseudo-implementation by
55 * Paul Hoffman.
00 /**
11 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
2 * \brief Testing interfaces to getdns
33 *
44 * This source was taken from the original pseudo-implementation by
55 * Paul Hoffman.
00 /**
11 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
2 * \brief Testing interfaces to getdns
33 *
44 * This source was taken from the original pseudo-implementation by
55 * Paul Hoffman.
00 /**
11 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
2 * \brief Testing interfaces to getdns
33 *
44 * This source was taken from the original pseudo-implementation by
55 * Paul Hoffman.
13801380 getdns_dict_destroy(response);
13811381 }
13821382
1383 /**
1384 * \brief A wrapper script for command line testing of getdns
1385 * getdns_query -h provides details of the available options (the syntax is
1386 * similar to that of drill)
1387 * Note that for getdns the -z options enables getdns as a daemon which
1388 * allows getdns to be used as the local stub (or recursive) resolver
1389 */
1390
13831391 int
13841392 main(int argc, char **argv)
13851393 {
6767 * description but the list_set functions seem to be designed to modify an existing
6868 * item in the list. The newly added item has no data type.
6969 * @param list list containing the item to which child_list is to be added
70 * @param *index assigned to the index of the newly added item on success
70 * @param *child_dict dict to append to the list
7171 * @return GETDNS_RETURN_GOOD on success
7272 * @return GETDNS_RETURN_GENERAL_ERROR if out of memory
7373 */